From nobody Fri Mar 29 09:22:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1568119493; cv=none; d=zoho.com; s=zohoarc; b=P5Z7URUMUSfnxQ8Q+32k0SsFB8OzxBWxXOnhsKsYvwf7wXwgw6tbb5PYNwf/j93ulBz3DIPLDW5wVuImv5i1w8e1zQQq+z5hyR+X/9rR1fWm6twuxhhz4ajwKFJSvil/8mPY1gDRo3m0AijaU9HJOBy/S/5o56sD72bVapTq1rE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568119493; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=4som7ZIy/piHaL6PUOAE8KL28otXTjiuvr5eSWSUX4I=; b=U0JwzA+BIZQuXJjnzWV1xRRSpLeIkzK48eXwr40d/3XUy9VZxL6YffGl027Z35VQkSmuA1rWQvTedYFnh4AEEwWvNTY/jpidkRnXLUhrQNLVksG6XKNGRX77U5ze09HFg1Nh7aaJSunuk+meG0t+SbFGld66ztGzPTC1wUZcebk= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1568119493299161.62828230947412; Tue, 10 Sep 2019 05:44:53 -0700 (PDT) Received: from localhost ([::1]:39374 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i7fVi-0004a9-46 for importer@patchew.org; Tue, 10 Sep 2019 08:44:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59458) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i7fSv-0002Mn-U4 for qemu-devel@nongnu.org; Tue, 10 Sep 2019 08:41:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i7fSv-00054r-1Q for qemu-devel@nongnu.org; Tue, 10 Sep 2019 08:41:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48734) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i7fSt-00054C-3M; Tue, 10 Sep 2019 08:41:47 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 571EA7E424; Tue, 10 Sep 2019 12:41:46 +0000 (UTC) Received: from localhost (ovpn-117-90.ams2.redhat.com [10.36.117.90]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A849B5D9DC; Tue, 10 Sep 2019 12:41:43 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Tue, 10 Sep 2019 14:41:30 +0200 Message-Id: <20190910124136.10565-2-mreitz@redhat.com> In-Reply-To: <20190910124136.10565-1-mreitz@redhat.com> References: <20190910124136.10565-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 10 Sep 2019 12:41:46 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 1/7] curl: Keep pointer to the CURLState in CURLSocket X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , qemu-stable@nongnu.org, John Snow , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" A follow-up patch will make curl_multi_do() and curl_multi_read() take a CURLSocket instead of the CURLState. They still need the latter, though, so add a pointer to it to the former. Cc: qemu-stable@nongnu.org Signed-off-by: Max Reitz Reviewed-by: John Snow Reviewed-by: Maxim Levitsky --- block/curl.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/block/curl.c b/block/curl.c index d4c8e94f3e..92dc2f630e 100644 --- a/block/curl.c +++ b/block/curl.c @@ -80,6 +80,7 @@ static CURLMcode __curl_multi_socket_action(CURLM *multi_= handle, #define CURL_BLOCK_OPT_TIMEOUT_DEFAULT 5 =20 struct BDRVCURLState; +struct CURLState; =20 static bool libcurl_initialized; =20 @@ -97,6 +98,7 @@ typedef struct CURLAIOCB { =20 typedef struct CURLSocket { int fd; + struct CURLState *state; QLIST_ENTRY(CURLSocket) next; } CURLSocket; =20 @@ -180,6 +182,7 @@ static int curl_sock_cb(CURL *curl, curl_socket_t fd, i= nt action, if (!socket) { socket =3D g_new0(CURLSocket, 1); socket->fd =3D fd; + socket->state =3D state; QLIST_INSERT_HEAD(&state->sockets, socket, next); } socket =3D NULL; --=20 2.21.0 From nobody Fri Mar 29 09:22:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1568119857; cv=none; d=zoho.com; s=zohoarc; b=OwWfanAGS0IalMpOEeMIyvXIfprrPEdxZZw+63dBpfzqmtxQvttXx2UiAcQ4KJqeqgeRDYdLO4SsBEZwyKoD8aNg/NrGpb4zBRXFTQ/jToWXWU9aKY7VjXMB/PQBmf6rVctv3/Z7dbw1TF0qWXDPRoDuEomdXX0UGYt3/Ak8WzQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568119857; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=5vvxABrCaGRXtFOd8l+7/p6fOqLWeRfIaOYv2yNYGwQ=; b=jjQ7G2wkIx4CMUvw2VAchrgz17aPQFeQk1YBMMzqPjWi3ZKw5A9fSf7tS/9lLWj+5SYGKk1gVEh5/5Agm/G/PF9pzrB099mTh9C5hcOYQgX1DiH323ofQ9dJPNl188329JUrmgyi72Tf1sveP2uSGjwX+CT7RkDwtV0RHYkPyoY= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1568119857206633.6988377576529; Tue, 10 Sep 2019 05:50:57 -0700 (PDT) Received: from localhost ([::1]:39426 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i7fbj-0000UQ-FO for importer@patchew.org; Tue, 10 Sep 2019 08:50:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59523) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i7fT1-0002T7-FV for qemu-devel@nongnu.org; Tue, 10 Sep 2019 08:41:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i7fT0-0005BK-Ew for qemu-devel@nongnu.org; Tue, 10 Sep 2019 08:41:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39056) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i7fSy-00059j-4L; Tue, 10 Sep 2019 08:41:52 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7083018F3507; Tue, 10 Sep 2019 12:41:51 +0000 (UTC) Received: from localhost (ovpn-117-90.ams2.redhat.com [10.36.117.90]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8FAA060BE2; Tue, 10 Sep 2019 12:41:48 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Tue, 10 Sep 2019 14:41:31 +0200 Message-Id: <20190910124136.10565-3-mreitz@redhat.com> In-Reply-To: <20190910124136.10565-1-mreitz@redhat.com> References: <20190910124136.10565-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.63]); Tue, 10 Sep 2019 12:41:51 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 2/7] curl: Keep *socket until the end of curl_sock_cb() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , qemu-stable@nongnu.org, John Snow , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: John Snow Reviewed-by: Maxim Levitsky --- block/curl.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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, =20 QLIST_FOREACH(socket, &state->sockets, next) { if (socket->fd =3D=3D fd) { - if (action =3D=3D 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, i= nt action, socket->state =3D state; QLIST_INSERT_HEAD(&state->sockets, socket, next); } - socket =3D NULL; =20 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; } =20 + if (action =3D=3D CURL_POLL_REMOVE) { + QLIST_REMOVE(socket, next); + g_free(socket); + } + return 0; } =20 --=20 2.21.0 From nobody Fri Mar 29 09:22:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1568119923; cv=none; d=zoho.com; s=zohoarc; b=SzbfLifBt13V1Ul942qvoo+4SX28+L+J5bjCfKb9oOmwdOiP2NH/IFcJmpfMTRp5RBqSLTn9q4unxNDLrelNQ2yImPpwGufnK3BC4FZdCpmF2Ml78TsUAUUNA2KU4LL5ZUtyTinqt9zIYJBXVrDbhzlsUMx/jbDkhk3oueInd4c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568119923; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=txosGHZW/lXbyos43SSKi1tx4n2bybas6mRQDACcY+4=; b=Yk6IEzZZYZXmQRrpSREf1PCM9PrADv+h5MerCbkM//D/xU3h/xrwJfh3JSXSXfEV2e88VBz3mvxDV7i012vEq93fsFN3/3HURtao86RU143jzggWzX6BC9FcNZn3dQqkK3XwrouZJijGuestZF02w1F7JJaHZdHB4ecGO+TRygE= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15681199237791013.8988225124425; Tue, 10 Sep 2019 05:52:03 -0700 (PDT) Received: from localhost ([::1]:39432 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i7fcl-0001Fa-6i for importer@patchew.org; Tue, 10 Sep 2019 08:51:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59564) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i7fT4-0002Wt-Qz for qemu-devel@nongnu.org; Tue, 10 Sep 2019 08:41:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i7fT3-0005CY-Lz for qemu-devel@nongnu.org; Tue, 10 Sep 2019 08:41:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59702) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i7fT1-0005BO-7c; Tue, 10 Sep 2019 08:41:55 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8AA5A10F23ED; Tue, 10 Sep 2019 12:41:54 +0000 (UTC) Received: from localhost (ovpn-117-90.ams2.redhat.com [10.36.117.90]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 06D2B5D9DC; Tue, 10 Sep 2019 12:41:53 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Tue, 10 Sep 2019 14:41:32 +0200 Message-Id: <20190910124136.10565-4-mreitz@redhat.com> In-Reply-To: <20190910124136.10565-1-mreitz@redhat.com> References: <20190910124136.10565-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.66]); Tue, 10 Sep 2019 12:41:54 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 3/7] curl: Check completion in curl_multi_do() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , qemu-stable@nongnu.org, John Snow , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" While it is more likely that transfers complete after some file descriptor has data ready to read, we probably should not rely on it. Better be safe than sorry and call curl_multi_check_completion() in curl_multi_do(), too, just like it is done in curl_multi_read(). With this change, curl_multi_do() and curl_multi_read() are actually the same, so drop curl_multi_read() and use curl_multi_do() as the sole FD handler. Signed-off-by: Max Reitz Reviewed-by: John Snow Reviewed-by: Maxim Levitsky --- block/curl.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/block/curl.c b/block/curl.c index 95d7b77dc0..5838afef99 100644 --- a/block/curl.c +++ b/block/curl.c @@ -139,7 +139,6 @@ typedef struct BDRVCURLState { =20 static void curl_clean_state(CURLState *s); static void curl_multi_do(void *arg); -static void curl_multi_read(void *arg); =20 #ifdef NEED_CURL_TIMER_CALLBACK /* Called from curl_multi_do_locked, with s->mutex held. */ @@ -186,7 +185,7 @@ static int curl_sock_cb(CURL *curl, curl_socket_t fd, i= nt action, switch (action) { case CURL_POLL_IN: aio_set_fd_handler(s->aio_context, fd, false, - curl_multi_read, NULL, NULL, state); + curl_multi_do, NULL, NULL, state); break; case CURL_POLL_OUT: aio_set_fd_handler(s->aio_context, fd, false, @@ -194,7 +193,7 @@ static int curl_sock_cb(CURL *curl, curl_socket_t fd, i= nt action, break; case CURL_POLL_INOUT: aio_set_fd_handler(s->aio_context, fd, false, - curl_multi_read, curl_multi_do, NULL, state= ); + curl_multi_do, curl_multi_do, NULL, state); break; case CURL_POLL_REMOVE: aio_set_fd_handler(s->aio_context, fd, false, @@ -416,15 +415,6 @@ static void curl_multi_do(void *arg) { CURLState *s =3D (CURLState *)arg; =20 - qemu_mutex_lock(&s->s->mutex); - curl_multi_do_locked(s); - qemu_mutex_unlock(&s->s->mutex); -} - -static void curl_multi_read(void *arg) -{ - CURLState *s =3D (CURLState *)arg; - qemu_mutex_lock(&s->s->mutex); curl_multi_do_locked(s); curl_multi_check_completion(s->s); --=20 2.21.0 From nobody Fri Mar 29 09:22:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1568120108; cv=none; d=zoho.com; s=zohoarc; b=gHFMvY6kjEWTXAKmLTOz461O3MefYgRGYhQT5PYbilFfRWCUcuyukBq152FUVLG4Nmbj5rZzSlAtfL8N1noFbsaCvFky4pC4oTlEg2bBQmtKlFPH+ekEQcHET0xyhPZ9VbZ8mKk11ijyuqTYkLVIso5FhKUKkkRB8Etp9gXTgDE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568120108; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=3INMCsWBRJjGbSlLdu1CC7+zDc8iKSzoK6H8ncxD9uM=; b=eeD89fu92wWVsuzKsLxnJmFeRJe1faQ7W+cfQr786RB+IOO9QU2BNk0Uj+cMHe/PzppRly+TxT0nqs7rwYxYMPYbQMIljEXkrKg/Jg2nIsLnzWEKsbX0cZqWLOJ6m4N7e8PX/yFaiZv0V9KWFuyoSj6fyv0hxVgUkG/Mk6Vvqpk= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1568120108573809.4238400381789; Tue, 10 Sep 2019 05:55:08 -0700 (PDT) Received: from localhost ([::1]:39464 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i7ffk-0004jo-MT for importer@patchew.org; Tue, 10 Sep 2019 08:55:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59602) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i7fTA-0002cA-Dq for qemu-devel@nongnu.org; Tue, 10 Sep 2019 08:42:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i7fT9-0005I8-BA for qemu-devel@nongnu.org; Tue, 10 Sep 2019 08:42:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:5600) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i7fT6-0005Dk-Hk; Tue, 10 Sep 2019 08:42:00 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D6376A2F86A; Tue, 10 Sep 2019 12:41:59 +0000 (UTC) Received: from localhost (ovpn-117-90.ams2.redhat.com [10.36.117.90]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 00FC45D6B2; Tue, 10 Sep 2019 12:41:56 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Tue, 10 Sep 2019 14:41:33 +0200 Message-Id: <20190910124136.10565-5-mreitz@redhat.com> In-Reply-To: <20190910124136.10565-1-mreitz@redhat.com> References: <20190910124136.10565-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.68]); Tue, 10 Sep 2019 12:41:59 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 4/7] curl: Pass CURLSocket to curl_multi_do() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , qemu-stable@nongnu.org, John Snow , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" curl_multi_do_locked() currently marks all sockets as ready. That is not only inefficient, but in fact unsafe (the loop is). A follow-up patch will change that, but to do so, curl_multi_do_locked() needs to know exactly which socket is ready; and that is accomplished by this patch here. Cc: qemu-stable@nongnu.org Signed-off-by: Max Reitz Reviewed-by: John Snow Reviewed-by: Maxim Levitsky --- block/curl.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/block/curl.c b/block/curl.c index 5838afef99..cf2686218d 100644 --- a/block/curl.c +++ b/block/curl.c @@ -185,15 +185,15 @@ static int curl_sock_cb(CURL *curl, curl_socket_t fd,= int action, switch (action) { case CURL_POLL_IN: aio_set_fd_handler(s->aio_context, fd, false, - curl_multi_do, NULL, NULL, state); + curl_multi_do, NULL, NULL, socket); break; case CURL_POLL_OUT: aio_set_fd_handler(s->aio_context, fd, false, - NULL, curl_multi_do, NULL, state); + NULL, curl_multi_do, NULL, socket); break; case CURL_POLL_INOUT: aio_set_fd_handler(s->aio_context, fd, false, - curl_multi_do, curl_multi_do, NULL, state); + curl_multi_do, curl_multi_do, NULL, socket); break; case CURL_POLL_REMOVE: aio_set_fd_handler(s->aio_context, fd, false, @@ -392,9 +392,10 @@ static void curl_multi_check_completion(BDRVCURLState = *s) } =20 /* Called with s->mutex held. */ -static void curl_multi_do_locked(CURLState *s) +static void curl_multi_do_locked(CURLSocket *ready_socket) { CURLSocket *socket, *next_socket; + CURLState *s =3D ready_socket->state; int running; int r; =20 @@ -413,12 +414,13 @@ static void curl_multi_do_locked(CURLState *s) =20 static void curl_multi_do(void *arg) { - CURLState *s =3D (CURLState *)arg; + CURLSocket *socket =3D arg; + BDRVCURLState *s =3D socket->state->s; =20 - qemu_mutex_lock(&s->s->mutex); - curl_multi_do_locked(s); - curl_multi_check_completion(s->s); - qemu_mutex_unlock(&s->s->mutex); + qemu_mutex_lock(&s->mutex); + curl_multi_do_locked(socket); + curl_multi_check_completion(s); + qemu_mutex_unlock(&s->mutex); } =20 static void curl_multi_timeout_do(void *arg) --=20 2.21.0 From nobody Fri Mar 29 09:22:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1568119604; cv=none; d=zoho.com; s=zohoarc; b=lGYfw8D6/P+yWlIcP4VMX9mLKmC0pKpInG4Lpq8S4V/2nUnric1Yy0xMDDlUX1mzwuZoRai9kcCxI/xRAaju+fS6l3xXAp2Qq93ap347c5EhI8KizicTxcNdSrIcfh0nZH52RXD54YCkFnsghFrPu4VQkyXy3qZARy5KrH0FSEM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568119604; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=IJNHxm959zWN4oYvkDRE5+LOXmAAoBXz9vW2RCymftI=; b=lFK3AFkpbahBu2swdJzP0uaiGrvl6Pnd+H2H/f8gC93uSqWGWHCub9mckAl8FyJ/V6onHYmkUFYcn5WI3XbZwHtxUzqX972U2W3oBFJnqS7thpofPS1G159eGwPryQelXwh7fx0RDTrdS22IKku7YDeLoAIG5ZC9+vjdhNs+A0Q= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1568119604753694.0338488167619; Tue, 10 Sep 2019 05:46:44 -0700 (PDT) Received: from localhost ([::1]:39380 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i7fXc-0005zS-EY for importer@patchew.org; Tue, 10 Sep 2019 08:46:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59656) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i7fTF-0002h3-Es for qemu-devel@nongnu.org; Tue, 10 Sep 2019 08:42:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i7fTE-0005LP-CS for qemu-devel@nongnu.org; Tue, 10 Sep 2019 08:42:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43226) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i7fTB-0005J7-Sd; Tue, 10 Sep 2019 08:42:05 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2F00E18CB516; Tue, 10 Sep 2019 12:42:05 +0000 (UTC) Received: from localhost (ovpn-117-90.ams2.redhat.com [10.36.117.90]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1C9B419C4F; Tue, 10 Sep 2019 12:42:01 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Tue, 10 Sep 2019 14:41:34 +0200 Message-Id: <20190910124136.10565-6-mreitz@redhat.com> In-Reply-To: <20190910124136.10565-1-mreitz@redhat.com> References: <20190910124136.10565-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.62]); Tue, 10 Sep 2019 12:42:05 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 5/7] curl: Report only ready sockets X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , qemu-stable@nongnu.org, John Snow , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Instead of reporting all sockets to cURL, only report the one that has caused curl_multi_do_locked() to be called. This lets us get rid of the QLIST_FOREACH_SAFE() list, which was actually wrong: SAFE foreaches are only safe when the current element is removed in each iteration. If it possible for the list to be concurrently modified, we cannot guarantee that only the current element will be removed. Therefore, we must not use QLIST_FOREACH_SAFE() here. Fixes: ff5ca1664af85b24a4180d595ea6873fd3deac57 Cc: qemu-stable@nongnu.org Signed-off-by: Max Reitz Reviewed-by: John Snow Reviewed-by: Maxim Levitsky --- block/curl.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/block/curl.c b/block/curl.c index cf2686218d..fd70f1ebc4 100644 --- a/block/curl.c +++ b/block/curl.c @@ -392,24 +392,19 @@ static void curl_multi_check_completion(BDRVCURLState= *s) } =20 /* Called with s->mutex held. */ -static void curl_multi_do_locked(CURLSocket *ready_socket) +static void curl_multi_do_locked(CURLSocket *socket) { - CURLSocket *socket, *next_socket; - CURLState *s =3D ready_socket->state; + BDRVCURLState *s =3D socket->state->s; int running; int r; =20 - if (!s->s->multi) { + if (!s->multi) { return; } =20 - /* Need to use _SAFE because curl_multi_socket_action() may trigger - * curl_sock_cb() which might modify this list */ - QLIST_FOREACH_SAFE(socket, &s->sockets, next, next_socket) { - do { - r =3D curl_multi_socket_action(s->s->multi, socket->fd, 0, &ru= nning); - } while (r =3D=3D CURLM_CALL_MULTI_PERFORM); - } + do { + r =3D curl_multi_socket_action(s->multi, socket->fd, 0, &running); + } while (r =3D=3D CURLM_CALL_MULTI_PERFORM); } =20 static void curl_multi_do(void *arg) --=20 2.21.0 From nobody Fri Mar 29 09:22:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1568119552; cv=none; d=zoho.com; s=zohoarc; b=gEW+UVDdXq72K69zRJyZyY+HTSMopK8WhT8hCzpO4UyGgqKjD7tXn+VUF45IZhUkYDUQQ4QXXGT3sx2CSmG4TWJ5+zlM3YHOWmcB+D/Oe7yhKYJkKtJXBZctlun/22geFGd8aAveNAQKhmAG77PUvA24M7EEldIuXRuWYlPGC4E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568119552; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=sZr/4wvTXpNffCf+rYSjT18IkTCvEPNq9KwFEoDHekQ=; b=h2J/Ws/9APvsVhEgVIFARoQn6mcuLXC2sGz9fbKtDKn4HqPdntcZi48wSe6QQlrhbqgf2ErcauQ2MmsHMVuidLDHIVc09CWyeBuVVjo3/Kv4hljhuCOSWOTOPVb0fCtPYxXwByfsmmnSH7HKDxoB7vR/fw6aGzlm2yLmDur1B7w= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1568119552719451.7772639505879; Tue, 10 Sep 2019 05:45:52 -0700 (PDT) Received: from localhost ([::1]:39378 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i7fWp-0005bN-7X for importer@patchew.org; Tue, 10 Sep 2019 08:45:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59740) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i7fTM-0002nJ-Hh for qemu-devel@nongnu.org; Tue, 10 Sep 2019 08:42:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i7fTK-0005PW-RS for qemu-devel@nongnu.org; Tue, 10 Sep 2019 08:42:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48830) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i7fTH-0005Mn-Du; Tue, 10 Sep 2019 08:42:11 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B9845769E1; Tue, 10 Sep 2019 12:42:10 +0000 (UTC) Received: from localhost (ovpn-117-90.ams2.redhat.com [10.36.117.90]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AD6A460BE2; Tue, 10 Sep 2019 12:42:07 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Tue, 10 Sep 2019 14:41:35 +0200 Message-Id: <20190910124136.10565-7-mreitz@redhat.com> In-Reply-To: <20190910124136.10565-1-mreitz@redhat.com> References: <20190910124136.10565-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 10 Sep 2019 12:42:10 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 6/7] curl: Handle success in multi_check_completion X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , qemu-stable@nongnu.org, John Snow , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Background: As of cURL 7.59.0, it verifies that several functions are not called from within a callback. Among these functions is curl_multi_add_handle(). curl_read_cb() is a callback from cURL and not a coroutine. Waking up acb->co will lead to entering it then and there, which means the current request will settle and the caller (if it runs in the same coroutine) may then issue the next request. In such a case, we will enter curl_setup_preadv() effectively from within curl_read_cb(). Calling curl_multi_add_handle() will then fail and the new request will not be processed. Fix this by not letting curl_read_cb() wake up acb->co. Instead, leave the whole business of settling the AIOCB objects to curl_multi_check_completion() (which is called from our timer callback and our FD handler, so not from any cURL callbacks). Reported-by: Natalie Gavrielov Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=3D1740193 Cc: qemu-stable@nongnu.org Signed-off-by: Max Reitz Reviewed-by: John Snow Reviewed-by: Maxim Levitsky --- block/curl.c | 69 ++++++++++++++++++++++------------------------------ 1 file changed, 29 insertions(+), 40 deletions(-) diff --git a/block/curl.c b/block/curl.c index fd70f1ebc4..c343c7ed3d 100644 --- a/block/curl.c +++ b/block/curl.c @@ -229,7 +229,6 @@ static size_t curl_read_cb(void *ptr, size_t size, size= _t nmemb, void *opaque) { CURLState *s =3D ((CURLState*)opaque); size_t realsize =3D size * nmemb; - int i; =20 trace_curl_read_cb(realsize); =20 @@ -245,32 +244,6 @@ static size_t curl_read_cb(void *ptr, size_t size, siz= e_t nmemb, void *opaque) memcpy(s->orig_buf + s->buf_off, ptr, realsize); s->buf_off +=3D realsize; =20 - for(i=3D0; iacb[i]; - - if (!acb) - continue; - - if ((s->buf_off >=3D acb->end)) { - size_t request_length =3D acb->bytes; - - qemu_iovec_from_buf(acb->qiov, 0, s->orig_buf + acb->start, - acb->end - acb->start); - - if (acb->end - acb->start < request_length) { - size_t offset =3D acb->end - acb->start; - qemu_iovec_memset(acb->qiov, offset, 0, - request_length - offset); - } - - acb->ret =3D 0; - s->acb[i] =3D NULL; - qemu_mutex_unlock(&s->s->mutex); - aio_co_wake(acb->co); - qemu_mutex_lock(&s->s->mutex); - } - } - read_end: /* curl will error out if we do not return this value */ return size * nmemb; @@ -351,13 +324,14 @@ static void curl_multi_check_completion(BDRVCURLState= *s) break; =20 if (msg->msg =3D=3D CURLMSG_DONE) { + int i; CURLState *state =3D NULL; + bool error =3D msg->data.result !=3D CURLE_OK; + curl_easy_getinfo(msg->easy_handle, CURLINFO_PRIVATE, (char **)&state); =20 - /* ACBs for successful messages get completed in curl_read_cb = */ - if (msg->data.result !=3D CURLE_OK) { - int i; + if (error) { static int errcount =3D 100; =20 /* Don't lose the original error message from curl, since @@ -369,20 +343,35 @@ static void curl_multi_check_completion(BDRVCURLState= *s) error_report("curl: further errors suppressed"); } } + } =20 - for (i =3D 0; i < CURL_NUM_ACB; i++) { - CURLAIOCB *acb =3D state->acb[i]; + for (i =3D 0; i < CURL_NUM_ACB; i++) { + CURLAIOCB *acb =3D state->acb[i]; =20 - if (acb =3D=3D NULL) { - continue; - } + if (acb =3D=3D NULL) { + continue; + } + + if (!error) { + /* Assert that we have read all data */ + assert(state->buf_off >=3D acb->end); + + qemu_iovec_from_buf(acb->qiov, 0, + state->orig_buf + acb->start, + acb->end - acb->start); =20 - acb->ret =3D -EIO; - state->acb[i] =3D NULL; - qemu_mutex_unlock(&s->mutex); - aio_co_wake(acb->co); - qemu_mutex_lock(&s->mutex); + if (acb->end - acb->start < acb->bytes) { + size_t offset =3D acb->end - acb->start; + qemu_iovec_memset(acb->qiov, offset, 0, + acb->bytes - offset); + } } + + acb->ret =3D error ? -EIO : 0; + state->acb[i] =3D NULL; + qemu_mutex_unlock(&s->mutex); + aio_co_wake(acb->co); + qemu_mutex_lock(&s->mutex); } =20 curl_clean_state(state); --=20 2.21.0 From nobody Fri Mar 29 09:22:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1568120319; cv=none; d=zoho.com; s=zohoarc; b=WxZb9vloIebKKQbWcIXaL86yKVNV+0yUq7Tfa2Cz3dY4sW55fvZWAlqyUepwam4OTjJA2qZwouT8T5I77GRo+m2S2DBImOuPZZ+aQ1xKwlvZfDMYaunnPF6HdfIaJIMJZpxfu9mMfsZTAGkSOopBtrHLrXRPZIWvwRjzr4J5rgY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568120319; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=ViBi7iZFVCEQqT7YUHSFN1fbSI46MCWBwkj3OxFYpWA=; b=erfAjlKhOwOQf5cXjdqvCJ/LmQTXoyyLDp0Sqru4V7sSJAl1Mrl4xUL74zJJAufxz6fvMxlmmhrWeWih2iY/eMiU3NC1T2t7xTLdnm0mMbL0oQ1pGZ/9lmt8BErM0m/TH6xg9I3fkww5JjsmiS88pW9i83f7QKEIgddoecEEB3Q= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1568120319973782.5754013852652; Tue, 10 Sep 2019 05:58:39 -0700 (PDT) Received: from localhost ([::1]:39506 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i7fjB-00087z-EN for importer@patchew.org; Tue, 10 Sep 2019 08:58:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59777) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i7fTQ-0002re-JH for qemu-devel@nongnu.org; Tue, 10 Sep 2019 08:42:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i7fTP-0005RR-IJ for qemu-devel@nongnu.org; Tue, 10 Sep 2019 08:42:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42004) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i7fTN-0005Qg-2L; Tue, 10 Sep 2019 08:42:17 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5F1F3C04B2D5; Tue, 10 Sep 2019 12:42:16 +0000 (UTC) Received: from localhost (ovpn-117-90.ams2.redhat.com [10.36.117.90]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 47AAF1001948; Tue, 10 Sep 2019 12:42:12 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Tue, 10 Sep 2019 14:41:36 +0200 Message-Id: <20190910124136.10565-8-mreitz@redhat.com> In-Reply-To: <20190910124136.10565-1-mreitz@redhat.com> References: <20190910124136.10565-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 10 Sep 2019 12:42:16 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 7/7] curl: Check curl_multi_add_handle()'s return code X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , qemu-stable@nongnu.org, John Snow , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" If we had done that all along, debugging would have been much simpler. (Also, I/O errors are better than hangs.) Signed-off-by: Max Reitz Reviewed-by: John Snow Reviewed-by: Maxim Levitsky --- block/curl.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/block/curl.c b/block/curl.c index c343c7ed3d..f86299378e 100644 --- a/block/curl.c +++ b/block/curl.c @@ -882,7 +882,13 @@ static void curl_setup_preadv(BlockDriverState *bs, CU= RLAIOCB *acb) trace_curl_setup_preadv(acb->bytes, start, state->range); curl_easy_setopt(state->curl, CURLOPT_RANGE, state->range); =20 - curl_multi_add_handle(s->multi, state->curl); + if (curl_multi_add_handle(s->multi, state->curl) !=3D CURLM_OK) { + state->acb[0] =3D NULL; + acb->ret =3D -EIO; + + curl_clean_state(state); + goto out; + } =20 /* Tell curl it needs to kick things off */ curl_multi_socket_action(s->multi, CURL_SOCKET_TIMEOUT, 0, &running); --=20 2.21.0