connect.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630
  1. /***************************************************************************
  2. * _ _ ____ _
  3. * Project ___| | | | _ \| |
  4. * / __| | | | |_) | |
  5. * | (__| |_| | _ <| |___
  6. * \___|\___/|_| \_\_____|
  7. *
  8. * Copyright (C) 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.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. * SPDX-License-Identifier: curl
  22. *
  23. ***************************************************************************/
  24. #include "curl_setup.h"
  25. #ifdef HAVE_NETINET_IN_H
  26. #include <netinet/in.h> /* <netinet/tcp.h> may need it */
  27. #endif
  28. #ifdef HAVE_SYS_UN_H
  29. #include <sys/un.h> /* for sockaddr_un */
  30. #endif
  31. #ifdef HAVE_LINUX_TCP_H
  32. #include <linux/tcp.h>
  33. #elif defined(HAVE_NETINET_TCP_H)
  34. #include <netinet/tcp.h>
  35. #endif
  36. #ifdef HAVE_SYS_IOCTL_H
  37. #include <sys/ioctl.h>
  38. #endif
  39. #ifdef HAVE_NETDB_H
  40. #include <netdb.h>
  41. #endif
  42. #ifdef HAVE_ARPA_INET_H
  43. #include <arpa/inet.h>
  44. #endif
  45. #ifdef __VMS
  46. #include <in.h>
  47. #include <inet.h>
  48. #endif
  49. #include "urldata.h"
  50. #include "sendf.h"
  51. #include "if2ip.h"
  52. #include "strerror.h"
  53. #include "cfilters.h"
  54. #include "connect.h"
  55. #include "cf-haproxy.h"
  56. #include "cf-https-connect.h"
  57. #include "cf-ip-happy.h"
  58. #include "cf-socket.h"
  59. #include "select.h"
  60. #include "url.h" /* for Curl_safefree() */
  61. #include "multiif.h"
  62. #include "sockaddr.h" /* required for Curl_sockaddr_storage */
  63. #include "curlx/inet_ntop.h"
  64. #include "curlx/inet_pton.h"
  65. #include "vtls/vtls.h" /* for vtsl cfilters */
  66. #include "progress.h"
  67. #include "curlx/warnless.h"
  68. #include "conncache.h"
  69. #include "multihandle.h"
  70. #include "share.h"
  71. #include "http_proxy.h"
  72. #include "socks.h"
  73. /* The last 2 #include files should be in this order */
  74. #include "curl_memory.h"
  75. #include "memdebug.h"
  76. #if !defined(CURL_DISABLE_ALTSVC) || defined(USE_HTTPSRR)
  77. enum alpnid Curl_alpn2alpnid(const char *name, size_t len)
  78. {
  79. if(len == 2) {
  80. if(curl_strnequal(name, "h1", 2))
  81. return ALPN_h1;
  82. if(curl_strnequal(name, "h2", 2))
  83. return ALPN_h2;
  84. if(curl_strnequal(name, "h3", 2))
  85. return ALPN_h3;
  86. }
  87. else if(len == 8) {
  88. if(curl_strnequal(name, "http/1.1", 8))
  89. return ALPN_h1;
  90. }
  91. return ALPN_none; /* unknown, probably rubbish input */
  92. }
  93. #endif
  94. /*
  95. * Curl_timeleft() returns the amount of milliseconds left allowed for the
  96. * transfer/connection. If the value is 0, there is no timeout (ie there is
  97. * infinite time left). If the value is negative, the timeout time has already
  98. * elapsed.
  99. * @param data the transfer to check on
  100. * @param nowp timestamp to use for calculation, NULL to use curlx_now()
  101. * @param duringconnect TRUE iff connect timeout is also taken into account.
  102. * @unittest: 1303
  103. */
  104. timediff_t Curl_timeleft(struct Curl_easy *data,
  105. struct curltime *nowp,
  106. bool duringconnect)
  107. {
  108. timediff_t timeleft_ms = 0;
  109. timediff_t ctimeleft_ms = 0;
  110. struct curltime now;
  111. /* The duration of a connect and the total transfer are calculated from two
  112. different time-stamps. It can end up with the total timeout being reached
  113. before the connect timeout expires and we must acknowledge whichever
  114. timeout that is reached first. The total timeout is set per entire
  115. operation, while the connect timeout is set per connect. */
  116. if((!data->set.timeout || data->set.connect_only) && !duringconnect)
  117. return 0; /* no timeout in place or checked, return "no limit" */
  118. if(!nowp) {
  119. now = curlx_now();
  120. nowp = &now;
  121. }
  122. if(data->set.timeout) {
  123. timeleft_ms = data->set.timeout -
  124. curlx_timediff(*nowp, data->progress.t_startop);
  125. if(!timeleft_ms)
  126. timeleft_ms = -1; /* 0 is "no limit", fake 1 ms expiry */
  127. if(!duringconnect)
  128. return timeleft_ms; /* no connect check, this is it */
  129. }
  130. if(duringconnect) {
  131. timediff_t ctimeout_ms = (data->set.connecttimeout > 0) ?
  132. data->set.connecttimeout : DEFAULT_CONNECT_TIMEOUT;
  133. ctimeleft_ms = ctimeout_ms -
  134. curlx_timediff(*nowp, data->progress.t_startsingle);
  135. if(!ctimeleft_ms)
  136. ctimeleft_ms = -1; /* 0 is "no limit", fake 1 ms expiry */
  137. if(!timeleft_ms)
  138. return ctimeleft_ms; /* no general timeout, this is it */
  139. }
  140. /* return minimal time left or max amount already expired */
  141. return (ctimeleft_ms < timeleft_ms) ? ctimeleft_ms : timeleft_ms;
  142. }
  143. void Curl_shutdown_start(struct Curl_easy *data, int sockindex,
  144. int timeout_ms, struct curltime *nowp)
  145. {
  146. struct curltime now;
  147. struct connectdata *conn = data->conn;
  148. DEBUGASSERT(conn);
  149. if(!nowp) {
  150. now = curlx_now();
  151. nowp = &now;
  152. }
  153. conn->shutdown.start[sockindex] = *nowp;
  154. conn->shutdown.timeout_ms = (timeout_ms > 0) ?
  155. (timediff_t)timeout_ms :
  156. ((data->set.shutdowntimeout > 0) ?
  157. data->set.shutdowntimeout : DEFAULT_SHUTDOWN_TIMEOUT_MS);
  158. /* Set a timer, unless we operate on the admin handle */
  159. if(data->mid)
  160. Curl_expire_ex(data, nowp, conn->shutdown.timeout_ms,
  161. EXPIRE_SHUTDOWN);
  162. }
  163. timediff_t Curl_shutdown_timeleft(struct connectdata *conn, int sockindex,
  164. struct curltime *nowp)
  165. {
  166. struct curltime now;
  167. timediff_t left_ms;
  168. if(!conn->shutdown.start[sockindex].tv_sec ||
  169. (conn->shutdown.timeout_ms <= 0))
  170. return 0; /* not started or no limits */
  171. if(!nowp) {
  172. now = curlx_now();
  173. nowp = &now;
  174. }
  175. left_ms = conn->shutdown.timeout_ms -
  176. curlx_timediff(*nowp, conn->shutdown.start[sockindex]);
  177. return left_ms ? left_ms : -1;
  178. }
  179. timediff_t Curl_conn_shutdown_timeleft(struct connectdata *conn,
  180. struct curltime *nowp)
  181. {
  182. timediff_t left_ms = 0, ms;
  183. struct curltime now;
  184. int i;
  185. for(i = 0; conn->shutdown.timeout_ms && (i < 2); ++i) {
  186. if(!conn->shutdown.start[i].tv_sec)
  187. continue;
  188. if(!nowp) {
  189. now = curlx_now();
  190. nowp = &now;
  191. }
  192. ms = Curl_shutdown_timeleft(conn, i, nowp);
  193. if(ms && (!left_ms || ms < left_ms))
  194. left_ms = ms;
  195. }
  196. return left_ms;
  197. }
  198. void Curl_shutdown_clear(struct Curl_easy *data, int sockindex)
  199. {
  200. struct curltime *pt = &data->conn->shutdown.start[sockindex];
  201. memset(pt, 0, sizeof(*pt));
  202. }
  203. bool Curl_shutdown_started(struct Curl_easy *data, int sockindex)
  204. {
  205. struct curltime *pt = &data->conn->shutdown.start[sockindex];
  206. return (pt->tv_sec > 0) || (pt->tv_usec > 0);
  207. }
  208. /* retrieves ip address and port from a sockaddr structure. note it calls
  209. curlx_inet_ntop which sets errno on fail, not SOCKERRNO. */
  210. bool Curl_addr2string(struct sockaddr *sa, curl_socklen_t salen,
  211. char *addr, int *port)
  212. {
  213. struct sockaddr_in *si = NULL;
  214. #ifdef USE_IPV6
  215. struct sockaddr_in6 *si6 = NULL;
  216. #endif
  217. #if (defined(HAVE_SYS_UN_H) || defined(WIN32_SOCKADDR_UN)) && defined(AF_UNIX)
  218. struct sockaddr_un *su = NULL;
  219. #else
  220. (void)salen;
  221. #endif
  222. switch(sa->sa_family) {
  223. case AF_INET:
  224. si = (struct sockaddr_in *)(void *) sa;
  225. if(curlx_inet_ntop(sa->sa_family, &si->sin_addr, addr, MAX_IPADR_LEN)) {
  226. unsigned short us_port = ntohs(si->sin_port);
  227. *port = us_port;
  228. return TRUE;
  229. }
  230. break;
  231. #ifdef USE_IPV6
  232. case AF_INET6:
  233. si6 = (struct sockaddr_in6 *)(void *) sa;
  234. if(curlx_inet_ntop(sa->sa_family, &si6->sin6_addr, addr,
  235. MAX_IPADR_LEN)) {
  236. unsigned short us_port = ntohs(si6->sin6_port);
  237. *port = us_port;
  238. return TRUE;
  239. }
  240. break;
  241. #endif
  242. #if (defined(HAVE_SYS_UN_H) || defined(WIN32_SOCKADDR_UN)) && defined(AF_UNIX)
  243. case AF_UNIX:
  244. if(salen > (curl_socklen_t)sizeof(CURL_SA_FAMILY_T)) {
  245. su = (struct sockaddr_un*)sa;
  246. curl_msnprintf(addr, MAX_IPADR_LEN, "%s", su->sun_path);
  247. }
  248. else
  249. addr[0] = 0; /* socket with no name */
  250. *port = 0;
  251. return TRUE;
  252. #endif
  253. default:
  254. break;
  255. }
  256. addr[0] = '\0';
  257. *port = 0;
  258. CURL_SETERRNO(SOCKEAFNOSUPPORT);
  259. return FALSE;
  260. }
  261. /*
  262. * Used to extract socket and connectdata struct for the most recent
  263. * transfer on the given Curl_easy.
  264. *
  265. * The returned socket will be CURL_SOCKET_BAD in case of failure!
  266. */
  267. curl_socket_t Curl_getconnectinfo(struct Curl_easy *data,
  268. struct connectdata **connp)
  269. {
  270. DEBUGASSERT(data);
  271. /* this works for an easy handle:
  272. * - that has been used for curl_easy_perform()
  273. * - that is associated with a multi handle, and whose connection
  274. * was detached with CURLOPT_CONNECT_ONLY
  275. */
  276. if(data->state.lastconnect_id != -1) {
  277. struct connectdata *conn;
  278. conn = Curl_cpool_get_conn(data, data->state.lastconnect_id);
  279. if(!conn) {
  280. data->state.lastconnect_id = -1;
  281. return CURL_SOCKET_BAD;
  282. }
  283. if(connp)
  284. /* only store this if the caller cares for it */
  285. *connp = conn;
  286. return conn->sock[FIRSTSOCKET];
  287. }
  288. return CURL_SOCKET_BAD;
  289. }
  290. /*
  291. * Curl_conncontrol() marks streams or connection for closure.
  292. */
  293. void Curl_conncontrol(struct connectdata *conn,
  294. int ctrl /* see defines in header */
  295. #if defined(DEBUGBUILD) && !defined(CURL_DISABLE_VERBOSE_STRINGS)
  296. , const char *reason
  297. #endif
  298. )
  299. {
  300. /* close if a connection, or a stream that is not multiplexed. */
  301. /* This function will be called both before and after this connection is
  302. associated with a transfer. */
  303. bool closeit, is_multiplex;
  304. DEBUGASSERT(conn);
  305. #if defined(DEBUGBUILD) && !defined(CURL_DISABLE_VERBOSE_STRINGS)
  306. (void)reason; /* useful for debugging */
  307. #endif
  308. is_multiplex = Curl_conn_is_multiplex(conn, FIRSTSOCKET);
  309. closeit = (ctrl == CONNCTRL_CONNECTION) ||
  310. ((ctrl == CONNCTRL_STREAM) && !is_multiplex);
  311. if((ctrl == CONNCTRL_STREAM) && is_multiplex)
  312. ; /* stream signal on multiplex conn never affects close state */
  313. else if((bit)closeit != conn->bits.close) {
  314. conn->bits.close = closeit; /* the only place in the source code that
  315. should assign this bit */
  316. }
  317. }
  318. typedef enum {
  319. CF_SETUP_INIT,
  320. CF_SETUP_CNNCT_EYEBALLS,
  321. CF_SETUP_CNNCT_SOCKS,
  322. CF_SETUP_CNNCT_HTTP_PROXY,
  323. CF_SETUP_CNNCT_HAPROXY,
  324. CF_SETUP_CNNCT_SSL,
  325. CF_SETUP_DONE
  326. } cf_setup_state;
  327. struct cf_setup_ctx {
  328. cf_setup_state state;
  329. int ssl_mode;
  330. int transport;
  331. };
  332. static CURLcode cf_setup_connect(struct Curl_cfilter *cf,
  333. struct Curl_easy *data,
  334. bool *done)
  335. {
  336. struct cf_setup_ctx *ctx = cf->ctx;
  337. CURLcode result = CURLE_OK;
  338. struct Curl_dns_entry *dns = data->state.dns[cf->sockindex];
  339. if(cf->connected) {
  340. *done = TRUE;
  341. return CURLE_OK;
  342. }
  343. /* connect current sub-chain */
  344. connect_sub_chain:
  345. if(!dns)
  346. return CURLE_FAILED_INIT;
  347. if(cf->next && !cf->next->connected) {
  348. result = Curl_conn_cf_connect(cf->next, data, done);
  349. if(result || !*done)
  350. return result;
  351. }
  352. if(ctx->state < CF_SETUP_CNNCT_EYEBALLS) {
  353. result = cf_ip_happy_insert_after(cf, data, ctx->transport);
  354. if(result)
  355. return result;
  356. ctx->state = CF_SETUP_CNNCT_EYEBALLS;
  357. if(!cf->next || !cf->next->connected)
  358. goto connect_sub_chain;
  359. }
  360. /* sub-chain connected, do we need to add more? */
  361. #ifndef CURL_DISABLE_PROXY
  362. if(ctx->state < CF_SETUP_CNNCT_SOCKS && cf->conn->bits.socksproxy) {
  363. result = Curl_cf_socks_proxy_insert_after(cf, data);
  364. if(result)
  365. return result;
  366. ctx->state = CF_SETUP_CNNCT_SOCKS;
  367. if(!cf->next || !cf->next->connected)
  368. goto connect_sub_chain;
  369. }
  370. if(ctx->state < CF_SETUP_CNNCT_HTTP_PROXY && cf->conn->bits.httpproxy) {
  371. #ifdef USE_SSL
  372. if(IS_HTTPS_PROXY(cf->conn->http_proxy.proxytype)
  373. && !Curl_conn_is_ssl(cf->conn, cf->sockindex)) {
  374. result = Curl_cf_ssl_proxy_insert_after(cf, data);
  375. if(result)
  376. return result;
  377. }
  378. #endif /* USE_SSL */
  379. #ifndef CURL_DISABLE_HTTP
  380. if(cf->conn->bits.tunnel_proxy) {
  381. result = Curl_cf_http_proxy_insert_after(cf, data);
  382. if(result)
  383. return result;
  384. }
  385. #endif /* !CURL_DISABLE_HTTP */
  386. ctx->state = CF_SETUP_CNNCT_HTTP_PROXY;
  387. if(!cf->next || !cf->next->connected)
  388. goto connect_sub_chain;
  389. }
  390. #endif /* !CURL_DISABLE_PROXY */
  391. if(ctx->state < CF_SETUP_CNNCT_HAPROXY) {
  392. #ifndef CURL_DISABLE_PROXY
  393. if(data->set.haproxyprotocol) {
  394. if(Curl_conn_is_ssl(cf->conn, cf->sockindex)) {
  395. failf(data, "haproxy protocol not support with SSL "
  396. "encryption in place (QUIC?)");
  397. return CURLE_UNSUPPORTED_PROTOCOL;
  398. }
  399. result = Curl_cf_haproxy_insert_after(cf, data);
  400. if(result)
  401. return result;
  402. }
  403. #endif /* !CURL_DISABLE_PROXY */
  404. ctx->state = CF_SETUP_CNNCT_HAPROXY;
  405. if(!cf->next || !cf->next->connected)
  406. goto connect_sub_chain;
  407. }
  408. if(ctx->state < CF_SETUP_CNNCT_SSL) {
  409. #ifdef USE_SSL
  410. if((ctx->ssl_mode == CURL_CF_SSL_ENABLE
  411. || (ctx->ssl_mode != CURL_CF_SSL_DISABLE
  412. && cf->conn->handler->flags & PROTOPT_SSL)) /* we want SSL */
  413. && !Curl_conn_is_ssl(cf->conn, cf->sockindex)) { /* it is missing */
  414. result = Curl_cf_ssl_insert_after(cf, data);
  415. if(result)
  416. return result;
  417. }
  418. #endif /* USE_SSL */
  419. ctx->state = CF_SETUP_CNNCT_SSL;
  420. if(!cf->next || !cf->next->connected)
  421. goto connect_sub_chain;
  422. }
  423. ctx->state = CF_SETUP_DONE;
  424. cf->connected = TRUE;
  425. *done = TRUE;
  426. return CURLE_OK;
  427. }
  428. static void cf_setup_close(struct Curl_cfilter *cf,
  429. struct Curl_easy *data)
  430. {
  431. struct cf_setup_ctx *ctx = cf->ctx;
  432. CURL_TRC_CF(data, cf, "close");
  433. cf->connected = FALSE;
  434. ctx->state = CF_SETUP_INIT;
  435. if(cf->next) {
  436. cf->next->cft->do_close(cf->next, data);
  437. Curl_conn_cf_discard_chain(&cf->next, data);
  438. }
  439. }
  440. static void cf_setup_destroy(struct Curl_cfilter *cf, struct Curl_easy *data)
  441. {
  442. struct cf_setup_ctx *ctx = cf->ctx;
  443. (void)data;
  444. CURL_TRC_CF(data, cf, "destroy");
  445. Curl_safefree(ctx);
  446. }
  447. struct Curl_cftype Curl_cft_setup = {
  448. "SETUP",
  449. 0,
  450. CURL_LOG_LVL_NONE,
  451. cf_setup_destroy,
  452. cf_setup_connect,
  453. cf_setup_close,
  454. Curl_cf_def_shutdown,
  455. Curl_cf_def_adjust_pollset,
  456. Curl_cf_def_data_pending,
  457. Curl_cf_def_send,
  458. Curl_cf_def_recv,
  459. Curl_cf_def_cntrl,
  460. Curl_cf_def_conn_is_alive,
  461. Curl_cf_def_conn_keep_alive,
  462. Curl_cf_def_query,
  463. };
  464. static CURLcode cf_setup_create(struct Curl_cfilter **pcf,
  465. struct Curl_easy *data,
  466. int transport,
  467. int ssl_mode)
  468. {
  469. struct Curl_cfilter *cf = NULL;
  470. struct cf_setup_ctx *ctx;
  471. CURLcode result = CURLE_OK;
  472. (void)data;
  473. ctx = calloc(1, sizeof(*ctx));
  474. if(!ctx) {
  475. result = CURLE_OUT_OF_MEMORY;
  476. goto out;
  477. }
  478. ctx->state = CF_SETUP_INIT;
  479. ctx->ssl_mode = ssl_mode;
  480. ctx->transport = transport;
  481. result = Curl_cf_create(&cf, &Curl_cft_setup, ctx);
  482. if(result)
  483. goto out;
  484. ctx = NULL;
  485. out:
  486. *pcf = result ? NULL : cf;
  487. if(ctx) {
  488. free(ctx);
  489. }
  490. return result;
  491. }
  492. static CURLcode cf_setup_add(struct Curl_easy *data,
  493. struct connectdata *conn,
  494. int sockindex,
  495. int transport,
  496. int ssl_mode)
  497. {
  498. struct Curl_cfilter *cf;
  499. CURLcode result = CURLE_OK;
  500. DEBUGASSERT(data);
  501. result = cf_setup_create(&cf, data, transport, ssl_mode);
  502. if(result)
  503. goto out;
  504. Curl_conn_cf_add(data, conn, sockindex, cf);
  505. out:
  506. return result;
  507. }
  508. CURLcode Curl_cf_setup_insert_after(struct Curl_cfilter *cf_at,
  509. struct Curl_easy *data,
  510. int transport,
  511. int ssl_mode)
  512. {
  513. struct Curl_cfilter *cf;
  514. CURLcode result;
  515. DEBUGASSERT(data);
  516. result = cf_setup_create(&cf, data, transport, ssl_mode);
  517. if(result)
  518. goto out;
  519. Curl_conn_cf_insert_after(cf_at, cf);
  520. out:
  521. return result;
  522. }
  523. CURLcode Curl_conn_setup(struct Curl_easy *data,
  524. struct connectdata *conn,
  525. int sockindex,
  526. struct Curl_dns_entry *dns,
  527. int ssl_mode)
  528. {
  529. CURLcode result = CURLE_OK;
  530. DEBUGASSERT(data);
  531. DEBUGASSERT(conn->handler);
  532. DEBUGASSERT(dns);
  533. Curl_resolv_unlink(data, &data->state.dns[sockindex]);
  534. data->state.dns[sockindex] = dns;
  535. #ifndef CURL_DISABLE_HTTP
  536. if(!conn->cfilter[sockindex] &&
  537. conn->handler->protocol == CURLPROTO_HTTPS) {
  538. DEBUGASSERT(ssl_mode != CURL_CF_SSL_DISABLE);
  539. result = Curl_cf_https_setup(data, conn, sockindex);
  540. if(result)
  541. goto out;
  542. }
  543. #endif /* !CURL_DISABLE_HTTP */
  544. /* Still no cfilter set, apply default. */
  545. if(!conn->cfilter[sockindex]) {
  546. result = cf_setup_add(data, conn, sockindex,
  547. conn->transport_wanted, ssl_mode);
  548. if(result)
  549. goto out;
  550. }
  551. DEBUGASSERT(conn->cfilter[sockindex]);
  552. out:
  553. if(result)
  554. Curl_resolv_unlink(data, &data->state.dns[sockindex]);
  555. return result;
  556. }
  557. void Curl_conn_set_multiplex(struct connectdata *conn)
  558. {
  559. if(!conn->bits.multiplex) {
  560. conn->bits.multiplex = TRUE;
  561. if(conn->attached_multi) {
  562. Curl_multi_connchanged(conn->attached_multi);
  563. }
  564. }
  565. }