summaryrefslogtreecommitdiffstats
path: root/lib/multi.c
diff options
context:
space:
mode:
authorCurl Upstream <curl-library@cool.haxx.se>2021-05-26 06:18:11 (GMT)
committerBrad King <brad.king@kitware.com>2021-05-27 19:11:35 (GMT)
commit18b2a8d7604f3aced9c93220806851f96e231f36 (patch)
tree5a79eb90691de68ebfb91ac85d7e8faea3190a4d /lib/multi.c
parent076b3219f58ca16afa52fe095019a05537ade0f3 (diff)
downloadCMake-18b2a8d7604f3aced9c93220806851f96e231f36.zip
CMake-18b2a8d7604f3aced9c93220806851f96e231f36.tar.gz
CMake-18b2a8d7604f3aced9c93220806851f96e231f36.tar.bz2
curl 2021-05-26 (6b951a69)
Code extracted from: https://github.com/curl/curl.git at commit 6b951a6928811507d493303b2878e848c077b471 (curl-7_77_0).
Diffstat (limited to 'lib/multi.c')
-rw-r--r--lib/multi.c480
1 files changed, 296 insertions, 184 deletions
diff --git a/lib/multi.c b/lib/multi.c
index 85707a1..1b3e261 100644
--- a/lib/multi.c
+++ b/lib/multi.c
@@ -83,19 +83,19 @@ static void process_pending_handles(struct Curl_multi *multi);
#ifdef DEBUGBUILD
static const char * const statename[]={
"INIT",
- "CONNECT_PEND",
+ "PENDING",
"CONNECT",
- "WAITRESOLVE",
- "WAITCONNECT",
- "WAITPROXYCONNECT",
- "SENDPROTOCONNECT",
+ "RESOLVING",
+ "CONNECTING",
+ "TUNNELING",
"PROTOCONNECT",
+ "PROTOCONNECTING",
"DO",
"DOING",
- "DO_MORE",
- "DO_DONE",
- "PERFORM",
- "TOOFAST",
+ "DOING_MORE",
+ "DID",
+ "PERFORMING",
+ "RATELIMITING",
"DONE",
"COMPLETED",
"MSGSENT",
@@ -105,8 +105,8 @@ static const char * const statename[]={
/* function pointer called once when switching TO a state */
typedef void (*init_multistate_func)(struct Curl_easy *data);
-/* called when the PERFORM state starts */
-static void init_perform(struct Curl_easy *data)
+/* called in DID state, before PERFORMING state */
+static void before_perform(struct Curl_easy *data)
{
data->req.chunk = FALSE;
Curl_pgrsTime(data, TIMER_PRETRANSFER);
@@ -130,21 +130,21 @@ static void mstate(struct Curl_easy *data, CURLMstate state
)
{
CURLMstate oldstate = data->mstate;
- static const init_multistate_func finit[CURLM_STATE_LAST] = {
+ static const init_multistate_func finit[MSTATE_LAST] = {
NULL, /* INIT */
- NULL, /* CONNECT_PEND */
+ NULL, /* PENDING */
Curl_init_CONNECT, /* CONNECT */
- NULL, /* WAITRESOLVE */
- NULL, /* WAITCONNECT */
- NULL, /* WAITPROXYCONNECT */
- NULL, /* SENDPROTOCONNECT */
+ NULL, /* RESOLVING */
+ NULL, /* CONNECTING */
+ NULL, /* TUNNELING */
NULL, /* PROTOCONNECT */
+ NULL, /* PROTOCONNECTING */
Curl_connect_free, /* DO */
NULL, /* DOING */
- NULL, /* DO_MORE */
- NULL, /* DO_DONE */
- init_perform, /* PERFORM */
- NULL, /* TOOFAST */
+ NULL, /* DOING_MORE */
+ before_perform, /* DID */
+ NULL, /* PERFORMING */
+ NULL, /* RATELIMITING */
NULL, /* DONE */
init_completed, /* COMPLETED */
NULL /* MSGSENT */
@@ -161,8 +161,8 @@ static void mstate(struct Curl_easy *data, CURLMstate state
data->mstate = state;
#if defined(DEBUGBUILD) && !defined(CURL_DISABLE_VERBOSE_STRINGS)
- if(data->mstate >= CURLM_STATE_CONNECT_PEND &&
- data->mstate < CURLM_STATE_COMPLETED) {
+ if(data->mstate >= MSTATE_PENDING &&
+ data->mstate < MSTATE_COMPLETED) {
long connection_id = -5000;
if(data->conn)
@@ -175,7 +175,7 @@ static void mstate(struct Curl_easy *data, CURLMstate state
}
#endif
- if(state == CURLM_STATE_COMPLETED) {
+ if(state == MSTATE_COMPLETED) {
/* changing to COMPLETED means there's one less easy handle 'alive' */
DEBUGASSERT(data->multi->num_alive > 0);
data->multi->num_alive--;
@@ -381,6 +381,11 @@ struct Curl_multi *Curl_multi_handle(int hashsize, /* socket hash */
multi->max_concurrent_streams = 100;
multi->ipv6_works = Curl_ipv6works(NULL);
+#ifdef USE_WINSOCK
+ multi->wsa_event = WSACreateEvent();
+ if(multi->wsa_event == WSA_INVALID_EVENT)
+ goto error;
+#else
#ifdef ENABLE_WAKEUP
if(Curl_socketpair(AF_UNIX, SOCK_STREAM, 0, multi->wakeup_pair) < 0) {
multi->wakeup_pair[0] = CURL_SOCKET_BAD;
@@ -394,6 +399,7 @@ struct Curl_multi *Curl_multi_handle(int hashsize, /* socket hash */
multi->wakeup_pair[1] = CURL_SOCKET_BAD;
}
#endif
+#endif
return multi;
@@ -447,7 +453,7 @@ CURLMcode curl_multi_add_handle(struct Curl_multi *multi,
data->set.errorbuffer[0] = 0;
/* set the easy handle */
- multistate(data, CURLM_STATE_INIT);
+ multistate(data, MSTATE_INIT);
/* for multi interface connections, we share DNS cache automatically if the
easy handle's one is currently not set. */
@@ -562,8 +568,6 @@ static CURLcode multi_done(struct Curl_easy *data,
/* Stop if multi_done() has already been called */
return CURLE_OK;
- conn->data = data; /* ensure the connection uses this transfer now */
-
/* Stop the resolver and free its own resources (but not dns_entry yet). */
Curl_resolver_kill(data);
@@ -604,16 +608,13 @@ static CURLcode multi_done(struct Curl_easy *data,
Curl_detach_connnection(data);
if(CONN_INUSE(conn)) {
/* Stop if still used. */
- /* conn->data must not remain pointing to this transfer since it is going
- away! Find another to own it! */
- conn->data = conn->easyq.head->ptr;
CONNCACHE_UNLOCK(data);
DEBUGF(infof(data, "Connection still in use %zu, "
"no more multi_done now!\n",
conn->easyq.size));
return CURLE_OK;
}
- conn->data = NULL; /* the connection now has no owner */
+
data->state.done = TRUE; /* called just now! */
if(conn->dns_entry) {
@@ -718,7 +719,6 @@ CURLMcode curl_multi_remove_handle(struct Curl_multi *multi,
{
struct Curl_easy *easy = data;
bool premature;
- bool easy_owns_conn;
struct Curl_llist_element *e;
/* First, make some basic checks that the CURLM handle is a good handle */
@@ -740,9 +740,7 @@ CURLMcode curl_multi_remove_handle(struct Curl_multi *multi,
if(multi->in_callback)
return CURLM_RECURSIVE_API_CALL;
- premature = (data->mstate < CURLM_STATE_COMPLETED) ? TRUE : FALSE;
- easy_owns_conn = (data->conn && (data->conn->data == easy)) ?
- TRUE : FALSE;
+ premature = (data->mstate < MSTATE_COMPLETED) ? TRUE : FALSE;
/* If the 'state' is not INIT or COMPLETED, we might need to do something
nice to put the easy_handle in a good known state when this returns. */
@@ -753,28 +751,20 @@ CURLMcode curl_multi_remove_handle(struct Curl_multi *multi,
}
if(data->conn &&
- data->mstate > CURLM_STATE_DO &&
- data->mstate < CURLM_STATE_COMPLETED) {
+ data->mstate > MSTATE_DO &&
+ data->mstate < MSTATE_COMPLETED) {
/* Set connection owner so that the DONE function closes it. We can
safely do this here since connection is killed. */
- data->conn->data = easy;
streamclose(data->conn, "Removed with partial response");
- easy_owns_conn = TRUE;
}
if(data->conn) {
+ /* multi_done() clears the association between the easy handle and the
+ connection.
- /* we must call multi_done() here (if we still own the connection) so that
- we don't leave a half-baked one around */
- if(easy_owns_conn) {
-
- /* multi_done() clears the association between the easy handle and the
- connection.
-
- Note that this ignores the return code simply because there's
- nothing really useful to do with it anyway! */
- (void)multi_done(data, data->result, premature);
- }
+ Note that this ignores the return code simply because there's
+ nothing really useful to do with it anyway! */
+ (void)multi_done(data, data->result, premature);
}
/* The timer must be shut down before data->multi is set to NULL, else the
@@ -802,7 +792,7 @@ CURLMcode curl_multi_remove_handle(struct Curl_multi *multi,
/* change state without using multistate(), only to make singlesocket() do
what we want */
- data->mstate = CURLM_STATE_COMPLETED;
+ data->mstate = MSTATE_COMPLETED;
singlesocket(multi, easy); /* to let the application know what sockets that
vanish with this handle */
@@ -840,6 +830,17 @@ CURLMcode curl_multi_remove_handle(struct Curl_multi *multi,
}
}
+ /* Remove from the pending list if it is there. Otherwise this will
+ remain on the pending list forever due to the state change. */
+ for(e = multi->pending.head; e; e = e->next) {
+ struct Curl_easy *curr_data = e->ptr;
+
+ if(curr_data == data) {
+ Curl_llist_remove(&multi->pending, e, NULL);
+ break;
+ }
+ }
+
/* make the previous node point to our next */
if(data->prev)
data->prev->next = data->next;
@@ -856,6 +857,8 @@ CURLMcode curl_multi_remove_handle(struct Curl_multi *multi,
We do not touch the easy handle here! */
multi->num_easy--; /* one less to care about now */
+ process_pending_handles(multi);
+
Curl_update_timer(multi);
return CURLM_OK;
}
@@ -875,8 +878,10 @@ bool Curl_multiplex_wanted(const struct Curl_multi *multi)
void Curl_detach_connnection(struct Curl_easy *data)
{
struct connectdata *conn = data->conn;
- if(conn)
+ if(conn) {
Curl_llist_remove(&conn->easyq, &data->conn_queue, NULL);
+ Curl_ssl_detach_conn(data, conn);
+ }
data->conn = NULL;
}
@@ -893,6 +898,9 @@ void Curl_attach_connnection(struct Curl_easy *data,
data->conn = conn;
Curl_llist_insert_next(&conn->easyq, conn->easyq.tail, data,
&data->conn_queue);
+ if(conn->handler->attach)
+ conn->handler->attach(data, conn);
+ Curl_ssl_associate_conn(data, conn);
}
static int waitconnect_getsock(struct connectdata *conn,
@@ -905,7 +913,7 @@ static int waitconnect_getsock(struct connectdata *conn,
#ifdef USE_SSL
#ifndef CURL_DISABLE_PROXY
if(CONNECT_FIRSTSOCKET_PROXY_SSL())
- return Curl_ssl_getsock(conn, sock);
+ return Curl_ssl->getsock(conn, sock);
#endif
#endif
@@ -933,10 +941,8 @@ static int waitproxyconnect_getsock(struct connectdata *conn,
{
sock[0] = conn->sock[FIRSTSOCKET];
- /* when we've sent a CONNECT to a proxy, we should rather wait for the
- socket to become readable to be able to get the response headers */
if(conn->connect_state)
- return GETSOCK_READSOCK(0);
+ return Curl_connect_getsock(conn);
return GETSOCK_WRITESOCK(0);
}
@@ -984,40 +990,33 @@ static int multi_getsock(struct Curl_easy *data,
if(!conn)
return 0;
- if(data->mstate > CURLM_STATE_CONNECT &&
- data->mstate < CURLM_STATE_COMPLETED) {
- /* Set up ownership correctly */
- data->conn->data = data;
- }
-
switch(data->mstate) {
default:
return 0;
- case CURLM_STATE_WAITRESOLVE:
+ case MSTATE_RESOLVING:
return Curl_resolv_getsock(data, socks);
- case CURLM_STATE_PROTOCONNECT:
- case CURLM_STATE_SENDPROTOCONNECT:
+ case MSTATE_PROTOCONNECTING:
+ case MSTATE_PROTOCONNECT:
return protocol_getsock(data, conn, socks);
- case CURLM_STATE_DO:
- case CURLM_STATE_DOING:
+ case MSTATE_DO:
+ case MSTATE_DOING:
return doing_getsock(data, conn, socks);
- case CURLM_STATE_WAITPROXYCONNECT:
+ case MSTATE_TUNNELING:
return waitproxyconnect_getsock(conn, socks);
- case CURLM_STATE_WAITCONNECT:
+ case MSTATE_CONNECTING:
return waitconnect_getsock(conn, socks);
- case CURLM_STATE_DO_MORE:
+ case MSTATE_DOING_MORE:
return domore_getsock(data, conn, socks);
- case CURLM_STATE_DO_DONE: /* since is set after DO is completed, we switch
- to waiting for the same as the *PERFORM
- states */
- case CURLM_STATE_PERFORM:
+ case MSTATE_DID: /* since is set after DO is completed, we switch to
+ waiting for the same as the PERFORMING state */
+ case MSTATE_PERFORMING:
return Curl_single_getsock(data, conn, socks);
}
@@ -1093,6 +1092,10 @@ static CURLMcode multi_wait(struct Curl_multi *multi,
struct pollfd a_few_on_stack[NUM_POLLS_ON_STACK];
struct pollfd *ufds = &a_few_on_stack[0];
bool ufds_malloc = FALSE;
+#ifdef USE_WINSOCK
+ WSANETWORKEVENTS wsa_events;
+ DEBUGASSERT(multi->wsa_event != WSA_INVALID_EVENT);
+#endif
if(!GOOD_MULTI_HANDLE(multi))
return CURLM_BAD_HANDLE;
@@ -1111,11 +1114,11 @@ static CURLMcode multi_wait(struct Curl_multi *multi,
for(i = 0; i< MAX_SOCKSPEREASYHANDLE; i++) {
curl_socket_t s = CURL_SOCKET_BAD;
- if(bitmap & GETSOCK_READSOCK(i)) {
+ if((bitmap & GETSOCK_READSOCK(i)) && VALID_SOCK((sockbunch[i]))) {
++nfds;
s = sockbunch[i];
}
- if(bitmap & GETSOCK_WRITESOCK(i)) {
+ if((bitmap & GETSOCK_WRITESOCK(i)) && VALID_SOCK((sockbunch[i]))) {
++nfds;
s = sockbunch[i];
}
@@ -1138,7 +1141,11 @@ static CURLMcode multi_wait(struct Curl_multi *multi,
nfds += extra_nfds; /* add the externally provided ones */
#ifdef ENABLE_WAKEUP
+#ifdef USE_WINSOCK
+ if(use_wakeup) {
+#else
if(use_wakeup && multi->wakeup_pair[0] != CURL_SOCKET_BAD) {
+#endif
++nfds;
}
#endif
@@ -1166,22 +1173,40 @@ static CURLMcode multi_wait(struct Curl_multi *multi,
for(i = 0; i < MAX_SOCKSPEREASYHANDLE; i++) {
curl_socket_t s = CURL_SOCKET_BAD;
-
+#ifdef USE_WINSOCK
+ long mask = 0;
+#endif
if(bitmap & GETSOCK_READSOCK(i)) {
- ufds[nfds].fd = sockbunch[i];
+ s = sockbunch[i];
+#ifdef USE_WINSOCK
+ mask |= FD_READ|FD_ACCEPT|FD_CLOSE;
+#endif
+ ufds[nfds].fd = s;
ufds[nfds].events = POLLIN;
++nfds;
- s = sockbunch[i];
}
if(bitmap & GETSOCK_WRITESOCK(i)) {
- ufds[nfds].fd = sockbunch[i];
+ s = sockbunch[i];
+#ifdef USE_WINSOCK
+ mask |= FD_WRITE|FD_CONNECT|FD_CLOSE;
+ send(s, NULL, 0, 0); /* reset FD_WRITE */
+#endif
+ ufds[nfds].fd = s;
ufds[nfds].events = POLLOUT;
++nfds;
- s = sockbunch[i];
}
+ /* s is only set if either being readable or writable is checked */
if(s == CURL_SOCKET_BAD) {
+ /* break on entry not checked for being readable or writable */
break;
}
+#ifdef USE_WINSOCK
+ if(WSAEventSelect(s, multi->wsa_event, mask) != 0) {
+ if(ufds_malloc)
+ free(ufds);
+ return CURLM_INTERNAL_ERROR;
+ }
+#endif
}
data = data->next; /* check next handle */
@@ -1190,6 +1215,22 @@ static CURLMcode multi_wait(struct Curl_multi *multi,
/* Add external file descriptions from poll-like struct curl_waitfd */
for(i = 0; i < extra_nfds; i++) {
+#ifdef USE_WINSOCK
+ long mask = 0;
+ if(extra_fds[i].events & CURL_WAIT_POLLIN)
+ mask |= FD_READ|FD_ACCEPT|FD_CLOSE;
+ if(extra_fds[i].events & CURL_WAIT_POLLPRI)
+ mask |= FD_OOB;
+ if(extra_fds[i].events & CURL_WAIT_POLLOUT) {
+ mask |= FD_WRITE|FD_CONNECT|FD_CLOSE;
+ send(extra_fds[i].fd, NULL, 0, 0); /* reset FD_WRITE */
+ }
+ if(WSAEventSelect(extra_fds[i].fd, multi->wsa_event, mask) != 0) {
+ if(ufds_malloc)
+ free(ufds);
+ return CURLM_INTERNAL_ERROR;
+ }
+#endif
ufds[nfds].fd = extra_fds[i].fd;
ufds[nfds].events = 0;
if(extra_fds[i].events & CURL_WAIT_POLLIN)
@@ -1202,25 +1243,62 @@ static CURLMcode multi_wait(struct Curl_multi *multi,
}
#ifdef ENABLE_WAKEUP
+#ifndef USE_WINSOCK
if(use_wakeup && multi->wakeup_pair[0] != CURL_SOCKET_BAD) {
ufds[nfds].fd = multi->wakeup_pair[0];
ufds[nfds].events = POLLIN;
++nfds;
}
#endif
+#endif
+#if defined(ENABLE_WAKEUP) && defined(USE_WINSOCK)
+ if(nfds || use_wakeup) {
+#else
if(nfds) {
- /* wait... */
- int pollrc = Curl_poll(ufds, nfds, timeout_ms);
+#endif
+ int pollrc;
+#ifdef USE_WINSOCK
+ if(nfds)
+ pollrc = Curl_poll(ufds, nfds, 0); /* just pre-check with WinSock */
+ else
+ pollrc = 0;
+ if(pollrc <= 0) /* now wait... if not ready during the pre-check above */
+ WSAWaitForMultipleEvents(1, &multi->wsa_event, FALSE, timeout_ms, FALSE);
+#else
+ pollrc = Curl_poll(ufds, nfds, timeout_ms); /* wait... */
+#endif
+
if(pollrc > 0) {
retcode = pollrc;
+#ifdef USE_WINSOCK
+ }
+ /* With WinSock, we have to run the following section unconditionally
+ to call WSAEventSelect(fd, event, 0) on all the sockets */
+ {
+#endif
/* copy revents results from the poll to the curl_multi_wait poll
struct, the bit values of the actual underlying poll() implementation
may not be the same as the ones in the public libcurl API! */
for(i = 0; i < extra_nfds; i++) {
- unsigned short mask = 0;
unsigned r = ufds[curlfds + i].revents;
-
+ unsigned short mask = 0;
+#ifdef USE_WINSOCK
+ wsa_events.lNetworkEvents = 0;
+ if(WSAEnumNetworkEvents(extra_fds[i].fd, NULL, &wsa_events) == 0) {
+ if(wsa_events.lNetworkEvents & (FD_READ|FD_ACCEPT|FD_CLOSE))
+ mask |= CURL_WAIT_POLLIN;
+ if(wsa_events.lNetworkEvents & (FD_WRITE|FD_CONNECT|FD_CLOSE))
+ mask |= CURL_WAIT_POLLOUT;
+ if(wsa_events.lNetworkEvents & FD_OOB)
+ mask |= CURL_WAIT_POLLPRI;
+ if(ret && pollrc <= 0 && wsa_events.lNetworkEvents)
+ retcode++;
+ }
+ WSAEventSelect(extra_fds[i].fd, multi->wsa_event, 0);
+ if(pollrc <= 0)
+ continue;
+#endif
if(r & POLLIN)
mask |= CURL_WAIT_POLLIN;
if(r & POLLOUT)
@@ -1230,6 +1308,35 @@ static CURLMcode multi_wait(struct Curl_multi *multi,
extra_fds[i].revents = mask;
}
+#ifdef USE_WINSOCK
+ /* Count up all our own sockets that had activity,
+ and remove them from the event. */
+ if(curlfds) {
+ data = multi->easyp;
+ while(data) {
+ bitmap = multi_getsock(data, sockbunch);
+
+ for(i = 0; i < MAX_SOCKSPEREASYHANDLE; i++) {
+ if(bitmap & (GETSOCK_READSOCK(i) | GETSOCK_WRITESOCK(i))) {
+ wsa_events.lNetworkEvents = 0;
+ if(WSAEnumNetworkEvents(sockbunch[i], NULL, &wsa_events) == 0) {
+ if(ret && pollrc <= 0 && wsa_events.lNetworkEvents)
+ retcode++;
+ }
+ WSAEventSelect(sockbunch[i], multi->wsa_event, 0);
+ }
+ else {
+ /* break on entry not checked for being readable or writable */
+ break;
+ }
+ }
+
+ data = data->next;
+ }
+ }
+
+ WSAResetEvent(multi->wsa_event);
+#else
#ifdef ENABLE_WAKEUP
if(use_wakeup && multi->wakeup_pair[0] != CURL_SOCKET_BAD) {
if(ufds[curlfds + extra_nfds].revents & POLLIN) {
@@ -1242,10 +1349,8 @@ static CURLMcode multi_wait(struct Curl_multi *multi,
when there is no more data, breaking the loop. */
nread = sread(multi->wakeup_pair[0], buf, sizeof(buf));
if(nread <= 0) {
-#ifndef USE_WINSOCK
if(nread < 0 && EINTR == SOCKERRNO)
continue;
-#endif
break;
}
}
@@ -1254,6 +1359,7 @@ static CURLMcode multi_wait(struct Curl_multi *multi,
}
}
#endif
+#endif
}
}
@@ -1261,10 +1367,11 @@ static CURLMcode multi_wait(struct Curl_multi *multi,
free(ufds);
if(ret)
*ret = retcode;
- if(!extrawait || nfds)
- /* if any socket was checked */
- ;
- else {
+#if defined(ENABLE_WAKEUP) && defined(USE_WINSOCK)
+ if(extrawait && !nfds && !use_wakeup) {
+#else
+ if(extrawait && !nfds) {
+#endif
long sleep_ms = 0;
/* Avoid busy-looping when there's nothing particular to wait for */
@@ -1313,6 +1420,10 @@ CURLMcode curl_multi_wakeup(struct Curl_multi *multi)
return CURLM_BAD_HANDLE;
#ifdef ENABLE_WAKEUP
+#ifdef USE_WINSOCK
+ if(WSASetEvent(multi->wsa_event))
+ return CURLM_OK;
+#else
/* the wakeup_pair variable is only written during init and cleanup,
making it safe to access from another thread after the init part
and before cleanup */
@@ -1346,6 +1457,7 @@ CURLMcode curl_multi_wakeup(struct Curl_multi *multi)
}
}
#endif
+#endif
return CURLM_WAKEUP_FAILURE;
}
@@ -1383,7 +1495,7 @@ CURLMcode Curl_multi_add_perform(struct Curl_multi *multi,
Curl_init_do(data, NULL);
/* take this handle to the perform state right away */
- multistate(data, CURLM_STATE_PERFORM);
+ multistate(data, MSTATE_PERFORMING);
Curl_attach_connnection(data, conn);
k->keepon |= KEEP_RECV; /* setup to receive! */
}
@@ -1397,7 +1509,6 @@ static CURLcode multi_do(struct Curl_easy *data, bool *done)
DEBUGASSERT(conn);
DEBUGASSERT(conn->handler);
- DEBUGASSERT(conn->data == data);
if(conn->handler->do_it)
/* generic protocol-specific function pointer set in curl_connect() */
@@ -1578,31 +1689,30 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
process_pending_handles(multi); /* multiplexed */
}
- if(data->mstate > CURLM_STATE_CONNECT &&
- data->mstate < CURLM_STATE_COMPLETED) {
+ if(data->mstate > MSTATE_CONNECT &&
+ data->mstate < MSTATE_COMPLETED) {
/* Make sure we set the connection's current owner */
DEBUGASSERT(data->conn);
if(!data->conn)
return CURLM_INTERNAL_ERROR;
- data->conn->data = data;
}
if(data->conn &&
- (data->mstate >= CURLM_STATE_CONNECT) &&
- (data->mstate < CURLM_STATE_COMPLETED)) {
+ (data->mstate >= MSTATE_CONNECT) &&
+ (data->mstate < MSTATE_COMPLETED)) {
/* we need to wait for the connect state as only then is the start time
stored, but we must not check already completed handles */
timeout_ms = Curl_timeleft(data, nowp,
- (data->mstate <= CURLM_STATE_DO)?
+ (data->mstate <= MSTATE_DO)?
TRUE:FALSE);
if(timeout_ms < 0) {
/* Handle timed out */
- if(data->mstate == CURLM_STATE_WAITRESOLVE)
+ if(data->mstate == MSTATE_RESOLVING)
failf(data, "Resolving timed out after %" CURL_FORMAT_TIMEDIFF_T
" milliseconds",
Curl_timediff(*nowp, data->progress.t_startsingle));
- else if(data->mstate == CURLM_STATE_WAITCONNECT)
+ else if(data->mstate == MSTATE_CONNECTING)
failf(data, "Connection timed out after %" CURL_FORMAT_TIMEDIFF_T
" milliseconds",
Curl_timediff(*nowp, data->progress.t_startsingle));
@@ -1625,7 +1735,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
}
/* Force connection closed if the connection has indeed been used */
- if(data->mstate > CURLM_STATE_DO) {
+ if(data->mstate > MSTATE_DO) {
streamclose(data->conn, "Disconnected with pending data");
stream_error = TRUE;
}
@@ -1637,24 +1747,24 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
}
switch(data->mstate) {
- case CURLM_STATE_INIT:
+ case MSTATE_INIT:
/* init this transfer. */
result = Curl_pretransfer(data);
if(!result) {
/* after init, go CONNECT */
- multistate(data, CURLM_STATE_CONNECT);
+ multistate(data, MSTATE_CONNECT);
*nowp = Curl_pgrsTime(data, TIMER_STARTOP);
rc = CURLM_CALL_MULTI_PERFORM;
}
break;
- case CURLM_STATE_CONNECT_PEND:
+ case MSTATE_PENDING:
/* We will stay here until there is a connection available. Then
- we try again in the CURLM_STATE_CONNECT state. */
+ we try again in the MSTATE_CONNECT state. */
break;
- case CURLM_STATE_CONNECT:
+ case MSTATE_CONNECT:
/* Connect. We want to get a connection identifier filled in. */
/* init this transfer. */
result = Curl_preconnect(data);
@@ -1672,7 +1782,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
if(CURLE_NO_CONNECTION_AVAILABLE == result) {
/* There was no connection available. We will go to the pending
state and wait for an available connection. */
- multistate(data, CURLM_STATE_CONNECT_PEND);
+ multistate(data, MSTATE_PENDING);
/* add this handle to the list of connect-pending handles */
Curl_llist_insert_next(&multi->pending, multi->pending.tail, data,
@@ -1689,7 +1799,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
if(!result) {
if(async)
/* We're now waiting for an asynchronous name lookup */
- multistate(data, CURLM_STATE_WAITRESOLVE);
+ multistate(data, MSTATE_RESOLVING);
else {
/* after the connect has been sent off, go WAITCONNECT unless the
protocol connect is already done and we can go directly to
@@ -1697,20 +1807,20 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
rc = CURLM_CALL_MULTI_PERFORM;
if(protocol_connected)
- multistate(data, CURLM_STATE_DO);
+ multistate(data, MSTATE_DO);
else {
#ifndef CURL_DISABLE_HTTP
if(Curl_connect_ongoing(data->conn))
- multistate(data, CURLM_STATE_WAITPROXYCONNECT);
+ multistate(data, MSTATE_TUNNELING);
else
#endif
- multistate(data, CURLM_STATE_WAITCONNECT);
+ multistate(data, MSTATE_CONNECTING);
}
}
}
break;
- case CURLM_STATE_WAITRESOLVE:
+ case MSTATE_RESOLVING:
/* awaiting an asynch name resolve to complete */
{
struct Curl_dns_entry *dns = NULL;
@@ -1764,14 +1874,14 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
/* call again please so that we get the next socket setup */
rc = CURLM_CALL_MULTI_PERFORM;
if(protocol_connected)
- multistate(data, CURLM_STATE_DO);
+ multistate(data, MSTATE_DO);
else {
#ifndef CURL_DISABLE_HTTP
if(Curl_connect_ongoing(data->conn))
- multistate(data, CURLM_STATE_WAITPROXYCONNECT);
+ multistate(data, MSTATE_TUNNELING);
else
#endif
- multistate(data, CURLM_STATE_WAITCONNECT);
+ multistate(data, MSTATE_CONNECTING);
}
}
}
@@ -1785,7 +1895,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
break;
#ifndef CURL_DISABLE_HTTP
- case CURLM_STATE_WAITPROXYCONNECT:
+ case MSTATE_TUNNELING:
/* this is HTTP-specific, but sending CONNECT to a proxy is HTTP... */
DEBUGASSERT(data->conn);
result = Curl_http_connect(data, &protocol_connected);
@@ -1795,7 +1905,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
/* connect back to proxy again */
result = CURLE_OK;
multi_done(data, CURLE_OK, FALSE);
- multistate(data, CURLM_STATE_CONNECT);
+ multistate(data, MSTATE_CONNECT);
}
else
#endif
@@ -1808,7 +1918,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
Curl_connect_complete(data->conn)) {
rc = CURLM_CALL_MULTI_PERFORM;
/* initiate protocol connect phase */
- multistate(data, CURLM_STATE_SENDPROTOCONNECT);
+ multistate(data, MSTATE_PROTOCONNECT);
}
}
else
@@ -1816,7 +1926,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
break;
#endif
- case CURLM_STATE_WAITCONNECT:
+ case MSTATE_CONNECTING:
/* awaiting a completion of an asynch TCP connect */
DEBUGASSERT(data->conn);
result = Curl_is_connected(data, data->conn, FIRSTSOCKET, &connected);
@@ -1828,7 +1938,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
!data->conn->bits.proxy_ssl_connected[FIRSTSOCKET]) ||
#endif
Curl_connect_ongoing(data->conn)) {
- multistate(data, CURLM_STATE_WAITPROXYCONNECT);
+ multistate(data, MSTATE_TUNNELING);
break;
}
#endif
@@ -1836,10 +1946,9 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
#ifndef CURL_DISABLE_PROXY
multistate(data,
data->conn->bits.tunnel_proxy?
- CURLM_STATE_WAITPROXYCONNECT:
- CURLM_STATE_SENDPROTOCONNECT);
+ MSTATE_TUNNELING : MSTATE_PROTOCONNECT);
#else
- multistate(data, CURLM_STATE_SENDPROTOCONNECT);
+ multistate(data, MSTATE_PROTOCONNECT);
#endif
}
else if(result) {
@@ -1851,14 +1960,14 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
}
break;
- case CURLM_STATE_SENDPROTOCONNECT:
+ case MSTATE_PROTOCONNECT:
result = protocol_connect(data, &protocol_connected);
if(!result && !protocol_connected)
/* switch to waiting state */
- multistate(data, CURLM_STATE_PROTOCONNECT);
+ multistate(data, MSTATE_PROTOCONNECTING);
else if(!result) {
/* protocol connect has completed, go WAITDO or DO */
- multistate(data, CURLM_STATE_DO);
+ multistate(data, MSTATE_DO);
rc = CURLM_CALL_MULTI_PERFORM;
}
else {
@@ -1869,12 +1978,12 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
}
break;
- case CURLM_STATE_PROTOCONNECT:
+ case MSTATE_PROTOCONNECTING:
/* protocol-specific connect phase */
result = protocol_connecting(data, &protocol_connected);
if(!result && protocol_connected) {
/* after the connect has completed, go WAITDO or DO */
- multistate(data, CURLM_STATE_DO);
+ multistate(data, MSTATE_DO);
rc = CURLM_CALL_MULTI_PERFORM;
}
else if(result) {
@@ -1885,11 +1994,11 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
}
break;
- case CURLM_STATE_DO:
+ case MSTATE_DO:
if(data->set.connect_only) {
/* keep connection open for application to use the socket */
connkeep(data->conn, "CONNECT_ONLY");
- multistate(data, CURLM_STATE_DONE);
+ multistate(data, MSTATE_DONE);
result = CURLE_OK;
rc = CURLM_CALL_MULTI_PERFORM;
}
@@ -1911,7 +2020,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
/* if there's no connection left, skip the DONE state */
multistate(data, data->conn ?
- CURLM_STATE_DONE : CURLM_STATE_COMPLETED);
+ MSTATE_DONE : MSTATE_COMPLETED);
rc = CURLM_CALL_MULTI_PERFORM;
break;
}
@@ -1919,7 +2028,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
#endif
/* DO was not completed in one function call, we must continue
DOING... */
- multistate(data, CURLM_STATE_DOING);
+ multistate(data, MSTATE_DOING);
rc = CURLM_OK;
}
@@ -1927,12 +2036,12 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
else if(data->conn->bits.do_more) {
/* we're supposed to do more, but we need to sit down, relax
and wait a little while first */
- multistate(data, CURLM_STATE_DO_MORE);
+ multistate(data, MSTATE_DOING_MORE);
rc = CURLM_OK;
}
else {
- /* we're done with the DO, now DO_DONE */
- multistate(data, CURLM_STATE_DO_DONE);
+ /* we're done with the DO, now DID */
+ multistate(data, MSTATE_DID);
rc = CURLM_CALL_MULTI_PERFORM;
}
}
@@ -1964,7 +2073,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
follow = FOLLOW_RETRY;
drc = Curl_follow(data, newurl, follow);
if(!drc) {
- multistate(data, CURLM_STATE_CONNECT);
+ multistate(data, MSTATE_CONNECT);
rc = CURLM_CALL_MULTI_PERFORM;
result = CURLE_OK;
}
@@ -1994,7 +2103,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
}
break;
- case CURLM_STATE_DOING:
+ case MSTATE_DOING:
/* we continue DOING until the DO phase is complete */
DEBUGASSERT(data->conn);
result = protocol_doing(data, &dophase_done);
@@ -2002,8 +2111,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
if(dophase_done) {
/* after DO, go DO_DONE or DO_MORE */
multistate(data, data->conn->bits.do_more?
- CURLM_STATE_DO_MORE:
- CURLM_STATE_DO_DONE);
+ MSTATE_DOING_MORE : MSTATE_DID);
rc = CURLM_CALL_MULTI_PERFORM;
} /* dophase_done */
}
@@ -2015,9 +2123,9 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
}
break;
- case CURLM_STATE_DO_MORE:
+ case MSTATE_DOING_MORE:
/*
- * When we are connected, DO MORE and then go DO_DONE
+ * When we are connected, DOING MORE and then go DID
*/
DEBUGASSERT(data->conn);
result = multi_do_more(data, &control);
@@ -2027,8 +2135,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
/* if positive, advance to DO_DONE
if negative, go back to DOING */
multistate(data, control == 1?
- CURLM_STATE_DO_DONE:
- CURLM_STATE_DOING);
+ MSTATE_DID : MSTATE_DOING);
rc = CURLM_CALL_MULTI_PERFORM;
}
else
@@ -2043,7 +2150,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
}
break;
- case CURLM_STATE_DO_DONE:
+ case MSTATE_DID:
DEBUGASSERT(data->conn);
if(data->conn->bits.multiplex)
/* Check if we can move pending requests to send pipe */
@@ -2053,7 +2160,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
Having both BAD is a signal to skip immediately to DONE */
if((data->conn->sockfd != CURL_SOCKET_BAD) ||
(data->conn->writesockfd != CURL_SOCKET_BAD))
- multistate(data, CURLM_STATE_PERFORM);
+ multistate(data, MSTATE_PERFORMING);
else {
#ifndef CURL_DISABLE_FTP
if(data->state.wildcardmatch &&
@@ -2061,12 +2168,12 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
data->wildcard.state = CURLWC_DONE;
}
#endif
- multistate(data, CURLM_STATE_DONE);
+ multistate(data, MSTATE_DONE);
}
rc = CURLM_CALL_MULTI_PERFORM;
break;
- case CURLM_STATE_TOOFAST: /* limit-rate exceeded in either direction */
+ case MSTATE_RATELIMITING: /* limit-rate exceeded in either direction */
DEBUGASSERT(data->conn);
/* if both rates are within spec, resume transfer */
if(Curl_pgrsUpdate(data))
@@ -2084,7 +2191,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
}
else {
send_timeout_ms = 0;
- if(data->set.max_send_speed > 0)
+ if(data->set.max_send_speed)
send_timeout_ms =
Curl_pgrsLimitWaitTime(data->progress.uploaded,
data->progress.ul_limit_size,
@@ -2093,7 +2200,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
*nowp);
recv_timeout_ms = 0;
- if(data->set.max_recv_speed > 0)
+ if(data->set.max_recv_speed)
recv_timeout_ms =
Curl_pgrsLimitWaitTime(data->progress.downloaded,
data->progress.dl_limit_size,
@@ -2102,7 +2209,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
*nowp);
if(!send_timeout_ms && !recv_timeout_ms) {
- multistate(data, CURLM_STATE_PERFORM);
+ multistate(data, MSTATE_PERFORMING);
Curl_ratelimit(data, *nowp);
}
else if(send_timeout_ms >= recv_timeout_ms)
@@ -2112,7 +2219,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
}
break;
- case CURLM_STATE_PERFORM:
+ case MSTATE_PERFORMING:
{
char *newurl = NULL;
bool retry = FALSE;
@@ -2120,7 +2227,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
DEBUGASSERT(data->state.buffer);
/* check if over send speed */
send_timeout_ms = 0;
- if(data->set.max_send_speed > 0)
+ if(data->set.max_send_speed)
send_timeout_ms = Curl_pgrsLimitWaitTime(data->progress.uploaded,
data->progress.ul_limit_size,
data->set.max_send_speed,
@@ -2129,7 +2236,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
/* check if over recv speed */
recv_timeout_ms = 0;
- if(data->set.max_recv_speed > 0)
+ if(data->set.max_recv_speed)
recv_timeout_ms = Curl_pgrsLimitWaitTime(data->progress.downloaded,
data->progress.dl_limit_size,
data->set.max_recv_speed,
@@ -2138,7 +2245,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
if(send_timeout_ms || recv_timeout_ms) {
Curl_ratelimit(data, *nowp);
- multistate(data, CURLM_STATE_TOOFAST);
+ multistate(data, MSTATE_RATELIMITING);
if(send_timeout_ms >= recv_timeout_ms)
Curl_expire(data, send_timeout_ms, EXPIRE_TOOFAST);
else
@@ -2168,17 +2275,18 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
}
}
else if((CURLE_HTTP2_STREAM == result) &&
- Curl_h2_http_1_1_error(data->conn)) {
+ Curl_h2_http_1_1_error(data)) {
CURLcode ret = Curl_retry_request(data, &newurl);
if(!ret) {
infof(data, "Downgrades to HTTP/1.1!\n");
- data->set.httpversion = CURL_HTTP_VERSION_1_1;
+ streamclose(data->conn, "Disconnect HTTP/2 for HTTP/1");
+ data->state.httpwant = CURL_HTTP_VERSION_1_1;
/* clear the error message bit too as we ignore the one we got */
data->state.errorbuf = FALSE;
if(!newurl)
/* typically for HTTP_1_1_REQUIRED error on first flight */
- newurl = strdup(data->change.url);
+ newurl = strdup(data->state.url);
/* if we are to retry, set the result to OK and consider the request
as done */
retry = TRUE;
@@ -2228,7 +2336,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
/* multi_done() might return CURLE_GOT_NOTHING */
result = Curl_follow(data, newurl, follow);
if(!result) {
- multistate(data, CURLM_STATE_CONNECT);
+ multistate(data, MSTATE_CONNECT);
rc = CURLM_CALL_MULTI_PERFORM;
}
free(newurl);
@@ -2251,7 +2359,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
}
if(!result) {
- multistate(data, CURLM_STATE_DONE);
+ multistate(data, MSTATE_DONE);
rc = CURLM_CALL_MULTI_PERFORM;
}
}
@@ -2266,7 +2374,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
break;
}
- case CURLM_STATE_DONE:
+ case MSTATE_DONE:
/* this state is highly transient, so run another loop after this */
rc = CURLM_CALL_MULTI_PERFORM;
@@ -2289,21 +2397,21 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
if(data->state.wildcardmatch) {
if(data->wildcard.state != CURLWC_DONE) {
/* if a wildcard is set and we are not ending -> lets start again
- with CURLM_STATE_INIT */
- multistate(data, CURLM_STATE_INIT);
+ with MSTATE_INIT */
+ multistate(data, MSTATE_INIT);
break;
}
}
#endif
/* after we have DONE what we're supposed to do, go COMPLETED, and
it doesn't matter what the multi_done() returned! */
- multistate(data, CURLM_STATE_COMPLETED);
+ multistate(data, MSTATE_COMPLETED);
break;
- case CURLM_STATE_COMPLETED:
+ case MSTATE_COMPLETED:
break;
- case CURLM_STATE_MSGSENT:
+ case MSTATE_MSGSENT:
data->result = result;
return CURLM_OK; /* do nothing */
@@ -2312,7 +2420,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
}
statemachine_end:
- if(data->mstate < CURLM_STATE_COMPLETED) {
+ if(data->mstate < MSTATE_COMPLETED) {
if(result) {
/*
* If an error was returned, and we aren't in completed state now,
@@ -2343,12 +2451,12 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
Curl_disconnect(data, conn, dead_connection);
}
}
- else if(data->mstate == CURLM_STATE_CONNECT) {
+ else if(data->mstate == MSTATE_CONNECT) {
/* Curl_connect() failed */
(void)Curl_posttransfer(data);
}
- multistate(data, CURLM_STATE_COMPLETED);
+ multistate(data, MSTATE_COMPLETED);
rc = CURLM_CALL_MULTI_PERFORM;
}
/* if there's still a connection to use, call the progress function */
@@ -2359,13 +2467,13 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
streamclose(data->conn, "Aborted by callback");
/* if not yet in DONE state, go there, otherwise COMPLETED */
- multistate(data, (data->mstate < CURLM_STATE_DONE)?
- CURLM_STATE_DONE: CURLM_STATE_COMPLETED);
+ multistate(data, (data->mstate < MSTATE_DONE)?
+ MSTATE_DONE: MSTATE_COMPLETED);
rc = CURLM_CALL_MULTI_PERFORM;
}
}
- if(CURLM_STATE_COMPLETED == data->mstate) {
+ if(MSTATE_COMPLETED == data->mstate) {
if(data->set.fmultidone) {
/* signal via callback instead */
data->set.fmultidone(data, result);
@@ -2381,7 +2489,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
rc = multi_addmsg(multi, msg);
DEBUGASSERT(!data->conn);
}
- multistate(data, CURLM_STATE_MSGSENT);
+ multistate(data, MSTATE_MSGSENT);
}
} while((rc == CURLM_CALL_MULTI_PERFORM) || multi_ischanged(multi, FALSE));
@@ -2492,10 +2600,14 @@ CURLMcode curl_multi_cleanup(struct Curl_multi *multi)
Curl_hash_destroy(&multi->hostcache);
Curl_psl_destroy(&multi->psl);
+#ifdef USE_WINSOCK
+ WSACloseEvent(multi->wsa_event);
+#else
#ifdef ENABLE_WAKEUP
sclose(multi->wakeup_pair[0]);
sclose(multi->wakeup_pair[1]);
#endif
+#endif
free(multi);
return CURLM_OK;
@@ -2554,7 +2666,7 @@ static CURLMcode singlesocket(struct Curl_multi *multi,
curl_socket_t s;
int num;
unsigned int curraction;
- int actions[MAX_SOCKSPEREASYHANDLE];
+ unsigned char actions[MAX_SOCKSPEREASYHANDLE];
for(i = 0; i< MAX_SOCKSPEREASYHANDLE; i++)
socks[i] = CURL_SOCKET_BAD;
@@ -2571,9 +2683,9 @@ static CURLMcode singlesocket(struct Curl_multi *multi,
for(i = 0; (i< MAX_SOCKSPEREASYHANDLE) &&
(curraction & (GETSOCK_READSOCK(i) | GETSOCK_WRITESOCK(i)));
i++) {
- unsigned int action = CURL_POLL_NONE;
- unsigned int prevaction = 0;
- unsigned int comboaction;
+ unsigned char action = CURL_POLL_NONE;
+ unsigned char prevaction = 0;
+ int comboaction;
bool sincebefore = FALSE;
s = socks[i];
@@ -2631,10 +2743,10 @@ static CURLMcode singlesocket(struct Curl_multi *multi,
}
comboaction = (entry->writers? CURL_POLL_OUT : 0) |
- (entry->readers ? CURL_POLL_IN : 0);
+ (entry->readers ? CURL_POLL_IN : 0);
/* socket existed before and has the same action set as before */
- if(sincebefore && (entry->action == comboaction))
+ if(sincebefore && ((int)entry->action == comboaction))
/* same, continue */
continue;
@@ -2667,7 +2779,7 @@ static CURLMcode singlesocket(struct Curl_multi *multi,
/* if this is NULL here, the socket has been closed and notified so
already by Curl_multi_closed() */
if(entry) {
- int oldactions = data->actions[i];
+ unsigned char oldactions = data->actions[i];
/* this socket has been removed. Decrease user count */
entry->users--;
if(oldactions & CURL_POLL_OUT)
@@ -2692,7 +2804,7 @@ static CURLMcode singlesocket(struct Curl_multi *multi,
} /* for loop over numsocks */
memcpy(data->sockets, socks, num*sizeof(curl_socket_t));
- memcpy(data->actions, actions, num*sizeof(int));
+ memcpy(data->actions, actions, num*sizeof(char));
data->numsocks = num;
return CURLM_OK;
}
@@ -3344,9 +3456,9 @@ static void process_pending_handles(struct Curl_multi *multi)
if(e) {
struct Curl_easy *data = e->ptr;
- DEBUGASSERT(data->mstate == CURLM_STATE_CONNECT_PEND);
+ DEBUGASSERT(data->mstate == MSTATE_PENDING);
- multistate(data, CURLM_STATE_CONNECT);
+ multistate(data, MSTATE_CONNECT);
/* Remove this node from the list */
Curl_llist_remove(&multi->pending, e, NULL);
@@ -3384,7 +3496,7 @@ void Curl_multi_dump(struct Curl_multi *multi)
fprintf(stderr, "* Multi status: %d handles, %d alive\n",
multi->num_easy, multi->num_alive);
for(data = multi->easyp; data; data = data->next) {
- if(data->mstate < CURLM_STATE_COMPLETED) {
+ if(data->mstate < MSTATE_COMPLETED) {
/* only display handles that are not completed */
fprintf(stderr, "handle %p, state %s, %d sockets\n",
(void *)data,