gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r11582 - gnunet/src/core
Date: Tue, 1 Jun 2010 00:03:09 +0200

Author: grothoff
Date: 2010-06-01 00:03:09 +0200 (Tue, 01 Jun 2010)
New Revision: 11582

Modified:
   gnunet/src/core/core_api.c
Log:
logging and proper limiting of message size

Modified: gnunet/src/core/core_api.c
===================================================================
--- gnunet/src/core/core_api.c  2010-05-31 22:02:38 UTC (rev 11581)
+++ gnunet/src/core/core_api.c  2010-05-31 22:03:09 UTC (rev 11582)
@@ -25,6 +25,7 @@
  * @author Christian Grothoff
  */
 #include "platform.h"
+#include "gnunet_constants.h"
 #include "gnunet_core_service.h"
 #include "core.h"
 
@@ -250,6 +251,10 @@
 static void
 reconnect (struct GNUNET_CORE_Handle *h)
 {
+#if DEBUG_CORE
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+             "Reconnecting to CORE service\n");
+#endif
   if (h->client_notifications != NULL)
     GNUNET_CLIENT_disconnect (h->client_notifications, GNUNET_NO);
   h->currently_down = GNUNET_YES;
@@ -277,11 +282,16 @@
  * @param tc context, can be NULL (!)
  */
 static void
-timeout_request (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+timeout_request (void *cls, 
+                const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   struct GNUNET_CORE_TransmitHandle *th = cls;
 
   th->timeout_task = GNUNET_SCHEDULER_NO_TASK;
+#if DEBUG_CORE
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+             "Signalling timeout of request for transmission to CORE 
service\n");
+#endif
   GNUNET_assert (0 == th->get_message (th->get_message_cls, 0, NULL));
 }
 
@@ -317,6 +327,11 @@
   GNUNET_assert (size >= th->msize);
   ret = th->get_message (th->get_message_cls, size, buf);
   GNUNET_assert (ret <= size);
+#if DEBUG_CORE
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+             "Transmitting %u bytes to core\n",
+             ret);
+#endif
   return ret;
 }
 
@@ -798,11 +813,6 @@
       trigger_next_request (h);
       return 0;
     }
-#if DEBUG_CORE
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-             "Preparing for P2P transmission to `%4s'.\n",
-             GNUNET_i2s(&th->peer));
-#endif
   sm = (struct SendMessage *) buf;
   sm->header.type = htons (GNUNET_MESSAGE_TYPE_CORE_SEND);
   sm->priority = htonl (th->priority);
@@ -812,6 +822,8 @@
   notify_cls = th->notify_cls;
   GNUNET_CORE_notify_transmit_ready_cancel (th);
   trigger_next_request (h);
+  size = GNUNET_MIN (size,
+                    GNUNET_CONSTANTS_MAX_ENCRYPTED_MESSAGE_SIZE);
   GNUNET_assert (size >= sizeof (struct SendMessage));
   dt = notify (notify_cls, size - sizeof (struct SendMessage), &sm[1]);
   if (0 == dt)
@@ -824,12 +836,23 @@
       /* client decided to send nothing! */
       return 0;
     }
+#if DEBUG_CORE
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+             "Produced SEND message to core with %u bytes payload\n",
+             dt);
+#endif
   GNUNET_assert (dt >= sizeof (struct GNUNET_MessageHeader));
   if (dt + sizeof (struct SendMessage) >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
     {
       GNUNET_break (0);
       return 0;
     }
+#if DEBUG_CORE
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+             "Preparing for P2P transmission of %u bytes to `%4s'.\n",
+             dt,
+             GNUNET_i2s(&th->peer));
+#endif
   sm->header.size = htons (dt + sizeof (struct SendMessage));
   GNUNET_assert (dt + sizeof (struct SendMessage) <= size);
   return dt + sizeof (struct SendMessage);




reply via email to

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