gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r33930 - gnunet/src/testbed


From: gnunet
Subject: [GNUnet-SVN] r33930 - gnunet/src/testbed
Date: Fri, 4 Jul 2014 23:38:45 +0200

Author: harsha
Date: 2014-07-04 23:38:45 +0200 (Fri, 04 Jul 2014)
New Revision: 33930

Modified:
   gnunet/src/testbed/testbed_api_operations.c
Log:
Do not cleanup operation queues if they are not empty.  Instead, mark them as 
expired and clean them in destructor.
 --This line, and those
below, will be ignored--

M    testbed/testbed_api_operations.c


Modified: gnunet/src/testbed/testbed_api_operations.c
===================================================================
--- gnunet/src/testbed/testbed_api_operations.c 2014-07-04 15:47:41 UTC (rev 
33929)
+++ gnunet/src/testbed/testbed_api_operations.c 2014-07-04 21:38:45 UTC (rev 
33930)
@@ -236,6 +236,11 @@
    * #OPERATION_QUEUE_TYPE_ADAPTIVE
    */
   unsigned int overload;
+
+  /**
+   * Is this queue marked for expiry?
+   */
+  unsigned int expired;
 };
 
 
@@ -375,14 +380,24 @@
 /**
  * DLL head for the ready queue
  */
-struct ReadyQueueEntry *rq_head;
+static struct ReadyQueueEntry *rq_head;
 
 /**
  * DLL tail for the ready queue
  */
-struct ReadyQueueEntry *rq_tail;
+static struct ReadyQueueEntry *rq_tail;
 
 /**
+ * Array of operation queues which are to be destroyed
+ */
+static struct OperationQueue **expired_opqs;
+
+/**
+ * Number of expired operation queues in the above array
+ */
+static unsigned int n_expired_opqs;
+
+/**
  * The id of the task to process the ready queue
  */
 GNUNET_SCHEDULER_TaskIdentifier process_rq_task_id;
@@ -1052,17 +1067,15 @@
 
 
 /**
- * Destroy an operation queue.  The queue MUST be empty
- * at this time.
+ * Cleanup the given operation queue.
  *
- * @param queue queue to destroy
+ * @param queue the operation queue to destroy
  */
-void
-GNUNET_TESTBED_operation_queue_destroy_ (struct OperationQueue *queue)
+static void
+queue_destroy (struct OperationQueue *queue)
 {
   struct FeedbackCtx *fctx;
 
-  GNUNET_break (GNUNET_YES == is_queue_empty (queue));
   if (OPERATION_QUEUE_TYPE_ADAPTIVE == queue->type)
   {
     cleanup_tslots (queue);
@@ -1075,6 +1088,27 @@
 
 
 /**
+ * Destroys an operation queue.  If the queue is still in use by operations it
+ * is marked as expired and its resources are released in the destructor
+ * GNUNET_TESTBED_operations_fini().
+ *
+ * @param queue queue to destroy
+ */
+void
+GNUNET_TESTBED_operation_queue_destroy_ (struct OperationQueue *queue)
+{
+  if (GNUNET_YES != is_queue_empty (queue))
+  {
+    GNUNET_assert (0 == queue->expired); /* Are you calling twice on same 
queue? */
+    queue->expired = 1;
+    GNUNET_array_append (expired_opqs, n_expired_opqs, queue);
+    return;
+  }
+  queue_destroy (queue);
+}
+
+
+/**
  * Destroys the operation queue if it is empty.  If not empty return GNUNET_NO.
  *
  * @param queue the queue to destroy if empty
@@ -1317,4 +1351,29 @@
 }
 
 
+/**
+ * Cleanup expired operation queues.  While doing so, also check for any
+ * operations which are not completed and warn about them.
+ */
+void __attribute__ ((destructor))
+GNUNET_TESTBED_operations_fini ()
+{
+  struct OperationQueue *queue;
+  unsigned int i;
+  int warn = 0;
+
+  for (i=0; i < n_expired_opqs; i++)
+  {
+    queue = expired_opqs[i];
+    if (GNUNET_NO == is_queue_empty (queue))
+      warn = 1;
+    queue_destroy (queue);
+  }
+  GNUNET_free_non_null (expired_opqs);
+  n_expired_opqs = 0;
+  if (warn)
+    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+                "Be disciplined.  Some operations were not marked as done.\n");
+
+}
 /* end of testbed_api_operations.c */




reply via email to

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