asyn-thread.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760
  1. /***************************************************************************
  2. * _ _ ____ _
  3. * Project ___| | | | _ \| |
  4. * / __| | | | |_) | |
  5. * | (__| |_| | _ <| |___
  6. * \___|\___/|_| \_\_____|
  7. *
  8. * Copyright (C) 1998 - 2019, Daniel Stenberg, <[email protected]>, et al.
  9. *
  10. * This software is licensed as described in the file COPYING, which
  11. * you should have received as part of this distribution. The terms
  12. * are also available at https://curl.haxx.se/docs/copyright.html.
  13. *
  14. * You may opt to use, copy, modify, merge, publish, distribute and/or sell
  15. * copies of the Software, and permit persons to whom the Software is
  16. * furnished to do so, under the terms of the COPYING file.
  17. *
  18. * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  19. * KIND, either express or implied.
  20. *
  21. ***************************************************************************/
  22. #include "curl_setup.h"
  23. /***********************************************************************
  24. * Only for threaded name resolves builds
  25. **********************************************************************/
  26. #ifdef CURLRES_THREADED
  27. #ifdef HAVE_NETINET_IN_H
  28. #include <netinet/in.h>
  29. #endif
  30. #ifdef HAVE_NETDB_H
  31. #include <netdb.h>
  32. #endif
  33. #ifdef HAVE_ARPA_INET_H
  34. #include <arpa/inet.h>
  35. #endif
  36. #ifdef __VMS
  37. #include <in.h>
  38. #include <inet.h>
  39. #endif
  40. #if defined(USE_THREADS_POSIX)
  41. # ifdef HAVE_PTHREAD_H
  42. # include <pthread.h>
  43. # endif
  44. #elif defined(USE_THREADS_WIN32)
  45. # ifdef HAVE_PROCESS_H
  46. # include <process.h>
  47. # endif
  48. #endif
  49. #if (defined(NETWARE) && defined(__NOVELL_LIBC__))
  50. #undef in_addr_t
  51. #define in_addr_t unsigned long
  52. #endif
  53. #ifdef HAVE_GETADDRINFO
  54. # define RESOLVER_ENOMEM EAI_MEMORY
  55. #else
  56. # define RESOLVER_ENOMEM ENOMEM
  57. #endif
  58. #include "urldata.h"
  59. #include "sendf.h"
  60. #include "hostip.h"
  61. #include "hash.h"
  62. #include "share.h"
  63. #include "strerror.h"
  64. #include "url.h"
  65. #include "multiif.h"
  66. #include "inet_pton.h"
  67. #include "inet_ntop.h"
  68. #include "curl_threads.h"
  69. #include "connect.h"
  70. /* The last 3 #include files should be in this order */
  71. #include "curl_printf.h"
  72. #include "curl_memory.h"
  73. #include "memdebug.h"
  74. struct resdata {
  75. struct curltime start;
  76. };
  77. /*
  78. * Curl_resolver_global_init()
  79. * Called from curl_global_init() to initialize global resolver environment.
  80. * Does nothing here.
  81. */
  82. int Curl_resolver_global_init(void)
  83. {
  84. return CURLE_OK;
  85. }
  86. /*
  87. * Curl_resolver_global_cleanup()
  88. * Called from curl_global_cleanup() to destroy global resolver environment.
  89. * Does nothing here.
  90. */
  91. void Curl_resolver_global_cleanup(void)
  92. {
  93. }
  94. /*
  95. * Curl_resolver_init()
  96. * Called from curl_easy_init() -> Curl_open() to initialize resolver
  97. * URL-state specific environment ('resolver' member of the UrlState
  98. * structure).
  99. */
  100. CURLcode Curl_resolver_init(struct Curl_easy *easy, void **resolver)
  101. {
  102. (void)easy;
  103. *resolver = calloc(1, sizeof(struct resdata));
  104. if(!*resolver)
  105. return CURLE_OUT_OF_MEMORY;
  106. return CURLE_OK;
  107. }
  108. /*
  109. * Curl_resolver_cleanup()
  110. * Called from curl_easy_cleanup() -> Curl_close() to cleanup resolver
  111. * URL-state specific environment ('resolver' member of the UrlState
  112. * structure).
  113. */
  114. void Curl_resolver_cleanup(void *resolver)
  115. {
  116. free(resolver);
  117. }
  118. /*
  119. * Curl_resolver_duphandle()
  120. * Called from curl_easy_duphandle() to duplicate resolver URL state-specific
  121. * environment ('resolver' member of the UrlState structure).
  122. */
  123. CURLcode Curl_resolver_duphandle(struct Curl_easy *easy, void **to, void *from)
  124. {
  125. (void)from;
  126. return Curl_resolver_init(easy, to);
  127. }
  128. static void destroy_async_data(struct Curl_async *);
  129. /*
  130. * Cancel all possibly still on-going resolves for this connection.
  131. */
  132. void Curl_resolver_cancel(struct connectdata *conn)
  133. {
  134. destroy_async_data(&conn->async);
  135. }
  136. /* This function is used to init a threaded resolve */
  137. static bool init_resolve_thread(struct connectdata *conn,
  138. const char *hostname, int port,
  139. const struct addrinfo *hints);
  140. /* Data for synchronization between resolver thread and its parent */
  141. struct thread_sync_data {
  142. curl_mutex_t * mtx;
  143. int done;
  144. char *hostname; /* hostname to resolve, Curl_async.hostname
  145. duplicate */
  146. int port;
  147. int sock_error;
  148. Curl_addrinfo *res;
  149. #ifdef HAVE_GETADDRINFO
  150. struct addrinfo hints;
  151. #endif
  152. struct thread_data *td; /* for thread-self cleanup */
  153. };
  154. struct thread_data {
  155. curl_thread_t thread_hnd;
  156. unsigned int poll_interval;
  157. time_t interval_end;
  158. struct thread_sync_data tsd;
  159. };
  160. static struct thread_sync_data *conn_thread_sync_data(struct connectdata *conn)
  161. {
  162. return &(((struct thread_data *)conn->async.os_specific)->tsd);
  163. }
  164. /* Destroy resolver thread synchronization data */
  165. static
  166. void destroy_thread_sync_data(struct thread_sync_data * tsd)
  167. {
  168. if(tsd->mtx) {
  169. Curl_mutex_destroy(tsd->mtx);
  170. free(tsd->mtx);
  171. }
  172. free(tsd->hostname);
  173. if(tsd->res)
  174. Curl_freeaddrinfo(tsd->res);
  175. memset(tsd, 0, sizeof(*tsd));
  176. }
  177. /* Initialize resolver thread synchronization data */
  178. static
  179. int init_thread_sync_data(struct thread_data * td,
  180. const char *hostname,
  181. int port,
  182. const struct addrinfo *hints)
  183. {
  184. struct thread_sync_data *tsd = &td->tsd;
  185. memset(tsd, 0, sizeof(*tsd));
  186. tsd->td = td;
  187. tsd->port = port;
  188. /* Treat the request as done until the thread actually starts so any early
  189. * cleanup gets done properly.
  190. */
  191. tsd->done = 1;
  192. #ifdef HAVE_GETADDRINFO
  193. DEBUGASSERT(hints);
  194. tsd->hints = *hints;
  195. #else
  196. (void) hints;
  197. #endif
  198. tsd->mtx = malloc(sizeof(curl_mutex_t));
  199. if(tsd->mtx == NULL)
  200. goto err_exit;
  201. Curl_mutex_init(tsd->mtx);
  202. tsd->sock_error = CURL_ASYNC_SUCCESS;
  203. /* Copying hostname string because original can be destroyed by parent
  204. * thread during gethostbyname execution.
  205. */
  206. tsd->hostname = strdup(hostname);
  207. if(!tsd->hostname)
  208. goto err_exit;
  209. return 1;
  210. err_exit:
  211. /* Memory allocation failed */
  212. destroy_thread_sync_data(tsd);
  213. return 0;
  214. }
  215. static int getaddrinfo_complete(struct connectdata *conn)
  216. {
  217. struct thread_sync_data *tsd = conn_thread_sync_data(conn);
  218. int rc;
  219. rc = Curl_addrinfo_callback(conn, tsd->sock_error, tsd->res);
  220. /* The tsd->res structure has been copied to async.dns and perhaps the DNS
  221. cache. Set our copy to NULL so destroy_thread_sync_data doesn't free it.
  222. */
  223. tsd->res = NULL;
  224. return rc;
  225. }
  226. #ifdef HAVE_GETADDRINFO
  227. /*
  228. * getaddrinfo_thread() resolves a name and then exits.
  229. *
  230. * For builds without ARES, but with ENABLE_IPV6, create a resolver thread
  231. * and wait on it.
  232. */
  233. static unsigned int CURL_STDCALL getaddrinfo_thread(void *arg)
  234. {
  235. struct thread_sync_data *tsd = (struct thread_sync_data*)arg;
  236. struct thread_data *td = tsd->td;
  237. char service[12];
  238. int rc;
  239. msnprintf(service, sizeof(service), "%d", tsd->port);
  240. rc = Curl_getaddrinfo_ex(tsd->hostname, service, &tsd->hints, &tsd->res);
  241. if(rc != 0) {
  242. tsd->sock_error = SOCKERRNO?SOCKERRNO:rc;
  243. if(tsd->sock_error == 0)
  244. tsd->sock_error = RESOLVER_ENOMEM;
  245. }
  246. else {
  247. Curl_addrinfo_set_port(tsd->res, tsd->port);
  248. }
  249. Curl_mutex_acquire(tsd->mtx);
  250. if(tsd->done) {
  251. /* too late, gotta clean up the mess */
  252. Curl_mutex_release(tsd->mtx);
  253. destroy_thread_sync_data(tsd);
  254. free(td);
  255. }
  256. else {
  257. tsd->done = 1;
  258. Curl_mutex_release(tsd->mtx);
  259. }
  260. return 0;
  261. }
  262. #else /* HAVE_GETADDRINFO */
  263. /*
  264. * gethostbyname_thread() resolves a name and then exits.
  265. */
  266. static unsigned int CURL_STDCALL gethostbyname_thread(void *arg)
  267. {
  268. struct thread_sync_data *tsd = (struct thread_sync_data *)arg;
  269. struct thread_data *td = tsd->td;
  270. tsd->res = Curl_ipv4_resolve_r(tsd->hostname, tsd->port);
  271. if(!tsd->res) {
  272. tsd->sock_error = SOCKERRNO;
  273. if(tsd->sock_error == 0)
  274. tsd->sock_error = RESOLVER_ENOMEM;
  275. }
  276. Curl_mutex_acquire(tsd->mtx);
  277. if(tsd->done) {
  278. /* too late, gotta clean up the mess */
  279. Curl_mutex_release(tsd->mtx);
  280. destroy_thread_sync_data(tsd);
  281. free(td);
  282. }
  283. else {
  284. tsd->done = 1;
  285. Curl_mutex_release(tsd->mtx);
  286. }
  287. return 0;
  288. }
  289. #endif /* HAVE_GETADDRINFO */
  290. /*
  291. * destroy_async_data() cleans up async resolver data and thread handle.
  292. */
  293. static void destroy_async_data(struct Curl_async *async)
  294. {
  295. if(async->os_specific) {
  296. struct thread_data *td = (struct thread_data*) async->os_specific;
  297. int done;
  298. /*
  299. * if the thread is still blocking in the resolve syscall, detach it and
  300. * let the thread do the cleanup...
  301. */
  302. Curl_mutex_acquire(td->tsd.mtx);
  303. done = td->tsd.done;
  304. td->tsd.done = 1;
  305. Curl_mutex_release(td->tsd.mtx);
  306. if(!done) {
  307. Curl_thread_destroy(td->thread_hnd);
  308. }
  309. else {
  310. if(td->thread_hnd != curl_thread_t_null)
  311. Curl_thread_join(&td->thread_hnd);
  312. destroy_thread_sync_data(&td->tsd);
  313. free(async->os_specific);
  314. }
  315. }
  316. async->os_specific = NULL;
  317. free(async->hostname);
  318. async->hostname = NULL;
  319. }
  320. /*
  321. * init_resolve_thread() starts a new thread that performs the actual
  322. * resolve. This function returns before the resolve is done.
  323. *
  324. * Returns FALSE in case of failure, otherwise TRUE.
  325. */
  326. static bool init_resolve_thread(struct connectdata *conn,
  327. const char *hostname, int port,
  328. const struct addrinfo *hints)
  329. {
  330. struct thread_data *td = calloc(1, sizeof(struct thread_data));
  331. int err = ENOMEM;
  332. conn->async.os_specific = (void *)td;
  333. if(!td)
  334. goto errno_exit;
  335. conn->async.port = port;
  336. conn->async.done = FALSE;
  337. conn->async.status = 0;
  338. conn->async.dns = NULL;
  339. td->thread_hnd = curl_thread_t_null;
  340. if(!init_thread_sync_data(td, hostname, port, hints)) {
  341. conn->async.os_specific = NULL;
  342. free(td);
  343. goto errno_exit;
  344. }
  345. free(conn->async.hostname);
  346. conn->async.hostname = strdup(hostname);
  347. if(!conn->async.hostname)
  348. goto err_exit;
  349. /* The thread will set this to 1 when complete. */
  350. td->tsd.done = 0;
  351. #ifdef HAVE_GETADDRINFO
  352. td->thread_hnd = Curl_thread_create(getaddrinfo_thread, &td->tsd);
  353. #else
  354. td->thread_hnd = Curl_thread_create(gethostbyname_thread, &td->tsd);
  355. #endif
  356. if(!td->thread_hnd) {
  357. /* The thread never started, so mark it as done here for proper cleanup. */
  358. td->tsd.done = 1;
  359. err = errno;
  360. goto err_exit;
  361. }
  362. return TRUE;
  363. err_exit:
  364. destroy_async_data(&conn->async);
  365. errno_exit:
  366. errno = err;
  367. return FALSE;
  368. }
  369. /*
  370. * resolver_error() calls failf() with the appropriate message after a resolve
  371. * error
  372. */
  373. static CURLcode resolver_error(struct connectdata *conn)
  374. {
  375. const char *host_or_proxy;
  376. CURLcode result;
  377. if(conn->bits.httpproxy) {
  378. host_or_proxy = "proxy";
  379. result = CURLE_COULDNT_RESOLVE_PROXY;
  380. }
  381. else {
  382. host_or_proxy = "host";
  383. result = CURLE_COULDNT_RESOLVE_HOST;
  384. }
  385. failf(conn->data, "Could not resolve %s: %s", host_or_proxy,
  386. conn->async.hostname);
  387. return result;
  388. }
  389. static CURLcode thread_wait_resolv(struct connectdata *conn,
  390. struct Curl_dns_entry **entry,
  391. bool report)
  392. {
  393. struct thread_data *td = (struct thread_data*) conn->async.os_specific;
  394. CURLcode result = CURLE_OK;
  395. DEBUGASSERT(conn && td);
  396. DEBUGASSERT(td->thread_hnd != curl_thread_t_null);
  397. /* wait for the thread to resolve the name */
  398. if(Curl_thread_join(&td->thread_hnd)) {
  399. if(entry)
  400. result = getaddrinfo_complete(conn);
  401. }
  402. else
  403. DEBUGASSERT(0);
  404. conn->async.done = TRUE;
  405. if(entry)
  406. *entry = conn->async.dns;
  407. if(!conn->async.dns && report)
  408. /* a name was not resolved, report error */
  409. result = resolver_error(conn);
  410. destroy_async_data(&conn->async);
  411. if(!conn->async.dns && report)
  412. connclose(conn, "asynch resolve failed");
  413. return result;
  414. }
  415. /*
  416. * Until we gain a way to signal the resolver threads to stop early, we must
  417. * simply wait for them and ignore their results.
  418. */
  419. void Curl_resolver_kill(struct connectdata *conn)
  420. {
  421. struct thread_data *td = (struct thread_data*) conn->async.os_specific;
  422. /* If we're still resolving, we must wait for the threads to fully clean up,
  423. unfortunately. Otherwise, we can simply cancel to clean up any resolver
  424. data. */
  425. if(td && td->thread_hnd != curl_thread_t_null)
  426. (void)thread_wait_resolv(conn, NULL, FALSE);
  427. else
  428. Curl_resolver_cancel(conn);
  429. }
  430. /*
  431. * Curl_resolver_wait_resolv()
  432. *
  433. * Waits for a resolve to finish. This function should be avoided since using
  434. * this risk getting the multi interface to "hang".
  435. *
  436. * If 'entry' is non-NULL, make it point to the resolved dns entry
  437. *
  438. * Returns CURLE_COULDNT_RESOLVE_HOST if the host was not resolved,
  439. * CURLE_OPERATION_TIMEDOUT if a time-out occurred, or other errors.
  440. *
  441. * This is the version for resolves-in-a-thread.
  442. */
  443. CURLcode Curl_resolver_wait_resolv(struct connectdata *conn,
  444. struct Curl_dns_entry **entry)
  445. {
  446. return thread_wait_resolv(conn, entry, TRUE);
  447. }
  448. /*
  449. * Curl_resolver_is_resolved() is called repeatedly to check if a previous
  450. * name resolve request has completed. It should also make sure to time-out if
  451. * the operation seems to take too long.
  452. */
  453. CURLcode Curl_resolver_is_resolved(struct connectdata *conn,
  454. struct Curl_dns_entry **entry)
  455. {
  456. struct Curl_easy *data = conn->data;
  457. struct thread_data *td = (struct thread_data*) conn->async.os_specific;
  458. int done = 0;
  459. *entry = NULL;
  460. if(!td) {
  461. DEBUGASSERT(td);
  462. return CURLE_COULDNT_RESOLVE_HOST;
  463. }
  464. Curl_mutex_acquire(td->tsd.mtx);
  465. done = td->tsd.done;
  466. Curl_mutex_release(td->tsd.mtx);
  467. if(done) {
  468. getaddrinfo_complete(conn);
  469. if(!conn->async.dns) {
  470. CURLcode result = resolver_error(conn);
  471. destroy_async_data(&conn->async);
  472. return result;
  473. }
  474. destroy_async_data(&conn->async);
  475. *entry = conn->async.dns;
  476. }
  477. else {
  478. /* poll for name lookup done with exponential backoff up to 250ms */
  479. timediff_t elapsed = Curl_timediff(Curl_now(),
  480. data->progress.t_startsingle);
  481. if(elapsed < 0)
  482. elapsed = 0;
  483. if(td->poll_interval == 0)
  484. /* Start at 1ms poll interval */
  485. td->poll_interval = 1;
  486. else if(elapsed >= td->interval_end)
  487. /* Back-off exponentially if last interval expired */
  488. td->poll_interval *= 2;
  489. if(td->poll_interval > 250)
  490. td->poll_interval = 250;
  491. td->interval_end = elapsed + td->poll_interval;
  492. Curl_expire(conn->data, td->poll_interval, EXPIRE_ASYNC_NAME);
  493. }
  494. return CURLE_OK;
  495. }
  496. int Curl_resolver_getsock(struct connectdata *conn,
  497. curl_socket_t *socks,
  498. int numsocks)
  499. {
  500. time_t milli;
  501. timediff_t ms;
  502. struct Curl_easy *data = conn->data;
  503. struct resdata *reslv = (struct resdata *)data->state.resolver;
  504. (void)socks;
  505. (void)numsocks;
  506. ms = Curl_timediff(Curl_now(), reslv->start);
  507. if(ms < 3)
  508. milli = 0;
  509. else if(ms <= 50)
  510. milli = ms/3;
  511. else if(ms <= 250)
  512. milli = 50;
  513. else
  514. milli = 200;
  515. Curl_expire(data, milli, EXPIRE_ASYNC_NAME);
  516. return 0;
  517. }
  518. #ifndef HAVE_GETADDRINFO
  519. /*
  520. * Curl_getaddrinfo() - for platforms without getaddrinfo
  521. */
  522. Curl_addrinfo *Curl_resolver_getaddrinfo(struct connectdata *conn,
  523. const char *hostname,
  524. int port,
  525. int *waitp)
  526. {
  527. struct in_addr in;
  528. struct Curl_easy *data = conn->data;
  529. struct resdata *reslv = (struct resdata *)data->state.resolver;
  530. *waitp = 0; /* default to synchronous response */
  531. if(Curl_inet_pton(AF_INET, hostname, &in) > 0)
  532. /* This is a dotted IP address 123.123.123.123-style */
  533. return Curl_ip2addr(AF_INET, &in, hostname, port);
  534. reslv->start = Curl_now();
  535. /* fire up a new resolver thread! */
  536. if(init_resolve_thread(conn, hostname, port, NULL)) {
  537. *waitp = 1; /* expect asynchronous response */
  538. return NULL;
  539. }
  540. failf(conn->data, "getaddrinfo() thread failed\n");
  541. return NULL;
  542. }
  543. #else /* !HAVE_GETADDRINFO */
  544. /*
  545. * Curl_resolver_getaddrinfo() - for getaddrinfo
  546. */
  547. Curl_addrinfo *Curl_resolver_getaddrinfo(struct connectdata *conn,
  548. const char *hostname,
  549. int port,
  550. int *waitp)
  551. {
  552. struct addrinfo hints;
  553. char sbuf[12];
  554. int pf = PF_INET;
  555. struct Curl_easy *data = conn->data;
  556. struct resdata *reslv = (struct resdata *)data->state.resolver;
  557. *waitp = 0; /* default to synchronous response */
  558. #ifndef USE_RESOLVE_ON_IPS
  559. {
  560. struct in_addr in;
  561. /* First check if this is an IPv4 address string */
  562. if(Curl_inet_pton(AF_INET, hostname, &in) > 0)
  563. /* This is a dotted IP address 123.123.123.123-style */
  564. return Curl_ip2addr(AF_INET, &in, hostname, port);
  565. }
  566. #ifdef CURLRES_IPV6
  567. {
  568. struct in6_addr in6;
  569. /* check if this is an IPv6 address string */
  570. if(Curl_inet_pton(AF_INET6, hostname, &in6) > 0)
  571. /* This is an IPv6 address literal */
  572. return Curl_ip2addr(AF_INET6, &in6, hostname, port);
  573. }
  574. #endif /* CURLRES_IPV6 */
  575. #endif /* !USE_RESOLVE_ON_IPS */
  576. #ifdef CURLRES_IPV6
  577. /*
  578. * Check if a limited name resolve has been requested.
  579. */
  580. switch(conn->ip_version) {
  581. case CURL_IPRESOLVE_V4:
  582. pf = PF_INET;
  583. break;
  584. case CURL_IPRESOLVE_V6:
  585. pf = PF_INET6;
  586. break;
  587. default:
  588. pf = PF_UNSPEC;
  589. break;
  590. }
  591. if((pf != PF_INET) && !Curl_ipv6works())
  592. /* The stack seems to be a non-IPv6 one */
  593. pf = PF_INET;
  594. #endif /* CURLRES_IPV6 */
  595. memset(&hints, 0, sizeof(hints));
  596. hints.ai_family = pf;
  597. hints.ai_socktype = conn->socktype;
  598. msnprintf(sbuf, sizeof(sbuf), "%d", port);
  599. reslv->start = Curl_now();
  600. /* fire up a new resolver thread! */
  601. if(init_resolve_thread(conn, hostname, port, &hints)) {
  602. *waitp = 1; /* expect asynchronous response */
  603. return NULL;
  604. }
  605. failf(data, "getaddrinfo() thread failed to start\n");
  606. return NULL;
  607. }
  608. #endif /* !HAVE_GETADDRINFO */
  609. CURLcode Curl_set_dns_servers(struct Curl_easy *data,
  610. char *servers)
  611. {
  612. (void)data;
  613. (void)servers;
  614. return CURLE_NOT_BUILT_IN;
  615. }
  616. CURLcode Curl_set_dns_interface(struct Curl_easy *data,
  617. const char *interf)
  618. {
  619. (void)data;
  620. (void)interf;
  621. return CURLE_NOT_BUILT_IN;
  622. }
  623. CURLcode Curl_set_dns_local_ip4(struct Curl_easy *data,
  624. const char *local_ip4)
  625. {
  626. (void)data;
  627. (void)local_ip4;
  628. return CURLE_NOT_BUILT_IN;
  629. }
  630. CURLcode Curl_set_dns_local_ip6(struct Curl_easy *data,
  631. const char *local_ip6)
  632. {
  633. (void)data;
  634. (void)local_ip6;
  635. return CURLE_NOT_BUILT_IN;
  636. }
  637. #endif /* CURLRES_THREADED */