diff options
author | Max Kellermann <max@musicpd.org> | 2017-01-08 12:40:56 +0100 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2017-01-08 12:46:35 +0100 |
commit | 3c66feff5ac2ea4641f52747d05125c320da3431 (patch) | |
tree | 1d812af03fd139c6b1d3042dc7d7fb7e47aeece9 | |
parent | 218c3bc0d5bef409a5195cf4d4e0b819999d42df (diff) |
lib/curl/Global: defer the ReadInfo() call
Fixes a crash that can occur due to recursion from InvalidateSockets()
to ReadInfo() to CurlRequest callbacks.
-rw-r--r-- | NEWS | 2 | ||||
-rw-r--r-- | src/lib/curl/Global.cxx | 8 | ||||
-rw-r--r-- | src/lib/curl/Global.hxx | 6 |
3 files changed, 14 insertions, 2 deletions
@@ -1,4 +1,6 @@ ver 0.20.1 (not yet released) +* input + - curl: fix crash bug * mixer - alsa: normalize displayed volume according to human perception * fix crash with volume_normalization enabled diff --git a/src/lib/curl/Global.cxx b/src/lib/curl/Global.cxx index 70d915b27..1033c7ae6 100644 --- a/src/lib/curl/Global.cxx +++ b/src/lib/curl/Global.cxx @@ -96,7 +96,7 @@ private: }; CurlGlobal::CurlGlobal(EventLoop &_loop) - :TimeoutMonitor(_loop) + :TimeoutMonitor(_loop), DeferredMonitor(_loop) { multi.SetOption(CURLMOPT_SOCKETFUNCTION, CurlSocket::SocketFunction); 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_strerror(mcode)); + DeferredMonitor::Schedule(); +} + +void +CurlGlobal::RunDeferred() +{ ReadInfo(); } diff --git a/src/lib/curl/Global.hxx b/src/lib/curl/Global.hxx index 8a57aba83..9591b3f80 100644 --- a/src/lib/curl/Global.hxx +++ b/src/lib/curl/Global.hxx @@ -32,6 +32,7 @@ #include "Multi.hxx" #include "event/TimeoutMonitor.hxx" +#include "event/DeferredMonitor.hxx" class CurlSocket; class CurlRequest; @@ -39,7 +40,7 @@ class CurlRequest; /** * Manager for the global CURLM object. */ -class CurlGlobal final : private TimeoutMonitor { +class CurlGlobal final : TimeoutMonitor, DeferredMonitor { CurlMulti multi; public: @@ -81,6 +82,9 @@ private: /* virtual methods from class TimeoutMonitor */ void OnTimeout() override; + + /* virtual methods from class DeferredMonitor */ + void RunDeferred() override; }; #endif |