/**
* @file util/server_nc.c
* @brief convenience functions for transmission of
- * a notification stream
+ * a notification stream
* @author Christian Grothoff
*/
#include "gnunet_server_lib.h"
#include "gnunet_time_lib.h"
+#define LOG(kind,...) GNUNET_log_from (kind, "util", __VA_ARGS__)
-#define DEBUG_SERVER_NC GNUNET_NO
+
+#define DEBUG_SERVER_NC GNUNET_EXTRA_LOGGING
/**
* Entry in list of messages pending to be transmitted.
struct ClientList *next;
/**
- * Overall context this client belongs to.
+ * Overall context this client belongs to.
*/
struct GNUNET_SERVER_NotificationContext *nc;
if (pos == NULL)
return;
#if DEBUG_SERVER_NC
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Client disconnected, cleaning up %u messages in NC queue\n",
- pos->num_pending);
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Client disconnected, cleaning up %u messages in NC queue\n",
+ pos->num_pending);
#endif
if (prev == NULL)
nc->clients = pos->next;
{
struct ClientList *cl;
+ for (cl = nc->clients; NULL != cl; cl = cl->next)
+ if (cl->client == client)
+ return; /* already present */
cl = GNUNET_malloc (sizeof (struct ClientList));
cl->next = nc->clients;
cl->nc = nc;
{
/* 'cl' should be freed via disconnect notification shortly */
#if DEBUG_SERVER_NC
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Failed to transmit message from NC queue to client\n");
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Failed to transmit message from NC queue to client\n");
#endif
return 0;
}
break;
GNUNET_CONTAINER_DLL_remove (cl->pending_head, cl->pending_tail, pml);
#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);
+ 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;
if (pml != NULL)
{
#if DEBUG_SERVER_NC
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Have %u messages left in NC queue, will try transmission again\n",
- cl->num_pending);
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Have %u messages left in NC queue, will try transmission again\n",
+ cl->num_pending);
#endif
cl->th =
GNUNET_SERVER_notify_transmit_ready (cl->client, ntohs (pml->msg->size),
if ((client->num_pending > nc->queue_length) && (GNUNET_YES == can_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);
+ 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)
pml->msg = (const struct GNUNET_MessageHeader *) &pml[1];
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);
+ 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 */