diff options
Diffstat (limited to 'src/lib/eventloop.c')
-rw-r--r-- | src/lib/eventloop.c | 32 |
1 files changed, 0 insertions, 32 deletions
diff --git a/src/lib/eventloop.c b/src/lib/eventloop.c index 5ef2282b..be76dddb 100644 --- a/src/lib/eventloop.c +++ b/src/lib/eventloop.c | |||
@@ -25,7 +25,6 @@ | |||
25 | */ | 25 | */ |
26 | #include "gnunet_gtk.h" | 26 | #include "gnunet_gtk.h" |
27 | 27 | ||
28 | #define DEBUG_EVENTLOOP GNUNET_NO | ||
29 | 28 | ||
30 | /** | 29 | /** |
31 | * Initial size of our poll array cache. | 30 | * Initial size of our poll array cache. |
@@ -437,11 +436,9 @@ gnunet_gtk_select (void *cls, struct GNUNET_NETWORK_FDSet *rfds, | |||
437 | 436 | ||
438 | if (error_code == ERROR_IO_PENDING) | 437 | if (error_code == ERROR_IO_PENDING) |
439 | { | 438 | { |
440 | #if DEBUG_EVENTLOOP | ||
441 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 439 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
442 | "Adding the pipe's 0x%x overlapped event to the array as %d\n", | 440 | "Adding the pipe's 0x%x overlapped event to the array as %d\n", |
443 | fh->h, nhandles); | 441 | fh->h, nhandles); |
444 | #endif | ||
445 | ml->cached_poll_array[fd_counter].fd = | 442 | ml->cached_poll_array[fd_counter].fd = |
446 | (intptr_t) fh->oOverlapRead->hEvent; | 443 | (intptr_t) fh->oOverlapRead->hEvent; |
447 | /* On W32 .events makes no sense - g_poll will just OR its | 444 | /* On W32 .events makes no sense - g_poll will just OR its |
@@ -465,11 +462,9 @@ gnunet_gtk_select (void *cls, struct GNUNET_NETWORK_FDSet *rfds, | |||
465 | } | 462 | } |
466 | else | 463 | else |
467 | { | 464 | { |
468 | #if DEBUG_EVENTLOOP | ||
469 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 465 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
470 | "Adding the read ready event to the array as %d\n", | 466 | "Adding the read ready event to the array as %d\n", |
471 | nhandles); | 467 | nhandles); |
472 | #endif | ||
473 | ml->cached_poll_array[fd_counter].fd = | 468 | ml->cached_poll_array[fd_counter].fd = |
474 | (intptr_t) ml->hEventReadReady; | 469 | (intptr_t) ml->hEventReadReady; |
475 | ml->cached_poll_array[fd_counter].events = G_IO_IN; | 470 | ml->cached_poll_array[fd_counter].events = G_IO_IN; |
@@ -522,11 +517,9 @@ gnunet_gtk_select (void *cls, struct GNUNET_NETWORK_FDSet *rfds, | |||
522 | 517 | ||
523 | if ((rfds != NULL) && (rfds->sds.fd_count > 0)) | 518 | if ((rfds != NULL) && (rfds->sds.fd_count > 0)) |
524 | { | 519 | { |
525 | #if DEBUG_EVENTLOOP | ||
526 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 520 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
527 | "Adding the socket read event to the array as %d\n", | 521 | "Adding the socket read event to the array as %d\n", |
528 | fd_counter); | 522 | fd_counter); |
529 | #endif | ||
530 | ml->cached_poll_array[fd_counter].fd = (intptr_t) ml->hEventRead; | 523 | ml->cached_poll_array[fd_counter].fd = (intptr_t) ml->hEventRead; |
531 | ml->cached_poll_array[fd_counter].events = G_IO_IN; | 524 | ml->cached_poll_array[fd_counter].events = G_IO_IN; |
532 | for (i = 0; i < rfds->sds.fd_count; i++) | 525 | for (i = 0; i < rfds->sds.fd_count; i++) |
@@ -539,11 +532,9 @@ gnunet_gtk_select (void *cls, struct GNUNET_NETWORK_FDSet *rfds, | |||
539 | { | 532 | { |
540 | int wakeup = 0; | 533 | int wakeup = 0; |
541 | 534 | ||
542 | #if DEBUG_EVENTLOOP | ||
543 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 535 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
544 | "Adding the socket write event to the array as %d\n", | 536 | "Adding the socket write event to the array as %d\n", |
545 | fd_counter); | 537 | fd_counter); |
546 | #endif | ||
547 | ml->cached_poll_array[fd_counter].fd = (intptr_t) ml->hEventWrite; | 538 | ml->cached_poll_array[fd_counter].fd = (intptr_t) ml->hEventWrite; |
548 | ml->cached_poll_array[fd_counter].events = G_IO_OUT; | 539 | ml->cached_poll_array[fd_counter].events = G_IO_OUT; |
549 | for (ui = 0; ui < wfds->sds.fd_count; ui++) | 540 | for (ui = 0; ui < wfds->sds.fd_count; ui++) |
@@ -553,11 +544,9 @@ gnunet_gtk_select (void *cls, struct GNUNET_NETWORK_FDSet *rfds, | |||
553 | 544 | ||
554 | status = send (wfds->sds.fd_array[ui], NULL, 0, 0); | 545 | status = send (wfds->sds.fd_array[ui], NULL, 0, 0); |
555 | error = GetLastError (); | 546 | error = GetLastError (); |
556 | #if DEBUG_EVENTLOOP | ||
557 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 547 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
558 | "pre-send to the socket %u returned %d (%u)\n", ui, status, | 548 | "pre-send to the socket %u returned %d (%u)\n", ui, status, |
559 | error); | 549 | error); |
560 | #endif | ||
561 | if (status == 0 || (error != WSAEWOULDBLOCK && error != WSAENOTCONN)) | 550 | if (status == 0 || (error != WSAEWOULDBLOCK && error != WSAENOTCONN)) |
562 | wakeup = 1; | 551 | wakeup = 1; |
563 | WSAEventSelect (wfds->sds.fd_array[ui], ml->hEventWrite, | 552 | WSAEventSelect (wfds->sds.fd_array[ui], ml->hEventWrite, |
@@ -570,11 +559,9 @@ gnunet_gtk_select (void *cls, struct GNUNET_NETWORK_FDSet *rfds, | |||
570 | } | 559 | } |
571 | if ((efds != NULL) && (efds->sds.fd_count > 0)) | 560 | if ((efds != NULL) && (efds->sds.fd_count > 0)) |
572 | { | 561 | { |
573 | #if DEBUG_EVENTLOOP | ||
574 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 562 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
575 | "Adding the socket error event to the array as %d\n", | 563 | "Adding the socket error event to the array as %d\n", |
576 | fd_counter); | 564 | fd_counter); |
577 | #endif | ||
578 | ml->cached_poll_array[fd_counter].fd = (intptr_t) ml->hEventException; | 565 | ml->cached_poll_array[fd_counter].fd = (intptr_t) ml->hEventException; |
579 | ml->cached_poll_array[fd_counter].events = G_IO_ERR; | 566 | ml->cached_poll_array[fd_counter].events = G_IO_ERR; |
580 | for (ui = 0; ui < efds->sds.fd_count; ui++) | 567 | for (ui = 0; ui < efds->sds.fd_count; ui++) |
@@ -615,24 +602,17 @@ gnunet_gtk_select (void *cls, struct GNUNET_NETWORK_FDSet *rfds, | |||
615 | #if WINDOWS | 602 | #if WINDOWS |
616 | if (pre_ret > 0) | 603 | if (pre_ret > 0) |
617 | { | 604 | { |
618 | #if DEBUG_EVENTLOOP | ||
619 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "pre_ret is %d, setting delay to 0\n", | 605 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "pre_ret is %d, setting delay to 0\n", |
620 | pre_ret); | 606 | pre_ret); |
621 | #endif | ||
622 | delay = 0; | 607 | delay = 0; |
623 | } | 608 | } |
624 | #endif | 609 | #endif |
625 | 610 | ||
626 | #if DEBUG_EVENTLOOP | ||
627 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 611 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
628 | "We have %d of our FDs and %d of GMC ones, going to wait %6dms\n", | 612 | "We have %d of our FDs and %d of GMC ones, going to wait %6dms\n", |
629 | fd_counter, need_gfds, delay); | 613 | fd_counter, need_gfds, delay); |
630 | #endif | ||
631 | |||
632 | poll_result = g_poll (ml->cached_poll_array, fd_counter + need_gfds, delay); | 614 | poll_result = g_poll (ml->cached_poll_array, fd_counter + need_gfds, delay); |
633 | #if DEBUG_EVENTLOOP | ||
634 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "g_poll returned : %d\n", poll_result); | 615 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "g_poll returned : %d\n", poll_result); |
635 | #endif | ||
636 | if (-1 == poll_result) | 616 | if (-1 == poll_result) |
637 | return GNUNET_SYSERR; | 617 | return GNUNET_SYSERR; |
638 | 618 | ||
@@ -692,18 +672,14 @@ gnunet_gtk_select (void *cls, struct GNUNET_NETWORK_FDSet *rfds, | |||
692 | select_ret = select (max_nfds, &aread, &awrite, &aexcept, &tvslice); | 672 | select_ret = select (max_nfds, &aread, &awrite, &aexcept, &tvslice); |
693 | if (select_ret == -1) | 673 | if (select_ret == -1) |
694 | select_ret = 0; | 674 | select_ret = 0; |
695 | #if DEBUG_EVENTLOOP | ||
696 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "select() returned %d\n", select_ret); | 675 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "select() returned %d\n", select_ret); |
697 | #endif | ||
698 | } | 676 | } |
699 | if (always_ready_write_fd >= 0 && | 677 | if (always_ready_write_fd >= 0 && |
700 | ml->cached_poll_array[always_ready_write_fd].revents & G_IO_OUT) | 678 | ml->cached_poll_array[always_ready_write_fd].revents & G_IO_OUT) |
701 | { | 679 | { |
702 | GNUNET_CONTAINER_slist_append (ml->handles_write, wfds->handles); | 680 | GNUNET_CONTAINER_slist_append (ml->handles_write, wfds->handles); |
703 | result += GNUNET_CONTAINER_slist_count (ml->handles_write); | 681 | result += GNUNET_CONTAINER_slist_count (ml->handles_write); |
704 | #if DEBUG_EVENTLOOP | ||
705 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Added write pipe\n"); | 682 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Added write pipe\n"); |
706 | #endif | ||
707 | } | 683 | } |
708 | for (i = 0; i < read_handles; i++) | 684 | for (i = 0; i < read_handles; i++) |
709 | { | 685 | { |
@@ -717,11 +693,9 @@ gnunet_gtk_select (void *cls, struct GNUNET_NETWORK_FDSet *rfds, | |||
717 | bret = | 693 | bret = |
718 | PeekNamedPipe (ml->read_array[i]->h, NULL, 0, NULL, &waitstatus, NULL); | 694 | PeekNamedPipe (ml->read_array[i]->h, NULL, 0, NULL, &waitstatus, NULL); |
719 | error = GetLastError (); | 695 | error = GetLastError (); |
720 | #if DEBUG_EVENTLOOP | ||
721 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 696 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
722 | "Peek at read pipe %d (0x%x) returned %d (%d bytes available) GLE %u\n", | 697 | "Peek at read pipe %d (0x%x) returned %d (%d bytes available) GLE %u\n", |
723 | i, ml->read_array[i]->h, bret, waitstatus, error); | 698 | i, ml->read_array[i]->h, bret, waitstatus, error); |
724 | #endif | ||
725 | if (bret == 0 || (ml->cached_poll_array[i].revents & G_IO_ERR)) | 699 | if (bret == 0 || (ml->cached_poll_array[i].revents & G_IO_ERR)) |
726 | { | 700 | { |
727 | if (efds != NULL) | 701 | if (efds != NULL) |
@@ -752,16 +726,12 @@ gnunet_gtk_select (void *cls, struct GNUNET_NETWORK_FDSet *rfds, | |||
752 | ml->read_array[i], | 726 | ml->read_array[i], |
753 | sizeof (struct GNUNET_DISK_FileHandle)); | 727 | sizeof (struct GNUNET_DISK_FileHandle)); |
754 | result += 1; | 728 | result += 1; |
755 | #if DEBUG_EVENTLOOP | ||
756 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Added read Pipe 0x%x (0x%x)\n", | 729 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Added read Pipe 0x%x (0x%x)\n", |
757 | ml->read_array[i], ml->read_array[i]->h); | 730 | ml->read_array[i], ml->read_array[i]->h); |
758 | #endif | ||
759 | } | 731 | } |
760 | waitstatus = WaitForSingleObject (ml->hEventWrite, 0); | 732 | waitstatus = WaitForSingleObject (ml->hEventWrite, 0); |
761 | #if DEBUG_EVENTLOOP | ||
762 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Wait for the write event returned %d\n", | 733 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Wait for the write event returned %d\n", |
763 | waitstatus); | 734 | waitstatus); |
764 | #endif | ||
765 | if (waitstatus == WAIT_OBJECT_0) | 735 | if (waitstatus == WAIT_OBJECT_0) |
766 | { | 736 | { |
767 | for (ui = 0; ui < wfds->sds.fd_count; ui++) | 737 | for (ui = 0; ui < wfds->sds.fd_count; ui++) |
@@ -776,11 +746,9 @@ gnunet_gtk_select (void *cls, struct GNUNET_NETWORK_FDSet *rfds, | |||
776 | 746 | ||
777 | status = send (wfds->sds.fd_array[ui], NULL, 0, 0); | 747 | status = send (wfds->sds.fd_array[ui], NULL, 0, 0); |
778 | error = GetLastError (); | 748 | error = GetLastError (); |
779 | #if DEBUG_EVENTLOOP | ||
780 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 749 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
781 | "send to the socket %u returned %d (%u)\n", ui, status, | 750 | "send to the socket %u returned %d (%u)\n", ui, status, |
782 | error); | 751 | error); |
783 | #endif | ||
784 | if (status == 0 || (error != WSAEWOULDBLOCK && error != WSAENOTCONN) || | 752 | if (status == 0 || (error != WSAEWOULDBLOCK && error != WSAENOTCONN) || |
785 | (status == -1 && gso_result == 0 && error == WSAENOTCONN && | 753 | (status == -1 && gso_result == 0 && error == WSAENOTCONN && |
786 | so_error == WSAECONNREFUSED)) | 754 | so_error == WSAECONNREFUSED)) |