aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2007-05-02 13:52:38 +0000
committerDaniel Stenberg <daniel@haxx.se>2007-05-02 13:52:38 +0000
commit1afb67e31b3e8f952e39e4de4f1abeac3fc84376 (patch)
treef9317915eccca3c1e547c9796602a8dbb5df0212
parent2f0539d8803e4f270c8584994f7fc8b90cd5e15c (diff)
- Jeff Pohlmeyer improved the hiperfifo.c example to use the
CURLMOPT_TIMERFUNCTION callback option.
-rw-r--r--CHANGES3
-rw-r--r--RELEASE-NOTES2
-rw-r--r--docs/examples/hiperfifo.c17
3 files changed, 10 insertions, 12 deletions
diff --git a/CHANGES b/CHANGES
index d7235d083..963716f07 100644
--- a/CHANGES
+++ b/CHANGES
@@ -7,6 +7,9 @@
Changelog
Daniel S (2 May 2007)
+- Jeff Pohlmeyer improved the hiperfifo.c example to use the
+ CURLMOPT_TIMERFUNCTION callback option.
+
- Set the timeout for easy handles to expire really soon after addition or
when CURLM_CALL_MULTI_PERFORM is returned from curl_multi_socket*/perform,
to make applications using only curl_multi_socket() to properly function
diff --git a/RELEASE-NOTES b/RELEASE-NOTES
index 210466433..66726a45e 100644
--- a/RELEASE-NOTES
+++ b/RELEASE-NOTES
@@ -57,6 +57,6 @@ advice from friends like these:
Song Ma, Dan Fandrich, Yang Tse, Jay Austin, Robert Iakobashvil,
James Housley, Daniel Black, Steve Little, Sonia Subramanian, Peter O'Gorman,
- Frank Hempel, Michael Wallner
+ Frank Hempel, Michael Wallner, Jeff Pohlmeyer
Thanks! (and sorry if I forgot to mention someone)
diff --git a/docs/examples/hiperfifo.c b/docs/examples/hiperfifo.c
index f640bf9dc..e8d767133 100644
--- a/docs/examples/hiperfifo.c
+++ b/docs/examples/hiperfifo.c
@@ -92,18 +92,15 @@ typedef struct _SockInfo {
/* Update the event timer after curl_multi library calls */
-static void update_timeout(GlobalInfo *g)
+static int multi_timer_cb(CURLM *multi, long timeout_ms, GlobalInfo *g)
{
- long timeout_ms;
struct timeval timeout;
- curl_multi_timeout(g->multi, &timeout_ms);
- if(timeout_ms < 0)
- return;
-
timeout.tv_sec = timeout_ms/1000;
timeout.tv_usec = (timeout_ms%1000)*1000;
+ fprintf(MSG_OUT, "multi_timer_cb: Setting timeout to %ld ms\n", timeout_ms);
evtimer_add(&g->timer_event, &timeout);
+ return 0;
}
@@ -185,9 +182,7 @@ static void event_cb(int fd, short kind, void *userp)
} while (rc == CURLM_CALL_MULTI_PERFORM);
mcode_or_die("event_cb: curl_multi_socket", rc);
check_run_count(g);
- if(g->still_running) {
- update_timeout(g);
- } else {
+ if ( g->still_running <= 0 ) {
fprintf(MSG_OUT, "last transfer done, kill timeout\n");
if (evtimer_pending(&g->timer_event, NULL)) {
evtimer_del(&g->timer_event);
@@ -210,7 +205,6 @@ static void timer_cb(int fd, short kind, void *userp)
} while (rc == CURLM_CALL_MULTI_PERFORM);
mcode_or_die("timer_cb: curl_multi_socket", rc);
check_run_count(g);
- if ( g->still_running ) { update_timeout(g); }
}
@@ -406,10 +400,11 @@ int main(int argc, char **argv)
evtimer_set(&g.timer_event, timer_cb, &g);
curl_multi_setopt(g.multi, CURLMOPT_SOCKETFUNCTION, sock_cb);
curl_multi_setopt(g.multi, CURLMOPT_SOCKETDATA, &g);
+ curl_multi_setopt(g.multi, CURLMOPT_TIMERFUNCTION, multi_timer_cb);
+ curl_multi_setopt(g.multi, CURLMOPT_TIMERDATA, &g);
do {
rc = curl_multi_socket_all(g.multi, &g.still_running);
} while (CURLM_CALL_MULTI_PERFORM == rc);
- update_timeout(&g);
event_dispatch();
curl_multi_cleanup(g.multi);
return 0;