gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r22130 - gnunet/src/core
Date: Wed, 20 Jun 2012 10:48:01 +0200

Author: grothoff
Date: 2012-06-20 10:48:01 +0200 (Wed, 20 Jun 2012)
New Revision: 22130

Modified:
   gnunet/src/core/core_api.c
Log:
-fixing #2434, plus some code cleanup

Modified: gnunet/src/core/core_api.c
===================================================================
--- gnunet/src/core/core_api.c  2012-06-20 07:56:37 UTC (rev 22129)
+++ gnunet/src/core/core_api.c  2012-06-20 08:48:01 UTC (rev 22130)
@@ -364,19 +364,19 @@
   struct GNUNET_CORE_TransmitHandle *th;
   struct PeerRecord *pr = value;
 
-  if (pr->timeout_task != GNUNET_SCHEDULER_NO_TASK)
+  if (GNUNET_SCHEDULER_NO_TASK != pr->timeout_task)
   {
     GNUNET_SCHEDULER_cancel (pr->timeout_task);
     pr->timeout_task = GNUNET_SCHEDULER_NO_TASK;
   }
-  if (pr->ntr_task != GNUNET_SCHEDULER_NO_TASK)
+  if (GNUNET_SCHEDULER_NO_TASK != pr->ntr_task)
   {
     GNUNET_SCHEDULER_cancel (pr->ntr_task);
     pr->ntr_task = GNUNET_SCHEDULER_NO_TASK;
   }
-  if ((pr->prev != NULL) || (pr->next != NULL) || (h->ready_peer_head == pr))
+  if ((NULL != pr->prev) || (NULL != pr->next) || (h->ready_peer_head == pr))
     GNUNET_CONTAINER_DLL_remove (h->ready_peer_head, h->ready_peer_tail, pr);
-  if (h->disconnects != NULL)
+  if (NULL != h->disconnects)
     h->disconnects (h->cls, &pr->peer);
   /* all requests should have been cancelled, clean up anyway, just in case */
   th = &pr->th;
@@ -384,15 +384,15 @@
   {
     GNUNET_break (0);
     th->peer = NULL;
-    if (th->cm != NULL)
+    if (NULL != th->cm)
       th->cm->th = NULL;
   }
   /* done with 'voluntary' cleanups, now on to normal freeing */
   GNUNET_assert (GNUNET_YES ==
                  GNUNET_CONTAINER_multihashmap_remove (h->peers, key, pr));
   GNUNET_assert (pr->ch == h);
-  GNUNET_assert (pr->timeout_task == GNUNET_SCHEDULER_NO_TASK);
-  GNUNET_assert (pr->ntr_task == GNUNET_SCHEDULER_NO_TASK);
+  GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == pr->timeout_taks);
+  GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == pr->ntr_task);
   GNUNET_free (pr);
   return GNUNET_YES;
 }
@@ -410,13 +410,13 @@
   struct ControlMessage *cm;
   struct PeerRecord *pr;
 
-  GNUNET_assert (h->reconnect_task == GNUNET_SCHEDULER_NO_TASK);
+  GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == h->reconnect_task);
   if (NULL != h->cth)
   {
     GNUNET_CLIENT_notify_transmit_ready_cancel (h->cth);
     h->cth = NULL;
   }
-  if (h->client != NULL)
+  if (NULL != h->client)
   {
     GNUNET_CLIENT_disconnect (h->client);
     h->client = NULL;
@@ -429,9 +429,9 @@
   {
     GNUNET_CONTAINER_DLL_remove (h->control_pending_head,
                                  h->control_pending_tail, cm);
-    if (cm->th != NULL)
+    if (NULL != cm->th)
       cm->th->cm = NULL;
-    if (cm->cont != NULL)
+    if (NULL != cm->cont)
       cm->cont (cm->cont_cls, GNUNET_NO);
     GNUNET_free (cm);
   }
@@ -537,9 +537,14 @@
   struct GNUNET_CORE_TransmitHandle *th;
 
   pr->timeout_task = GNUNET_SCHEDULER_NO_TASK;
+  if (GNUNET_SCHEDULER_NO_TASK != pr->ntr_task)
+  {
+    GNUNET_SCHEDULER_cancel (pr->ntr_task);
+    pr->ntr_task = GNUNET_SCHEDULER_NO_TASK;
+  }
   th = &pr->th;
   th->peer = NULL;
-  if ((pr->prev != NULL) || (pr->next != NULL) || (pr == h->ready_peer_head))
+  if ((NULL != pr->prev) || (NULL != pr->next) || (pr == h->ready_peer_head))
   {
     /* the request that was 'approved' by core was
      * canceled before it could be transmitted; remove
@@ -584,7 +589,7 @@
 
   GNUNET_assert (h->reconnect_task == GNUNET_SCHEDULER_NO_TASK);
   h->cth = NULL;
-  if (buf == NULL)
+  if (NULL == buf)
   {
     LOG (GNUNET_ERROR_TYPE_DEBUG,
          "Transmission failed, initiating reconnect\n");
@@ -607,7 +612,7 @@
     memcpy (buf, hdr, msize);
     GNUNET_CONTAINER_DLL_remove (h->control_pending_head,
                                  h->control_pending_tail, cm);
-    if (cm->th != NULL)
+    if (NULL != cm->th)
       cm->th->cm = NULL;
     if (NULL != cm->cont)
       cm->cont (cm->cont_cls, GNUNET_OK);
@@ -627,7 +632,7 @@
   }
   GNUNET_CONTAINER_DLL_remove (h->ready_peer_head, h->ready_peer_tail, pr);
   th->peer = NULL;
-  if (pr->timeout_task != GNUNET_SCHEDULER_NO_TASK)
+  if (GNUNET_SCHEDULER_NO_TASK != pr->timeout_task)
   {
     GNUNET_SCHEDULER_cancel (pr->timeout_task);
     pr->timeout_task = GNUNET_SCHEDULER_NO_TASK;
@@ -699,7 +704,7 @@
     LOG (GNUNET_ERROR_TYPE_DEBUG, "Request pending, not processing queue\n");
     return;
   }
-  if (h->control_pending_head != NULL)
+  if (NULL != h->control_pending_head)
     msize =
         ntohs (((struct GNUNET_MessageHeader *) &h->
                 control_pending_head[1])->size);




reply via email to

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