Skip to content

Commit

Permalink
booru/imagefetcher: Handle timeout_ms according to curl docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ahodesuka committed Nov 25, 2017
1 parent 68b939a commit 212626b
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/booru/imagefetcher.cc
Expand Up @@ -46,8 +46,13 @@ int ImageFetcher::timer_cb(CURLM*, long timeout_ms, void *userp)
{
ImageFetcher *self = static_cast<ImageFetcher*>(userp);

self->m_TimeoutConn = self->m_MainContext->signal_timeout().connect(
sigc::mem_fun(self, &ImageFetcher::timeout_cb), timeout_ms);
if (timeout_ms > 0)
self->m_TimeoutConn = self->m_MainContext->signal_timeout().connect(
sigc::mem_fun(self, &ImageFetcher::timeout_cb), timeout_ms);
else if (timeout_ms == 0)
self->timeout_cb();
else if (timeout_ms == -1 && self->m_TimeoutConn)
self->m_TimeoutConn.disconnect();

return 0;
}
Expand All @@ -68,6 +73,9 @@ ImageFetcher::ImageFetcher()

ImageFetcher::~ImageFetcher()
{
if (m_TimeoutConn)
m_TimeoutConn.disconnect();

m_MainLoop->quit();
m_Thread.join();

Expand Down

0 comments on commit 212626b

Please sign in to comment.