|
7 | 7 | *
|
8 | 8 | * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
|
9 | 9 | *
|
10 |
| - * $Id: thread.c,v 1.7 2003/09/13 14:49:51 momjian Exp $ |
| 10 | + * $Id: thread.c,v 1.8 2003/09/15 02:30:29 momjian Exp $ |
11 | 11 | *
|
12 | 12 | *-------------------------------------------------------------------------
|
13 | 13 | */
|
|
17 | 17 | #include<pthread.h>
|
18 | 18 | #include<sys/types.h>
|
19 | 19 | #include<pwd.h>
|
| 20 | +#include<errno.h> |
20 | 21 |
|
21 | 22 | /*
|
22 | 23 | *Threading sometimes requires specially-named versions of functions
|
|
48 | 49 | *use *_r functions if they exist (configure test)
|
49 | 50 | *do our own locking and copying of non-threadsafe functions
|
50 | 51 | *
|
| 52 | + *The disadvantage of the last option is not the thread overhead but |
| 53 | + *the fact that all function calls are serialized, and with gethostbyname() |
| 54 | + *requiring a DNS lookup, that could be slow. |
| 55 | + * |
| 56 | + *One thread-safe solution for gethostbyname() might be to use getaddrinfo(). |
| 57 | + * |
51 | 58 | *Compile and run src/tools/test_thread_funcs.c to see if your operating
|
52 | 59 | *system has thread-safe non-*_r functions.
|
53 | 60 | */
|
@@ -143,7 +150,10 @@ pqGetpwuid(uid_t uid, struct passwd *resultbuf, char *buffer,
|
143 | 150 | *result=resultbuf;
|
144 | 151 | }
|
145 | 152 | else
|
| 153 | +{ |
146 | 154 | *result=NULL;
|
| 155 | +errno=ERANGE; |
| 156 | +} |
147 | 157 |
|
148 | 158 | pthread_mutex_unlock(&getpwuid_lock);
|
149 | 159 | #endif
|
@@ -239,7 +249,10 @@ pqGethostbyname(const char *name,
|
239 | 249 | *result=resultbuf;
|
240 | 250 | }
|
241 | 251 | else
|
| 252 | +{ |
242 | 253 | *result=NULL;
|
| 254 | +errno=ERANGE; |
| 255 | +} |
243 | 256 | }
|
244 | 257 | #endif
|
245 | 258 |
|
|