add units to time, use configuration time api where appropriate, fixing Mantis #1875
[oweals/gnunet.git] / src / util / server_nc.c
index 7a26ab9bf7f374d0f7b5bbbf8dad4a25fc1b80f7..a36fa0c505a21d15881e56de2dd4e7929b01aabd 100644 (file)
 #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.
@@ -170,9 +172,9 @@ handle_client_disconnect (void *cls, struct GNUNET_SERVER_Client *client)
   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;
@@ -293,8 +295,8 @@ transmit_message (void *cls, size_t size, void *buf)
   {
     /* '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;
   }
@@ -306,9 +308,9 @@ transmit_message (void *cls, size_t size, void *buf)
       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;
@@ -319,9 +321,9 @@ transmit_message (void *cls, size_t size, void *buf)
   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),
@@ -352,10 +354,9 @@ do_unicast (struct GNUNET_SERVER_NotificationContext *nc,
 
   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)
@@ -369,10 +370,9 @@ do_unicast (struct GNUNET_SERVER_NotificationContext *nc,
   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 */