cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: PacRunner libcurl plugin broken?

From: David Woodhouse <dwmw2_at_infradead.org>
Date: Tue, 07 Dec 2010 11:45:27 +0000

On Tue, 2010-12-07 at 09:53 +0000, David Woodhouse wrote:
>
> Yes, the problem still happens. I've made a simpler test case out of
> the
> code in PacRunner: http://david.woodhou.se/gcurl.c

OK, I think I have this working.

The problem is that my timer callback isn't being called after the first
time.

It's called to set the *first* timer (the 1ms timer which is set on
calling curl_multi_add_handle()), but curl never seems to call my timer
callback again, even though there are more timeouts to come.

If I change my timeout_callback() function to call curl_multi_timeout()
and manually set *itself* up to recur at the designated time, it now
works fine with libcurl 7.21.2. Is that intended? It doesn't seem to be
particularly well-documented if so.

In 7.21.0 the note in the curl_multi_timeout() man page is true — if it
returns a -1 timeout, I *do* need to call it within a few seconds
anyway. Otherwise we never poll for completion of the asynchronous
getaddrinfo() thread.

--- gcurl.c~ 2010-12-07 09:48:58.000000000 +0000
+++ gcurl.c 2010-12-07 11:29:53.765982368 +0000
@@ -146,11 +146,13 @@ static int socket_callback(CURL *easy, c
         return 0;
 }
 
+static int timer_callback(CURLM *multi, long timeout_ms, void *user_data);
 static gboolean timeout_callback(gpointer user_data)
 {
         CURLM *multi = user_data;
         CURLMcode result;
         int handles;
+ long next;
 
         DBG("");
 
@@ -164,6 +166,11 @@ static gboolean timeout_callback(gpointe
 #endif
 
         timeout_source = 0;
+ curl_multi_timeout(multi, &next);
+ if (next == -1 && handles)
+ next = 1000;
+ if (next != -1)
+ timer_callback(multi, next, NULL);
 
         return FALSE;
 }

-- 
dwmw2
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2010-12-07