gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r21007 - gnunet/src/core


From: gnunet
Subject: [GNUnet-SVN] r21007 - gnunet/src/core
Date: Wed, 18 Apr 2012 13:49:58 +0200

Author: grothoff
Date: 2012-04-18 13:49:58 +0200 (Wed, 18 Apr 2012)
New Revision: 21007

Modified:
   gnunet/src/core/core_api.c
   gnunet/src/core/gnunet-service-core_clients.c
Log:
-fixing core traffic monitoring assertion, code cleanup

Modified: gnunet/src/core/core_api.c
===================================================================
--- gnunet/src/core/core_api.c  2012-04-18 10:27:15 UTC (rev 21006)
+++ gnunet/src/core/core_api.c  2012-04-18 11:49:58 UTC (rev 21007)
@@ -767,7 +767,7 @@
   uint16_t et;
   uint32_t ats_count;
 
-  if (msg == NULL)
+  if (NULL == msg)
   {
     LOG (GNUNET_ERROR_TYPE_INFO,
          _
@@ -813,7 +813,7 @@
     }
     /* fake 'connect to self' */
     pr = GNUNET_CONTAINER_multihashmap_get (h->peers, &h->me.hashPubKey);
-    GNUNET_assert (pr == NULL);
+    GNUNET_assert (NULL == pr);
     pr = GNUNET_malloc (sizeof (struct PeerRecord));
     pr->peer = h->me;
     pr->ch = h;
@@ -851,7 +851,7 @@
       return;
     }
     pr = GNUNET_CONTAINER_multihashmap_get (h->peers, &cnm->peer.hashPubKey);
-    if (pr != NULL)
+    if (NULL != pr)
     {
       GNUNET_break (0);
       reconnect_later (h);
@@ -887,7 +887,7 @@
          "Received notification about disconnect from `%s'.\n",
          GNUNET_i2s (&dnm->peer));
     pr = GNUNET_CONTAINER_multihashmap_get (h->peers, &dnm->peer.hashPubKey);
-    if (pr == NULL)
+    if (NULL == pr)
     {
       GNUNET_break (0);
       reconnect_later (h);
@@ -923,13 +923,6 @@
     LOG (GNUNET_ERROR_TYPE_DEBUG,
          "Received message of type %u and size %u from peer `%4s'\n",
          ntohs (em->type), ntohs (em->size), GNUNET_i2s (&ntm->peer));
-    pr = GNUNET_CONTAINER_multihashmap_get (h->peers, &ntm->peer.hashPubKey);
-    if (pr == NULL)
-    {
-      GNUNET_break (0);
-      reconnect_later (h);
-      return;
-    }
     if ((GNUNET_NO == h->inbound_hdr_only) &&
         (msize !=
          ntohs (em->size) + sizeof (struct NotifyTrafficMessage) +
@@ -953,6 +946,13 @@
         GNUNET_break_op (0);
         continue;
       }
+      pr = GNUNET_CONTAINER_multihashmap_get (h->peers, &ntm->peer.hashPubKey);
+      if (NULL == pr)
+      {
+       GNUNET_break (0);
+       reconnect_later (h);
+       return;
+      }
       if (GNUNET_OK !=
           h->handlers[hpos].callback (h->cls, &ntm->peer, em, &ntm->ats,
                                       ats_count))
@@ -990,13 +990,6 @@
       return;
     }
     em = (const struct GNUNET_MessageHeader *) &(&ntm->ats)[ats_count + 1];
-    pr = GNUNET_CONTAINER_multihashmap_get (h->peers, &ntm->peer.hashPubKey);
-    if (pr == NULL)
-    {
-      GNUNET_break (0);
-      reconnect_later (h);
-      return;
-    }
     LOG (GNUNET_ERROR_TYPE_DEBUG,
          "Received notification about transmission to `%s'.\n",
          GNUNET_i2s (&ntm->peer));
@@ -1025,7 +1018,7 @@
     }
     smr = (const struct SendMessageReady *) msg;
     pr = GNUNET_CONTAINER_multihashmap_get (h->peers, &smr->peer.hashPubKey);
-    if (pr == NULL)
+    if (NULL == pr)
     {
       GNUNET_break (0);
       reconnect_later (h);
@@ -1034,7 +1027,7 @@
     LOG (GNUNET_ERROR_TYPE_DEBUG,
          "Received notification about transmission readiness to `%s'.\n",
          GNUNET_i2s (&smr->peer));
-    if (pr->pending_head == NULL)
+    if (NULL == pr->pending_head)
     {
       /* request must have been cancelled between the original request
        * and the response from core, ignore core's readiness */
@@ -1048,7 +1041,7 @@
        * ignore! (we should have already sent another request) */
       break;
     }
-    if ((pr->prev != NULL) || (pr->next != NULL) || (h->ready_peer_head == pr))
+    if ((NULL != pr->prev) || (NULL != pr->next) || (h->ready_peer_head == pr))
     {
       /* we should not already be on the ready list... */
       GNUNET_break (0);
@@ -1079,9 +1072,9 @@
 {
   struct GNUNET_CORE_Handle *h = cls;
 
-  if (success == GNUNET_SYSERR)
+  if (GNUNET_SYSERR == success)
     return;                     /* shutdown */
-  if (success == GNUNET_NO)
+  if (GNUNET_NO == success)
   {
     LOG (GNUNET_ERROR_TYPE_DEBUG,
          "Failed to exchange INIT with core, retrying\n");
@@ -1110,10 +1103,10 @@
   uint16_t *ts;
   unsigned int hpos;
 
-  GNUNET_assert (h->client == NULL);
+  GNUNET_assert (NULL == h->client);
   GNUNET_assert (h->currently_down == GNUNET_YES);
   h->client = GNUNET_CLIENT_connect ("core", h->cfg);
-  if (h->client == NULL)
+  if (NULL == h->client)
   {
     reconnect_later (h);
     return;

Modified: gnunet/src/core/gnunet-service-core_clients.c
===================================================================
--- gnunet/src/core/gnunet-service-core_clients.c       2012-04-18 10:27:15 UTC 
(rev 21006)
+++ gnunet/src/core/gnunet-service-core_clients.c       2012-04-18 11:49:58 UTC 
(rev 21007)
@@ -223,16 +223,18 @@
                      uint32_t options, uint16_t type)
 {
   struct GSC_Client *c;
+  int tm;
 
   for (c = client_head; c != NULL; c = c->next)
   {
+    tm = type_match (type, c);
     if (!  ( (0 != (c->options & options)) ||
             ( (0 != (options & GNUNET_CORE_OPTION_SEND_FULL_INBOUND)) &&
-              (GNUNET_YES == type_match (type, c)) ) ) )
+              (GNUNET_YES == tm) ) ) )
       continue;  /* neither options nor type match permit the message */
     if ( (0 != (options & GNUNET_CORE_OPTION_SEND_HDR_INBOUND)) &&
         ( (0 != (c->options & GNUNET_CORE_OPTION_SEND_FULL_INBOUND)) ||
-          (GNUNET_YES == type_match (type, c)) ) )
+          (GNUNET_YES == tm) ) )
       continue;
     if ( (0 != (options & GNUNET_CORE_OPTION_SEND_HDR_OUTBOUND)) &&
         (0 != (c->options & GNUNET_CORE_OPTION_SEND_FULL_OUTBOUND)) )
@@ -242,9 +244,11 @@
                options,
                ntohs (msg->size),
                 (unsigned int) type);
-    GNUNET_assert (GNUNET_YES ==
-                   GNUNET_CONTAINER_multihashmap_contains (c->connectmap,
-                                                           
&partner->hashPubKey));
+    GNUNET_assert ( (0 == (c->options & GNUNET_CORE_OPTION_SEND_FULL_INBOUND)) 
||
+                   (GNUNET_YES != tm) ||
+                   (GNUNET_YES ==
+                    GNUNET_CONTAINER_multihashmap_contains (c->connectmap,
+                                                            
&partner->hashPubKey)) );
     send_to_client (c, msg, can_drop);
   }
 }




reply via email to

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