lib/curl/Global: defer the ReadInfo() call

Fixes a crash that can occur due to recursion from InvalidateSockets()
to ReadInfo() to CurlRequest callbacks.
This commit is contained in:
Max Kellermann 2017-01-08 12:40:56 +01:00
parent 218c3bc0d5
commit 3c66feff5a
3 changed files with 14 additions and 2 deletions

2
NEWS
View File

@ -1,4 +1,6 @@
ver 0.20.1 (not yet released) ver 0.20.1 (not yet released)
* input
- curl: fix crash bug
* mixer * mixer
- alsa: normalize displayed volume according to human perception - alsa: normalize displayed volume according to human perception
* fix crash with volume_normalization enabled * fix crash with volume_normalization enabled

View File

@ -96,7 +96,7 @@ private:
}; };
CurlGlobal::CurlGlobal(EventLoop &_loop) CurlGlobal::CurlGlobal(EventLoop &_loop)
:TimeoutMonitor(_loop) :TimeoutMonitor(_loop), DeferredMonitor(_loop)
{ {
multi.SetOption(CURLMOPT_SOCKETFUNCTION, CurlSocket::SocketFunction); multi.SetOption(CURLMOPT_SOCKETFUNCTION, CurlSocket::SocketFunction);
multi.SetOption(CURLMOPT_SOCKETDATA, this); multi.SetOption(CURLMOPT_SOCKETDATA, this);
@ -262,5 +262,11 @@ CurlGlobal::SocketAction(curl_socket_t fd, int ev_bitmask)
"curl_multi_socket_action() failed: %s", "curl_multi_socket_action() failed: %s",
curl_multi_strerror(mcode)); curl_multi_strerror(mcode));
DeferredMonitor::Schedule();
}
void
CurlGlobal::RunDeferred()
{
ReadInfo(); ReadInfo();
} }

View File

@ -32,6 +32,7 @@
#include "Multi.hxx" #include "Multi.hxx"
#include "event/TimeoutMonitor.hxx" #include "event/TimeoutMonitor.hxx"
#include "event/DeferredMonitor.hxx"
class CurlSocket; class CurlSocket;
class CurlRequest; class CurlRequest;
@ -39,7 +40,7 @@ class CurlRequest;
/** /**
* Manager for the global CURLM object. * Manager for the global CURLM object.
*/ */
class CurlGlobal final : private TimeoutMonitor { class CurlGlobal final : TimeoutMonitor, DeferredMonitor {
CurlMulti multi; CurlMulti multi;
public: public:
@ -81,6 +82,9 @@ private:
/* virtual methods from class TimeoutMonitor */ /* virtual methods from class TimeoutMonitor */
void OnTimeout() override; void OnTimeout() override;
/* virtual methods from class DeferredMonitor */
void RunDeferred() override;
}; };
#endif #endif