--- CVS-latest/lib/hostip.c Mon Apr 12 08:55:25 2004 +++ lib/hostip.c Tue Apr 13 15:34:11 2004 @@ -137,6 +137,7 @@ HANDLE thread_hnd; unsigned thread_id; DWORD thread_status; + curl_socket_t dummy_sock; /* dummy for Curl_multi_ares_fdset() */ }; #endif @@ -817,10 +818,20 @@ fd_set *write_fd_set, int *max_fdp) { +#ifdef USE_THREADING_GETHOSTBYNAME + const struct thread_data *td = (const struct thread_data *) conn->async.os_specific; + + if (td && td->dummy_sock != CURL_SOCKET_BAD) { + FD_SET(td->dummy_sock,write_fd_set); + *max_fdp = td->dummy_sock; + } + else { /* should never happen */ +#endif (void)conn; (void)read_fd_set; (void)write_fd_set; (void)max_fdp; + } return CURLE_OK; } #endif @@ -1332,7 +1343,7 @@ return; va_start (args, fmt); vfprintf (stderr, fmt, args); - fflush (stderr); +/*fflush (stderr); */ /* seems a bad idea in a multi-threaded app */ va_end (args); } #endif @@ -1373,8 +1384,14 @@ { if (async->hostname) free(async->hostname); - if (async->os_specific) + + if (async->os_specific) { + curl_socket_t sock = ((const struct thread_data*)async->os_specific)->dummy_sock; + + if (sock != CURL_SOCKET_BAD) + sclose(sock); free(async->os_specific); + } async->hostname = NULL; async->os_specific = NULL; } @@ -1407,6 +1424,7 @@ conn->async.dns = NULL; conn->async.os_specific = (void*) td; + td->dummy_sock = CURL_SOCKET_BAD; td->thread_hnd = (HANDLE) _beginthreadex(NULL, 0, gethostbyname_thread, conn, 0, &td->thread_id); if (!td->thread_hnd) { @@ -1415,6 +1433,11 @@ destroy_thread_data(&conn->async); return (0); } + /* this socket is only to keep Curl_multi_ares_fdset() and select() happy; + * should never become signalled for read/write since it's unbound but Windows + * needs atleast 1 socket in select(). + */ + td->dummy_sock = socket(AF_INET, SOCK_DGRAM, 0); return (1); }