summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2018-07-04 14:47:10 +0200
committerDaniel Stenberg <daniel@haxx.se>2018-07-05 22:25:22 +0200
commit13a5ed5a122122eebdc966ccbaf59184ea57931c (patch)
tree4a2997f55524453a965b2ba85b614472baeafd89
parent858991c9c5b7e7db6529ebc1401ef2532b0ad19e (diff)
downloadcurl-13a5ed5a122122eebdc966ccbaf59184ea57931c.tar.gz
multi: always do the COMPLETED procedure
remember: remove the extra continue
-rw-r--r--lib/multi.c55
-rw-r--r--lib/url.c8
2 files changed, 36 insertions, 27 deletions
diff --git a/lib/multi.c b/lib/multi.c
index da5191fd1..3f7a77813 100644
--- a/lib/multi.c
+++ b/lib/multi.c
@@ -107,6 +107,16 @@ static const char * const statename[]={
/* function pointer called once when switching TO a state */
typedef void (*init_multistate_func)(struct Curl_easy *data);
+static void Curl_init_completed(struct Curl_easy *data)
+{
+ /* this is a completed transfer */
+
+ /* Important: reset the conn pointer so that we don't point to memory
+ that could be freed anytime */
+ data->easy_conn = NULL;
+ Curl_expire_clear(data); /* stop all timers */
+}
+
/* always use this function to change state, to make debugging easier */
static void mstate(struct Curl_easy *data, CURLMstate state
#ifdef DEBUGBUILD
@@ -116,17 +126,25 @@ static void mstate(struct Curl_easy *data, CURLMstate state
{
CURLMstate oldstate = data->mstate;
static const init_multistate_func finit[CURLM_STATE_LAST] = {
- NULL,
- NULL,
+ NULL, /* INIT */
+ NULL, /* CONNECT_PEND */
Curl_init_CONNECT, /* CONNECT */
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- Curl_connect_free /* DO */
- /* the rest is NULL too */
+ NULL, /* WAITRESOLVE */
+ NULL, /* WAITCONNECT */
+ NULL, /* WAITPROXYCONNECT */
+ NULL, /* SENDPROTOCONNECT */
+ NULL, /* PROTOCONNECT */
+ NULL, /* WAITDO */
+ Curl_connect_free, /* DO */
+ NULL, /* DOING */
+ NULL, /* DO_MORE */
+ NULL, /* DO_DONE */
+ NULL, /* WAITPERFORM */
+ NULL, /* PERFORM */
+ NULL, /* TOOFAST */
+ NULL, /* DONE */
+ Curl_init_completed, /* COMPLETED */
+ NULL /* MSGSENT */
};
#if defined(DEBUGBUILD) && defined(CURL_DISABLE_VERBOSE_STRINGS)
@@ -2062,16 +2080,6 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
break;
case CURLM_STATE_COMPLETED:
- /* this is a completed transfer, it is likely to still be connected */
-
- /* This node should be delinked from the list now and we should post
- an information message that we are complete. */
-
- /* Important: reset the conn pointer so that we don't point to memory
- that could be freed anytime */
- data->easy_conn = NULL;
-
- Curl_expire_clear(data); /* stop all timers */
break;
case CURLM_STATE_MSGSENT:
@@ -2123,6 +2131,8 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
}
multistate(data, CURLM_STATE_COMPLETED);
+ rc = CURLM_CALL_MULTI_PERFORM;
+ continue;
}
/* if there's still a connection to use, call the progress function */
else if(data->easy_conn && Curl_pgrsUpdate(data->easy_conn)) {
@@ -2135,6 +2145,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
multistate(data, (data->mstate < CURLM_STATE_DONE)?
CURLM_STATE_DONE: CURLM_STATE_COMPLETED);
rc = CURLM_CALL_MULTI_PERFORM;
+ continue;
}
}
@@ -2147,14 +2158,12 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
msg->extmsg.data.result = result;
rc = multi_addmsg(multi, msg);
-
+ DEBUGASSERT(!data->easy_conn);
multistate(data, CURLM_STATE_MSGSENT);
}
} while((rc == CURLM_CALL_MULTI_PERFORM) || multi_ischanged(multi, FALSE));
data->result = result;
-
-
return rc;
}
diff --git a/lib/url.c b/lib/url.c
index 81755440b..bdc3f36ca 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -747,7 +747,7 @@ CURLcode Curl_disconnect(struct connectdata *conn, bool dead_connection)
data = conn->data;
if(!data) {
- DEBUGF(fprintf(stderr, "DISCONNECT without easy handle, ignoring\n"));
+ fprintf(stderr, "DISCONNECT without easy handle, ignoring\n");
return CURLE_OK;
}
@@ -756,8 +756,8 @@ CURLcode Curl_disconnect(struct connectdata *conn, bool dead_connection)
* are other users of it
*/
if(!conn->bits.close && !CONN_INUSE(conn)) {
- DEBUGF(fprintf(stderr, "Curl_disconnect when inuse: %d\n",
- CONN_INUSE(conn)));
+ fprintf(stderr, "Curl_disconnect when inuse: %d\n",
+ CONN_INUSE(conn));
return CURLE_OK;
}
@@ -796,6 +796,7 @@ CURLcode Curl_disconnect(struct connectdata *conn, bool dead_connection)
conn_free(conn);
+ fprintf(stderr, "Curl_disconnected!\n");
return CURLE_OK;
}
@@ -913,7 +914,6 @@ void Curl_getoff_all_pipelines(struct Curl_easy *data,
int rc;
rc = Curl_removeHandleFromPipeline(data, &conn->recv_pipe);
rc += Curl_removeHandleFromPipeline(data, &conn->send_pipe);
- fprintf(stderr, "%s:%d %s == %d\n", __FILE__, __LINE__, __func__, rc);
}
}