gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r21304 - gnunet/src/statistics
Date: Sun, 6 May 2012 20:37:04 +0200

Author: grothoff
Date: 2012-05-06 20:37:04 +0200 (Sun, 06 May 2012)
New Revision: 21304

Modified:
   gnunet/src/statistics/statistics_api.c
Log:
-fixing #2310

Modified: gnunet/src/statistics/statistics_api.c
===================================================================
--- gnunet/src/statistics/statistics_api.c      2012-05-06 18:24:05 UTC (rev 
21303)
+++ gnunet/src/statistics/statistics_api.c      2012-05-06 18:37:04 UTC (rev 
21304)
@@ -280,8 +280,8 @@
   size_t nlen;
   size_t nsize;
 
-  GNUNET_assert (h != NULL);
-  GNUNET_assert (watch != NULL);
+  GNUNET_assert (NULL != h);
+  GNUNET_assert (NULL != watch);
 
   slen = strlen (watch->subsystem) + 1;
   nlen = strlen (watch->name) + 1;
@@ -344,7 +344,7 @@
   if (NULL != (c = h->current))
   {
     h->current = NULL;
-    if (c->cont != NULL)
+    if (NULL != c->cont)
       c->cont (c->cls, GNUNET_SYSERR);
     free_action_item (c);
   }
@@ -364,12 +364,12 @@
   struct GNUNET_STATISTICS_GetHandle *gn;
   unsigned int i;
 
-  if (h->backoff_task != GNUNET_SCHEDULER_NO_TASK)
+  if (GNUNET_SCHEDULER_NO_TASK != h->backoff_task)
     return GNUNET_NO;
-  if (h->client != NULL)
+  if (NULL != h->client)
     return GNUNET_YES;
   h->client = GNUNET_CLIENT_connect ("statistics", h->cfg);  
-  if (h->client != NULL)
+  if (NULL != h->client)
   {
     gn = h->action_head; 
     while (NULL != (gh = gn))
@@ -440,7 +440,7 @@
   struct GNUNET_STATISTICS_GetHandle *gh;
 
   GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == h->backoff_task);
-  if (h->do_destroy)
+  if (GNUNET_YES == h->do_destroy)
   {
     /* So we are shutting down and the service is not reachable.
      * Chances are that it's down for good and we are not going to connect to
@@ -449,7 +449,7 @@
      */
     loss = GNUNET_NO;
     for (gh = h->action_head; NULL != gh; gh = gh->next)
-      if ( (gh->make_persistent) && (gh->type == ACTION_SET) )
+      if ( (gh->make_persistent) && (ACTION_SET == gh->type) )
        loss = GNUNET_YES;
     if (GNUNET_YES == loss)
       GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -565,7 +565,7 @@
 {
   struct GNUNET_STATISTICS_Handle *h = cls;
 
-  GNUNET_STATISTICS_destroy (h, GNUNET_YES);
+  GNUNET_STATISTICS_destroy (h, GNUNET_NO);
 }
 
 
@@ -582,7 +582,7 @@
   struct GNUNET_STATISTICS_GetHandle *c;
   int ret;
 
-  if (msg == NULL)
+  if (NULL == msg)
   {
     LOG (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
          "Error receiving statistics from service, is the service running?\n");
@@ -626,7 +626,7 @@
     }    
     h->current = NULL;
     schedule_action (h);
-    if (c->cont != NULL)
+    if (NULL != c->cont)
       c->cont (c->cls, GNUNET_OK);
     free_action_item (c);
     return;
@@ -688,7 +688,7 @@
   uint16_t msize;
 
   GNUNET_assert (NULL != (c = handle->current));
-  if (buf == NULL)
+  if (NULL == buf)
   {
     /* timeout / error */
     LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -737,7 +737,7 @@
   size_t slen2;
   uint16_t msize;
 
-  if (buf == NULL)
+  if (NULL == buf)
   {
     /* timeout / error */
     LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -875,8 +875,8 @@
 {
   struct GNUNET_STATISTICS_Handle *ret;
 
-  GNUNET_assert (subsystem != NULL);
-  GNUNET_assert (cfg != NULL);
+  GNUNET_assert (NULL != subsystem);
+  GNUNET_assert (NULL != cfg);
   ret = GNUNET_malloc (sizeof (struct GNUNET_STATISTICS_Handle));
   ret->cfg = cfg;
   ret->subsystem = GNUNET_strdup (subsystem);
@@ -901,7 +901,7 @@
   struct GNUNET_TIME_Relative timeout;
   int i;
 
-  if (h == NULL)
+  if (NULL == h)
     return;
   GNUNET_assert (GNUNET_NO == h->do_destroy); // Don't call twice.
   if (GNUNET_SCHEDULER_NO_TASK != h->backoff_task)
@@ -913,7 +913,7 @@
   {
     if (NULL != h->current)
     {
-      if (h->current->type == ACTION_GET)
+      if (ACTION_GET == h->current->type)
       {
         GNUNET_CLIENT_notify_transmit_ready_cancel (h->th);
         h->th = NULL;
@@ -925,7 +925,7 @@
     while (NULL != (pos = next))
     {
       next = pos->next;
-      if (pos->type == ACTION_GET)
+      if (ACTION_GET == pos->type)
       {
        GNUNET_CONTAINER_DLL_remove (h->action_head,
                                     h->action_tail,
@@ -939,7 +939,7 @@
                                   h->action_tail,
                                   h->current);
     h->do_destroy = GNUNET_YES;
-    if ((h->current != NULL) && (h->th == NULL) &&
+    if ((NULL != h->current) && (NULL == h->th) &&
        (NULL != h->client))
     {
       timeout = GNUNET_TIME_absolute_get_remaining (h->current->timeout);
@@ -992,6 +992,7 @@
   struct GNUNET_STATISTICS_Handle *h = cls;
   struct GNUNET_MessageHeader hdr;
 
+  h->th = NULL;
   if (NULL == buf)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -1004,6 +1005,12 @@
   hdr.type = htons (GNUNET_MESSAGE_TYPE_TEST);
   hdr.size = htons (sizeof (struct GNUNET_MessageHeader));
   memcpy (buf, &hdr, sizeof (hdr));
+  if (GNUNET_YES != h->receiving)
+  {
+    h->receiving = GNUNET_YES;
+    GNUNET_CLIENT_receive (h->client, &receive_stats, h,
+                           GNUNET_TIME_UNIT_FOREVER_REL);
+  }
   return sizeof (struct GNUNET_MessageHeader);
 }
 
@@ -1018,8 +1025,8 @@
 {
   struct GNUNET_TIME_Relative timeout;
 
-  if ( (h->th != NULL) ||
-       (h->backoff_task != GNUNET_SCHEDULER_NO_TASK) )
+  if ( (NULL != h->th) ||
+       (GNUNET_SCHEDULER_NO_TASK != h->backoff_task) )
     return;                     /* action already pending */
   if (GNUNET_YES != try_connect (h))
   {
@@ -1032,7 +1039,7 @@
   h->current = h->action_head;
   if (NULL == h->current)
   {
-    if (h->do_destroy)
+    if (GNUNET_YES == h->do_destroy)
     {
       h->do_destroy = GNUNET_SYSERR; /* in 'TEST' mode */
       h->th = GNUNET_CLIENT_notify_transmit_ready (h->client,
@@ -1085,11 +1092,11 @@
 
   if (NULL == handle)
     return NULL;
-  GNUNET_assert (proc != NULL);
+  GNUNET_assert (NULL != proc);
   GNUNET_assert (GNUNET_NO == handle->do_destroy);
-  if (subsystem == NULL)
+  if (NULL == subsystem)
     subsystem = "";
-  if (name == NULL)
+  if (NULL == name)
     name = "";
   slen1 = strlen (subsystem) + 1;
   slen2 = strlen (name) + 1;
@@ -1154,7 +1161,7 @@
 {
   struct GNUNET_STATISTICS_WatchEntry *w;
 
-  if (handle == NULL)
+  if (NULL == handle)
     return GNUNET_SYSERR;
   w = GNUNET_malloc (sizeof (struct GNUNET_STATISTICS_WatchEntry));
   w->subsystem = GNUNET_strdup (subsystem);
@@ -1185,7 +1192,7 @@
   struct GNUNET_STATISTICS_WatchEntry *w;
   unsigned int i;
 
-  if (handle == NULL)
+  if (NULL == handle)
     return GNUNET_SYSERR;
   for (i=0;i<handle->watches_size;i++)
   {
@@ -1228,8 +1235,8 @@
   size_t nsize;
   int64_t delta;
 
-  GNUNET_assert (h != NULL);
-  GNUNET_assert (name != NULL);
+  GNUNET_assert (NULL != h);
+  GNUNET_assert (NULL != name);
   slen = strlen (h->subsystem) + 1;
   nlen = strlen (name) + 1;
   nsize = sizeof (struct GNUNET_STATISTICS_SetMessage) + slen + nlen;
@@ -1238,16 +1245,16 @@
     GNUNET_break (0);
     return;
   }
-  for (ai = h->action_head; ai != NULL; ai = ai->next)
+  for (ai = h->action_head; NULL != ai; ai = ai->next)
   {
     if (! ( (0 == strcmp (ai->subsystem, h->subsystem)) &&
            (0 == strcmp (ai->name, name)) && 
-           ( (ai->type == ACTION_UPDATE) ||
-             (ai->type == ACTION_SET) ) ) )
+           ( (ACTION_UPDATE == ai->type) ||
+             (ACTION_SET == ai->type) ) ) )
       continue;
-    if (ai->type == ACTION_SET)
+    if (ACTION_SET == ai->type)
     {
-      if (type == ACTION_UPDATE)
+      if (ACTION_UPDATE == type)
       {
        delta = (int64_t) value;
        if (delta > 0)
@@ -1272,7 +1279,7 @@
     }
     else
     {
-      if (type == ACTION_UPDATE)
+      if (ACTION_UPDATE == type)
       {
        /* make delta cummulative */
        delta = (int64_t) value;
@@ -1318,7 +1325,7 @@
 GNUNET_STATISTICS_set (struct GNUNET_STATISTICS_Handle *handle,
                        const char *name, uint64_t value, int make_persistent)
 {
-  if (handle == NULL)
+  if (NULL == handle)
     return;
   GNUNET_assert (GNUNET_NO == handle->do_destroy);
   add_setter_action (handle, name, make_persistent, value, ACTION_SET);
@@ -1338,9 +1345,9 @@
 GNUNET_STATISTICS_update (struct GNUNET_STATISTICS_Handle *handle,
                           const char *name, int64_t delta, int make_persistent)
 {
-  if (handle == NULL)
+  if (NULL == handle)
     return;
-  if (delta == 0)
+  if (0 == delta)
     return;
   GNUNET_assert (GNUNET_NO == handle->do_destroy);
   add_setter_action (handle, name, make_persistent, (uint64_t) delta,




reply via email to

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