aboutsummaryrefslogtreecommitdiff
path: root/src/util/server_nc.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2010-05-31 22:01:42 +0000
committerChristian Grothoff <christian@grothoff.org>2010-05-31 22:01:42 +0000
commit37e18e24a0be2ed99eb63108a9909121b96447a5 (patch)
treea3d520bb1778812fd783b7c4ce3d6b8351859d71 /src/util/server_nc.c
parentb80779dcac50d599d078b233ab323cbcc88e9218 (diff)
downloadgnunet-37e18e24a0be2ed99eb63108a9909121b96447a5.tar.gz
gnunet-37e18e24a0be2ed99eb63108a9909121b96447a5.zip
fixing bug with queue management in server nc -- and some additional debug messages
Diffstat (limited to 'src/util/server_nc.c')
-rw-r--r--src/util/server_nc.c32
1 files changed, 27 insertions, 5 deletions
diff --git a/src/util/server_nc.c b/src/util/server_nc.c
index 88de62c63..1cf3df8bd 100644
--- a/src/util/server_nc.c
+++ b/src/util/server_nc.c
@@ -33,6 +33,8 @@
33#include "gnunet_time_lib.h" 33#include "gnunet_time_lib.h"
34 34
35 35
36#define DEBUG_SERVER_NC GNUNET_NO
37
36/** 38/**
37 * Entry in list of messages pending to be transmitted. 39 * Entry in list of messages pending to be transmitted.
38 */ 40 */
@@ -289,12 +291,18 @@ transmit_message (void *cls,
289 while (cl->pending_head != NULL) 291 while (cl->pending_head != NULL)
290 { 292 {
291 pml = cl->pending_head; 293 pml = cl->pending_head;
292 cl->pending_head = pml->next;
293 if (pml->next == NULL)
294 cl->pending_tail = NULL;
295 msize = ntohs (pml->msg->size); 294 msize = ntohs (pml->msg->size);
296 if (size < msize) 295 if (size < msize)
297 break; 296 break;
297 cl->pending_head = pml->next;
298 if (pml->next == NULL)
299 cl->pending_tail = NULL;
300#if DEBUG_SERVER_NC
301 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
302 "Copying message of type %u and size %u from pending queue to transmission buffer\n",
303 ntohs (pml->msg->type),
304 msize);
305#endif
298 memcpy (&cbuf[ret], pml->msg, msize); 306 memcpy (&cbuf[ret], pml->msg, msize);
299 ret += msize; 307 ret += msize;
300 size -= msize; 308 size -= msize;
@@ -330,7 +338,14 @@ do_unicast (struct GNUNET_SERVER_NotificationContext *nc,
330 338
331 if ( (client->num_pending > nc->queue_length) && 339 if ( (client->num_pending > nc->queue_length) &&
332 (GNUNET_YES == can_drop) ) 340 (GNUNET_YES == can_drop) )
333 return; /* drop! */ 341 {
342 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
343 "Dropping message of type %u and size %u due to full queue (%u entries)\n",
344 ntohs (msg->type),
345 ntohs (msg->size),
346 (unsigned int) nc->queue_length);
347 return; /* drop! */
348 }
334 if (client->num_pending > nc->queue_length) 349 if (client->num_pending > nc->queue_length)
335 { 350 {
336 /* FIXME: consider checking for other messages in the 351 /* FIXME: consider checking for other messages in the
@@ -340,7 +355,14 @@ do_unicast (struct GNUNET_SERVER_NotificationContext *nc,
340 size = ntohs (msg->size); 355 size = ntohs (msg->size);
341 pml = GNUNET_malloc (sizeof (struct PendingMessageList) + size); 356 pml = GNUNET_malloc (sizeof (struct PendingMessageList) + size);
342 pml->msg = (const struct GNUNET_MessageHeader*) &pml[1]; 357 pml->msg = (const struct GNUNET_MessageHeader*) &pml[1];
343 pml->can_drop = can_drop; 358 pml->can_drop = can_drop;
359#if DEBUG_SERVER_NC
360 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
361 "Adding message of type %u and size %u to pending queue (which has %u entries)\n",
362 ntohs (msg->type),
363 ntohs (msg->size),
364 (unsigned int) nc->queue_length);
365#endif
344 memcpy (&pml[1], msg, size); 366 memcpy (&pml[1], msg, size);
345 /* append */ 367 /* append */
346 if (client->pending_tail != NULL) 368 if (client->pending_tail != NULL)