X-Git-Url: http://lists.indexdata.com/cgi-bin?a=blobdiff_plain;f=src%2Fgetaddrinfo.c;h=4718f5bad362b2915792f08edb48a06517608d4f;hb=b2807317725db68d786503711be67ecf163115b7;hp=b504ec735765a8c42eb3996e171ad7f8e215d112;hpb=2819110732a5e3cdc6de71333977ff39d7cf8bf3;p=pazpar2-moved-to-github.git diff --git a/src/getaddrinfo.c b/src/getaddrinfo.c index b504ec7..4718f5b 100644 --- a/src/getaddrinfo.c +++ b/src/getaddrinfo.c @@ -51,6 +51,15 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "connection.h" #include "host.h" +/* Only use a threaded resolver on Unix that offers getaddrinfo. + gethostbyname is NOT reentrant. + */ +#if HAVE_GETADDRINFO +#ifndef WIN32 +#define USE_THREADED_RESOLVER 1 +#endif +#endif + struct work { char *hostport; /* hostport to be resolved in separate thread */ char *ipport; /* result or NULL if it could not be resolved */ @@ -140,7 +149,7 @@ static void work_handler(void *vp) perform_getaddrinfo(w); } -#ifndef WIN32 +#if USE_THREADED_RESOLVER void iochan_handler(struct iochan *i, int event) { sel_thread_t p = iochan_getdata(i); @@ -186,7 +195,7 @@ int host_getaddrinfo(struct host *host) w->hostport = host->hostport; w->ipport = 0; w->host = host; -#ifndef WIN32 +#if USE_THREADED_RESOLVER if (use_thread) { if (resolver_thread == 0) @@ -207,7 +216,9 @@ int host_getaddrinfo(struct host *host) /* * Local variables: * c-basic-offset: 4 + * c-file-style: "Stroustrup" * indent-tabs-mode: nil * End: * vim: shiftwidth=4 tabstop=8 expandtab */ +