|
|
016a62 |
From 37acfe84ccbc4cc050e7be0ba9c8c4134a7b004e Mon Sep 17 00:00:00 2001
|
|
|
016a62 |
From: Max Reitz <mreitz@redhat.com>
|
|
|
016a62 |
Date: Tue, 19 Nov 2019 15:29:57 +0000
|
|
|
016a62 |
Subject: [PATCH 5/8] curl: Pass CURLSocket to curl_multi_do()
|
|
|
016a62 |
MIME-Version: 1.0
|
|
|
016a62 |
Content-Type: text/plain; charset=UTF-8
|
|
|
016a62 |
Content-Transfer-Encoding: 8bit
|
|
|
016a62 |
|
|
|
016a62 |
RH-Author: Max Reitz <mreitz@redhat.com>
|
|
|
016a62 |
Message-id: <20191119153000.101646-5-mreitz@redhat.com>
|
|
|
016a62 |
Patchwork-id: 92518
|
|
|
016a62 |
O-Subject: [RHEL-8.2.0 qemu-kvm PATCH 4/7] curl: Pass CURLSocket to curl_multi_do()
|
|
|
016a62 |
Bugzilla: 1744602
|
|
|
016a62 |
RH-Acked-by: Maxim Levitsky <mlevitsk@redhat.com>
|
|
|
016a62 |
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
|
|
|
016a62 |
RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
|
|
|
016a62 |
|
|
|
016a62 |
curl_multi_do_locked() currently marks all sockets as ready. That is
|
|
|
016a62 |
not only inefficient, but in fact unsafe (the loop is). A follow-up
|
|
|
016a62 |
patch will change that, but to do so, curl_multi_do_locked() needs to
|
|
|
016a62 |
know exactly which socket is ready; and that is accomplished by this
|
|
|
016a62 |
patch here.
|
|
|
016a62 |
|
|
|
016a62 |
Cc: qemu-stable@nongnu.org
|
|
|
016a62 |
Signed-off-by: Max Reitz <mreitz@redhat.com>
|
|
|
016a62 |
Message-id: 20190910124136.10565-5-mreitz@redhat.com
|
|
|
016a62 |
Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>
|
|
|
016a62 |
Reviewed-by: John Snow <jsnow@redhat.com>
|
|
|
016a62 |
Signed-off-by: Max Reitz <mreitz@redhat.com>
|
|
|
016a62 |
(cherry picked from commit 9dbad87d25587ff640ef878f7b6159fc368ff541)
|
|
|
016a62 |
Signed-off-by: Max Reitz <mreitz@redhat.com>
|
|
|
016a62 |
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
|
|
016a62 |
---
|
|
|
016a62 |
block/curl.c | 20 +++++++++++---------
|
|
|
016a62 |
1 file changed, 11 insertions(+), 9 deletions(-)
|
|
|
016a62 |
|
|
|
016a62 |
diff --git a/block/curl.c b/block/curl.c
|
|
|
016a62 |
index 8f31594..de00ec8 100644
|
|
|
016a62 |
--- a/block/curl.c
|
|
|
016a62 |
+++ b/block/curl.c
|
|
|
016a62 |
@@ -194,15 +194,15 @@ static int curl_sock_cb(CURL *curl, curl_socket_t fd, int action,
|
|
|
016a62 |
switch (action) {
|
|
|
016a62 |
case CURL_POLL_IN:
|
|
|
016a62 |
aio_set_fd_handler(s->aio_context, fd, false,
|
|
|
016a62 |
- curl_multi_do, NULL, NULL, state);
|
|
|
016a62 |
+ curl_multi_do, NULL, NULL, socket);
|
|
|
016a62 |
break;
|
|
|
016a62 |
case CURL_POLL_OUT:
|
|
|
016a62 |
aio_set_fd_handler(s->aio_context, fd, false,
|
|
|
016a62 |
- NULL, curl_multi_do, NULL, state);
|
|
|
016a62 |
+ NULL, curl_multi_do, NULL, socket);
|
|
|
016a62 |
break;
|
|
|
016a62 |
case CURL_POLL_INOUT:
|
|
|
016a62 |
aio_set_fd_handler(s->aio_context, fd, false,
|
|
|
016a62 |
- curl_multi_do, curl_multi_do, NULL, state);
|
|
|
016a62 |
+ curl_multi_do, curl_multi_do, NULL, socket);
|
|
|
016a62 |
break;
|
|
|
016a62 |
case CURL_POLL_REMOVE:
|
|
|
016a62 |
aio_set_fd_handler(s->aio_context, fd, false,
|
|
|
016a62 |
@@ -401,9 +401,10 @@ static void curl_multi_check_completion(BDRVCURLState *s)
|
|
|
016a62 |
}
|
|
|
016a62 |
|
|
|
016a62 |
/* Called with s->mutex held. */
|
|
|
016a62 |
-static void curl_multi_do_locked(CURLState *s)
|
|
|
016a62 |
+static void curl_multi_do_locked(CURLSocket *ready_socket)
|
|
|
016a62 |
{
|
|
|
016a62 |
CURLSocket *socket, *next_socket;
|
|
|
016a62 |
+ CURLState *s = ready_socket->state;
|
|
|
016a62 |
int running;
|
|
|
016a62 |
int r;
|
|
|
016a62 |
|
|
|
016a62 |
@@ -422,12 +423,13 @@ static void curl_multi_do_locked(CURLState *s)
|
|
|
016a62 |
|
|
|
016a62 |
static void curl_multi_do(void *arg)
|
|
|
016a62 |
{
|
|
|
016a62 |
- CURLState *s = (CURLState *)arg;
|
|
|
016a62 |
+ CURLSocket *socket = arg;
|
|
|
016a62 |
+ BDRVCURLState *s = socket->state->s;
|
|
|
016a62 |
|
|
|
016a62 |
- qemu_mutex_lock(&s->s->mutex);
|
|
|
016a62 |
- curl_multi_do_locked(s);
|
|
|
016a62 |
- curl_multi_check_completion(s->s);
|
|
|
016a62 |
- qemu_mutex_unlock(&s->s->mutex);
|
|
|
016a62 |
+ qemu_mutex_lock(&s->mutex);
|
|
|
016a62 |
+ curl_multi_do_locked(socket);
|
|
|
016a62 |
+ curl_multi_check_completion(s);
|
|
|
016a62 |
+ qemu_mutex_unlock(&s->mutex);
|
|
|
016a62 |
}
|
|
|
016a62 |
|
|
|
016a62 |
static void curl_multi_timeout_do(void *arg)
|
|
|
016a62 |
--
|
|
|
016a62 |
1.8.3.1
|
|
|
016a62 |
|