1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-30 00:00:16 +01:00

client: iterate connection attempts through addrinfo list

This commit is contained in:
Andy Green 2019-09-16 04:12:45 +01:00
parent c591e1adfc
commit 5c3e8b2e41
2 changed files with 6 additions and 1 deletions

View file

@ -751,6 +751,7 @@ struct lws {
#endif
#if defined(LWS_WITH_CLIENT)
char chunk_parser; /* enum lws_chunk_parser */
uint8_t addrinfo_idx;
#endif
#if defined(LWS_WITH_CGI) || defined(LWS_WITH_CLIENT)
char reason_bf; /* internal writeable callback reason bitfield */

View file

@ -260,6 +260,7 @@ lws_client_connect_3_connect(struct lws *wsi, const char *ads,
#endif
#endif
/*
* async dns calls back here for everybody who cares when it gets a
* result... but if we are piggybacking, we do not want to connect
@ -554,6 +555,7 @@ ads_known:
m = connect(wsi->desc.sockfd, (const struct sockaddr *)psa, n);
if (m == -1) {
lwsl_debug("%s: connect says errno: %d\n", __func__, LWS_ERRNO);
if (LWS_ERRNO != LWS_EALREADY &&
@ -597,7 +599,6 @@ conn_good:
return lws_client_connect_4_established(wsi, NULL, plen);
oom4:
if (lwsi_role_client(wsi) && wsi->protocol /* && lwsi_state_est(wsi) */)
lws_inform_client_conn_fail(wsi,(void *)cce, strlen(cce));
@ -623,6 +624,7 @@ oom4:
return NULL;
try_next_result_fds:
wsi->oom4 = 0;
__remove_wsi_socket_from_fds(wsi);
@ -763,6 +765,8 @@ lws_client_connect_2_dnsreq(struct lws *wsi)
create_new_conn:
#endif
wsi->addrinfo_idx = 0;
/*
* clients who will create their own fresh connection keep a copy of
* the hostname they originally connected to, in case other connections