aboutsummaryrefslogtreecommitdiff
path: root/src/lib/eventloop.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/eventloop.c')
-rw-r--r--src/lib/eventloop.c35
1 files changed, 19 insertions, 16 deletions
diff --git a/src/lib/eventloop.c b/src/lib/eventloop.c
index 67a78f50..c013a556 100644
--- a/src/lib/eventloop.c
+++ b/src/lib/eventloop.c
@@ -25,6 +25,7 @@
25 */ 25 */
26#include "gnunet_gtk.h" 26#include "gnunet_gtk.h"
27 27
28#define DEBUG_EVENTLOOP GNUNET_YES
28 29
29/** 30/**
30 * Initial size of our poll array cache. 31 * Initial size of our poll array cache.
@@ -239,6 +240,8 @@ keepalive_task (void *cls,
239{ 240{
240 struct GNUNET_GTK_MainLoop *ml = cls; 241 struct GNUNET_GTK_MainLoop *ml = cls;
241 242
243 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
244 "Dummy task was scheduled\n");
242 ml->dummy_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, 245 ml->dummy_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
243 &keepalive_task, 246 &keepalive_task,
244 ml); 247 ml);
@@ -391,7 +394,7 @@ gnunet_gtk_select (void *cls,
391 DWORD error_code = GetLastError(); 394 DWORD error_code = GetLastError();
392 if (error_code == ERROR_IO_PENDING) 395 if (error_code == ERROR_IO_PENDING)
393 { 396 {
394#if DEBUG_NETWORK 397#if DEBUG_EVENTLOOP
395 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 398 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
396 "Adding the pipe's 0x%x overlapped event to the array as %d\n", 399 "Adding the pipe's 0x%x overlapped event to the array as %d\n",
397 fh->h, nhandles); 400 fh->h, nhandles);
@@ -417,7 +420,7 @@ gnunet_gtk_select (void *cls,
417 } 420 }
418 else 421 else
419 { 422 {
420#if DEBUG_NETWORK 423#if DEBUG_EVENTLOOP
421 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 424 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
422 "Adding the read ready event to the array as %d\n", 425 "Adding the read ready event to the array as %d\n",
423 nhandles); 426 nhandles);
@@ -470,7 +473,7 @@ gnunet_gtk_select (void *cls,
470 473
471 if ( (rfds != NULL) && (rfds->sds.fd_count > 0) ) 474 if ( (rfds != NULL) && (rfds->sds.fd_count > 0) )
472 { 475 {
473#if DEBUG_NETWORK 476#if DEBUG_EVENTLOOP
474 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 477 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
475 "Adding the socket read event to the array as %d\n", 478 "Adding the socket read event to the array as %d\n",
476 fd_counter); 479 fd_counter);
@@ -485,7 +488,7 @@ gnunet_gtk_select (void *cls,
485 if ( (wfds != NULL) && (wfds->sds.fd_count > 0) ) 488 if ( (wfds != NULL) && (wfds->sds.fd_count > 0) )
486 { 489 {
487 int wakeup = 0; 490 int wakeup = 0;
488#if DEBUG_NETWORK 491#if DEBUG_EVENTLOOP
489 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 492 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
490 "Adding the socket write event to the array as %d\n", 493 "Adding the socket write event to the array as %d\n",
491 fd_counter); 494 fd_counter);
@@ -498,7 +501,7 @@ gnunet_gtk_select (void *cls,
498 int status; 501 int status;
499 status = send (wfds->sds.fd_array[i], NULL, 0, 0); 502 status = send (wfds->sds.fd_array[i], NULL, 0, 0);
500 error = GetLastError (); 503 error = GetLastError ();
501#if DEBUG_NETWORK 504#if DEBUG_EVENTLOOP
502 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 505 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
503 "pre-send to the socket %d returned %d (%u)\n", 506 "pre-send to the socket %d returned %d (%u)\n",
504 i, status, error); 507 i, status, error);
@@ -514,7 +517,7 @@ gnunet_gtk_select (void *cls,
514 } 517 }
515 if ( (efds != NULL) && (efds->sds.fd_count > 0) ) 518 if ( (efds != NULL) && (efds->sds.fd_count > 0) )
516 { 519 {
517#if DEBUG_NETWORK 520#if DEBUG_EVENTLOOP
518 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 521 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
519 "Adding the socket error event to the array as %d\n", 522 "Adding the socket error event to the array as %d\n",
520 fd_counter); 523 fd_counter);
@@ -540,7 +543,7 @@ gnunet_gtk_select (void *cls,
540 &delay, 543 &delay,
541 &ml->cached_poll_array[fd_counter], 544 &ml->cached_poll_array[fd_counter],
542 ml->cached_poll_array_size - fd_counter); 545 ml->cached_poll_array_size - fd_counter);
543 if (ml->cached_poll_array_size < need_gfds + fd_counter) 546 if (ml->cached_poll_array_size >= need_gfds + fd_counter)
544 break; 547 break;
545 resize_cached_poll_array (ml, 548 resize_cached_poll_array (ml,
546 fd_counter + need_gfds); 549 fd_counter + need_gfds);
@@ -558,7 +561,7 @@ gnunet_gtk_select (void *cls,
558#if WINDOWS 561#if WINDOWS
559 if (pre_ret > 0) 562 if (pre_ret > 0)
560 { 563 {
561#if DEBUG_NETWORK 564#if DEBUG_EVENTLOOP
562 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 565 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
563 "pre_ret is %d, setting delay to 0\n", 566 "pre_ret is %d, setting delay to 0\n",
564 pre_ret); 567 pre_ret);
@@ -567,7 +570,7 @@ gnunet_gtk_select (void *cls,
567 } 570 }
568#endif 571#endif
569 572
570#if DEBUG_NETWORK 573#if DEBUG_EVENTLOOP
571 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 574 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
572 "We have %d of our FDs and %d of GMC ones, going to wait %6dms\n", 575 "We have %d of our FDs and %d of GMC ones, going to wait %6dms\n",
573 fd_counter, need_gfds, delay); 576 fd_counter, need_gfds, delay);
@@ -576,7 +579,7 @@ gnunet_gtk_select (void *cls,
576 poll_result = g_poll (ml->cached_poll_array, 579 poll_result = g_poll (ml->cached_poll_array,
577 fd_counter + need_gfds, 580 fd_counter + need_gfds,
578 delay); 581 delay);
579#if DEBUG_NETWORK 582#if DEBUG_EVENTLOOP
580 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 583 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
581 "g_poll returned : %d\n", 584 "g_poll returned : %d\n",
582 poll_result); 585 poll_result);
@@ -630,7 +633,7 @@ gnunet_gtk_select (void *cls,
630 select_ret = select (max_nfds, &aread, &awrite, &aexcept, &tvslice); 633 select_ret = select (max_nfds, &aread, &awrite, &aexcept, &tvslice);
631 if (select_ret == -1) 634 if (select_ret == -1)
632 select_ret = 0; 635 select_ret = 0;
633#if DEBUG_NETWORK 636#if DEBUG_EVENTLOOP
634 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 637 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
635 "select() returned %d\n", 638 "select() returned %d\n",
636 select_ret); 639 select_ret);
@@ -640,7 +643,7 @@ gnunet_gtk_select (void *cls,
640 { 643 {
641 GNUNET_CONTAINER_slist_append (ml->handles_write, wfds->handles); 644 GNUNET_CONTAINER_slist_append (ml->handles_write, wfds->handles);
642 result += GNUNET_CONTAINER_slist_count (ml->handles_write); 645 result += GNUNET_CONTAINER_slist_count (ml->handles_write);
643#if DEBUG_NETWORK 646#if DEBUG_EVENTLOOP
644 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Added write pipe\n"); 647 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Added write pipe\n");
645#endif 648#endif
646 } 649 }
@@ -654,7 +657,7 @@ gnunet_gtk_select (void *cls,
654 waitstatus = 0; 657 waitstatus = 0;
655 bret = PeekNamedPipe (ml->read_array[i]->h, NULL, 0, NULL, &waitstatus, NULL); 658 bret = PeekNamedPipe (ml->read_array[i]->h, NULL, 0, NULL, &waitstatus, NULL);
656 error = GetLastError (); 659 error = GetLastError ();
657#if DEBUG_NETWORK 660#if DEBUG_EVENTLOOP
658 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 661 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
659 "Peek at read pipe %d (0x%x) returned %d (%d bytes available) GLE %u\n", 662 "Peek at read pipe %d (0x%x) returned %d (%d bytes available) GLE %u\n",
660 i, ml->read_array[i]->h, bret, waitstatus, error); 663 i, ml->read_array[i]->h, bret, waitstatus, error);
@@ -686,7 +689,7 @@ gnunet_gtk_select (void *cls,
686 GNUNET_CONTAINER_SLIST_DISPOSITION_TRANSIENT, 689 GNUNET_CONTAINER_SLIST_DISPOSITION_TRANSIENT,
687 ml->read_array[i], sizeof (struct GNUNET_DISK_FileHandle)); 690 ml->read_array[i], sizeof (struct GNUNET_DISK_FileHandle));
688 result += 1; 691 result += 1;
689#if DEBUG_NETWORK 692#if DEBUG_EVENTLOOP
690 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 693 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
691 "Added read Pipe 0x%x (0x%x)\n", 694 "Added read Pipe 0x%x (0x%x)\n",
692 ml->read_array[i], 695 ml->read_array[i],
@@ -694,7 +697,7 @@ gnunet_gtk_select (void *cls,
694#endif 697#endif
695 } 698 }
696 waitstatus = WaitForSingleObject (ml->hEventWrite, 0); 699 waitstatus = WaitForSingleObject (ml->hEventWrite, 0);
697#if DEBUG_NETWORK 700#if DEBUG_EVENTLOOP
698 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 701 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
699 "Wait for the write event returned %d\n", 702 "Wait for the write event returned %d\n",
700 waitstatus); 703 waitstatus);
@@ -712,7 +715,7 @@ gnunet_gtk_select (void *cls,
712 (char *) &so_error, &sizeof_so_error); 715 (char *) &so_error, &sizeof_so_error);
713 status = send (wfds->sds.fd_array[i], NULL, 0, 0); 716 status = send (wfds->sds.fd_array[i], NULL, 0, 0);
714 error = GetLastError (); 717 error = GetLastError ();
715#if DEBUG_NETWORK 718#if DEBUG_EVENTLOOP
716 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 719 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
717 "send to the socket %d returned %d (%u)\n", 720 "send to the socket %d returned %d (%u)\n",
718 i, status, error); 721 i, status, error);