#include "gnunet_time_lib.h"
+#define DEBUG_SERVER_NC GNUNET_NO
+
/**
* Entry in list of messages pending to be transmitted.
*/
struct ClientList *prev;
struct PendingMessageList *pml;
+ if (client == NULL)
+ {
+ nc->server = NULL;
+ return;
+ }
prev = NULL;
pos = nc->clients;
while (NULL != pos)
GNUNET_free (pml);
}
GNUNET_SERVER_client_drop (client);
+ if (pos->th != NULL)
+ {
+ GNUNET_CONNECTION_notify_transmit_ready_cancel (pos->th);
+ pos->th = NULL;
+ }
GNUNET_free (pos);
}
while (NULL != (pos = nc->clients))
{
nc->clients = pos->next;
- GNUNET_SERVER_receive_done (pos->client, GNUNET_NO);
GNUNET_SERVER_client_drop (pos->client);
+ GNUNET_SERVER_receive_done (pos->client, GNUNET_NO);
while (NULL != (pml = pos->pending_head))
{
pos->pending_head = pml->next;
}
GNUNET_free (pos);
}
- GNUNET_SERVER_disconnect_notify_cancel (nc->server,
- &handle_client_disconnect,
- nc);
+ if (nc->server != NULL)
+ GNUNET_SERVER_disconnect_notify_cancel (nc->server,
+ &handle_client_disconnect,
+ nc);
GNUNET_free (nc);
}
while (cl->pending_head != NULL)
{
pml = cl->pending_head;
- cl->pending_head = pml->next;
- if (pml->next == NULL)
- cl->pending_tail = NULL;
msize = ntohs (pml->msg->size);
if (size < msize)
break;
+ cl->pending_head = pml->next;
+ if (pml->next == NULL)
+ cl->pending_tail = NULL;
+#if DEBUG_SERVER_NC
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Copying message of type %u and size %u from pending queue to transmission buffer\n",
+ ntohs (pml->msg->type),
+ msize);
+#endif
memcpy (&cbuf[ret], pml->msg, msize);
ret += msize;
size -= msize;
if ( (client->num_pending > nc->queue_length) &&
(GNUNET_YES == can_drop) )
- return; /* drop! */
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Dropping message of type %u and size %u due to full queue (%u entries)\n",
+ ntohs (msg->type),
+ ntohs (msg->size),
+ (unsigned int) nc->queue_length);
+ return; /* drop! */
+ }
if (client->num_pending > nc->queue_length)
{
/* FIXME: consider checking for other messages in the
size = ntohs (msg->size);
pml = GNUNET_malloc (sizeof (struct PendingMessageList) + size);
pml->msg = (const struct GNUNET_MessageHeader*) &pml[1];
- pml->can_drop = can_drop;
+ pml->can_drop = can_drop;
+#if DEBUG_SERVER_NC
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Adding message of type %u and size %u to pending queue (which has %u entries)\n",
+ ntohs (msg->type),
+ ntohs (msg->size),
+ (unsigned int) nc->queue_length);
+#endif
memcpy (&pml[1], msg, size);
/* append */
if (client->pending_tail != NULL)