aports/community/net-cpp/0002-curl-multi-fix-timer_callback-behavior-with-0-timeou.patch
Luca Weiss cdee8cba85 community/net-cpp: fix issues with new libcurl
We can also re-enable tests now.

Also increase the timeout to start httpbin from 5 seconds to 10 seconds
because apparently 5 is not enough for s390x on GitLab.

Fixes alpine/aports#13719
2022-06-18 15:46:19 +02:00

66 lines
2.3 KiB
Diff

From d0f636236b0bb013ca8f51af4041244d702cb0e3 Mon Sep 17 00:00:00 2001
From: Luca Weiss <luca@z3ntu.xyz>
Date: Sat, 18 Jun 2022 11:35:58 +0200
Subject: [PATCH 2/2] curl/multi: fix timer_callback behavior with 0 timeout
As per libcurl documentation don't call any libcurl function directly
from the timer callback. This has worked in the past but due to possible
issues newer libcurl versions return the error CURLM_RECURSIVE_API_CALL
when this happens.
---
src/core/net/http/impl/curl/multi.cpp | 34 ++++++++++-----------------
1 file changed, 12 insertions(+), 22 deletions(-)
diff --git a/src/core/net/http/impl/curl/multi.cpp b/src/core/net/http/impl/curl/multi.cpp
index acfa8a1..21cca50 100644
--- a/src/core/net/http/impl/curl/multi.cpp
+++ b/src/core/net/http/impl/curl/multi.cpp
@@ -387,32 +387,22 @@ void multi::Handle::Private::Timeout::Private::cancel()
void multi::Handle::Private::Timeout::Private::async_wait_for(const std::weak_ptr<Handle::Private>& context, const std::chrono::milliseconds& ms)
{
- if (ms.count() > 0)
+ std::weak_ptr<Private> self{shared_from_this()};
+ timer.expires_from_now(boost::posix_time::milliseconds{ms.count()});
+ timer.async_wait([self, context](const boost::system::error_code& ec)
{
- std::weak_ptr<Private> self{shared_from_this()};
- timer.expires_from_now(boost::posix_time::milliseconds{ms.count()});
- timer.async_wait([self, context](const boost::system::error_code& ec)
- {
- if (ec)
- return;
+ if (ec)
+ return;
- if (auto spc = context.lock())
+ if (auto spc = context.lock())
+ {
+ if (auto sp = self.lock())
{
- if (auto sp = self.lock())
- {
- std::lock_guard<std::mutex> lg(spc->guard);
- sp->handle_timeout(spc);
- }
+ std::lock_guard<std::mutex> lg(spc->guard);
+ sp->handle_timeout(spc);
}
- });
- } else if (ms.count() == 0)
- {
- auto sp = context.lock();
- if (not sp)
- return;
-
- handle_timeout(sp);
- }
+ }
+ });
}
void multi::Handle::Private::Timeout::Private::handle_timeout(const std::shared_ptr<Handle::Private>& context)
--
2.36.1