gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r21833 - gnunet/src/core
Date: Sat, 9 Jun 2012 22:01:13 +0200

Author: grothoff
Date: 2012-06-09 22:01:13 +0200 (Sat, 09 Jun 2012)
New Revision: 21833

Modified:
   gnunet/src/core/core_api.c
Log:
-code simplification

Modified: gnunet/src/core/core_api.c
===================================================================
--- gnunet/src/core/core_api.c  2012-06-09 19:49:32 UTC (rev 21832)
+++ gnunet/src/core/core_api.c  2012-06-09 20:01:13 UTC (rev 21833)
@@ -555,7 +555,7 @@
   }
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "Signalling timeout of request for transmission to CORE service\n");
-  request_next_transmission (pr);
+  trigger_next_request (h, GNUNET_NO);
   GNUNET_assert (0 == th->get_message (th->get_message_cls, 0, NULL));
 }
 
@@ -614,65 +614,63 @@
     return msize;
   }
   /* now check for 'ready' P2P messages */
-  if (NULL != (pr = h->ready_peer_head))
+  if (NULL == (pr = h->ready_peer_head))
+    return 0;
+  GNUNET_assert (NULL != pr->th.peer);
+  th = &pr->th;
+  if (size < th->msize + sizeof (struct SendMessage))
   {
-    GNUNET_assert (NULL != pr->th.peer);
-    th = &pr->th;
-    if (size < th->msize + sizeof (struct SendMessage))
-    {
-      trigger_next_request (h, GNUNET_NO);
-      return 0;
-    }
-    GNUNET_CONTAINER_DLL_remove (h->ready_peer_head, h->ready_peer_tail, pr);
-    th->peer = NULL;
-    if (pr->timeout_task != GNUNET_SCHEDULER_NO_TASK)
-    {
-      GNUNET_SCHEDULER_cancel (pr->timeout_task);
-      pr->timeout_task = GNUNET_SCHEDULER_NO_TASK;
-    }
+    trigger_next_request (h, GNUNET_NO);
+    return 0;
+  }
+  GNUNET_CONTAINER_DLL_remove (h->ready_peer_head, h->ready_peer_tail, pr);
+  th->peer = NULL;
+  if (pr->timeout_task != GNUNET_SCHEDULER_NO_TASK)
+  {
+    GNUNET_SCHEDULER_cancel (pr->timeout_task);
+    pr->timeout_task = GNUNET_SCHEDULER_NO_TASK;
+  }
+  LOG (GNUNET_ERROR_TYPE_DEBUG,
+       "Transmitting SEND request to `%s' with %u bytes.\n",
+       GNUNET_i2s (&pr->peer), (unsigned int) th->msize);
+  sm = (struct SendMessage *) buf;
+  sm->header.type = htons (GNUNET_MESSAGE_TYPE_CORE_SEND);
+  sm->priority = htonl (th->priority);
+  sm->deadline = GNUNET_TIME_absolute_hton (th->timeout);
+  sm->peer = pr->peer;
+  sm->cork = htonl ((uint32_t) th->cork);
+  sm->reserved = htonl (0);
+  ret =
+    th->get_message (th->get_message_cls,
+                    size - sizeof (struct SendMessage), &sm[1]);
+  
+  LOG (GNUNET_ERROR_TYPE_DEBUG,
+       "Transmitting SEND request to `%s' yielded %u bytes.\n",
+       GNUNET_i2s (&pr->peer), ret);
+  if (0 == ret)
+  {
     LOG (GNUNET_ERROR_TYPE_DEBUG,
-         "Transmitting SEND request to `%s' with %u bytes.\n",
-         GNUNET_i2s (&pr->peer), (unsigned int) th->msize);
-    sm = (struct SendMessage *) buf;
-    sm->header.type = htons (GNUNET_MESSAGE_TYPE_CORE_SEND);
-    sm->priority = htonl (th->priority);
-    sm->deadline = GNUNET_TIME_absolute_hton (th->timeout);
-    sm->peer = pr->peer;
-    sm->cork = htonl ((uint32_t) th->cork);
-    sm->reserved = htonl (0);
-    ret =
-        th->get_message (th->get_message_cls,
-                         size - sizeof (struct SendMessage), &sm[1]);
-
-    LOG (GNUNET_ERROR_TYPE_DEBUG,
-         "Transmitting SEND request to `%s' yielded %u bytes.\n",
-         GNUNET_i2s (&pr->peer), ret);
-    if (0 == ret)
-    {
-      LOG (GNUNET_ERROR_TYPE_DEBUG,
-           "Size of clients message to peer %s is 0!\n",
-           GNUNET_i2s (&pr->peer));
-      /* client decided to send nothing! */
-      request_next_transmission (pr);
-      return 0;
-    }
-    LOG (GNUNET_ERROR_TYPE_DEBUG,
-         "Produced SEND message to core with %u bytes payload\n",
-         (unsigned int) ret);
-    GNUNET_assert (ret >= sizeof (struct GNUNET_MessageHeader));
-    if (ret + sizeof (struct SendMessage) >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
-    {
-      GNUNET_break (0);
-      request_next_transmission (pr);
-      return 0;
-    }
-    ret += sizeof (struct SendMessage);
-    sm->header.size = htons (ret);
-    GNUNET_assert (ret <= size);
+        "Size of clients message to peer %s is 0!\n",
+        GNUNET_i2s (&pr->peer));
+    /* client decided to send nothing! */
     request_next_transmission (pr);
-    return ret;
+    return 0;
   }
-  return 0;
+  LOG (GNUNET_ERROR_TYPE_DEBUG,
+       "Produced SEND message to core with %u bytes payload\n",
+       (unsigned int) ret);
+  GNUNET_assert (ret >= sizeof (struct GNUNET_MessageHeader));
+  if (ret + sizeof (struct SendMessage) >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
+  {
+    GNUNET_break (0);
+    request_next_transmission (pr);
+    return 0;
+  }
+  ret += sizeof (struct SendMessage);
+  sm->header.size = htons (ret);
+  GNUNET_assert (ret <= size);
+  request_next_transmission (pr);
+  return ret;
 }
 
 
@@ -1295,7 +1293,7 @@
   if (NULL != pr->th.peer)
   {
     /* attempting to queue a second request for the same destination */
-    GNUNET_break (0);
+    GNUNET_assert (0);
     return NULL;
   }
   GNUNET_assert (notify_size + sizeof (struct SendMessage) <




reply via email to

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