aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-02-26 14:21:49 +0000
committerChristian Grothoff <christian@grothoff.org>2012-02-26 14:21:49 +0000
commit34961f382d98822d1fa3506e8bfdf163e2e915ea (patch)
tree855ac5770b741da80fc8c2fff1bfb283913e9685 /src
parent3d97cc0d1b93fd0ee2deb2440b3c3a59bfa506ed (diff)
downloadgnunet-34961f382d98822d1fa3506e8bfdf163e2e915ea.tar.gz
gnunet-34961f382d98822d1fa3506e8bfdf163e2e915ea.zip
-some more #if DEBUG elimination
Diffstat (limited to 'src')
-rw-r--r--src/util/bandwidth.c30
-rw-r--r--src/util/connection.c90
-rw-r--r--src/util/network.c48
-rw-r--r--src/util/scheduler.c34
4 files changed, 16 insertions, 186 deletions
diff --git a/src/util/bandwidth.c b/src/util/bandwidth.c
index 0920362f5..9d679493a 100644
--- a/src/util/bandwidth.c
+++ b/src/util/bandwidth.c
@@ -27,9 +27,8 @@
27#include "gnunet_bandwidth_lib.h" 27#include "gnunet_bandwidth_lib.h"
28#include "gnunet_server_lib.h" 28#include "gnunet_server_lib.h"
29 29
30#define DEBUG_BANDWIDTH GNUNET_EXTRA_LOGGING
31 30
32#define LOG(kind,...) GNUNET_log_from (kind, "util",__VA_ARGS__) 31#define LOG(kind,...) GNUNET_log_from (kind, "util-bandwidth", __VA_ARGS__)
33 32
34/** 33/**
35 * Create a new bandwidth value. 34 * Create a new bandwidth value.
@@ -42,10 +41,8 @@ GNUNET_BANDWIDTH_value_init (uint32_t bytes_per_second)
42{ 41{
43 struct GNUNET_BANDWIDTH_Value32NBO ret; 42 struct GNUNET_BANDWIDTH_Value32NBO ret;
44 43
45#if DEBUG_BANDWIDTH
46 LOG (GNUNET_ERROR_TYPE_DEBUG, "Initializing bandwidth of %u Bps\n", 44 LOG (GNUNET_ERROR_TYPE_DEBUG, "Initializing bandwidth of %u Bps\n",
47 (unsigned int) bytes_per_second); 45 (unsigned int) bytes_per_second);
48#endif
49 ret.value__ = htonl (bytes_per_second); 46 ret.value__ = htonl (bytes_per_second);
50 return ret; 47 return ret;
51} 48}
@@ -85,12 +82,10 @@ GNUNET_BANDWIDTH_value_get_available_until (struct GNUNET_BANDWIDTH_Value32NBO
85 uint64_t b; 82 uint64_t b;
86 83
87 b = ntohl (bps.value__); 84 b = ntohl (bps.value__);
88#if DEBUG_BANDWIDTH
89 LOG (GNUNET_ERROR_TYPE_DEBUG, 85 LOG (GNUNET_ERROR_TYPE_DEBUG,
90 "Bandwidth has %llu bytes available until deadline in %llums\n", 86 "Bandwidth has %llu bytes available until deadline in %llums\n",
91 (unsigned long long) ((b * deadline.rel_value + 500LL) / 1000LL), 87 (unsigned long long) ((b * deadline.rel_value + 500LL) / 1000LL),
92 deadline.rel_value); 88 deadline.rel_value);
93#endif
94 return (b * deadline.rel_value + 500LL) / 1000LL; 89 return (b * deadline.rel_value + 500LL) / 1000LL;
95} 90}
96 91
@@ -113,18 +108,14 @@ GNUNET_BANDWIDTH_value_get_delay_for (struct GNUNET_BANDWIDTH_Value32NBO bps,
113 b = ntohl (bps.value__); 108 b = ntohl (bps.value__);
114 if (b == 0) 109 if (b == 0)
115 { 110 {
116#if DEBUG_BANDWIDTH
117 LOG (GNUNET_ERROR_TYPE_DEBUG, 111 LOG (GNUNET_ERROR_TYPE_DEBUG,
118 "Bandwidth suggests delay of infinity (zero bandwidth)\n"); 112 "Bandwidth suggests delay of infinity (zero bandwidth)\n");
119#endif
120 return GNUNET_TIME_UNIT_FOREVER_REL; 113 return GNUNET_TIME_UNIT_FOREVER_REL;
121 } 114 }
122 ret.rel_value = size * 1000LL / b; 115 ret.rel_value = size * 1000LL / b;
123#if DEBUG_BANDWIDTH
124 LOG (GNUNET_ERROR_TYPE_DEBUG, 116 LOG (GNUNET_ERROR_TYPE_DEBUG,
125 "Bandwidth suggests delay of %llu ms for %llu bytes of traffic\n", 117 "Bandwidth suggests delay of %llu ms for %llu bytes of traffic\n",
126 (unsigned long long) ret.rel_value, (unsigned long long) size); 118 (unsigned long long) ret.rel_value, (unsigned long long) size);
127#endif
128 return ret; 119 return ret;
129} 120}
130 121
@@ -152,11 +143,9 @@ GNUNET_BANDWIDTH_tracker_init (struct GNUNET_BANDWIDTH_Tracker *av,
152 av->last_update__ = GNUNET_TIME_absolute_get (); 143 av->last_update__ = GNUNET_TIME_absolute_get ();
153 av->available_bytes_per_s__ = ntohl (bytes_per_second_limit.value__); 144 av->available_bytes_per_s__ = ntohl (bytes_per_second_limit.value__);
154 av->max_carry_s__ = max_carry_s; 145 av->max_carry_s__ = max_carry_s;
155#if DEBUG_BANDWIDTH
156 LOG (GNUNET_ERROR_TYPE_DEBUG, 146 LOG (GNUNET_ERROR_TYPE_DEBUG,
157 "Tracker %p initialized with %u Bps and max carry %u\n", av, 147 "Tracker %p initialized with %u Bps and max carry %u\n", av,
158 (unsigned int) av->available_bytes_per_s__, (unsigned int) max_carry_s); 148 (unsigned int) av->available_bytes_per_s__, (unsigned int) max_carry_s);
159#endif
160} 149}
161 150
162 151
@@ -193,13 +182,10 @@ update_tracker (struct GNUNET_BANDWIDTH_Tracker *av)
193 else 182 else
194 av->consumption_since_last_update__ = -max_carry; 183 av->consumption_since_last_update__ = -max_carry;
195 } 184 }
196#if DEBUG_BANDWIDTH
197 LOG (GNUNET_ERROR_TYPE_DEBUG, 185 LOG (GNUNET_ERROR_TYPE_DEBUG,
198 "Tracker %p updated, have %u Bps, last update was %llu ms ago\n", av, 186 "Tracker %p updated, have %u Bps, last update was %llu ms ago\n", av,
199 (unsigned int) av->available_bytes_per_s__, 187 (unsigned int) av->available_bytes_per_s__,
200 (unsigned long long) delta_time); 188 (unsigned long long) delta_time);
201#endif
202
203} 189}
204 190
205 191
@@ -220,10 +206,8 @@ GNUNET_BANDWIDTH_tracker_consume (struct GNUNET_BANDWIDTH_Tracker *av,
220{ 206{
221 int64_t nc; 207 int64_t nc;
222 208
223#if DEBUG_BANDWIDTH
224 LOG (GNUNET_ERROR_TYPE_DEBUG, "Tracker %p consumes %d bytes\n", av, 209 LOG (GNUNET_ERROR_TYPE_DEBUG, "Tracker %p consumes %d bytes\n", av,
225 (int) size); 210 (int) size);
226#endif
227 if (size > 0) 211 if (size > 0)
228 { 212 {
229 nc = av->consumption_since_last_update__ + size; 213 nc = av->consumption_since_last_update__ + size;
@@ -236,11 +220,9 @@ GNUNET_BANDWIDTH_tracker_consume (struct GNUNET_BANDWIDTH_Tracker *av,
236 update_tracker (av); 220 update_tracker (av);
237 if (av->consumption_since_last_update__ > 0) 221 if (av->consumption_since_last_update__ > 0)
238 { 222 {
239#if DEBUG_BANDWIDTH
240 LOG (GNUNET_ERROR_TYPE_DEBUG, 223 LOG (GNUNET_ERROR_TYPE_DEBUG,
241 "Tracker %p consumption %llu bytes above limit\n", av, 224 "Tracker %p consumption %llu bytes above limit\n", av,
242 (unsigned long long) av->consumption_since_last_update__); 225 (unsigned long long) av->consumption_since_last_update__);
243#endif
244 return GNUNET_YES; 226 return GNUNET_YES;
245 } 227 }
246 } 228 }
@@ -270,28 +252,22 @@ GNUNET_BANDWIDTH_tracker_get_delay (struct GNUNET_BANDWIDTH_Tracker *av,
270 252
271 if (av->available_bytes_per_s__ == 0) 253 if (av->available_bytes_per_s__ == 0)
272 { 254 {
273#if DEBUG_BANDWIDTH
274 LOG (GNUNET_ERROR_TYPE_DEBUG, "Tracker %p delay is infinity\n", av); 255 LOG (GNUNET_ERROR_TYPE_DEBUG, "Tracker %p delay is infinity\n", av);
275#endif
276 return GNUNET_TIME_UNIT_FOREVER_REL; 256 return GNUNET_TIME_UNIT_FOREVER_REL;
277 } 257 }
278 update_tracker (av); 258 update_tracker (av);
279 bytes_needed = size + av->consumption_since_last_update__; 259 bytes_needed = size + av->consumption_since_last_update__;
280 if (bytes_needed <= 0) 260 if (bytes_needed <= 0)
281 { 261 {
282#if DEBUG_BANDWIDTH
283 LOG (GNUNET_ERROR_TYPE_DEBUG, "Tracker %p delay for %u bytes is zero\n", av, 262 LOG (GNUNET_ERROR_TYPE_DEBUG, "Tracker %p delay for %u bytes is zero\n", av,
284 (unsigned int) size); 263 (unsigned int) size);
285#endif
286 return GNUNET_TIME_UNIT_ZERO; 264 return GNUNET_TIME_UNIT_ZERO;
287 } 265 }
288 ret.rel_value = 266 ret.rel_value =
289 (1000LL * bytes_needed) / 267 (1000LL * bytes_needed) /
290 (unsigned long long) av->available_bytes_per_s__; 268 (unsigned long long) av->available_bytes_per_s__;
291#if DEBUG_BANDWIDTH
292 LOG (GNUNET_ERROR_TYPE_DEBUG, "Tracker %p delay for %u bytes is %llu ms\n", 269 LOG (GNUNET_ERROR_TYPE_DEBUG, "Tracker %p delay for %u bytes is %llu ms\n",
293 av, (unsigned int) size, (unsigned long long) ret.rel_value); 270 av, (unsigned int) size, (unsigned long long) ret.rel_value);
294#endif
295 return ret; 271 return ret;
296} 272}
297 273
@@ -317,11 +293,9 @@ GNUNET_BANDWIDTH_tracker_get_available (struct GNUNET_BANDWIDTH_Tracker * av)
317 GNUNET_TIME_absolute_get_duration 293 GNUNET_TIME_absolute_get_duration
318 (av->last_update__)); 294 (av->last_update__));
319 used = av->consumption_since_last_update__; 295 used = av->consumption_since_last_update__;
320#if DEBUG_BANDWIDTH
321 LOG (GNUNET_ERROR_TYPE_DEBUG, 296 LOG (GNUNET_ERROR_TYPE_DEBUG,
322 "Tracker %p available bandwidth is %lld bytes\n", av, 297 "Tracker %p available bandwidth is %lld bytes\n", av,
323 (long long) (int64_t) (avail - used)); 298 (long long) (int64_t) (avail - used));
324#endif
325 return (int64_t) (avail - used); 299 return (int64_t) (avail - used);
326} 300}
327 301
@@ -341,10 +315,8 @@ GNUNET_BANDWIDTH_tracker_update_quota (struct GNUNET_BANDWIDTH_Tracker *av,
341 uint32_t new_limit; 315 uint32_t new_limit;
342 316
343 new_limit = ntohl (bytes_per_second_limit.value__); 317 new_limit = ntohl (bytes_per_second_limit.value__);
344#if DEBUG_BANDWIDTH
345 LOG (GNUNET_ERROR_TYPE_DEBUG, "Tracker %p bandwidth changed to %u Bps\n", av, 318 LOG (GNUNET_ERROR_TYPE_DEBUG, "Tracker %p bandwidth changed to %u Bps\n", av,
346 (unsigned int) new_limit); 319 (unsigned int) new_limit);
347#endif
348 update_tracker (av); 320 update_tracker (av);
349 old_limit = av->available_bytes_per_s__; 321 old_limit = av->available_bytes_per_s__;
350 av->available_bytes_per_s__ = new_limit; 322 av->available_bytes_per_s__ = new_limit;
diff --git a/src/util/connection.c b/src/util/connection.c
index 61c26673b..8224479f9 100644
--- a/src/util/connection.c
+++ b/src/util/connection.c
@@ -39,7 +39,6 @@
39#include "gnunet_scheduler_lib.h" 39#include "gnunet_scheduler_lib.h"
40#include "gnunet_server_lib.h" 40#include "gnunet_server_lib.h"
41 41
42#define DEBUG_CONNECTION GNUNET_EXTRA_LOGGING
43 42
44#define LOG(kind,...) GNUNET_log_from (kind, "util", __VA_ARGS__) 43#define LOG(kind,...) GNUNET_log_from (kind, "util", __VA_ARGS__)
45 44
@@ -472,10 +471,9 @@ GNUNET_CONNECTION_create_from_accept (GNUNET_CONNECTION_AccessCheck access,
472 ret->addr = uaddr; 471 ret->addr = uaddr;
473 ret->addrlen = addrlen; 472 ret->addrlen = addrlen;
474 ret->sock = sock; 473 ret->sock = sock;
475#if DEBUG_CONNECTION 474 LOG (GNUNET_ERROR_TYPE_INFO,
476 LOG (GNUNET_ERROR_TYPE_INFO, _("Accepting connection from `%s': %p\n"), 475 _("Accepting connection from `%s': %p\n"),
477 GNUNET_a2s (uaddr, addrlen), ret); 476 GNUNET_a2s (uaddr, addrlen), ret);
478#endif
479 return ret; 477 return ret;
480} 478}
481 479
@@ -532,19 +530,15 @@ destroy_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
532 GNUNET_assert (sock->dns_active == NULL); 530 GNUNET_assert (sock->dns_active == NULL);
533 if (0 != (sock->ccs & COCO_TRANSMIT_READY)) 531 if (0 != (sock->ccs & COCO_TRANSMIT_READY))
534 { 532 {
535#if DEBUG_CONNECTION
536 LOG (GNUNET_ERROR_TYPE_DEBUG, "Destroy waits for CCS-TR to be done (%p)\n", 533 LOG (GNUNET_ERROR_TYPE_DEBUG, "Destroy waits for CCS-TR to be done (%p)\n",
537 sock); 534 sock);
538#endif
539 sock->ccs |= COCO_DESTROY_CONTINUATION; 535 sock->ccs |= COCO_DESTROY_CONTINUATION;
540 return; 536 return;
541 } 537 }
542 if (sock->write_task != GNUNET_SCHEDULER_NO_TASK) 538 if (sock->write_task != GNUNET_SCHEDULER_NO_TASK)
543 { 539 {
544#if DEBUG_CONNECTION
545 LOG (GNUNET_ERROR_TYPE_DEBUG, 540 LOG (GNUNET_ERROR_TYPE_DEBUG,
546 "Destroy waits for write_task to be done (%p)\n", sock); 541 "Destroy waits for write_task to be done (%p)\n", sock);
547#endif
548 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == sock->destroy_task); 542 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == sock->destroy_task);
549 sock->destroy_task = 543 sock->destroy_task =
550 GNUNET_SCHEDULER_add_after (sock->write_task, &destroy_continuation, 544 GNUNET_SCHEDULER_add_after (sock->write_task, &destroy_continuation,
@@ -558,9 +552,7 @@ destroy_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
558 } 552 }
559 if (sock->sock != NULL) 553 if (sock->sock != NULL)
560 { 554 {
561#if DEBUG_CONNECTION
562 LOG (GNUNET_ERROR_TYPE_DEBUG, "Shutting down socket (%p)\n", sock); 555 LOG (GNUNET_ERROR_TYPE_DEBUG, "Shutting down socket (%p)\n", sock);
563#endif
564 if (sock->persist != GNUNET_YES) 556 if (sock->persist != GNUNET_YES)
565 { 557 {
566 if ((GNUNET_YES != GNUNET_NETWORK_socket_shutdown (sock->sock, SHUT_RDWR)) 558 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)
576 sock); 568 sock);
577 return; 569 return;
578 } 570 }
579#if DEBUG_CONNECTION
580 LOG (GNUNET_ERROR_TYPE_DEBUG, "Destroy actually runs (%p)!\n", sock); 571 LOG (GNUNET_ERROR_TYPE_DEBUG, "Destroy actually runs (%p)!\n", sock);
581#endif
582 while (NULL != (pos = sock->ap_head)) 572 while (NULL != (pos = sock->ap_head))
583 { 573 {
584 GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (pos->sock)); 574 GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (pos->sock));
@@ -605,9 +595,7 @@ destroy_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
605 GNUNET_free_non_null (sock->addr); 595 GNUNET_free_non_null (sock->addr);
606 GNUNET_free_non_null (sock->hostname); 596 GNUNET_free_non_null (sock->hostname);
607 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == sock->destroy_task); 597 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == sock->destroy_task);
608#if DEBUG_CONNECTION
609 LOG (GNUNET_ERROR_TYPE_DEBUG, "Freeing memory of connection %p.\n", sock); 598 LOG (GNUNET_ERROR_TYPE_DEBUG, "Freeing memory of connection %p.\n", sock);
610#endif
611 GNUNET_free (sock->write_buffer); 599 GNUNET_free (sock->write_buffer);
612 GNUNET_free (sock); 600 GNUNET_free (sock);
613} 601}
@@ -634,14 +622,12 @@ transmit_ready (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
634static void 622static void
635connect_fail_continuation (struct GNUNET_CONNECTION_Handle *h) 623connect_fail_continuation (struct GNUNET_CONNECTION_Handle *h)
636{ 624{
637#if DEBUG_CONNECTION
638 LOG ((0 != 625 LOG ((0 !=
639 strncmp (h->hostname, "localhost:", 626 strncmp (h->hostname, "localhost:",
640 10)) ? GNUNET_ERROR_TYPE_INFO : GNUNET_ERROR_TYPE_WARNING, 627 10)) ? GNUNET_ERROR_TYPE_INFO : GNUNET_ERROR_TYPE_WARNING,
641 _ 628 _
642 ("Failed to establish TCP connection to `%s:%u', no further addresses to try.\n"), 629 ("Failed to establish TCP connection to `%s:%u', no further addresses to try.\n"),
643 h->hostname, h->port); 630 h->hostname, h->port);
644#endif
645 /* connect failed / timed out */ 631 /* connect failed / timed out */
646 GNUNET_break (h->ap_head == NULL); 632 GNUNET_break (h->ap_head == NULL);
647 GNUNET_break (h->ap_tail == NULL); 633 GNUNET_break (h->ap_tail == NULL);
@@ -651,20 +637,16 @@ connect_fail_continuation (struct GNUNET_CONNECTION_Handle *h)
651 /* trigger jobs that used to wait on "connect_task" */ 637 /* trigger jobs that used to wait on "connect_task" */
652 if (0 != (h->ccs & COCO_RECEIVE_AGAIN)) 638 if (0 != (h->ccs & COCO_RECEIVE_AGAIN))
653 { 639 {
654#if DEBUG_CONNECTION
655 LOG (GNUNET_ERROR_TYPE_DEBUG, 640 LOG (GNUNET_ERROR_TYPE_DEBUG,
656 "connect_fail_continuation triggers receive_again (%p)\n", h); 641 "connect_fail_continuation triggers receive_again (%p)\n", h);
657#endif
658 h->ccs -= COCO_RECEIVE_AGAIN; 642 h->ccs -= COCO_RECEIVE_AGAIN;
659 h->read_task = GNUNET_SCHEDULER_add_now (&receive_again, h); 643 h->read_task = GNUNET_SCHEDULER_add_now (&receive_again, h);
660 } 644 }
661 if (0 != (h->ccs & COCO_TRANSMIT_READY)) 645 if (0 != (h->ccs & COCO_TRANSMIT_READY))
662 { 646 {
663#if DEBUG_CONNECTION
664 LOG (GNUNET_ERROR_TYPE_DEBUG, 647 LOG (GNUNET_ERROR_TYPE_DEBUG,
665 "connect_fail_continuation cancels timeout_task, triggers transmit_ready (%p)\n", 648 "connect_fail_continuation cancels timeout_task, triggers transmit_ready (%p)\n",
666 h); 649 h);
667#endif
668 GNUNET_assert (h->nth.timeout_task != GNUNET_SCHEDULER_NO_TASK); 650 GNUNET_assert (h->nth.timeout_task != GNUNET_SCHEDULER_NO_TASK);
669 GNUNET_SCHEDULER_cancel (h->nth.timeout_task); 651 GNUNET_SCHEDULER_cancel (h->nth.timeout_task);
670 h->nth.timeout_task = GNUNET_SCHEDULER_NO_TASK; 652 h->nth.timeout_task = GNUNET_SCHEDULER_NO_TASK;
@@ -675,10 +657,8 @@ connect_fail_continuation (struct GNUNET_CONNECTION_Handle *h)
675 } 657 }
676 if (0 != (h->ccs & COCO_DESTROY_CONTINUATION)) 658 if (0 != (h->ccs & COCO_DESTROY_CONTINUATION))
677 { 659 {
678#if DEBUG_CONNECTION
679 LOG (GNUNET_ERROR_TYPE_DEBUG, 660 LOG (GNUNET_ERROR_TYPE_DEBUG,
680 "connect_fail_continuation runs destroy_continuation (%p)\n", h); 661 "connect_fail_continuation runs destroy_continuation (%p)\n", h);
681#endif
682 h->ccs -= COCO_DESTROY_CONTINUATION; 662 h->ccs -= COCO_DESTROY_CONTINUATION;
683 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == h->destroy_task); 663 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == h->destroy_task);
684 h->destroy_task = GNUNET_SCHEDULER_add_now (&destroy_continuation, h); 664 h->destroy_task = GNUNET_SCHEDULER_add_now (&destroy_continuation, h);
@@ -694,27 +674,21 @@ connect_fail_continuation (struct GNUNET_CONNECTION_Handle *h)
694static void 674static void
695connect_success_continuation (struct GNUNET_CONNECTION_Handle *h) 675connect_success_continuation (struct GNUNET_CONNECTION_Handle *h)
696{ 676{
697#if DEBUG_CONNECTION
698 LOG (GNUNET_ERROR_TYPE_DEBUG, "Connection to `%s' succeeded! (%p)\n", 677 LOG (GNUNET_ERROR_TYPE_DEBUG, "Connection to `%s' succeeded! (%p)\n",
699 GNUNET_a2s (h->addr, h->addrlen), h); 678 GNUNET_a2s (h->addr, h->addrlen), h);
700#endif
701 /* trigger jobs that waited for the connection */ 679 /* trigger jobs that waited for the connection */
702 if (0 != (h->ccs & COCO_RECEIVE_AGAIN)) 680 if (0 != (h->ccs & COCO_RECEIVE_AGAIN))
703 { 681 {
704#if DEBUG_CONNECTION
705 LOG (GNUNET_ERROR_TYPE_DEBUG, 682 LOG (GNUNET_ERROR_TYPE_DEBUG,
706 "connect_success_continuation runs receive_again (%p)\n", h); 683 "connect_success_continuation runs receive_again (%p)\n", h);
707#endif
708 h->ccs -= COCO_RECEIVE_AGAIN; 684 h->ccs -= COCO_RECEIVE_AGAIN;
709 h->read_task = GNUNET_SCHEDULER_add_now (&receive_again, h); 685 h->read_task = GNUNET_SCHEDULER_add_now (&receive_again, h);
710 } 686 }
711 if (0 != (h->ccs & COCO_TRANSMIT_READY)) 687 if (0 != (h->ccs & COCO_TRANSMIT_READY))
712 { 688 {
713#if DEBUG_CONNECTION
714 LOG (GNUNET_ERROR_TYPE_DEBUG, 689 LOG (GNUNET_ERROR_TYPE_DEBUG,
715 "connect_success_continuation runs transmit_ready, cancels timeout_task (%p)\n", 690 "connect_success_continuation runs transmit_ready, cancels timeout_task (%p)\n",
716 h); 691 h);
717#endif
718 GNUNET_assert (h->nth.timeout_task != GNUNET_SCHEDULER_NO_TASK); 692 GNUNET_assert (h->nth.timeout_task != GNUNET_SCHEDULER_NO_TASK);
719 GNUNET_SCHEDULER_cancel (h->nth.timeout_task); 693 GNUNET_SCHEDULER_cancel (h->nth.timeout_task);
720 h->nth.timeout_task = GNUNET_SCHEDULER_NO_TASK; 694 h->nth.timeout_task = GNUNET_SCHEDULER_NO_TASK;
@@ -728,10 +702,8 @@ connect_success_continuation (struct GNUNET_CONNECTION_Handle *h)
728 } 702 }
729 if (0 != (h->ccs & COCO_DESTROY_CONTINUATION)) 703 if (0 != (h->ccs & COCO_DESTROY_CONTINUATION))
730 { 704 {
731#if DEBUG_CONNECTION
732 LOG (GNUNET_ERROR_TYPE_DEBUG, 705 LOG (GNUNET_ERROR_TYPE_DEBUG,
733 "connect_success_continuation runs destroy_continuation (%p)\n", h); 706 "connect_success_continuation runs destroy_continuation (%p)\n", h);
734#endif
735 h->ccs -= COCO_DESTROY_CONTINUATION; 707 h->ccs -= COCO_DESTROY_CONTINUATION;
736 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == h->destroy_task); 708 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == h->destroy_task);
737 h->destroy_task = GNUNET_SCHEDULER_add_now (&destroy_continuation, h); 709 h->destroy_task = GNUNET_SCHEDULER_add_now (&destroy_continuation, h);
@@ -818,11 +790,9 @@ try_connect_using_address (void *cls, const struct sockaddr *addr,
818 return; /* already connected */ 790 return; /* already connected */
819 GNUNET_assert (h->addr == NULL); 791 GNUNET_assert (h->addr == NULL);
820 /* try to connect */ 792 /* try to connect */
821#if DEBUG_CONNECTION
822 LOG (GNUNET_ERROR_TYPE_DEBUG, 793 LOG (GNUNET_ERROR_TYPE_DEBUG,
823 "Trying to connect using address `%s:%u/%s:%u'\n", h->hostname, h->port, 794 "Trying to connect using address `%s:%u/%s:%u'\n", h->hostname, h->port,
824 GNUNET_a2s (addr, addrlen), h->port); 795 GNUNET_a2s (addr, addrlen), h->port);
825#endif
826 ap = GNUNET_malloc (sizeof (struct AddressProbe) + addrlen); 796 ap = GNUNET_malloc (sizeof (struct AddressProbe) + addrlen);
827 ap->addr = (const struct sockaddr *) &ap[1]; 797 ap->addr = (const struct sockaddr *) &ap[1];
828 memcpy (&ap[1], addr, addrlen); 798 memcpy (&ap[1], addr, addrlen);
@@ -848,10 +818,8 @@ try_connect_using_address (void *cls, const struct sockaddr *addr,
848 GNUNET_free (ap); 818 GNUNET_free (ap);
849 return; /* not supported by OS */ 819 return; /* not supported by OS */
850 } 820 }
851#if DEBUG_CONNECTION
852 LOG (GNUNET_ERROR_TYPE_INFO, _("Trying to connect to `%s' (%p)\n"), 821 LOG (GNUNET_ERROR_TYPE_INFO, _("Trying to connect to `%s' (%p)\n"),
853 GNUNET_a2s (ap->addr, ap->addrlen), h); 822 GNUNET_a2s (ap->addr, ap->addrlen), h);
854#endif
855 if ((GNUNET_OK != 823 if ((GNUNET_OK !=
856 GNUNET_NETWORK_socket_connect (ap->sock, ap->addr, ap->addrlen)) && 824 GNUNET_NETWORK_socket_connect (ap->sock, ap->addr, ap->addrlen)) &&
857 (errno != EINPROGRESS)) 825 (errno != EINPROGRESS))
@@ -1021,10 +989,8 @@ GNUNET_CONNECTION_create_from_sockaddr (int af_family,
1021 ret->addr = GNUNET_malloc (addrlen); 989 ret->addr = GNUNET_malloc (addrlen);
1022 memcpy (ret->addr, serv_addr, addrlen); 990 memcpy (ret->addr, serv_addr, addrlen);
1023 ret->addrlen = addrlen; 991 ret->addrlen = addrlen;
1024#if DEBUG_CONNECTION
1025 LOG (GNUNET_ERROR_TYPE_INFO, _("Trying to connect to `%s' (%p)\n"), 992 LOG (GNUNET_ERROR_TYPE_INFO, _("Trying to connect to `%s' (%p)\n"),
1026 GNUNET_a2s (serv_addr, addrlen), ret); 993 GNUNET_a2s (serv_addr, addrlen), ret);
1027#endif
1028 return ret; 994 return ret;
1029} 995}
1030 996
@@ -1092,10 +1058,8 @@ signal_timeout (struct GNUNET_CONNECTION_Handle *sh)
1092{ 1058{
1093 GNUNET_CONNECTION_Receiver receiver; 1059 GNUNET_CONNECTION_Receiver receiver;
1094 1060
1095#if DEBUG_CONNECTION
1096 LOG (GNUNET_ERROR_TYPE_DEBUG, "Network signals time out to receiver (%p)!\n", 1061 LOG (GNUNET_ERROR_TYPE_DEBUG, "Network signals time out to receiver (%p)!\n",
1097 sh); 1062 sh);
1098#endif
1099 GNUNET_assert (NULL != (receiver = sh->receiver)); 1063 GNUNET_assert (NULL != (receiver = sh->receiver));
1100 sh->receiver = NULL; 1064 sh->receiver = NULL;
1101 receiver (sh->receiver_cls, NULL, 0, NULL, 0, 0); 1065 receiver (sh->receiver_cls, NULL, 0, NULL, 0, 0);
@@ -1134,10 +1098,8 @@ receive_ready (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1134 (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))) 1098 (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)))
1135 { 1099 {
1136 /* ignore shutdown request, go again immediately */ 1100 /* ignore shutdown request, go again immediately */
1137#if DEBUG_CONNECTION
1138 LOG (GNUNET_ERROR_TYPE_DEBUG, 1101 LOG (GNUNET_ERROR_TYPE_DEBUG,
1139 "Ignoring shutdown signal per configuration\n"); 1102 "Ignoring shutdown signal per configuration\n");
1140#endif
1141 sh->read_task = 1103 sh->read_task =
1142 GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_absolute_get_remaining 1104 GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_absolute_get_remaining
1143 (sh->receive_timeout), sh->sock, 1105 (sh->receive_timeout), sh->sock,
@@ -1149,24 +1111,20 @@ receive_ready (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1149 (0 != (tc->reason & GNUNET_SCHEDULER_REASON_TIMEOUT)) || 1111 (0 != (tc->reason & GNUNET_SCHEDULER_REASON_TIMEOUT)) ||
1150 (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))) 1112 (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)))
1151 { 1113 {
1152#if DEBUG_CONNECTION
1153 if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) 1114 if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
1154 LOG (GNUNET_ERROR_TYPE_DEBUG, 1115 LOG (GNUNET_ERROR_TYPE_DEBUG,
1155 "Receive from `%s' encounters error: time out by %llums... (%p)\n", 1116 "Receive from `%s' encounters error: time out by %llums... (%p)\n",
1156 GNUNET_a2s (sh->addr, sh->addrlen), 1117 GNUNET_a2s (sh->addr, sh->addrlen),
1157 GNUNET_TIME_absolute_get_duration (sh->receive_timeout).rel_value, 1118 GNUNET_TIME_absolute_get_duration (sh->receive_timeout).rel_value,
1158 sh); 1119 sh);
1159#endif
1160 signal_timeout (sh); 1120 signal_timeout (sh);
1161 return; 1121 return;
1162 } 1122 }
1163 if (sh->sock == NULL) 1123 if (sh->sock == NULL)
1164 { 1124 {
1165 /* connect failed for good */ 1125 /* connect failed for good */
1166#if DEBUG_CONNECTION
1167 LOG (GNUNET_ERROR_TYPE_DEBUG, 1126 LOG (GNUNET_ERROR_TYPE_DEBUG,
1168 "Receive encounters error, socket closed... (%p)\n", sh); 1127 "Receive encounters error, socket closed... (%p)\n", sh);
1169#endif
1170 signal_error (sh, ECONNREFUSED); 1128 signal_error (sh, ECONNREFUSED);
1171 return; 1129 return;
1172 } 1130 }
@@ -1177,17 +1135,13 @@ RETRY:
1177 { 1135 {
1178 if (errno == EINTR) 1136 if (errno == EINTR)
1179 goto RETRY; 1137 goto RETRY;
1180#if DEBUG_CONNECTION
1181 LOG (GNUNET_ERROR_TYPE_DEBUG, "Error receiving: %s\n", STRERROR (errno)); 1138 LOG (GNUNET_ERROR_TYPE_DEBUG, "Error receiving: %s\n", STRERROR (errno));
1182#endif
1183 signal_error (sh, errno); 1139 signal_error (sh, errno);
1184 return; 1140 return;
1185 } 1141 }
1186#if DEBUG_CONNECTION
1187 LOG (GNUNET_ERROR_TYPE_DEBUG, 1142 LOG (GNUNET_ERROR_TYPE_DEBUG,
1188 "receive_ready read %u/%u bytes from `%s' (%p)!\n", (unsigned int) ret, 1143 "receive_ready read %u/%u bytes from `%s' (%p)!\n", (unsigned int) ret,
1189 sh->max, GNUNET_a2s (sh->addr, sh->addrlen), sh); 1144 sh->max, GNUNET_a2s (sh->addr, sh->addrlen), sh);
1190#endif
1191 GNUNET_assert (NULL != (receiver = sh->receiver)); 1145 GNUNET_assert (NULL != (receiver = sh->receiver));
1192 sh->receiver = NULL; 1146 sh->receiver = NULL;
1193 receiver (sh->receiver_cls, buffer, ret, sh->addr, sh->addrlen, 0); 1147 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)
1214 if (sh->sock == NULL) 1168 if (sh->sock == NULL)
1215 { 1169 {
1216 /* not connected and no longer trying */ 1170 /* not connected and no longer trying */
1217#if DEBUG_CONNECTION
1218 LOG (GNUNET_ERROR_TYPE_DEBUG, 1171 LOG (GNUNET_ERROR_TYPE_DEBUG,
1219 "Receive encounters error, socket closed (%p)...\n", sh); 1172 "Receive encounters error, socket closed (%p)...\n", sh);
1220#endif
1221 signal_error (sh, ECONNREFUSED); 1173 signal_error (sh, ECONNREFUSED);
1222 return; 1174 return;
1223 } 1175 }
@@ -1225,10 +1177,8 @@ receive_again (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1225 if ((now.abs_value > sh->receive_timeout.abs_value) || 1177 if ((now.abs_value > sh->receive_timeout.abs_value) ||
1226 (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))) 1178 (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)))
1227 { 1179 {
1228#if DEBUG_CONNECTION
1229 LOG (GNUNET_ERROR_TYPE_DEBUG, 1180 LOG (GNUNET_ERROR_TYPE_DEBUG,
1230 "Receive encounters error: time out (%p)...\n", sh); 1181 "Receive encounters error: time out (%p)...\n", sh);
1231#endif
1232 signal_timeout (sh); 1182 signal_timeout (sh);
1233 return; 1183 return;
1234 } 1184 }
@@ -1385,15 +1335,11 @@ transmit_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1385 struct GNUNET_CONNECTION_Handle *sock = cls; 1335 struct GNUNET_CONNECTION_Handle *sock = cls;
1386 GNUNET_CONNECTION_TransmitReadyNotify notify; 1336 GNUNET_CONNECTION_TransmitReadyNotify notify;
1387 1337
1388#if DEBUG_CONNECTION
1389 LOG (GNUNET_ERROR_TYPE_DEBUG, "transmit_timeout running (%p)\n", sock);
1390#endif
1391 sock->nth.timeout_task = GNUNET_SCHEDULER_NO_TASK; 1338 sock->nth.timeout_task = GNUNET_SCHEDULER_NO_TASK;
1392#if DEBUG_CONNECTION
1393 LOG (GNUNET_ERROR_TYPE_DEBUG, 1339 LOG (GNUNET_ERROR_TYPE_DEBUG,
1394 "Transmit to `%s:%u/%s' fails, time out reached (%p).\n", sock->hostname, 1340 "Transmit to `%s:%u/%s' fails, time out reached (%p).\n",
1341 sock->hostname,
1395 sock->port, GNUNET_a2s (sock->addr, sock->addrlen), sock); 1342 sock->port, GNUNET_a2s (sock->addr, sock->addrlen), sock);
1396#endif
1397 GNUNET_assert (0 != (sock->ccs & COCO_TRANSMIT_READY)); 1343 GNUNET_assert (0 != (sock->ccs & COCO_TRANSMIT_READY));
1398 sock->ccs -= COCO_TRANSMIT_READY; /* remove request */ 1344 sock->ccs -= COCO_TRANSMIT_READY; /* remove request */
1399 notify = sock->nth.notify_ready; 1345 notify = sock->nth.notify_ready;
@@ -1417,11 +1363,9 @@ connect_error (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1417 struct GNUNET_CONNECTION_Handle *sock = cls; 1363 struct GNUNET_CONNECTION_Handle *sock = cls;
1418 GNUNET_CONNECTION_TransmitReadyNotify notify; 1364 GNUNET_CONNECTION_TransmitReadyNotify notify;
1419 1365
1420#if DEBUG_CONNECTION
1421 LOG (GNUNET_ERROR_TYPE_DEBUG, 1366 LOG (GNUNET_ERROR_TYPE_DEBUG,
1422 "Transmission request of size %u fails (%s/%u), connection failed (%p).\n", 1367 "Transmission request of size %u fails (%s/%u), connection failed (%p).\n",
1423 sock->nth.notify_size, sock->hostname, sock->port, sock); 1368 sock->nth.notify_size, sock->hostname, sock->port, sock);
1424#endif
1425 sock->write_task = GNUNET_SCHEDULER_NO_TASK; 1369 sock->write_task = GNUNET_SCHEDULER_NO_TASK;
1426 notify = sock->nth.notify_ready; 1370 notify = sock->nth.notify_ready;
1427 sock->nth.notify_ready = NULL; 1371 sock->nth.notify_ready = NULL;
@@ -1476,9 +1420,7 @@ transmit_ready (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1476 ssize_t ret; 1420 ssize_t ret;
1477 size_t have; 1421 size_t have;
1478 1422
1479#if DEBUG_CONNECTION
1480 LOG (GNUNET_ERROR_TYPE_DEBUG, "transmit_ready running (%p).\n", sock); 1423 LOG (GNUNET_ERROR_TYPE_DEBUG, "transmit_ready running (%p).\n", sock);
1481#endif
1482 GNUNET_assert (sock->write_task != GNUNET_SCHEDULER_NO_TASK); 1424 GNUNET_assert (sock->write_task != GNUNET_SCHEDULER_NO_TASK);
1483 sock->write_task = GNUNET_SCHEDULER_NO_TASK; 1425 sock->write_task = GNUNET_SCHEDULER_NO_TASK;
1484 GNUNET_assert (sock->nth.timeout_task == GNUNET_SCHEDULER_NO_TASK); 1426 GNUNET_assert (sock->nth.timeout_task == GNUNET_SCHEDULER_NO_TASK);
@@ -1486,11 +1428,9 @@ transmit_ready (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1486 { 1428 {
1487 if ((sock->ignore_shutdown == GNUNET_YES) && (NULL != sock->sock)) 1429 if ((sock->ignore_shutdown == GNUNET_YES) && (NULL != sock->sock))
1488 goto SCHEDULE_WRITE; /* ignore shutdown, go again immediately */ 1430 goto SCHEDULE_WRITE; /* ignore shutdown, go again immediately */
1489#if DEBUG_CONNECTION
1490 LOG (GNUNET_ERROR_TYPE_DEBUG, 1431 LOG (GNUNET_ERROR_TYPE_DEBUG,
1491 "Transmit to `%s' fails, shutdown happened (%p).\n", 1432 "Transmit to `%s' fails, shutdown happened (%p).\n",
1492 GNUNET_a2s (sock->addr, sock->addrlen), sock); 1433 GNUNET_a2s (sock->addr, sock->addrlen), sock);
1493#endif
1494 notify = sock->nth.notify_ready; 1434 notify = sock->nth.notify_ready;
1495 if (NULL != notify) 1435 if (NULL != notify)
1496 { 1436 {
@@ -1501,11 +1441,9 @@ transmit_ready (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1501 } 1441 }
1502 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_TIMEOUT)) 1442 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_TIMEOUT))
1503 { 1443 {
1504#if DEBUG_CONNECTION
1505 LOG (GNUNET_ERROR_TYPE_DEBUG, 1444 LOG (GNUNET_ERROR_TYPE_DEBUG,
1506 "Transmit to `%s' fails, time out reached (%p).\n", 1445 "Transmit to `%s' fails, time out reached (%p).\n",
1507 GNUNET_a2s (sock->addr, sock->addrlen), sock); 1446 GNUNET_a2s (sock->addr, sock->addrlen), sock);
1508#endif
1509 notify = sock->nth.notify_ready; 1447 notify = sock->nth.notify_ready;
1510 GNUNET_assert (NULL != notify); 1448 GNUNET_assert (NULL != notify);
1511 sock->nth.notify_ready = NULL; 1449 sock->nth.notify_ready = NULL;
@@ -1522,12 +1460,10 @@ transmit_ready (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1522 } 1460 }
1523 if (!GNUNET_NETWORK_fdset_isset (tc->write_ready, sock->sock)) 1461 if (!GNUNET_NETWORK_fdset_isset (tc->write_ready, sock->sock))
1524 { 1462 {
1525#if DEBUG_CONNECTION
1526 LOG (GNUNET_ERROR_TYPE_INFO, 1463 LOG (GNUNET_ERROR_TYPE_INFO,
1527 _ 1464 _
1528 ("Could not satisfy pending transmission request, socket closed or connect failed (%p).\n"), 1465 ("Could not satisfy pending transmission request, socket closed or connect failed (%p).\n"),
1529 sock); 1466 sock);
1530#endif
1531 transmit_error (sock); 1467 transmit_error (sock);
1532 return; /* connect failed for good, we're finished */ 1468 return; /* connect failed for good, we're finished */
1533 } 1469 }
@@ -1558,23 +1494,13 @@ RETRY:
1558 { 1494 {
1559 if (errno == EINTR) 1495 if (errno == EINTR)
1560 goto RETRY; 1496 goto RETRY;
1561#if 0
1562 int en = errno;
1563
1564 LOG (GNUNET_ERROR_TYPE_ERROR, _("Failed to send to `%s': %s\n"),
1565 GNUNET_a2s (sock->addr, sock->addrlen), STRERROR (en));
1566#endif
1567#if DEBUG_CONNECTION
1568 LOG_STRERROR (GNUNET_ERROR_TYPE_DEBUG, "send"); 1497 LOG_STRERROR (GNUNET_ERROR_TYPE_DEBUG, "send");
1569#endif
1570 transmit_error (sock); 1498 transmit_error (sock);
1571 return; 1499 return;
1572 } 1500 }
1573#if DEBUG_CONNECTION
1574 LOG (GNUNET_ERROR_TYPE_DEBUG, 1501 LOG (GNUNET_ERROR_TYPE_DEBUG,
1575 "transmit_ready transmitted %u/%u bytes to `%s' (%p)\n", 1502 "transmit_ready transmitted %u/%u bytes to `%s' (%p)\n",
1576 (unsigned int) ret, have, GNUNET_a2s (sock->addr, sock->addrlen), sock); 1503 (unsigned int) ret, have, GNUNET_a2s (sock->addr, sock->addrlen), sock);
1577#endif
1578 sock->write_buffer_pos += ret; 1504 sock->write_buffer_pos += ret;
1579 if (sock->write_buffer_pos == sock->write_buffer_off) 1505 if (sock->write_buffer_pos == sock->write_buffer_off)
1580 { 1506 {
@@ -1586,10 +1512,8 @@ RETRY:
1586 return; /* all data sent! */ 1512 return; /* all data sent! */
1587 /* not done writing, schedule more */ 1513 /* not done writing, schedule more */
1588SCHEDULE_WRITE: 1514SCHEDULE_WRITE:
1589#if DEBUG_CONNECTION
1590 LOG (GNUNET_ERROR_TYPE_DEBUG, 1515 LOG (GNUNET_ERROR_TYPE_DEBUG,
1591 "Re-scheduling transmit_ready (more to do) (%p).\n", sock); 1516 "Re-scheduling transmit_ready (more to do) (%p).\n", sock);
1592#endif
1593 have = sock->write_buffer_off - sock->write_buffer_pos; 1517 have = sock->write_buffer_off - sock->write_buffer_pos;
1594 GNUNET_assert ((sock->nth.notify_ready != NULL) || (have > 0)); 1518 GNUNET_assert ((sock->nth.notify_ready != NULL) || (have > 0));
1595 if (sock->write_task == GNUNET_SCHEDULER_NO_TASK) 1519 if (sock->write_task == GNUNET_SCHEDULER_NO_TASK)
@@ -1651,9 +1575,7 @@ GNUNET_CONNECTION_notify_transmit_ready (struct GNUNET_CONNECTION_Handle *sock,
1651 return &sock->nth; 1575 return &sock->nth;
1652 if (sock->sock != NULL) 1576 if (sock->sock != NULL)
1653 { 1577 {
1654#if DEBUG_CONNECTION
1655 LOG (GNUNET_ERROR_TYPE_DEBUG, "Scheduling transmit_ready (%p).\n", sock); 1578 LOG (GNUNET_ERROR_TYPE_DEBUG, "Scheduling transmit_ready (%p).\n", sock);
1656#endif
1657 sock->write_task = 1579 sock->write_task =
1658 GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_absolute_get_remaining 1580 GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_absolute_get_remaining
1659 (sock->nth.transmit_timeout), 1581 (sock->nth.transmit_timeout),
@@ -1661,10 +1583,8 @@ GNUNET_CONNECTION_notify_transmit_ready (struct GNUNET_CONNECTION_Handle *sock,
1661 } 1583 }
1662 else 1584 else
1663 { 1585 {
1664#if DEBUG_CONNECTION
1665 LOG (GNUNET_ERROR_TYPE_DEBUG, 1586 LOG (GNUNET_ERROR_TYPE_DEBUG,
1666 "CCS-Scheduling transmit_ready, adding timeout task (%p).\n", sock); 1587 "CCS-Scheduling transmit_ready, adding timeout task (%p).\n", sock);
1667#endif
1668 sock->ccs |= COCO_TRANSMIT_READY; 1588 sock->ccs |= COCO_TRANSMIT_READY;
1669 sock->nth.timeout_task = 1589 sock->nth.timeout_task =
1670 GNUNET_SCHEDULER_add_delayed (timeout, &transmit_timeout, sock); 1590 GNUNET_SCHEDULER_add_delayed (timeout, &transmit_timeout, sock);
@@ -1686,10 +1606,8 @@ GNUNET_CONNECTION_notify_transmit_ready_cancel (struct
1686 GNUNET_assert (th->notify_ready != NULL); 1606 GNUNET_assert (th->notify_ready != NULL);
1687 if (0 != (th->sh->ccs & COCO_TRANSMIT_READY)) 1607 if (0 != (th->sh->ccs & COCO_TRANSMIT_READY))
1688 { 1608 {
1689#if DEBUG_CONNECTION
1690 LOG (GNUNET_ERROR_TYPE_DEBUG, 1609 LOG (GNUNET_ERROR_TYPE_DEBUG,
1691 "notify_transmit_ready_cancel cancels timeout_task (%p)\n", th); 1610 "notify_transmit_ready_cancel cancels timeout_task (%p)\n", th);
1692#endif
1693 GNUNET_SCHEDULER_cancel (th->timeout_task); 1611 GNUNET_SCHEDULER_cancel (th->timeout_task);
1694 th->timeout_task = GNUNET_SCHEDULER_NO_TASK; 1612 th->timeout_task = GNUNET_SCHEDULER_NO_TASK;
1695 th->sh->ccs -= COCO_TRANSMIT_READY; 1613 th->sh->ccs -= COCO_TRANSMIT_READY;
diff --git a/src/util/network.c b/src/util/network.c
index fb8744af1..e530ab743 100644
--- a/src/util/network.c
+++ b/src/util/network.c
@@ -35,7 +35,6 @@
35 35
36#define DEBUG_NETWORK GNUNET_EXTRA_LOGGING 36#define DEBUG_NETWORK GNUNET_EXTRA_LOGGING
37 37
38#define DEBUG_W32_CYCLES GNUNET_EXTRA_LOGGING
39 38
40#ifndef INVALID_SOCKET 39#ifndef INVALID_SOCKET
41#define INVALID_SOCKET -1 40#define INVALID_SOCKET -1
@@ -46,7 +45,6 @@ struct GNUNET_NETWORK_Handle
46{ 45{
47#ifndef MINGW 46#ifndef MINGW
48 int fd; 47 int fd;
49
50#else 48#else
51 SOCKET fd; 49 SOCKET fd;
52#endif 50#endif
@@ -337,19 +335,13 @@ GNUNET_NETWORK_socket_close (struct GNUNET_NETWORK_Handle *desc)
337#ifdef MINGW 335#ifdef MINGW
338 DWORD error = 0; 336 DWORD error = 0;
339 337
340#if DEBUG_NETWORK
341 LOG (GNUNET_ERROR_TYPE_DEBUG, "Closing 0x%x\n",
342 desc->fd);
343#endif
344 SetLastError (0); 338 SetLastError (0);
345 ret = closesocket (desc->fd); 339 ret = closesocket (desc->fd);
346 error = WSAGetLastError (); 340 error = WSAGetLastError ();
347 SetErrnoFromWinsockError (error); 341 SetErrnoFromWinsockError (error);
348#if DEBUG_NETWORK
349 LOG (GNUNET_ERROR_TYPE_DEBUG, 342 LOG (GNUNET_ERROR_TYPE_DEBUG,
350 "Closed 0x%x, closesocket() returned %d, GLE is %u\n", desc->fd, ret, 343 "Closed 0x%x, closesocket() returned %d, GLE is %u\n", desc->fd, ret,
351 error); 344 error);
352#endif
353#else 345#else
354 ret = close (desc->fd); 346 ret = close (desc->fd);
355#endif 347#endif
@@ -1301,40 +1293,32 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds,
1301 if (fh->type == GNUNET_PIPE) 1293 if (fh->type == GNUNET_PIPE)
1302 { 1294 {
1303 /* Read zero bytes to check the status of the pipe */ 1295 /* Read zero bytes to check the status of the pipe */
1304#if DEBUG_NETWORK
1305 LOG (GNUNET_ERROR_TYPE_DEBUG, "Reading 0 bytes from the pipe 0x%x\n", 1296 LOG (GNUNET_ERROR_TYPE_DEBUG, "Reading 0 bytes from the pipe 0x%x\n",
1306 fh->h); 1297 fh->h);
1307#endif
1308 if (!ReadFile (fh->h, NULL, 0, NULL, fh->oOverlapRead)) 1298 if (!ReadFile (fh->h, NULL, 0, NULL, fh->oOverlapRead))
1309 { 1299 {
1310 DWORD error_code = GetLastError (); 1300 DWORD error_code = GetLastError ();
1311 1301
1312 if (error_code == ERROR_IO_PENDING) 1302 if (error_code == ERROR_IO_PENDING)
1313 { 1303 {
1314#if DEBUG_NETWORK
1315 LOG (GNUNET_ERROR_TYPE_DEBUG, 1304 LOG (GNUNET_ERROR_TYPE_DEBUG,
1316 "Adding the pipe's 0x%x overlapped event to the array as %d\n", 1305 "Adding the pipe's 0x%x overlapped event to the array as %d\n",
1317 fh->h, nhandles); 1306 fh->h, nhandles);
1318#endif
1319 handle_array[nhandles++] = fh->oOverlapRead->hEvent; 1307 handle_array[nhandles++] = fh->oOverlapRead->hEvent;
1320 readArray[readPipes++] = fh; 1308 readArray[readPipes++] = fh;
1321 } 1309 }
1322 else 1310 else
1323 { 1311 {
1324#if DEBUG_NETWORK
1325 LOG (GNUNET_ERROR_TYPE_DEBUG, 1312 LOG (GNUNET_ERROR_TYPE_DEBUG,
1326 "Read failed, adding the read ready event to the array as %d\n", nhandles); 1313 "Read failed, adding the read ready event to the array as %d\n", nhandles);
1327#endif
1328 handle_array[nhandles++] = hEventReadReady; 1314 handle_array[nhandles++] = hEventReadReady;
1329 readArray[readPipes++] = fh; 1315 readArray[readPipes++] = fh;
1330 } 1316 }
1331 } 1317 }
1332 else 1318 else
1333 { 1319 {
1334#if DEBUG_NETWORK
1335 LOG (GNUNET_ERROR_TYPE_DEBUG, 1320 LOG (GNUNET_ERROR_TYPE_DEBUG,
1336 "Adding the read ready event to the array as %d\n", nhandles); 1321 "Adding the read ready event to the array as %d\n", nhandles);
1337#endif
1338 handle_array[nhandles++] = hEventReadReady; 1322 handle_array[nhandles++] = hEventReadReady;
1339 readArray[readPipes++] = fh; 1323 readArray[readPipes++] = fh;
1340 } 1324 }
@@ -1349,10 +1333,8 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds,
1349 } 1333 }
1350 if (wfds && write_handles) 1334 if (wfds && write_handles)
1351 { 1335 {
1352#if DEBUG_NETWORK
1353 LOG (GNUNET_ERROR_TYPE_DEBUG, 1336 LOG (GNUNET_ERROR_TYPE_DEBUG,
1354 "Adding the write ready event to the array as %d\n", nhandles); 1337 "Adding the write ready event to the array as %d\n", nhandles);
1355#endif
1356 handle_array[nhandles++] = hEventPipeWrite; 1338 handle_array[nhandles++] = hEventPipeWrite;
1357 writePipePos = nhandles; 1339 writePipePos = nhandles;
1358 } 1340 }
@@ -1386,10 +1368,8 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds,
1386 { 1368 {
1387 if (rfds) 1369 if (rfds)
1388 { 1370 {
1389#if DEBUG_NETWORK
1390 LOG (GNUNET_ERROR_TYPE_DEBUG, 1371 LOG (GNUNET_ERROR_TYPE_DEBUG,
1391 "Adding the socket read event to the array as %d\n", nhandles); 1372 "Adding the socket read event to the array as %d\n", nhandles);
1392#endif
1393 handle_array[nhandles++] = hEventRead; 1373 handle_array[nhandles++] = hEventRead;
1394 nSockEvents++; 1374 nSockEvents++;
1395 for (i = 0; i < rfds->sds.fd_count; i++) 1375 for (i = 0; i < rfds->sds.fd_count; i++)
@@ -1403,10 +1383,8 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds,
1403 { 1383 {
1404 int wakeup = 0; 1384 int wakeup = 0;
1405 1385
1406#if DEBUG_NETWORK
1407 LOG (GNUNET_ERROR_TYPE_DEBUG, 1386 LOG (GNUNET_ERROR_TYPE_DEBUG,
1408 "Adding the socket write event to the array as %d\n", nhandles); 1387 "Adding the socket write event to the array as %d\n", nhandles);
1409#endif
1410 handle_array[nhandles++] = hEventWrite; 1388 handle_array[nhandles++] = hEventWrite;
1411 nSockEvents++; 1389 nSockEvents++;
1412 for (i = 0; i < wfds->sds.fd_count; i++) 1390 for (i = 0; i < wfds->sds.fd_count; i++)
@@ -1416,10 +1394,8 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds,
1416 1394
1417 status = send (wfds->sds.fd_array[i], NULL, 0, 0); 1395 status = send (wfds->sds.fd_array[i], NULL, 0, 0);
1418 error = GetLastError (); 1396 error = GetLastError ();
1419#if DEBUG_NETWORK
1420 LOG (GNUNET_ERROR_TYPE_DEBUG, 1397 LOG (GNUNET_ERROR_TYPE_DEBUG,
1421 "pre-send to the socket %d returned %d (%u)\n", i, status, error); 1398 "pre-send to the socket %d returned %d (%u)\n", i, status, error);
1422#endif
1423 if (status == 0 || (error != WSAEWOULDBLOCK && error != WSAENOTCONN)) 1399 if (status == 0 || (error != WSAEWOULDBLOCK && error != WSAENOTCONN))
1424 wakeup = 1; 1400 wakeup = 1;
1425 WSAEventSelect (wfds->sds.fd_array[i], hEventWrite, 1401 WSAEventSelect (wfds->sds.fd_array[i], hEventWrite,
@@ -1431,10 +1407,8 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds,
1431 } 1407 }
1432 if (efds) 1408 if (efds)
1433 { 1409 {
1434#if DEBUG_NETWORK
1435 LOG (GNUNET_ERROR_TYPE_DEBUG, 1410 LOG (GNUNET_ERROR_TYPE_DEBUG,
1436 "Adding the socket error event to the array as %d\n", nhandles); 1411 "Adding the socket error event to the array as %d\n", nhandles);
1437#endif
1438 handle_array[nhandles++] = hEventException; 1412 handle_array[nhandles++] = hEventException;
1439 nSockEvents++; 1413 nSockEvents++;
1440 for (i = 0; i < efds->sds.fd_count; i++) 1414 for (i = 0; i < efds->sds.fd_count; i++)
@@ -1464,9 +1438,7 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds,
1464#endif 1438#endif
1465 1439
1466 returnedpos = returncode - WAIT_OBJECT_0; 1440 returnedpos = returncode - WAIT_OBJECT_0;
1467#if DEBUG_NETWORK
1468 LOG (GNUNET_ERROR_TYPE_DEBUG, "return pos is : %d\n", returnedpos); 1441 LOG (GNUNET_ERROR_TYPE_DEBUG, "return pos is : %d\n", returnedpos);
1469#endif
1470 1442
1471 /* FIXME: THIS LINE IS WRONG !! We should add to handles only handles that fired the events, not all ! */ 1443 /* FIXME: THIS LINE IS WRONG !! We should add to handles only handles that fired the events, not all ! */
1472 /* 1444 /*
@@ -1487,22 +1459,16 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds,
1487 retcode = select (nfds, &aread, &awrite, &aexcept, &tvslice); 1459 retcode = select (nfds, &aread, &awrite, &aexcept, &tvslice);
1488 if (retcode == -1) 1460 if (retcode == -1)
1489 retcode = 0; 1461 retcode = 0;
1490#if DEBUG_NETWORK
1491 LOG (GNUNET_ERROR_TYPE_DEBUG, "Select retcode : %d\n", retcode); 1462 LOG (GNUNET_ERROR_TYPE_DEBUG, "Select retcode : %d\n", retcode);
1492#endif
1493 } 1463 }
1494 /* FIXME: <= writePipePos? Really? */ 1464 /* FIXME: <= writePipePos? Really? */
1495 if ((writePipePos != -1) && (returnedpos <= writePipePos)) 1465 if ((writePipePos != -1) && (returnedpos <= writePipePos))
1496 { 1466 {
1497 GNUNET_CONTAINER_slist_append (handles_write, wfds->handles); 1467 GNUNET_CONTAINER_slist_append (handles_write, wfds->handles);
1498 retcode += write_handles; 1468 retcode += write_handles;
1499#if DEBUG_NETWORK
1500 LOG (GNUNET_ERROR_TYPE_DEBUG, "Added write pipe\n"); 1469 LOG (GNUNET_ERROR_TYPE_DEBUG, "Added write pipe\n");
1501#endif
1502 } 1470 }
1503#if DEBUG_NETWORK
1504 LOG (GNUNET_ERROR_TYPE_DEBUG, "ReadPipes is : %d\n", readPipes); 1471 LOG (GNUNET_ERROR_TYPE_DEBUG, "ReadPipes is : %d\n", readPipes);
1505#endif
1506 /* We have some pipes ready for read. */ 1472 /* We have some pipes ready for read. */
1507 /* FIXME: it is supposed to work !! Only choose the Pipes who fired the event, but it is not working */ 1473 /* FIXME: it is supposed to work !! Only choose the Pipes who fired the event, but it is not working */
1508 1474
@@ -1532,11 +1498,9 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds,
1532 bret = 1498 bret =
1533 PeekNamedPipe (readArray[i]->h, NULL, 0, NULL, &waitstatus, NULL); 1499 PeekNamedPipe (readArray[i]->h, NULL, 0, NULL, &waitstatus, NULL);
1534 error = GetLastError (); 1500 error = GetLastError ();
1535#if DEBUG_NETWORK
1536 LOG (GNUNET_ERROR_TYPE_DEBUG, 1501 LOG (GNUNET_ERROR_TYPE_DEBUG,
1537 "Peek at read pipe %d (0x%x) returned %d (%d bytes available) GLE %u\n", 1502 "Peek at read pipe %d (0x%x) returned %d (%d bytes available) GLE %u\n",
1538 i, readArray[i]->h, bret, waitstatus, error); 1503 i, readArray[i]->h, bret, waitstatus, error);
1539#endif
1540 if (bret == 0) 1504 if (bret == 0)
1541 { 1505 {
1542 if (error != ERROR_BROKEN_PIPE) 1506 if (error != ERROR_BROKEN_PIPE)
@@ -1549,17 +1513,13 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds,
1549 readArray[i], 1513 readArray[i],
1550 sizeof (struct GNUNET_DISK_FileHandle)); 1514 sizeof (struct GNUNET_DISK_FileHandle));
1551 retcode++; 1515 retcode++;
1552#if DEBUG_NETWORK
1553 LOG (GNUNET_ERROR_TYPE_DEBUG, "Added read Pipe 0x%x (0x%x)\n", 1516 LOG (GNUNET_ERROR_TYPE_DEBUG, "Added read Pipe 0x%x (0x%x)\n",
1554 readArray[i], readArray[i]->h); 1517 readArray[i], readArray[i]->h);
1555#endif
1556 } 1518 }
1557 } 1519 }
1558 waitstatus = WaitForSingleObject (hEventWrite, 0); 1520 waitstatus = WaitForSingleObject (hEventWrite, 0);
1559#if DEBUG_NETWORK
1560 LOG (GNUNET_ERROR_TYPE_DEBUG, "Wait for the write event returned %d\n", 1521 LOG (GNUNET_ERROR_TYPE_DEBUG, "Wait for the write event returned %d\n",
1561 waitstatus); 1522 waitstatus);
1562#endif
1563 if (waitstatus == WAIT_OBJECT_0) 1523 if (waitstatus == WAIT_OBJECT_0)
1564 { 1524 {
1565 for (i = 0; i < wfds->sds.fd_count; i++) 1525 for (i = 0; i < wfds->sds.fd_count; i++)
@@ -1574,10 +1534,8 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds,
1574 1534
1575 status = send (wfds->sds.fd_array[i], NULL, 0, 0); 1535 status = send (wfds->sds.fd_array[i], NULL, 0, 0);
1576 error = GetLastError (); 1536 error = GetLastError ();
1577#if DEBUG_NETWORK
1578 LOG (GNUNET_ERROR_TYPE_DEBUG, 1537 LOG (GNUNET_ERROR_TYPE_DEBUG,
1579 "send to the socket %d returned %d (%u)\n", i, status, error); 1538 "send to the socket %d returned %d (%u)\n", i, status, error);
1580#endif
1581 if (status == 0 || (error != WSAEWOULDBLOCK && error != WSAENOTCONN) || 1539 if (status == 0 || (error != WSAEWOULDBLOCK && error != WSAENOTCONN) ||
1582 (status == -1 && gso_result == 0 && error == WSAENOTCONN && 1540 (status == -1 && gso_result == 0 && error == WSAENOTCONN &&
1583 so_error == WSAECONNREFUSED)) 1541 so_error == WSAECONNREFUSED))
@@ -1614,9 +1572,7 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds,
1614 CancelIo (fh->h); 1572 CancelIo (fh->h);
1615 } 1573 }
1616 } 1574 }
1617#if DEBUG_NETWORK
1618 LOG (GNUNET_ERROR_TYPE_DEBUG, "Zeroing rfds\n"); 1575 LOG (GNUNET_ERROR_TYPE_DEBUG, "Zeroing rfds\n");
1619#endif
1620 GNUNET_NETWORK_fdset_zero (rfds); 1576 GNUNET_NETWORK_fdset_zero (rfds);
1621 if (retcode != -1 && nhandles && (returnedpos < nhandles)) 1577 if (retcode != -1 && nhandles && (returnedpos < nhandles))
1622 GNUNET_NETWORK_fdset_copy_native (rfds, &aread, retcode); 1578 GNUNET_NETWORK_fdset_copy_native (rfds, &aread, retcode);
@@ -1629,9 +1585,7 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds,
1629 WSAEventSelect (wfds->sds.fd_array[i], hEventWrite, 0); 1585 WSAEventSelect (wfds->sds.fd_array[i], hEventWrite, 0);
1630 nsock++; 1586 nsock++;
1631 } 1587 }
1632#if DEBUG_NETWORK
1633 LOG (GNUNET_ERROR_TYPE_DEBUG, "Zeroing wfds\n"); 1588 LOG (GNUNET_ERROR_TYPE_DEBUG, "Zeroing wfds\n");
1634#endif
1635 GNUNET_NETWORK_fdset_zero (wfds); 1589 GNUNET_NETWORK_fdset_zero (wfds);
1636 if (retcode != -1 && nhandles && (returnedpos < nhandles)) 1590 if (retcode != -1 && nhandles && (returnedpos < nhandles))
1637 GNUNET_NETWORK_fdset_copy_native (wfds, &awrite, retcode); 1591 GNUNET_NETWORK_fdset_copy_native (wfds, &awrite, retcode);
@@ -1644,9 +1598,7 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds,
1644 WSAEventSelect (efds->sds.fd_array[i], hEventException, 0); 1598 WSAEventSelect (efds->sds.fd_array[i], hEventException, 0);
1645 nsock++; 1599 nsock++;
1646 } 1600 }
1647#if DEBUG_NETWORK
1648 LOG (GNUNET_ERROR_TYPE_DEBUG, "Zeroing efds\n"); 1601 LOG (GNUNET_ERROR_TYPE_DEBUG, "Zeroing efds\n");
1649#endif
1650 GNUNET_NETWORK_fdset_zero (efds); 1602 GNUNET_NETWORK_fdset_zero (efds);
1651 if (retcode != -1 && nhandles && (returnedpos < nhandles)) 1603 if (retcode != -1 && nhandles && (returnedpos < nhandles))
1652 GNUNET_NETWORK_fdset_copy_native (efds, &aexcept, retcode); 1604 GNUNET_NETWORK_fdset_copy_native (efds, &aexcept, retcode);
diff --git a/src/util/scheduler.c b/src/util/scheduler.c
index 412896946..f1cecd4ef 100644
--- a/src/util/scheduler.c
+++ b/src/util/scheduler.c
@@ -30,14 +30,15 @@
30#include "gnunet_signal_lib.h" 30#include "gnunet_signal_lib.h"
31#include "gnunet_time_lib.h" 31#include "gnunet_time_lib.h"
32#include "disk.h" 32#include "disk.h"
33#define LOG(kind,...) GNUNET_log_from (kind, "util", __VA_ARGS__)
34 33
35#define LOG_STRERROR(kind,syscall) GNUNET_log_from_strerror (kind, "util", syscall) 34#define LOG(kind,...) GNUNET_log_from (kind, "util-scheduler", __VA_ARGS__)
36#ifdef LINUX
37#include "execinfo.h"
38 35
36#define LOG_STRERROR(kind,syscall) GNUNET_log_from_strerror (kind, "util-scheduler", syscall)
39 37
40 38
39#ifdef LINUX
40#include "execinfo.h"
41
41/** 42/**
42 * Use lsof to generate file descriptor reports on select error? 43 * Use lsof to generate file descriptor reports on select error?
43 * (turn off for stable releases). 44 * (turn off for stable releases).
@@ -52,7 +53,7 @@
52/** 53/**
53 * Check each file descriptor before adding 54 * Check each file descriptor before adding
54 */ 55 */
55#define DEBUG_FDS GNUNET_EXTRA_LOGGING 56#define DEBUG_FDS GNUNET_NO
56 57
57/** 58/**
58 * Depth of the traces collected via EXECINFO. 59 * Depth of the traces collected via EXECINFO.
@@ -60,8 +61,6 @@
60#define MAX_TRACE_DEPTH 50 61#define MAX_TRACE_DEPTH 50
61#endif 62#endif
62 63
63#define DEBUG_TASKS GNUNET_EXTRA_LOGGING
64
65/** 64/**
66 * Should we figure out which tasks are delayed for a while 65 * Should we figure out which tasks are delayed for a while
67 * before they are run? (Consider using in combination with EXECINFO). 66 * before they are run? (Consider using in combination with EXECINFO).
@@ -74,6 +73,7 @@
74 */ 73 */
75#define DELAY_THRESHOLD GNUNET_TIME_UNIT_SECONDS 74#define DELAY_THRESHOLD GNUNET_TIME_UNIT_SECONDS
76 75
76
77/** 77/**
78 * Linked list of pending tasks. 78 * Linked list of pending tasks.
79 */ 79 */
@@ -526,10 +526,9 @@ check_ready (const struct GNUNET_NETWORK_FDSet *rs,
526 pos = pending; 526 pos = pending;
527 while (pos != NULL) 527 while (pos != NULL)
528 { 528 {
529#if DEBUG_TASKS 529 LOG (GNUNET_ERROR_TYPE_DEBUG,
530 LOG (GNUNET_ERROR_TYPE_DEBUG, "Checking readiness of task: %llu / %p\n", 530 "Checking readiness of task: %llu / %p\n",
531 pos->id, pos->callback_cls); 531 pos->id, pos->callback_cls);
532#endif
533 next = pos->next; 532 next = pos->next;
534 if (GNUNET_YES == is_ready (pos, now, rs, ws)) 533 if (GNUNET_YES == is_ready (pos, now, rs, ws))
535 { 534 {
@@ -677,10 +676,9 @@ run_ready (struct GNUNET_NETWORK_FDSet *rs, struct GNUNET_NETWORK_FDSet *ws)
677 (pos->write_fd != -1) && 676 (pos->write_fd != -1) &&
678 (!GNUNET_NETWORK_fdset_test_native (ws, pos->write_fd))) 677 (!GNUNET_NETWORK_fdset_test_native (ws, pos->write_fd)))
679 GNUNET_abort (); // added to ready in previous select loop! 678 GNUNET_abort (); // added to ready in previous select loop!
680#if DEBUG_TASKS 679 LOG (GNUNET_ERROR_TYPE_DEBUG,
681 LOG (GNUNET_ERROR_TYPE_DEBUG, "Running task: %llu / %p\n", pos->id, 680 "Running task: %llu / %p\n", pos->id,
682 pos->callback_cls); 681 pos->callback_cls);
683#endif
684 pos->callback (pos->callback_cls, &tc); 682 pos->callback (pos->callback_cls, &tc);
685#if EXECINFO 683#if EXECINFO
686 int i; 684 int i;
@@ -1037,10 +1035,8 @@ GNUNET_SCHEDULER_cancel (GNUNET_SCHEDULER_TaskIdentifier task)
1037 prev->next = t->next; 1035 prev->next = t->next;
1038 } 1036 }
1039 ret = t->callback_cls; 1037 ret = t->callback_cls;
1040#if DEBUG_TASKS
1041 LOG (GNUNET_ERROR_TYPE_DEBUG, "Canceling task: %llu / %p\n", task, 1038 LOG (GNUNET_ERROR_TYPE_DEBUG, "Canceling task: %llu / %p\n", task,
1042 t->callback_cls); 1039 t->callback_cls);
1043#endif
1044 destroy_task (t); 1040 destroy_task (t);
1045 return ret; 1041 return ret;
1046} 1042}
@@ -1087,10 +1083,8 @@ GNUNET_SCHEDULER_add_continuation_with_priority (GNUNET_SCHEDULER_Task task, voi
1087 t->reason = reason; 1083 t->reason = reason;
1088 t->priority = priority; 1084 t->priority = priority;
1089 t->lifeness = current_lifeness; 1085 t->lifeness = current_lifeness;
1090#if DEBUG_TASKS
1091 LOG (GNUNET_ERROR_TYPE_DEBUG, "Adding continuation task: %llu / %p\n", t->id, 1086 LOG (GNUNET_ERROR_TYPE_DEBUG, "Adding continuation task: %llu / %p\n", t->id,
1092 t->callback_cls); 1087 t->callback_cls);
1093#endif
1094 queue_ready_task (t); 1088 queue_ready_task (t);
1095} 1089}
1096 1090
@@ -1233,10 +1227,8 @@ GNUNET_SCHEDULER_add_delayed_with_priority (struct GNUNET_TIME_Relative delay,
1233 /* hyper-optimization... */ 1227 /* hyper-optimization... */
1234 pending_timeout_last = t; 1228 pending_timeout_last = t;
1235 1229
1236#if DEBUG_TASKS
1237 LOG (GNUNET_ERROR_TYPE_DEBUG, "Adding task: %llu / %p\n", t->id, 1230 LOG (GNUNET_ERROR_TYPE_DEBUG, "Adding task: %llu / %p\n", t->id,
1238 t->callback_cls); 1231 t->callback_cls);
1239#endif
1240#if EXECINFO 1232#if EXECINFO
1241 int i; 1233 int i;
1242 1234
@@ -1416,10 +1408,8 @@ add_without_sets (struct GNUNET_TIME_Relative delay,
1416 t->next = pending; 1408 t->next = pending;
1417 pending = t; 1409 pending = t;
1418 max_priority_added = GNUNET_MAX (max_priority_added, t->priority); 1410 max_priority_added = GNUNET_MAX (max_priority_added, t->priority);
1419#if DEBUG_TASKS
1420 LOG (GNUNET_ERROR_TYPE_DEBUG, "Adding task: %llu / %p\n", t->id, 1411 LOG (GNUNET_ERROR_TYPE_DEBUG, "Adding task: %llu / %p\n", t->id,
1421 t->callback_cls); 1412 t->callback_cls);
1422#endif
1423#if EXECINFO 1413#if EXECINFO
1424 int i; 1414 int i;
1425 1415
@@ -1693,10 +1683,8 @@ GNUNET_SCHEDULER_add_select (enum GNUNET_SCHEDULER_Priority prio,
1693 t->next = pending; 1683 t->next = pending;
1694 pending = t; 1684 pending = t;
1695 max_priority_added = GNUNET_MAX (max_priority_added, t->priority); 1685 max_priority_added = GNUNET_MAX (max_priority_added, t->priority);
1696#if DEBUG_TASKS
1697 LOG (GNUNET_ERROR_TYPE_DEBUG, "Adding task: %llu / %p\n", t->id, 1686 LOG (GNUNET_ERROR_TYPE_DEBUG, "Adding task: %llu / %p\n", t->id,
1698 t->callback_cls); 1687 t->callback_cls);
1699#endif
1700#if EXECINFO 1688#if EXECINFO
1701 int i; 1689 int i;
1702 1690