From: Max Reitz Date: Tue, 10 Sep 2019 12:41:31 +0000 (+0200) Subject: curl: Keep *socket until the end of curl_sock_cb() X-Git-Tag: qemu-xen-4.13.1~2^2~50 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=78ea94e389b2d503ae9a3023759050fd8072e581;p=qemu-xen.git curl: Keep *socket until the end of curl_sock_cb() This does not really change anything, but it makes the code a bit easier to follow once we use @socket as the opaque pointer for aio_set_fd_handler(). Cc: qemu-stable@nongnu.org Signed-off-by: Max Reitz Message-id: 20190910124136.10565-3-mreitz@redhat.com Reviewed-by: Maxim Levitsky Reviewed-by: John Snow Signed-off-by: Max Reitz (cherry picked from commit 007f339b1099af46a008dac438ca0943e31dba72) Signed-off-by: Michael Roth --- diff --git a/block/curl.c b/block/curl.c index 92dc2f630e..95d7b77dc0 100644 --- a/block/curl.c +++ b/block/curl.c @@ -172,10 +172,6 @@ static int curl_sock_cb(CURL *curl, curl_socket_t fd, int action, QLIST_FOREACH(socket, &state->sockets, next) { if (socket->fd == fd) { - if (action == CURL_POLL_REMOVE) { - QLIST_REMOVE(socket, next); - g_free(socket); - } break; } } @@ -185,7 +181,6 @@ static int curl_sock_cb(CURL *curl, curl_socket_t fd, int action, socket->state = state; QLIST_INSERT_HEAD(&state->sockets, socket, next); } - socket = NULL; trace_curl_sock_cb(action, (int)fd); switch (action) { @@ -207,6 +202,11 @@ static int curl_sock_cb(CURL *curl, curl_socket_t fd, int action, break; } + if (action == CURL_POLL_REMOVE) { + QLIST_REMOVE(socket, next); + g_free(socket); + } + return 0; }