gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [gnurl] 142/173: docs: fix timeout handling in multi-uv exa


From: gnunet
Subject: [GNUnet-SVN] [gnurl] 142/173: docs: fix timeout handling in multi-uv example
Date: Fri, 24 Feb 2017 14:02:44 +0100

This is an automated email from the git hooks/post-receive script.

ng0 pushed a commit to annotated tag gnurl-7.53.1
in repository gnurl.

commit 4ddf9798ab1ae0c6d18d8f12ce531991dbd2575a
Author: Michael Kaufmann <address@hidden>
AuthorDate: Sun Jan 29 17:06:49 2017 +0100

    docs: fix timeout handling in multi-uv example
---
 docs/examples/multi-uv.c | 32 ++++++++++++++++++--------------
 1 file changed, 18 insertions(+), 14 deletions(-)

diff --git a/docs/examples/multi-uv.c b/docs/examples/multi-uv.c
index c0228945d..406a5e062 100644
--- a/docs/examples/multi-uv.c
+++ b/docs/examples/multi-uv.c
@@ -46,7 +46,7 @@ typedef struct curl_context_s {
   curl_socket_t sockfd;
 } curl_context_t;
 
-curl_context_t* create_curl_context(curl_socket_t sockfd)
+static curl_context_t* create_curl_context(curl_socket_t sockfd)
 {
   curl_context_t *context;
 
@@ -60,18 +60,18 @@ curl_context_t* create_curl_context(curl_socket_t sockfd)
   return context;
 }
 
-void curl_close_cb(uv_handle_t *handle)
+static void curl_close_cb(uv_handle_t *handle)
 {
   curl_context_t *context = (curl_context_t *) handle->data;
   free(context);
 }
 
-void destroy_curl_context(curl_context_t *context)
+static void destroy_curl_context(curl_context_t *context)
 {
   uv_close((uv_handle_t *) &context->poll_handle, curl_close_cb);
 }
 
-void add_download(const char *url, int num)
+static void add_download(const char *url, int num)
 {
   char filename[50];
   FILE *file;
@@ -129,14 +129,12 @@ static void check_multi_info(void)
   }
 }
 
-void curl_perform(uv_poll_t *req, int status, int events)
+static void curl_perform(uv_poll_t *req, int status, int events)
 {
   int running_handles;
   int flags = 0;
   curl_context_t *context;
 
-  uv_timer_stop(&timeout);
-
   if(events & UV_READABLE)
     flags |= CURL_CSELECT_IN;
   if(events & UV_WRITABLE)
@@ -150,7 +148,7 @@ void curl_perform(uv_poll_t *req, int status, int events)
   check_multi_info();
 }
 
-void on_timeout(uv_timer_t *req, int status)
+static void on_timeout(uv_timer_t *req, int status)
 {
   int running_handles;
   curl_multi_socket_action(curl_handle, CURL_SOCKET_TIMEOUT, 0,
@@ -158,15 +156,21 @@ void on_timeout(uv_timer_t *req, int status)
   check_multi_info();
 }
 
-void start_timeout(CURLM *multi, long timeout_ms, void *userp)
+static int start_timeout(CURLM *multi, long timeout_ms, void *userp)
 {
-  if(timeout_ms <= 0)
-    timeout_ms = 1; /* 0 means directly call socket_action, but we'll do it in
-                       a bit */
-  uv_timer_start(&timeout, on_timeout, timeout_ms, 0);
+  if(timeout_ms < 0) {
+    uv_timer_stop(&timeout);
+  }
+  else {
+    if(timeout_ms == 0)
+      timeout_ms = 1; /* 0 means directly call socket_action, but we'll do it 
in
+                         a bit */
+    uv_timer_start(&timeout, on_timeout, timeout_ms, 0);
+  }
+  return 0;
 }
 
-int handle_socket(CURL *easy, curl_socket_t s, int action, void *userp,
+static int handle_socket(CURL *easy, curl_socket_t s, int action, void *userp,
                   void *socketp)
 {
   curl_context_t *curl_context;

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]