From: Bruce Momjian Date: Mon, 15 Sep 2003 02:30:29 +0000 (+0000) Subject: Add errno value for thread *_r function call buffer too small. Improve X-Git-Tag: REL7_4_BETA3~3 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=72ed916a1f26c9847114ccab703d05b902a7381e;p=postgresql Add errno value for thread *_r function call buffer too small. Improve thread comments. --- diff --git a/src/port/thread.c b/src/port/thread.c index 193b2e0808..bfc315cc0e 100644 --- a/src/port/thread.c +++ b/src/port/thread.c @@ -7,7 +7,7 @@ * * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * - * $Id: thread.c,v 1.7 2003/09/13 14:49:51 momjian Exp $ + * $Id: thread.c,v 1.8 2003/09/15 02:30:29 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -17,6 +17,7 @@ #include #include #include +#include /* * Threading sometimes requires specially-named versions of functions @@ -48,6 +49,12 @@ * use *_r functions if they exist (configure test) * do our own locking and copying of non-threadsafe functions * + * The disadvantage of the last option is not the thread overhead but + * the fact that all function calls are serialized, and with gethostbyname() + * requiring a DNS lookup, that could be slow. + * + * One thread-safe solution for gethostbyname() might be to use getaddrinfo(). + * * Compile and run src/tools/test_thread_funcs.c to see if your operating * system has thread-safe non-*_r functions. */ @@ -143,7 +150,10 @@ pqGetpwuid(uid_t uid, struct passwd *resultbuf, char *buffer, *result = resultbuf; } else + { *result = NULL; + errno = ERANGE; + } pthread_mutex_unlock(&getpwuid_lock); #endif @@ -239,7 +249,10 @@ pqGethostbyname(const char *name, *result = resultbuf; } else + { *result = NULL; + errno = ERANGE; + } } #endif