gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [gnunet] branch master updated (81e835f8d -> 542bf871c)


From: gnunet
Subject: [GNUnet-SVN] [gnunet] branch master updated (81e835f8d -> 542bf871c)
Date: Sun, 22 Jan 2017 00:35:39 +0100

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

grothoff pushed a change to branch master
in repository gnunet.

    from 81e835f8d fix crash on early abort due to dangling connect task
     new 9855137d1 another connect_task init missing
     new 542bf871c extending scheduler API with 'add_at' functionality to avoid 
unnecessary time conversions

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/cadet/cadet.conf.in            |  1 +
 src/cadet/test_cadet_local.c       | 20 +++++----
 src/include/gnunet_scheduler_lib.h | 45 +++++++++++++++++---
 src/util/scheduler.c               | 85 ++++++++++++++++++++++++++++++--------
 4 files changed, 120 insertions(+), 31 deletions(-)

diff --git a/src/cadet/cadet.conf.in b/src/cadet/cadet.conf.in
index 88f49fde8..48fd03329 100644
--- a/src/cadet/cadet.conf.in
+++ b/src/cadet/cadet.conf.in
@@ -4,6 +4,7 @@ AUTOSTART = @AUTOSTART@
 @address@hidden = 2096
 HOSTNAME = localhost
 BINARY = gnunet-service-cadet
+# PREFIX = valgrind --leak-check=yes
 ACCEPT_FROM = 127.0.0.1;
 ACCEPT_FROM6 = ::1;
 UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-cadet.sock
diff --git a/src/cadet/test_cadet_local.c b/src/cadet/test_cadet_local.c
index 05cfdb1ba..ddd294d6b 100644
--- a/src/cadet/test_cadet_local.c
+++ b/src/cadet/test_cadet_local.c
@@ -80,13 +80,15 @@ do_shutdown (void *cls)
     GNUNET_CADET_channel_destroy (ch);
     ch = NULL;
   }
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnect client 1\n");
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Disconnect client 1\n");
   if (NULL != cadet_peer_1)
   {
     GNUNET_CADET_disconnect (cadet_peer_1);
     cadet_peer_1 = NULL;
   }
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnect client 2\n");
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Disconnect client 2\n");
   if (NULL != cadet_peer_2)
   {
     GNUNET_CADET_disconnect (cadet_peer_2);
@@ -196,10 +198,12 @@ channel_end (void *cls,
     ch = NULL;
   if (GNUNET_NO == got_data)
   {
-    GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (
-                                  GNUNET_TIME_UNIT_SECONDS,
-                                  2),
-                                  &do_connect, NULL);
+    if (NULL == connect_task)
+      connect_task
+        = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply 
(GNUNET_TIME_UNIT_SECONDS,
+                                                                       2),
+                                        &do_connect,
+                                        NULL);
   }
 }
 
@@ -298,13 +302,13 @@ run (void *cls,
                                      (void *) 1L,       /* cls */
                                      &channel_end,      /* channel end hndlr */
                                      handlers1); /* traffic handlers */
-
   cadet_peer_2 = GNUNET_CADET_connect (cfg,       /* configuration */
                                      (void *) 2L,     /* cls */
                                      &channel_end,      /* channel end hndlr */
                                      handlers2); /* traffic handlers */
 
-  if (NULL == cadet_peer_1 || NULL == cadet_peer_2)
+  if ( (NULL == cadet_peer_1) ||
+       (NULL == cadet_peer_2) )
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                "Couldn't connect to cadet :(\n");
diff --git a/src/include/gnunet_scheduler_lib.h 
b/src/include/gnunet_scheduler_lib.h
index 1a0438bed..2be1858ce 100644
--- a/src/include/gnunet_scheduler_lib.h
+++ b/src/include/gnunet_scheduler_lib.h
@@ -172,7 +172,7 @@ GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_TaskCallback task,
 
 
 /**
- * Request the shutdown of a scheduler.  Marks all tasks 
+ * Request the shutdown of a scheduler.  Marks all tasks
  * awaiting shutdown as ready. Note that tasks
  * scheduled with #GNUNET_SCHEDULER_add_shutdown() AFTER this call
  * will be delayed until the next shutdown signal.
@@ -309,7 +309,7 @@ GNUNET_SCHEDULER_add_now_with_lifeness (int lifeness,
  * will be scheduled for execution once the delay has expired. It
  * will be run with the DEFAULT priority.
  *
- * @param delay when should this operation time out?
+ * @param delay with which the operation should be run
  * @param task main function of the task
  * @param task_cls closure of @a task
  * @return unique task identifier for the job
@@ -322,10 +322,27 @@ GNUNET_SCHEDULER_add_delayed (struct GNUNET_TIME_Relative 
delay,
 
 
 /**
+ * Schedule a new task to be run at the specified time.  The task
+ * will be scheduled for execution once specified time has been
+ * reached. It will be run with the DEFAULT priority.
+ *
+ * @param at time at which this operation should run
+ * @param task main function of the task
+ * @param task_cls closure of @a task
+ * @return unique task identifier for the job
+ *         only valid until @a task is started!
+ */
+struct GNUNET_SCHEDULER_Task *
+GNUNET_SCHEDULER_add_at (struct GNUNET_TIME_Absolute at,
+                         GNUNET_SCHEDULER_TaskCallback task,
+                         void *task_cls);
+
+
+/**
  * Schedule a new task to be run with a specified delay.  The task
  * will be scheduled for execution once the delay has expired.
  *
- * @param delay when should this operation time out? 
+ * @param delay when should this operation time out?
  * @param priority priority to use for the task
  * @param task main function of the task
  * @param task_cls closure of @a task
@@ -340,6 +357,24 @@ GNUNET_SCHEDULER_add_delayed_with_priority (struct 
GNUNET_TIME_Relative delay,
 
 
 /**
+ * Schedule a new task to be run at the specified time.  The task
+ * will be scheduled for execution at time @a at.
+ *
+ * @param at time when the operation should run
+ * @param priority priority to use for the task
+ * @param task main function of the task
+ * @param task_cls closure of @a task
+ * @return unique task identifier for the job
+ *         only valid until @a task is started!
+ */
+struct GNUNET_SCHEDULER_Task *
+GNUNET_SCHEDULER_add_at_with_priority (struct GNUNET_TIME_Absolute at,
+                                       enum GNUNET_SCHEDULER_Priority priority,
+                                       GNUNET_SCHEDULER_TaskCallback task,
+                                       void *task_cls);
+
+
+/**
  * Schedule a new task to be run with a specified delay or when the
  * specified file descriptor is ready for reading.  The delay can be
  * used as a timeout on the socket being ready.  The task will be
@@ -480,7 +515,7 @@ GNUNET_SCHEDULER_add_write_file (struct 
GNUNET_TIME_Relative delay,
  * scheduled for execution once either the delay has expired or the
  * socket operation is ready.
  *
- * @param delay when should this operation time out? 
+ * @param delay when should this operation time out?
  * @param priority priority of the task
  * @param fd file-descriptor
  * @param on_read whether to poll the file-descriptor for readability
@@ -516,7 +551,7 @@ GNUNET_SCHEDULER_add_file_with_priority (struct 
GNUNET_TIME_Relative delay,
  * </code>
  *
  * @param prio how important is this task?
- * @param delay how long should we wait? 
+ * @param delay how long should we wait?
  * @param rs set of file descriptors we want to read (can be NULL)
  * @param ws set of file descriptors we want to write (can be NULL)
  * @param task main function of the task
diff --git a/src/util/scheduler.c b/src/util/scheduler.c
index b016b91b7..409a0942f 100644
--- a/src/util/scheduler.c
+++ b/src/util/scheduler.c
@@ -155,7 +155,7 @@ struct GNUNET_SCHEDULER_Task
    * Is this task run on shutdown?
    */
   int on_shutdown;
-  
+
   /**
    * Is this task in the ready list?
    */
@@ -490,7 +490,7 @@ check_ready (const struct GNUNET_NETWORK_FDSet *rs,
 
 
 /**
- * Request the shutdown of a scheduler.  Marks all tasks 
+ * Request the shutdown of a scheduler.  Marks all tasks
  * awaiting shutdown as ready. Note that tasks
  * scheduled with #GNUNET_SCHEDULER_add_shutdown() AFTER this call
  * will be delayed until the next shutdown signal.
@@ -534,13 +534,13 @@ destroy_task (struct GNUNET_SCHEDULER_Task *t)
  * Output stack trace of task @a t.
  *
  * @param t task to dump stack trace of
- */ 
+ */
 static void
 dump_backtrace (struct GNUNET_SCHEDULER_Task *t)
 {
 #if EXECINFO
   unsigned int i;
-  
+
   for (i = 0; i < t->num_backtrace_strings; i++)
     LOG (GNUNET_ERROR_TYPE_DEBUG,
         "Task %p trace %u: %s\n",
@@ -1080,10 +1080,10 @@ GNUNET_SCHEDULER_add_with_reason_and_priority 
(GNUNET_SCHEDULER_TaskCallback tas
 
 
 /**
- * Schedule a new task to be run with a specified delay.  The task
- * will be scheduled for execution once the delay has expired.
+ * Schedule a new task to be run at the specified time.  The task
+ * will be scheduled for execution at time @a at.
  *
- * @param delay when should this operation time out?
+ * @param at time when the operation should run
  * @param priority priority to use for the task
  * @param task main function of the task
  * @param task_cls closure of @a task
@@ -1091,10 +1091,10 @@ GNUNET_SCHEDULER_add_with_reason_and_priority 
(GNUNET_SCHEDULER_TaskCallback tas
  *         only valid until @a task is started!
  */
 struct GNUNET_SCHEDULER_Task *
-GNUNET_SCHEDULER_add_delayed_with_priority (struct GNUNET_TIME_Relative delay,
-                                           enum GNUNET_SCHEDULER_Priority 
priority,
-                                           GNUNET_SCHEDULER_TaskCallback task,
-                                            void *task_cls)
+GNUNET_SCHEDULER_add_at_with_priority (struct GNUNET_TIME_Absolute at,
+                                       enum GNUNET_SCHEDULER_Priority priority,
+                                       GNUNET_SCHEDULER_TaskCallback task,
+                                       void *task_cls)
 {
   struct GNUNET_SCHEDULER_Task *t;
   struct GNUNET_SCHEDULER_Task *pos;
@@ -1110,12 +1110,13 @@ GNUNET_SCHEDULER_add_delayed_with_priority (struct 
GNUNET_TIME_Relative delay,
 #if PROFILE_DELAYS
   t->start_time = GNUNET_TIME_absolute_get ();
 #endif
-  t->timeout = GNUNET_TIME_relative_to_absolute (delay);
+  t->timeout = at;
   t->priority = priority;
   t->lifeness = current_lifeness;
   /* try tail first (optimization in case we are
    * appending to a long list of tasks with timeouts) */
-  if (0 == delay.rel_value_us)
+  if ( (NULL == pending_timeout_head) ||
+       (at.abs_value_us < pending_timeout_head->timeout.abs_value_us) )
   {
     GNUNET_CONTAINER_DLL_insert (pending_timeout_head,
                                  pending_timeout_tail,
@@ -1144,9 +1145,9 @@ GNUNET_SCHEDULER_add_delayed_with_priority (struct 
GNUNET_TIME_Relative delay,
                                        pending_timeout_tail,
                                        prev,
                                        t);
-    /* finally, update heuristic insertion point to last insertion... */
-    pending_timeout_last = t;
   }
+  /* finally, update heuristic insertion point to last insertion... */
+  pending_timeout_last = t;
 
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "Adding task: %p\n",
@@ -1157,6 +1158,30 @@ GNUNET_SCHEDULER_add_delayed_with_priority (struct 
GNUNET_TIME_Relative delay,
 
 
 /**
+ * Schedule a new task to be run with a specified delay.  The task
+ * will be scheduled for execution once the delay has expired.
+ *
+ * @param delay when should this operation time out?
+ * @param priority priority to use for the task
+ * @param task main function of the task
+ * @param task_cls closure of @a task
+ * @return unique task identifier for the job
+ *         only valid until @a task is started!
+ */
+struct GNUNET_SCHEDULER_Task *
+GNUNET_SCHEDULER_add_delayed_with_priority (struct GNUNET_TIME_Relative delay,
+                                           enum GNUNET_SCHEDULER_Priority 
priority,
+                                           GNUNET_SCHEDULER_TaskCallback task,
+                                            void *task_cls)
+{
+  return GNUNET_SCHEDULER_add_at_with_priority 
(GNUNET_TIME_relative_to_absolute (delay),
+                                                priority,
+                                                task,
+                                                task_cls);
+}
+
+
+/**
  * Schedule a new task to be run with a specified priority.
  *
  * @param prio how important is the new task?
@@ -1178,6 +1203,29 @@ GNUNET_SCHEDULER_add_with_priority (enum 
GNUNET_SCHEDULER_Priority prio,
 
 
 /**
+ * Schedule a new task to be run at the specified time.  The task
+ * will be scheduled for execution once specified time has been
+ * reached. It will be run with the DEFAULT priority.
+ *
+ * @param at time at which this operation should run
+ * @param task main function of the task
+ * @param task_cls closure of @a task
+ * @return unique task identifier for the job
+ *         only valid until @a task is started!
+ */
+struct GNUNET_SCHEDULER_Task *
+GNUNET_SCHEDULER_add_at (struct GNUNET_TIME_Absolute at,
+                         GNUNET_SCHEDULER_TaskCallback task,
+                         void *task_cls)
+{
+  return GNUNET_SCHEDULER_add_at_with_priority (at,
+                                                
GNUNET_SCHEDULER_PRIORITY_DEFAULT,
+                                                task,
+                                                task_cls);
+}
+
+
+/**
  * Schedule a new task to be run with a specified delay.  The task
  * will be scheduled for execution once the delay has expired. It
  * will be run with the DEFAULT priority.
@@ -1195,7 +1243,8 @@ GNUNET_SCHEDULER_add_delayed (struct GNUNET_TIME_Relative 
delay,
 {
   return GNUNET_SCHEDULER_add_delayed_with_priority (delay,
                                                     
GNUNET_SCHEDULER_PRIORITY_DEFAULT,
-                                                    task, task_cls);
+                                                    task,
+                                                     task_cls);
 }
 
 
@@ -1391,7 +1440,7 @@ add_without_sets (struct GNUNET_TIME_Relative delay,
  * scheduled for execution once either the delay has expired or the
  * socket operation is ready.  It will be run with the DEFAULT priority.
  *
- * @param delay when should this operation time out? 
+ * @param delay when should this operation time out?
  * @param rfd read file-descriptor
  * @param task main function of the task
  * @param task_cls closure of @a task
@@ -1640,7 +1689,7 @@ GNUNET_SCHEDULER_add_file_with_priority (struct 
GNUNET_TIME_Relative delay,
  * </code>
  *
  * @param prio how important is this task?
- * @param delay how long should we wait? 
+ * @param delay how long should we wait?
  * @param rs set of file descriptors we want to read (can be NULL)
  * @param ws set of file descriptors we want to write (can be NULL)
  * @param task main function of the task

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



reply via email to

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