gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r9273 - gnunet/src/statistics


From: gnunet
Subject: [GNUnet-SVN] r9273 - gnunet/src/statistics
Date: Sun, 25 Oct 2009 04:24:57 -0600

Author: grothoff
Date: 2009-10-25 04:24:57 -0600 (Sun, 25 Oct 2009)
New Revision: 9273

Modified:
   gnunet/src/statistics/statistics_api.c
Log:
fix

Modified: gnunet/src/statistics/statistics_api.c
===================================================================
--- gnunet/src/statistics/statistics_api.c      2009-10-25 10:22:49 UTC (rev 
9272)
+++ gnunet/src/statistics/statistics_api.c      2009-10-25 10:24:57 UTC (rev 
9273)
@@ -139,6 +139,11 @@
   struct GNUNET_CLIENT_Connection *client;
 
   /**
+   * Currently pending transmission request.
+   */
+  struct GNUNET_CLIENT_TransmitHandle *th;
+
+  /**
    * Head of the linked list of pending actions (first action
    * to be performed).
    */
@@ -156,11 +161,6 @@
    */
   struct ActionItem *current;
 
-  /**
-   * Should this handle be destroyed once we've processed
-   * all actions?
-   */
-  int do_destroy;
 
 };
 
@@ -226,13 +226,25 @@
 
 
 /**
- * Actually free the handle.
+ * Destroy a handle (free all state associated with
+ * it).
  */
-static void
-do_destroy (struct GNUNET_STATISTICS_Handle *h)
+void
+GNUNET_STATISTICS_destroy (struct GNUNET_STATISTICS_Handle *h)
 {
-  GNUNET_assert (h->action_head == NULL);
-  GNUNET_assert (h->current == NULL);
+  struct ActionItem *pos;
+  if (NULL != h->th)
+    {
+      GNUNET_CLIENT_notify_transmit_ready_cancel (h->th);
+      h->th = NULL;
+    }
+  if (h->current != NULL)
+    free_action_item (h->current);
+  while (NULL != (pos = h->action_head))
+    {
+      h->action_head = pos->next;
+      free_action_item (pos);
+    }
   if (h->client != NULL)
     {
       GNUNET_CLIENT_disconnect (h->client);
@@ -244,23 +256,6 @@
 
 
 /**
- * Destroy a handle (free all state associated with
- * it).
- */
-void
-GNUNET_STATISTICS_destroy (struct GNUNET_STATISTICS_Handle *handle)
-{
-  GNUNET_assert (handle->do_destroy == GNUNET_NO);
-  if ((handle->action_head != NULL) || (handle->current != NULL))
-    {
-      handle->do_destroy = GNUNET_YES;
-      return;
-    }
-  do_destroy (handle);
-}
-
-
-/**
  * Process the message.
  *
  * @return GNUNET_OK if the message was well-formed
@@ -348,8 +343,11 @@
 
   if (msg == NULL)
     {
-      GNUNET_CLIENT_disconnect (h->client);
-      h->client = NULL;
+      if (NULL != h->client)
+       {
+         GNUNET_CLIENT_disconnect (h->client);
+         h->client = NULL;
+       }
 #if DEBUG_STATISTICS
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
                  "Error receiving statistics from service, is the service 
running?\n" );
@@ -383,8 +381,11 @@
       GNUNET_break (0);
       break;
     }
-  GNUNET_CLIENT_disconnect (h->client);
-  h->client = NULL;
+  if (NULL != h->client)
+    {
+      GNUNET_CLIENT_disconnect (h->client);
+      h->client = NULL;
+    }
   finish (h, GNUNET_SYSERR);
 }
 
@@ -486,6 +487,7 @@
   struct GNUNET_STATISTICS_Handle *handle = cls;
   size_t ret;
 
+  handle->th = NULL;
   switch (handle->current->type)
     {
     case ACTION_GET:
@@ -523,25 +525,18 @@
   /* schedule next action */
   h->current = h->action_head;
   if (NULL == h->current)
-    {
-      /* no pending network action, check destroy! */
-      if (h->do_destroy != GNUNET_YES)
-        return;
-      do_destroy (h);
-      return;
-    }
+    return;
   h->action_head = h->action_head->next;
   if (NULL == h->action_head)
     h->action_tail = NULL;
   h->current->next = NULL;
-
   timeout = GNUNET_TIME_absolute_get_remaining (h->current->timeout);
   if (NULL ==
-      GNUNET_CLIENT_notify_transmit_ready (h->client,
-                                           h->current->msize,
-                                           timeout,
-                                          GNUNET_YES,
-                                          &transmit_action, h))
+      (h->th = GNUNET_CLIENT_notify_transmit_ready (h->client,
+                                                   h->current->msize,
+                                                   timeout,
+                                                   GNUNET_YES,
+                                                   &transmit_action, h)))
     {
 #if DEBUG_STATISTICS
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,





reply via email to

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