Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix connection ownership issue #2217 #2221

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 13 additions & 1 deletion lib/easy.c
Expand Up @@ -1045,6 +1045,8 @@ CURLcode curl_easy_pause(struct Curl_easy *data, int action)
unsigned int i;
unsigned int count = data->state.tempcount;
struct tempbuf writebuf[3]; /* there can only be three */
struct connectdata *conn = data->easy_conn;
struct Curl_easy *saved_data = NULL;

/* copy the structs to allow for immediate re-pausing */
for(i = 0; i < data->state.tempcount; i++) {
Expand All @@ -1053,16 +1055,26 @@ CURLcode curl_easy_pause(struct Curl_easy *data, int action)
}
data->state.tempcount = 0;

if(conn && conn->data != data) {
/* Make sure we set the connection's current owner */
saved_data = conn->data;
conn->data = data;
}

for(i = 0; i < count; i++) {
/* even if one function returns error, this loops through and frees all
buffers */
if(!result)
result = Curl_client_chop_write(data->easy_conn,
result = Curl_client_chop_write(conn,
writebuf[i].type,
writebuf[i].buf,
writebuf[i].len);
free(writebuf[i].buf);
}
/* recover previous owner of the connection */
if(saved_data)
conn->data = saved_data;

if(result)
return result;
}
Expand Down