allow empty/NULL context message
[oweals/gnunet.git] / src / curl / curl_reschedule.c
index 3e6c887f3f75b756e0ff700652f7bc37e3e2358a..6da930ea068a62aec434d6d176ca8bf9ac2d4642 100644 (file)
@@ -75,7 +75,7 @@ GNUNET_CURL_gnunet_rc_destroy (struct GNUNET_CURL_RescheduleContext *rc)
 /**
  * Task that runs the context's event loop with the GNUnet scheduler.
  *
- * @param cls the `struct GNUNET_CURL_RescheduleContext`
+ * @param cls a `struct GNUNET_CURL_RescheduleContext *`
  */
 static void
 context_task (void *cls)
@@ -116,12 +116,13 @@ context_task (void *cls)
   GNUNET_NETWORK_fdset_copy_native (ws,
                                     &write_fd_set,
                                     max_fd + 1);
-  rc->task = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT,
-                                          delay,
-                                          rs,
-                                          ws,
-                                          &context_task,
-                                          rc);
+  if (NULL == rc->task)
+    rc->task = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT,
+                                            delay,
+                                            rs,
+                                            ws,
+                                            &context_task,
+                                            rc);
   GNUNET_NETWORK_fdset_destroy (rs);
   GNUNET_NETWORK_fdset_destroy (ws);
 }
@@ -133,12 +134,13 @@ context_task (void *cls)
  * Note that you MUST immediately destroy the reschedule context after
  * calling #GNUNET_CURL_fini().
  *
- * @param cls must point to a `struct GNUNET_CURL_RescheduleContext`
+ * @param cls must point to a `struct GNUNET_CURL_RescheduleContext *`
+ *           (pointer to a pointer!)
  */
 void
 GNUNET_CURL_gnunet_scheduler_reschedule (void *cls)
 {
-  struct GNUNET_CURL_RescheduleContext *rc = cls;
+  struct GNUNET_CURL_RescheduleContext *rc = *(void**) cls;
 
   if (NULL != rc->task)
     GNUNET_SCHEDULER_cancel (rc->task);