curl: Handle success in multi_check_completion
commitbfb23b480a49114315877aacf700b49453e0f9d9
authorMax Reitz <mreitz@redhat.com>
Tue, 10 Sep 2019 12:41:35 +0000 (10 14:41 +0200)
committerMax Reitz <mreitz@redhat.com>
Mon, 16 Sep 2019 13:31:11 +0000 (16 15:31 +0200)
tree874e2730b5e25f56bcf179263a7301c56c24884f
parent9abaf9fc474c3dd53e8e119326abc774c977c331
curl: Handle success in multi_check_completion

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 <ngavrilo@redhat.com>
Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1740193
Cc: qemu-stable@nongnu.org
Signed-off-by: Max Reitz <mreitz@redhat.com>
Message-id: 20190910124136.10565-7-mreitz@redhat.com
Reviewed-by: John Snow <jsnow@redhat.com>
Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
block/curl.c