-some more #if DEBUG elimination
authorChristian Grothoff <christian@grothoff.org>
Sun, 26 Feb 2012 14:21:49 +0000 (14:21 +0000)
committerChristian Grothoff <christian@grothoff.org>
Sun, 26 Feb 2012 14:21:49 +0000 (14:21 +0000)
src/util/bandwidth.c
src/util/connection.c
src/util/network.c
src/util/scheduler.c

index 0920362f5a529c0cda8f1da732aa738f863656b4..9d679493ae05fd6274c88c1a6c34b614bfccd04c 100644 (file)
@@ -27,9 +27,8 @@
 #include "gnunet_bandwidth_lib.h"
 #include "gnunet_server_lib.h"
 
-#define DEBUG_BANDWIDTH GNUNET_EXTRA_LOGGING
 
-#define LOG(kind,...) GNUNET_log_from (kind, "util",__VA_ARGS__)
+#define LOG(kind,...) GNUNET_log_from (kind, "util-bandwidth", __VA_ARGS__)
 
 /**
  * Create a new bandwidth value.
@@ -42,10 +41,8 @@ GNUNET_BANDWIDTH_value_init (uint32_t bytes_per_second)
 {
   struct GNUNET_BANDWIDTH_Value32NBO ret;
 
-#if DEBUG_BANDWIDTH
   LOG (GNUNET_ERROR_TYPE_DEBUG, "Initializing bandwidth of %u Bps\n",
        (unsigned int) bytes_per_second);
-#endif
   ret.value__ = htonl (bytes_per_second);
   return ret;
 }
@@ -85,12 +82,10 @@ GNUNET_BANDWIDTH_value_get_available_until (struct GNUNET_BANDWIDTH_Value32NBO
   uint64_t b;
 
   b = ntohl (bps.value__);
-#if DEBUG_BANDWIDTH
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "Bandwidth has %llu bytes available until deadline in %llums\n",
        (unsigned long long) ((b * deadline.rel_value + 500LL) / 1000LL),
        deadline.rel_value);
-#endif
   return (b * deadline.rel_value + 500LL) / 1000LL;
 }
 
@@ -113,18 +108,14 @@ GNUNET_BANDWIDTH_value_get_delay_for (struct GNUNET_BANDWIDTH_Value32NBO bps,
   b = ntohl (bps.value__);
   if (b == 0)
   {
-#if DEBUG_BANDWIDTH
     LOG (GNUNET_ERROR_TYPE_DEBUG,
          "Bandwidth suggests delay of infinity (zero bandwidth)\n");
-#endif
     return GNUNET_TIME_UNIT_FOREVER_REL;
   }
   ret.rel_value = size * 1000LL / b;
-#if DEBUG_BANDWIDTH
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "Bandwidth suggests delay of %llu ms for %llu bytes of traffic\n",
        (unsigned long long) ret.rel_value, (unsigned long long) size);
-#endif
   return ret;
 }
 
@@ -152,11 +143,9 @@ GNUNET_BANDWIDTH_tracker_init (struct GNUNET_BANDWIDTH_Tracker *av,
   av->last_update__ = GNUNET_TIME_absolute_get ();
   av->available_bytes_per_s__ = ntohl (bytes_per_second_limit.value__);
   av->max_carry_s__ = max_carry_s;
-#if DEBUG_BANDWIDTH
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "Tracker %p initialized with %u Bps and max carry %u\n", av,
        (unsigned int) av->available_bytes_per_s__, (unsigned int) max_carry_s);
-#endif
 }
 
 
@@ -193,13 +182,10 @@ update_tracker (struct GNUNET_BANDWIDTH_Tracker *av)
     else
       av->consumption_since_last_update__ = -max_carry;
   }
-#if DEBUG_BANDWIDTH
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "Tracker %p  updated, have %u Bps, last update was %llu ms ago\n", av,
        (unsigned int) av->available_bytes_per_s__,
        (unsigned long long) delta_time);
-#endif
-
 }
 
 
@@ -220,10 +206,8 @@ GNUNET_BANDWIDTH_tracker_consume (struct GNUNET_BANDWIDTH_Tracker *av,
 {
   int64_t nc;
 
-#if DEBUG_BANDWIDTH
   LOG (GNUNET_ERROR_TYPE_DEBUG, "Tracker %p consumes %d bytes\n", av,
        (int) size);
-#endif
   if (size > 0)
   {
     nc = av->consumption_since_last_update__ + size;
@@ -236,11 +220,9 @@ GNUNET_BANDWIDTH_tracker_consume (struct GNUNET_BANDWIDTH_Tracker *av,
     update_tracker (av);
     if (av->consumption_since_last_update__ > 0)
     {
-#if DEBUG_BANDWIDTH
       LOG (GNUNET_ERROR_TYPE_DEBUG,
            "Tracker %p consumption %llu bytes above limit\n", av,
            (unsigned long long) av->consumption_since_last_update__);
-#endif
       return GNUNET_YES;
     }
   }
@@ -270,28 +252,22 @@ GNUNET_BANDWIDTH_tracker_get_delay (struct GNUNET_BANDWIDTH_Tracker *av,
 
   if (av->available_bytes_per_s__ == 0)
   {
-#if DEBUG_BANDWIDTH
     LOG (GNUNET_ERROR_TYPE_DEBUG, "Tracker %p delay is infinity\n", av);
-#endif
     return GNUNET_TIME_UNIT_FOREVER_REL;
   }
   update_tracker (av);
   bytes_needed = size + av->consumption_since_last_update__;
   if (bytes_needed <= 0)
   {
-#if DEBUG_BANDWIDTH
     LOG (GNUNET_ERROR_TYPE_DEBUG, "Tracker %p delay for %u bytes is zero\n", av,
          (unsigned int) size);
-#endif
     return GNUNET_TIME_UNIT_ZERO;
   }
   ret.rel_value =
       (1000LL * bytes_needed) /
       (unsigned long long) av->available_bytes_per_s__;
-#if DEBUG_BANDWIDTH
   LOG (GNUNET_ERROR_TYPE_DEBUG, "Tracker %p delay for %u bytes is %llu ms\n",
        av, (unsigned int) size, (unsigned long long) ret.rel_value);
-#endif
   return ret;
 }
 
@@ -317,11 +293,9 @@ GNUNET_BANDWIDTH_tracker_get_available (struct GNUNET_BANDWIDTH_Tracker * av)
                                                   GNUNET_TIME_absolute_get_duration
                                                   (av->last_update__));
   used = av->consumption_since_last_update__;
-#if DEBUG_BANDWIDTH
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "Tracker %p  available bandwidth is %lld bytes\n", av,
        (long long) (int64_t) (avail - used));
-#endif
   return (int64_t) (avail - used);
 }
 
@@ -341,10 +315,8 @@ GNUNET_BANDWIDTH_tracker_update_quota (struct GNUNET_BANDWIDTH_Tracker *av,
   uint32_t new_limit;
 
   new_limit = ntohl (bytes_per_second_limit.value__);
-#if DEBUG_BANDWIDTH
   LOG (GNUNET_ERROR_TYPE_DEBUG, "Tracker %p bandwidth changed to %u Bps\n", av,
        (unsigned int) new_limit);
-#endif
   update_tracker (av);
   old_limit = av->available_bytes_per_s__;
   av->available_bytes_per_s__ = new_limit;
index 61c26673be681dcddcb96421b68edceb24078b3a..8224479f9b655c6b4d18960c4aa868316dcf8439 100644 (file)
@@ -39,7 +39,6 @@
 #include "gnunet_scheduler_lib.h"
 #include "gnunet_server_lib.h"
 
-#define DEBUG_CONNECTION GNUNET_EXTRA_LOGGING
 
 #define LOG(kind,...) GNUNET_log_from (kind, "util", __VA_ARGS__)
 
@@ -472,10 +471,9 @@ GNUNET_CONNECTION_create_from_accept (GNUNET_CONNECTION_AccessCheck access,
   ret->addr = uaddr;
   ret->addrlen = addrlen;
   ret->sock = sock;
-#if DEBUG_CONNECTION
-  LOG (GNUNET_ERROR_TYPE_INFO, _("Accepting connection from `%s': %p\n"),
+  LOG (GNUNET_ERROR_TYPE_INFO, 
+       _("Accepting connection from `%s': %p\n"),
        GNUNET_a2s (uaddr, addrlen), ret);
-#endif
   return ret;
 }
 
@@ -532,19 +530,15 @@ destroy_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   GNUNET_assert (sock->dns_active == NULL);
   if (0 != (sock->ccs & COCO_TRANSMIT_READY))
   {
-#if DEBUG_CONNECTION
     LOG (GNUNET_ERROR_TYPE_DEBUG, "Destroy waits for CCS-TR to be done (%p)\n",
          sock);
-#endif
     sock->ccs |= COCO_DESTROY_CONTINUATION;
     return;
   }
   if (sock->write_task != GNUNET_SCHEDULER_NO_TASK)
   {
-#if DEBUG_CONNECTION
     LOG (GNUNET_ERROR_TYPE_DEBUG,
          "Destroy waits for write_task to be done (%p)\n", sock);
-#endif
     GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == sock->destroy_task);
     sock->destroy_task =
         GNUNET_SCHEDULER_add_after (sock->write_task, &destroy_continuation,
@@ -558,9 +552,7 @@ destroy_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   }
   if (sock->sock != NULL)
   {
-#if DEBUG_CONNECTION
     LOG (GNUNET_ERROR_TYPE_DEBUG, "Shutting down socket (%p)\n", sock);
-#endif
     if (sock->persist != GNUNET_YES)
     {
       if ((GNUNET_YES != GNUNET_NETWORK_socket_shutdown (sock->sock, SHUT_RDWR))
@@ -576,9 +568,7 @@ destroy_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
                                     sock);
     return;
   }
-#if DEBUG_CONNECTION
   LOG (GNUNET_ERROR_TYPE_DEBUG, "Destroy actually runs (%p)!\n", sock);
-#endif
   while (NULL != (pos = sock->ap_head))
   {
     GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (pos->sock));
@@ -605,9 +595,7 @@ destroy_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   GNUNET_free_non_null (sock->addr);
   GNUNET_free_non_null (sock->hostname);
   GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == sock->destroy_task);
-#if DEBUG_CONNECTION
   LOG (GNUNET_ERROR_TYPE_DEBUG, "Freeing memory of connection %p.\n", sock);
-#endif
   GNUNET_free (sock->write_buffer);
   GNUNET_free (sock);
 }
@@ -634,14 +622,12 @@ transmit_ready (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
 static void
 connect_fail_continuation (struct GNUNET_CONNECTION_Handle *h)
 {
-#if DEBUG_CONNECTION
   LOG ((0 !=
         strncmp (h->hostname, "localhost:",
                  10)) ? GNUNET_ERROR_TYPE_INFO : GNUNET_ERROR_TYPE_WARNING,
        _
        ("Failed to establish TCP connection to `%s:%u', no further addresses to try.\n"),
        h->hostname, h->port);
-#endif
   /* connect failed / timed out */
   GNUNET_break (h->ap_head == NULL);
   GNUNET_break (h->ap_tail == NULL);
@@ -651,20 +637,16 @@ connect_fail_continuation (struct GNUNET_CONNECTION_Handle *h)
   /* trigger jobs that used to wait on "connect_task" */
   if (0 != (h->ccs & COCO_RECEIVE_AGAIN))
   {
-#if DEBUG_CONNECTION
     LOG (GNUNET_ERROR_TYPE_DEBUG,
          "connect_fail_continuation triggers receive_again (%p)\n", h);
-#endif
     h->ccs -= COCO_RECEIVE_AGAIN;
     h->read_task = GNUNET_SCHEDULER_add_now (&receive_again, h);
   }
   if (0 != (h->ccs & COCO_TRANSMIT_READY))
   {
-#if DEBUG_CONNECTION
     LOG (GNUNET_ERROR_TYPE_DEBUG,
          "connect_fail_continuation cancels timeout_task, triggers transmit_ready (%p)\n",
          h);
-#endif
     GNUNET_assert (h->nth.timeout_task != GNUNET_SCHEDULER_NO_TASK);
     GNUNET_SCHEDULER_cancel (h->nth.timeout_task);
     h->nth.timeout_task = GNUNET_SCHEDULER_NO_TASK;
@@ -675,10 +657,8 @@ connect_fail_continuation (struct GNUNET_CONNECTION_Handle *h)
   }
   if (0 != (h->ccs & COCO_DESTROY_CONTINUATION))
   {
-#if DEBUG_CONNECTION
     LOG (GNUNET_ERROR_TYPE_DEBUG,
          "connect_fail_continuation runs destroy_continuation (%p)\n", h);
-#endif
     h->ccs -= COCO_DESTROY_CONTINUATION;
     GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == h->destroy_task);
     h->destroy_task = GNUNET_SCHEDULER_add_now (&destroy_continuation, h);
@@ -694,27 +674,21 @@ connect_fail_continuation (struct GNUNET_CONNECTION_Handle *h)
 static void
 connect_success_continuation (struct GNUNET_CONNECTION_Handle *h)
 {
-#if DEBUG_CONNECTION
   LOG (GNUNET_ERROR_TYPE_DEBUG, "Connection to `%s' succeeded! (%p)\n",
        GNUNET_a2s (h->addr, h->addrlen), h);
-#endif
   /* trigger jobs that waited for the connection */
   if (0 != (h->ccs & COCO_RECEIVE_AGAIN))
   {
-#if DEBUG_CONNECTION
     LOG (GNUNET_ERROR_TYPE_DEBUG,
          "connect_success_continuation runs receive_again (%p)\n", h);
-#endif
     h->ccs -= COCO_RECEIVE_AGAIN;
     h->read_task = GNUNET_SCHEDULER_add_now (&receive_again, h);
   }
   if (0 != (h->ccs & COCO_TRANSMIT_READY))
   {
-#if DEBUG_CONNECTION
     LOG (GNUNET_ERROR_TYPE_DEBUG,
          "connect_success_continuation runs transmit_ready, cancels timeout_task (%p)\n",
          h);
-#endif
     GNUNET_assert (h->nth.timeout_task != GNUNET_SCHEDULER_NO_TASK);
     GNUNET_SCHEDULER_cancel (h->nth.timeout_task);
     h->nth.timeout_task = GNUNET_SCHEDULER_NO_TASK;
@@ -728,10 +702,8 @@ connect_success_continuation (struct GNUNET_CONNECTION_Handle *h)
   }
   if (0 != (h->ccs & COCO_DESTROY_CONTINUATION))
   {
-#if DEBUG_CONNECTION
     LOG (GNUNET_ERROR_TYPE_DEBUG,
          "connect_success_continuation runs destroy_continuation (%p)\n", h);
-#endif
     h->ccs -= COCO_DESTROY_CONTINUATION;
     GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == h->destroy_task);
     h->destroy_task = GNUNET_SCHEDULER_add_now (&destroy_continuation, h);
@@ -818,11 +790,9 @@ try_connect_using_address (void *cls, const struct sockaddr *addr,
     return;                     /* already connected */
   GNUNET_assert (h->addr == NULL);
   /* try to connect */
-#if DEBUG_CONNECTION
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "Trying to connect using address `%s:%u/%s:%u'\n", h->hostname, h->port,
        GNUNET_a2s (addr, addrlen), h->port);
-#endif
   ap = GNUNET_malloc (sizeof (struct AddressProbe) + addrlen);
   ap->addr = (const struct sockaddr *) &ap[1];
   memcpy (&ap[1], addr, addrlen);
@@ -848,10 +818,8 @@ try_connect_using_address (void *cls, const struct sockaddr *addr,
     GNUNET_free (ap);
     return;                     /* not supported by OS */
   }
-#if DEBUG_CONNECTION
   LOG (GNUNET_ERROR_TYPE_INFO, _("Trying to connect to `%s' (%p)\n"),
        GNUNET_a2s (ap->addr, ap->addrlen), h);
-#endif
   if ((GNUNET_OK !=
        GNUNET_NETWORK_socket_connect (ap->sock, ap->addr, ap->addrlen)) &&
       (errno != EINPROGRESS))
@@ -1021,10 +989,8 @@ GNUNET_CONNECTION_create_from_sockaddr (int af_family,
   ret->addr = GNUNET_malloc (addrlen);
   memcpy (ret->addr, serv_addr, addrlen);
   ret->addrlen = addrlen;
-#if DEBUG_CONNECTION
   LOG (GNUNET_ERROR_TYPE_INFO, _("Trying to connect to `%s' (%p)\n"),
        GNUNET_a2s (serv_addr, addrlen), ret);
-#endif
   return ret;
 }
 
@@ -1092,10 +1058,8 @@ signal_timeout (struct GNUNET_CONNECTION_Handle *sh)
 {
   GNUNET_CONNECTION_Receiver receiver;
 
-#if DEBUG_CONNECTION
   LOG (GNUNET_ERROR_TYPE_DEBUG, "Network signals time out to receiver (%p)!\n",
        sh);
-#endif
   GNUNET_assert (NULL != (receiver = sh->receiver));
   sh->receiver = NULL;
   receiver (sh->receiver_cls, NULL, 0, NULL, 0, 0);
@@ -1134,10 +1098,8 @@ receive_ready (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
       (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)))
   {
     /* ignore shutdown request, go again immediately */
-#if DEBUG_CONNECTION
     LOG (GNUNET_ERROR_TYPE_DEBUG,
          "Ignoring shutdown signal per configuration\n");
-#endif
     sh->read_task =
         GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_absolute_get_remaining
                                        (sh->receive_timeout), sh->sock,
@@ -1149,24 +1111,20 @@ receive_ready (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
       (0 != (tc->reason & GNUNET_SCHEDULER_REASON_TIMEOUT)) ||
       (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)))
   {
-#if DEBUG_CONNECTION
     if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
       LOG (GNUNET_ERROR_TYPE_DEBUG,
            "Receive from `%s' encounters error: time out by %llums... (%p)\n",
            GNUNET_a2s (sh->addr, sh->addrlen),
            GNUNET_TIME_absolute_get_duration (sh->receive_timeout).rel_value,
            sh);
-#endif
     signal_timeout (sh);
     return;
   }
   if (sh->sock == NULL)
   {
     /* connect failed for good */
-#if DEBUG_CONNECTION
     LOG (GNUNET_ERROR_TYPE_DEBUG,
          "Receive encounters error, socket closed... (%p)\n", sh);
-#endif
     signal_error (sh, ECONNREFUSED);
     return;
   }
@@ -1177,17 +1135,13 @@ RETRY:
   {
     if (errno == EINTR)
       goto RETRY;
-#if DEBUG_CONNECTION
     LOG (GNUNET_ERROR_TYPE_DEBUG, "Error receiving: %s\n", STRERROR (errno));
-#endif
     signal_error (sh, errno);
     return;
   }
-#if DEBUG_CONNECTION
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "receive_ready read %u/%u bytes from `%s' (%p)!\n", (unsigned int) ret,
        sh->max, GNUNET_a2s (sh->addr, sh->addrlen), sh);
-#endif
   GNUNET_assert (NULL != (receiver = sh->receiver));
   sh->receiver = NULL;
   receiver (sh->receiver_cls, buffer, ret, sh->addr, sh->addrlen, 0);
@@ -1214,10 +1168,8 @@ receive_again (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   if (sh->sock == NULL)
   {
     /* not connected and no longer trying */
-#if DEBUG_CONNECTION
     LOG (GNUNET_ERROR_TYPE_DEBUG,
          "Receive encounters error, socket closed (%p)...\n", sh);
-#endif
     signal_error (sh, ECONNREFUSED);
     return;
   }
@@ -1225,10 +1177,8 @@ receive_again (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   if ((now.abs_value > sh->receive_timeout.abs_value) ||
       (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)))
   {
-#if DEBUG_CONNECTION
     LOG (GNUNET_ERROR_TYPE_DEBUG,
          "Receive encounters error: time out (%p)...\n", sh);
-#endif
     signal_timeout (sh);
     return;
   }
@@ -1385,15 +1335,11 @@ transmit_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   struct GNUNET_CONNECTION_Handle *sock = cls;
   GNUNET_CONNECTION_TransmitReadyNotify notify;
 
-#if DEBUG_CONNECTION
-  LOG (GNUNET_ERROR_TYPE_DEBUG, "transmit_timeout running (%p)\n", sock);
-#endif
   sock->nth.timeout_task = GNUNET_SCHEDULER_NO_TASK;
-#if DEBUG_CONNECTION
   LOG (GNUNET_ERROR_TYPE_DEBUG,
-       "Transmit to `%s:%u/%s' fails, time out reached (%p).\n", sock->hostname,
+       "Transmit to `%s:%u/%s' fails, time out reached (%p).\n",
+       sock->hostname,
        sock->port, GNUNET_a2s (sock->addr, sock->addrlen), sock);
-#endif
   GNUNET_assert (0 != (sock->ccs & COCO_TRANSMIT_READY));
   sock->ccs -= COCO_TRANSMIT_READY;     /* remove request */
   notify = sock->nth.notify_ready;
@@ -1417,11 +1363,9 @@ connect_error (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   struct GNUNET_CONNECTION_Handle *sock = cls;
   GNUNET_CONNECTION_TransmitReadyNotify notify;
 
-#if DEBUG_CONNECTION
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "Transmission request of size %u fails (%s/%u), connection failed (%p).\n",
        sock->nth.notify_size, sock->hostname, sock->port, sock);
-#endif
   sock->write_task = GNUNET_SCHEDULER_NO_TASK;
   notify = sock->nth.notify_ready;
   sock->nth.notify_ready = NULL;
@@ -1476,9 +1420,7 @@ transmit_ready (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   ssize_t ret;
   size_t have;
 
-#if DEBUG_CONNECTION
   LOG (GNUNET_ERROR_TYPE_DEBUG, "transmit_ready running (%p).\n", sock);
-#endif
   GNUNET_assert (sock->write_task != GNUNET_SCHEDULER_NO_TASK);
   sock->write_task = GNUNET_SCHEDULER_NO_TASK;
   GNUNET_assert (sock->nth.timeout_task == GNUNET_SCHEDULER_NO_TASK);
@@ -1486,11 +1428,9 @@ transmit_ready (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   {
     if ((sock->ignore_shutdown == GNUNET_YES) && (NULL != sock->sock))
       goto SCHEDULE_WRITE;      /* ignore shutdown, go again immediately */
-#if DEBUG_CONNECTION
     LOG (GNUNET_ERROR_TYPE_DEBUG,
          "Transmit to `%s' fails, shutdown happened (%p).\n",
          GNUNET_a2s (sock->addr, sock->addrlen), sock);
-#endif
     notify = sock->nth.notify_ready;
     if (NULL != notify)
     {
@@ -1501,11 +1441,9 @@ transmit_ready (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   }
   if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_TIMEOUT))
   {
-#if DEBUG_CONNECTION
     LOG (GNUNET_ERROR_TYPE_DEBUG,
          "Transmit to `%s' fails, time out reached (%p).\n",
          GNUNET_a2s (sock->addr, sock->addrlen), sock);
-#endif
     notify = sock->nth.notify_ready;
     GNUNET_assert (NULL != notify);
     sock->nth.notify_ready = NULL;
@@ -1522,12 +1460,10 @@ transmit_ready (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   }
   if (!GNUNET_NETWORK_fdset_isset (tc->write_ready, sock->sock))
   {
-#if DEBUG_CONNECTION
     LOG (GNUNET_ERROR_TYPE_INFO,
          _
          ("Could not satisfy pending transmission request, socket closed or connect failed (%p).\n"),
          sock);
-#endif
     transmit_error (sock);
     return;                     /* connect failed for good, we're finished */
   }
@@ -1558,23 +1494,13 @@ RETRY:
   {
     if (errno == EINTR)
       goto RETRY;
-#if 0
-    int en = errno;
-
-    LOG (GNUNET_ERROR_TYPE_ERROR, _("Failed to send to `%s': %s\n"),
-         GNUNET_a2s (sock->addr, sock->addrlen), STRERROR (en));
-#endif
-#if DEBUG_CONNECTION
     LOG_STRERROR (GNUNET_ERROR_TYPE_DEBUG, "send");
-#endif
     transmit_error (sock);
     return;
   }
-#if DEBUG_CONNECTION
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "transmit_ready transmitted %u/%u bytes to `%s' (%p)\n",
        (unsigned int) ret, have, GNUNET_a2s (sock->addr, sock->addrlen), sock);
-#endif
   sock->write_buffer_pos += ret;
   if (sock->write_buffer_pos == sock->write_buffer_off)
   {
@@ -1586,10 +1512,8 @@ RETRY:
     return;                     /* all data sent! */
   /* not done writing, schedule more */
 SCHEDULE_WRITE:
-#if DEBUG_CONNECTION
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "Re-scheduling transmit_ready (more to do) (%p).\n", sock);
-#endif
   have = sock->write_buffer_off - sock->write_buffer_pos;
   GNUNET_assert ((sock->nth.notify_ready != NULL) || (have > 0));
   if (sock->write_task == GNUNET_SCHEDULER_NO_TASK)
@@ -1651,9 +1575,7 @@ GNUNET_CONNECTION_notify_transmit_ready (struct GNUNET_CONNECTION_Handle *sock,
     return &sock->nth;
   if (sock->sock != NULL)
   {
-#if DEBUG_CONNECTION
     LOG (GNUNET_ERROR_TYPE_DEBUG, "Scheduling transmit_ready (%p).\n", sock);
-#endif
     sock->write_task =
         GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_absolute_get_remaining
                                         (sock->nth.transmit_timeout),
@@ -1661,10 +1583,8 @@ GNUNET_CONNECTION_notify_transmit_ready (struct GNUNET_CONNECTION_Handle *sock,
   }
   else
   {
-#if DEBUG_CONNECTION
     LOG (GNUNET_ERROR_TYPE_DEBUG,
          "CCS-Scheduling transmit_ready, adding timeout task (%p).\n", sock);
-#endif
     sock->ccs |= COCO_TRANSMIT_READY;
     sock->nth.timeout_task =
         GNUNET_SCHEDULER_add_delayed (timeout, &transmit_timeout, sock);
@@ -1686,10 +1606,8 @@ GNUNET_CONNECTION_notify_transmit_ready_cancel (struct
   GNUNET_assert (th->notify_ready != NULL);
   if (0 != (th->sh->ccs & COCO_TRANSMIT_READY))
   {
-#if DEBUG_CONNECTION
     LOG (GNUNET_ERROR_TYPE_DEBUG,
          "notify_transmit_ready_cancel cancels timeout_task (%p)\n", th);
-#endif
     GNUNET_SCHEDULER_cancel (th->timeout_task);
     th->timeout_task = GNUNET_SCHEDULER_NO_TASK;
     th->sh->ccs -= COCO_TRANSMIT_READY;
index fb8744af186aa4662ae14cc1c724ec7035b54e4f..e530ab7432b5e359d9717b41b0695bade24fd697 100644 (file)
@@ -35,7 +35,6 @@
 
 #define DEBUG_NETWORK GNUNET_EXTRA_LOGGING
 
-#define DEBUG_W32_CYCLES GNUNET_EXTRA_LOGGING
 
 #ifndef INVALID_SOCKET
 #define INVALID_SOCKET -1
@@ -46,7 +45,6 @@ struct GNUNET_NETWORK_Handle
 {
 #ifndef MINGW
   int fd;
-
 #else
   SOCKET fd;
 #endif
@@ -337,19 +335,13 @@ GNUNET_NETWORK_socket_close (struct GNUNET_NETWORK_Handle *desc)
 #ifdef MINGW
   DWORD error = 0;
 
-#if DEBUG_NETWORK
-  LOG (GNUNET_ERROR_TYPE_DEBUG, "Closing 0x%x\n",
-       desc->fd);
-#endif
   SetLastError (0);
   ret = closesocket (desc->fd);
   error = WSAGetLastError ();
   SetErrnoFromWinsockError (error);
-#if DEBUG_NETWORK
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "Closed 0x%x, closesocket() returned %d, GLE is %u\n", desc->fd, ret,
        error);
-#endif
 #else
   ret = close (desc->fd);
 #endif
@@ -1301,40 +1293,32 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds,
       if (fh->type == GNUNET_PIPE)
       {
         /* Read zero bytes to check the status of the pipe */
-#if DEBUG_NETWORK
         LOG (GNUNET_ERROR_TYPE_DEBUG, "Reading 0 bytes from the pipe 0x%x\n",
              fh->h);
-#endif
         if (!ReadFile (fh->h, NULL, 0, NULL, fh->oOverlapRead))
         {
           DWORD error_code = GetLastError ();
 
           if (error_code == ERROR_IO_PENDING)
           {
-#if DEBUG_NETWORK
             LOG (GNUNET_ERROR_TYPE_DEBUG,
                  "Adding the pipe's 0x%x overlapped event to the array as %d\n",
                  fh->h, nhandles);
-#endif
             handle_array[nhandles++] = fh->oOverlapRead->hEvent;
             readArray[readPipes++] = fh;
           }
           else
           {
-#if DEBUG_NETWORK
             LOG (GNUNET_ERROR_TYPE_DEBUG,
                  "Read failed, adding the read ready event to the array as %d\n", nhandles);
-#endif
             handle_array[nhandles++] = hEventReadReady;
             readArray[readPipes++] = fh;
           }
         }
         else
         {
-#if DEBUG_NETWORK
           LOG (GNUNET_ERROR_TYPE_DEBUG,
                "Adding the read ready event to the array as %d\n", nhandles);
-#endif
           handle_array[nhandles++] = hEventReadReady;
           readArray[readPipes++] = fh;
         }
@@ -1349,10 +1333,8 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds,
   }
   if (wfds && write_handles)
   {
-#if DEBUG_NETWORK
     LOG (GNUNET_ERROR_TYPE_DEBUG,
          "Adding the write ready event to the array as %d\n", nhandles);
-#endif
     handle_array[nhandles++] = hEventPipeWrite;
     writePipePos = nhandles;
   }
@@ -1386,10 +1368,8 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds,
   {
     if (rfds)
     {
-#if DEBUG_NETWORK
       LOG (GNUNET_ERROR_TYPE_DEBUG,
            "Adding the socket read event to the array as %d\n", nhandles);
-#endif
       handle_array[nhandles++] = hEventRead;
       nSockEvents++;
       for (i = 0; i < rfds->sds.fd_count; i++)
@@ -1403,10 +1383,8 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds,
     {
       int wakeup = 0;
 
-#if DEBUG_NETWORK
       LOG (GNUNET_ERROR_TYPE_DEBUG,
            "Adding the socket write event to the array as %d\n", nhandles);
-#endif
       handle_array[nhandles++] = hEventWrite;
       nSockEvents++;
       for (i = 0; i < wfds->sds.fd_count; i++)
@@ -1416,10 +1394,8 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds,
 
         status = send (wfds->sds.fd_array[i], NULL, 0, 0);
         error = GetLastError ();
-#if DEBUG_NETWORK
         LOG (GNUNET_ERROR_TYPE_DEBUG,
              "pre-send to the socket %d returned %d (%u)\n", i, status, error);
-#endif
         if (status == 0 || (error != WSAEWOULDBLOCK && error != WSAENOTCONN))
           wakeup = 1;
         WSAEventSelect (wfds->sds.fd_array[i], hEventWrite,
@@ -1431,10 +1407,8 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds,
     }
     if (efds)
     {
-#if DEBUG_NETWORK
       LOG (GNUNET_ERROR_TYPE_DEBUG,
            "Adding the socket error event to the array as %d\n", nhandles);
-#endif
       handle_array[nhandles++] = hEventException;
       nSockEvents++;
       for (i = 0; i < efds->sds.fd_count; i++)
@@ -1464,9 +1438,7 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds,
 #endif
 
   returnedpos = returncode - WAIT_OBJECT_0;
-#if DEBUG_NETWORK
   LOG (GNUNET_ERROR_TYPE_DEBUG, "return pos is : %d\n", returnedpos);
-#endif
 
   /* FIXME: THIS LINE IS WRONG !! We should add to handles only handles that fired the events, not all ! */
   /*
@@ -1487,22 +1459,16 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds,
       retcode = select (nfds, &aread, &awrite, &aexcept, &tvslice);
       if (retcode == -1)
         retcode = 0;
-#if DEBUG_NETWORK
       LOG (GNUNET_ERROR_TYPE_DEBUG, "Select retcode : %d\n", retcode);
-#endif
     }
     /* FIXME: <= writePipePos? Really? */
     if ((writePipePos != -1) && (returnedpos <= writePipePos))
     {
       GNUNET_CONTAINER_slist_append (handles_write, wfds->handles);
       retcode += write_handles;
-#if DEBUG_NETWORK
       LOG (GNUNET_ERROR_TYPE_DEBUG, "Added write pipe\n");
-#endif
     }
-#if DEBUG_NETWORK
     LOG (GNUNET_ERROR_TYPE_DEBUG, "ReadPipes is : %d\n", readPipes);
-#endif
     /* We have some pipes ready for read. */
     /* FIXME: it is supposed to work !! Only choose the Pipes who fired the event, but it is not working */
 
@@ -1532,11 +1498,9 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds,
         bret =
             PeekNamedPipe (readArray[i]->h, NULL, 0, NULL, &waitstatus, NULL);
         error = GetLastError ();
-#if DEBUG_NETWORK
         LOG (GNUNET_ERROR_TYPE_DEBUG,
              "Peek at read pipe %d (0x%x) returned %d (%d bytes available) GLE %u\n",
              i, readArray[i]->h, bret, waitstatus, error);
-#endif
         if (bret == 0)
         {
           if (error != ERROR_BROKEN_PIPE)
@@ -1549,17 +1513,13 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds,
                                     readArray[i],
                                     sizeof (struct GNUNET_DISK_FileHandle));
         retcode++;
-#if DEBUG_NETWORK
         LOG (GNUNET_ERROR_TYPE_DEBUG, "Added read Pipe 0x%x (0x%x)\n",
              readArray[i], readArray[i]->h);
-#endif
       }
     }
     waitstatus = WaitForSingleObject (hEventWrite, 0);
-#if DEBUG_NETWORK
     LOG (GNUNET_ERROR_TYPE_DEBUG, "Wait for the write event returned %d\n",
          waitstatus);
-#endif
     if (waitstatus == WAIT_OBJECT_0)
     {
       for (i = 0; i < wfds->sds.fd_count; i++)
@@ -1574,10 +1534,8 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds,
 
         status = send (wfds->sds.fd_array[i], NULL, 0, 0);
         error = GetLastError ();
-#if DEBUG_NETWORK
         LOG (GNUNET_ERROR_TYPE_DEBUG,
              "send to the socket %d returned %d (%u)\n", i, status, error);
-#endif
         if (status == 0 || (error != WSAEWOULDBLOCK && error != WSAENOTCONN) ||
             (status == -1 && gso_result == 0 && error == WSAENOTCONN &&
              so_error == WSAECONNREFUSED))
@@ -1614,9 +1572,7 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds,
         CancelIo (fh->h);
       }
     }
-#if DEBUG_NETWORK
     LOG (GNUNET_ERROR_TYPE_DEBUG, "Zeroing rfds\n");
-#endif
     GNUNET_NETWORK_fdset_zero (rfds);
     if (retcode != -1 && nhandles && (returnedpos < nhandles))
       GNUNET_NETWORK_fdset_copy_native (rfds, &aread, retcode);
@@ -1629,9 +1585,7 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds,
       WSAEventSelect (wfds->sds.fd_array[i], hEventWrite, 0);
       nsock++;
     }
-#if DEBUG_NETWORK
     LOG (GNUNET_ERROR_TYPE_DEBUG, "Zeroing wfds\n");
-#endif
     GNUNET_NETWORK_fdset_zero (wfds);
     if (retcode != -1 && nhandles && (returnedpos < nhandles))
       GNUNET_NETWORK_fdset_copy_native (wfds, &awrite, retcode);
@@ -1644,9 +1598,7 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds,
       WSAEventSelect (efds->sds.fd_array[i], hEventException, 0);
       nsock++;
     }
-#if DEBUG_NETWORK
     LOG (GNUNET_ERROR_TYPE_DEBUG, "Zeroing efds\n");
-#endif
     GNUNET_NETWORK_fdset_zero (efds);
     if (retcode != -1 && nhandles && (returnedpos < nhandles))
       GNUNET_NETWORK_fdset_copy_native (efds, &aexcept, retcode);
index 4128969466e72f83c40db5978e234a6305f67717..f1cecd4effba507f5c69272d0902d83a94ab2e38 100644 (file)
 #include "gnunet_signal_lib.h"
 #include "gnunet_time_lib.h"
 #include "disk.h"
-#define LOG(kind,...) GNUNET_log_from (kind, "util", __VA_ARGS__)
 
-#define LOG_STRERROR(kind,syscall) GNUNET_log_from_strerror (kind, "util", syscall)
-#ifdef LINUX
-#include "execinfo.h"
+#define LOG(kind,...) GNUNET_log_from (kind, "util-scheduler", __VA_ARGS__)
 
+#define LOG_STRERROR(kind,syscall) GNUNET_log_from_strerror (kind, "util-scheduler", syscall)
 
 
+#ifdef LINUX
+#include "execinfo.h"
+
 /**
  * Use lsof to generate file descriptor reports on select error?
  * (turn off for stable releases).
@@ -52,7 +53,7 @@
 /**
  * Check each file descriptor before adding
  */
-#define DEBUG_FDS GNUNET_EXTRA_LOGGING
+#define DEBUG_FDS GNUNET_NO
 
 /**
  * Depth of the traces collected via EXECINFO.
@@ -60,8 +61,6 @@
 #define MAX_TRACE_DEPTH 50
 #endif
 
-#define DEBUG_TASKS GNUNET_EXTRA_LOGGING
-
 /**
  * Should we figure out which tasks are delayed for a while
  * before they are run? (Consider using in combination with EXECINFO).
@@ -74,6 +73,7 @@
  */
 #define DELAY_THRESHOLD GNUNET_TIME_UNIT_SECONDS
 
+
 /**
  * Linked list of pending tasks.
  */
@@ -526,10 +526,9 @@ check_ready (const struct GNUNET_NETWORK_FDSet *rs,
   pos = pending;
   while (pos != NULL)
   {
-#if DEBUG_TASKS
-    LOG (GNUNET_ERROR_TYPE_DEBUG, "Checking readiness of task: %llu / %p\n",
+    LOG (GNUNET_ERROR_TYPE_DEBUG, 
+        "Checking readiness of task: %llu / %p\n",
          pos->id, pos->callback_cls);
-#endif
     next = pos->next;
     if (GNUNET_YES == is_ready (pos, now, rs, ws))
     {
@@ -677,10 +676,9 @@ run_ready (struct GNUNET_NETWORK_FDSet *rs, struct GNUNET_NETWORK_FDSet *ws)
         (pos->write_fd != -1) &&
         (!GNUNET_NETWORK_fdset_test_native (ws, pos->write_fd)))
       GNUNET_abort ();          // added to ready in previous select loop!
-#if DEBUG_TASKS
-    LOG (GNUNET_ERROR_TYPE_DEBUG, "Running task: %llu / %p\n", pos->id,
+    LOG (GNUNET_ERROR_TYPE_DEBUG, 
+        "Running task: %llu / %p\n", pos->id,
          pos->callback_cls);
-#endif
     pos->callback (pos->callback_cls, &tc);
 #if EXECINFO
     int i;
@@ -1037,10 +1035,8 @@ GNUNET_SCHEDULER_cancel (GNUNET_SCHEDULER_TaskIdentifier task)
     prev->next = t->next;
   }
   ret = t->callback_cls;
-#if DEBUG_TASKS
   LOG (GNUNET_ERROR_TYPE_DEBUG, "Canceling task: %llu / %p\n", task,
        t->callback_cls);
-#endif
   destroy_task (t);
   return ret;
 }
@@ -1087,10 +1083,8 @@ GNUNET_SCHEDULER_add_continuation_with_priority (GNUNET_SCHEDULER_Task task, voi
   t->reason = reason;
   t->priority = priority;
   t->lifeness = current_lifeness;
-#if DEBUG_TASKS
   LOG (GNUNET_ERROR_TYPE_DEBUG, "Adding continuation task: %llu / %p\n", t->id,
        t->callback_cls);
-#endif
   queue_ready_task (t);
 }
 
@@ -1233,10 +1227,8 @@ GNUNET_SCHEDULER_add_delayed_with_priority (struct GNUNET_TIME_Relative delay,
   /* hyper-optimization... */
   pending_timeout_last = t;
 
-#if DEBUG_TASKS
   LOG (GNUNET_ERROR_TYPE_DEBUG, "Adding task: %llu / %p\n", t->id,
        t->callback_cls);
-#endif
 #if EXECINFO
   int i;
 
@@ -1416,10 +1408,8 @@ add_without_sets (struct GNUNET_TIME_Relative delay,
   t->next = pending;
   pending = t;
   max_priority_added = GNUNET_MAX (max_priority_added, t->priority);
-#if DEBUG_TASKS
   LOG (GNUNET_ERROR_TYPE_DEBUG, "Adding task: %llu / %p\n", t->id,
        t->callback_cls);
-#endif
 #if EXECINFO
   int i;
 
@@ -1693,10 +1683,8 @@ GNUNET_SCHEDULER_add_select (enum GNUNET_SCHEDULER_Priority prio,
   t->next = pending;
   pending = t;
   max_priority_added = GNUNET_MAX (max_priority_added, t->priority);
-#if DEBUG_TASKS
   LOG (GNUNET_ERROR_TYPE_DEBUG, "Adding task: %llu / %p\n", t->id,
        t->callback_cls);
-#endif
 #if EXECINFO
   int i;