From 9f5eddcd13e3fc2ef69c1439512d4ccc5d0e57e3 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 8 Jan 2017 12:41:59 +0100 Subject: [PATCH] lib/curl/Global: move code to UpdateTimeout() --- src/lib/curl/Global.cxx | 22 ++++++++++++++-------- src/lib/curl/Global.hxx | 1 + 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/lib/curl/Global.cxx b/src/lib/curl/Global.cxx index 977b84157..70d915b27 100644 --- a/src/lib/curl/Global.cxx +++ b/src/lib/curl/Global.cxx @@ -217,15 +217,12 @@ CurlGlobal::ReadInfo() } } -int -CurlGlobal::TimerFunction(gcc_unused CURLM *_global, long timeout_ms, void *userp) +inline void +CurlGlobal::UpdateTimeout(long timeout_ms) { - auto &global = *(CurlGlobal *)userp; - assert(_global == global.multi.Get()); - if (timeout_ms < 0) { - global.Cancel(); - return 0; + TimeoutMonitor::Cancel(); + return; } if (timeout_ms < 10) @@ -235,7 +232,16 @@ CurlGlobal::TimerFunction(gcc_unused CURLM *_global, long timeout_ms, void *user of 10ms. */ timeout_ms = 10; - global.Schedule(std::chrono::milliseconds(timeout_ms)); + TimeoutMonitor::Schedule(std::chrono::milliseconds(timeout_ms)); +} + +int +CurlGlobal::TimerFunction(gcc_unused CURLM *_global, long timeout_ms, void *userp) +{ + auto &global = *(CurlGlobal *)userp; + assert(_global == global.multi.Get()); + + global.UpdateTimeout(timeout_ms); return 0; } diff --git a/src/lib/curl/Global.hxx b/src/lib/curl/Global.hxx index e7b03f684..8a57aba83 100644 --- a/src/lib/curl/Global.hxx +++ b/src/lib/curl/Global.hxx @@ -76,6 +76,7 @@ public: } private: + void UpdateTimeout(long timeout_ms); static int TimerFunction(CURLM *global, long timeout_ms, void *userp); /* virtual methods from class TimeoutMonitor */