diff options
author | lurchi <lurchi@strangeplace.net> | 2017-08-16 13:57:37 +0200 |
---|---|---|
committer | lurchi <lurchi@strangeplace.net> | 2017-08-16 13:57:37 +0200 |
commit | 16824d5bb7c3699bc6628c1bfabd53e2f3fe5a95 (patch) | |
tree | bfd98b9d68606c5c583ca399ecc0d0929c5149fc /src/util/scheduler.c | |
parent | a4cf7b69030ba9ded923828a781a65f62e5dc616 (diff) | |
download | gnunet-16824d5bb7c3699bc6628c1bfabd53e2f3fe5a95.tar.gz gnunet-16824d5bb7c3699bc6628c1bfabd53e2f3fe5a95.zip |
add buggy state of refactored GNUNET_SCHEDULER_add_select
Diffstat (limited to 'src/util/scheduler.c')
-rw-r--r-- | src/util/scheduler.c | 305 |
1 files changed, 186 insertions, 119 deletions
diff --git a/src/util/scheduler.c b/src/util/scheduler.c index c4017f23b..353b4a669 100644 --- a/src/util/scheduler.c +++ b/src/util/scheduler.c | |||
@@ -117,20 +117,20 @@ struct GNUNET_SCHEDULER_Task | |||
117 | */ | 117 | */ |
118 | void *callback_cls; | 118 | void *callback_cls; |
119 | 119 | ||
120 | /** | 120 | ///** |
121 | * Set of file descriptors this task is waiting | 121 | // * Set of file descriptors this task is waiting |
122 | * for for reading. Once ready, this is updated | 122 | // * for for reading. Once ready, this is updated |
123 | * to reflect the set of file descriptors ready | 123 | // * to reflect the set of file descriptors ready |
124 | * for operation. | 124 | // * for operation. |
125 | */ | 125 | // */ |
126 | struct GNUNET_NETWORK_FDSet *read_set; | 126 | //struct GNUNET_NETWORK_FDSet *read_set; |
127 | 127 | ||
128 | /** | 128 | ///** |
129 | * Set of file descriptors this task is waiting for for writing. | 129 | // * Set of file descriptors this task is waiting for for writing. |
130 | * Once ready, this is updated to reflect the set of file | 130 | // * Once ready, this is updated to reflect the set of file |
131 | * descriptors ready for operation. | 131 | // * descriptors ready for operation. |
132 | */ | 132 | // */ |
133 | struct GNUNET_NETWORK_FDSet *write_set; | 133 | //struct GNUNET_NETWORK_FDSet *write_set; |
134 | 134 | ||
135 | /** | 135 | /** |
136 | * Information about which FDs are ready for this task (and why). | 136 | * Information about which FDs are ready for this task (and why). |
@@ -485,10 +485,30 @@ static void | |||
485 | destroy_task (struct GNUNET_SCHEDULER_Task *t) | 485 | destroy_task (struct GNUNET_SCHEDULER_Task *t) |
486 | { | 486 | { |
487 | // FIXME: destroy fds! | 487 | // FIXME: destroy fds! |
488 | if (NULL != t->read_set) | 488 | if (t->fds_len > 1) |
489 | GNUNET_NETWORK_fdset_destroy (t->read_set); | 489 | { |
490 | if (NULL != t->write_set) | 490 | size_t i; |
491 | GNUNET_NETWORK_fdset_destroy (t->write_set); | 491 | for (i = 0; i != t->fds_len; ++i) |
492 | { | ||
493 | const struct GNUNET_SCHEDULER_FdInfo *fdi = t->fds + i; | ||
494 | if (fdi->fd) | ||
495 | { | ||
496 | GNUNET_NETWORK_socket_free_memory_only_ ((struct GNUNET_NETWORK_Handle *) fdi->fd); | ||
497 | } | ||
498 | if (fdi->fh) | ||
499 | { | ||
500 | // FIXME: on WIN32 this is not enough! A function | ||
501 | // GNUNET_DISK_file_free_memory_only would be nice | ||
502 | GNUNET_free ((void *) fdi->fh); | ||
503 | } | ||
504 | } | ||
505 | /* free the array */ | ||
506 | GNUNET_array_grow (t->fds, t->fds_len, 0); | ||
507 | } | ||
508 | //if (NULL != t->read_set) | ||
509 | // GNUNET_NETWORK_fdset_destroy (t->read_set); | ||
510 | //if (NULL != t->write_set) | ||
511 | // GNUNET_NETWORK_fdset_destroy (t->write_set); | ||
492 | #if EXECINFO | 512 | #if EXECINFO |
493 | GNUNET_free (t->backtrace_strings); | 513 | GNUNET_free (t->backtrace_strings); |
494 | #endif | 514 | #endif |
@@ -695,13 +715,13 @@ GNUNET_SCHEDULER_get_load (enum GNUNET_SCHEDULER_Priority p) | |||
695 | 715 | ||
696 | void | 716 | void |
697 | init_fd_info (struct GNUNET_SCHEDULER_Task *t, | 717 | init_fd_info (struct GNUNET_SCHEDULER_Task *t, |
698 | const struct GNUNET_NETWORK_Handle **read_nh, | 718 | const struct GNUNET_NETWORK_Handle *const *read_nh, |
699 | size_t read_nh_len, | 719 | size_t read_nh_len, |
700 | const struct GNUNET_NETWORK_Handle **write_nh, | 720 | const struct GNUNET_NETWORK_Handle *const *write_nh, |
701 | size_t write_nh_len, | 721 | size_t write_nh_len, |
702 | const struct GNUNET_DISK_FileHandle **read_fh, | 722 | const struct GNUNET_DISK_FileHandle *const *read_fh, |
703 | size_t read_fh_len, | 723 | size_t read_fh_len, |
704 | const struct GNUNET_DISK_FileHandle **write_fh, | 724 | const struct GNUNET_DISK_FileHandle *const *write_fh, |
705 | size_t write_fh_len) | 725 | size_t write_fh_len) |
706 | { | 726 | { |
707 | struct GNUNET_SCHEDULER_FdInfo *fdi; | 727 | struct GNUNET_SCHEDULER_FdInfo *fdi; |
@@ -713,7 +733,8 @@ init_fd_info (struct GNUNET_SCHEDULER_Task *t, | |||
713 | t->fds = fdi; | 733 | t->fds = fdi; |
714 | if (1 == read_nh_len) | 734 | if (1 == read_nh_len) |
715 | { | 735 | { |
716 | fdi->fd = *read_nh; | 736 | fdi->fd = GNUNET_NETWORK_socket_box_native (GNUNET_NETWORK_get_fd (*read_nh)); |
737 | GNUNET_assert (NULL != fdi->fd); | ||
717 | fdi->et = GNUNET_SCHEDULER_ET_IN; | 738 | fdi->et = GNUNET_SCHEDULER_ET_IN; |
718 | fdi->sock = GNUNET_NETWORK_get_fd (*read_nh); | 739 | fdi->sock = GNUNET_NETWORK_get_fd (*read_nh); |
719 | t->read_fd = fdi->sock; | 740 | t->read_fd = fdi->sock; |
@@ -721,7 +742,8 @@ init_fd_info (struct GNUNET_SCHEDULER_Task *t, | |||
721 | } | 742 | } |
722 | else if (1 == write_nh_len) | 743 | else if (1 == write_nh_len) |
723 | { | 744 | { |
724 | fdi->fd = *write_nh; | 745 | fdi->fd = GNUNET_NETWORK_socket_box_native (GNUNET_NETWORK_get_fd (*write_nh)); |
746 | GNUNET_assert (NULL != fdi->fd); | ||
725 | fdi->et = GNUNET_SCHEDULER_ET_OUT; | 747 | fdi->et = GNUNET_SCHEDULER_ET_OUT; |
726 | fdi->sock = GNUNET_NETWORK_get_fd (*write_nh); | 748 | fdi->sock = GNUNET_NETWORK_get_fd (*write_nh); |
727 | t->read_fd = -1; | 749 | t->read_fd = -1; |
@@ -729,7 +751,8 @@ init_fd_info (struct GNUNET_SCHEDULER_Task *t, | |||
729 | } | 751 | } |
730 | else if (1 == read_fh_len) | 752 | else if (1 == read_fh_len) |
731 | { | 753 | { |
732 | fdi->fh = *read_fh; | 754 | fdi->fh = GNUNET_DISK_get_handle_from_int_fd ((*read_fh)->fd); |
755 | GNUNET_assert (NULL != fdi->fh); | ||
733 | fdi->et = GNUNET_SCHEDULER_ET_IN; | 756 | fdi->et = GNUNET_SCHEDULER_ET_IN; |
734 | fdi->sock = (*read_fh)->fd; // FIXME: does not work under WIN32 | 757 | fdi->sock = (*read_fh)->fd; // FIXME: does not work under WIN32 |
735 | t->read_fd = fdi->sock; | 758 | t->read_fd = fdi->sock; |
@@ -737,7 +760,8 @@ init_fd_info (struct GNUNET_SCHEDULER_Task *t, | |||
737 | } | 760 | } |
738 | else | 761 | else |
739 | { | 762 | { |
740 | fdi->fh = *write_fh; | 763 | fdi->fh = GNUNET_DISK_get_handle_from_int_fd ((*write_fh)->fd); |
764 | GNUNET_assert (NULL != fdi->fh); | ||
741 | fdi->et = GNUNET_SCHEDULER_ET_OUT; | 765 | fdi->et = GNUNET_SCHEDULER_ET_OUT; |
742 | fdi->sock = (*write_fh)->fd; // FIXME: does not work under WIN32 | 766 | fdi->sock = (*write_fh)->fd; // FIXME: does not work under WIN32 |
743 | t->read_fd = -1; | 767 | t->read_fd = -1; |
@@ -753,28 +777,32 @@ init_fd_info (struct GNUNET_SCHEDULER_Task *t, | |||
753 | size_t i; | 777 | size_t i; |
754 | for (i = 0; i != read_nh_len; ++i) | 778 | for (i = 0; i != read_nh_len; ++i) |
755 | { | 779 | { |
756 | fdi->fd = read_nh[i]; | 780 | fdi->fd = GNUNET_NETWORK_socket_box_native (GNUNET_NETWORK_get_fd (read_nh[i])); |
781 | GNUNET_assert (NULL != fdi->fd); | ||
757 | fdi->et = GNUNET_SCHEDULER_ET_IN; | 782 | fdi->et = GNUNET_SCHEDULER_ET_IN; |
758 | fdi->sock = GNUNET_NETWORK_get_fd (read_nh[i]); | 783 | fdi->sock = GNUNET_NETWORK_get_fd (read_nh[i]); |
759 | ++fdi; | 784 | ++fdi; |
760 | } | 785 | } |
761 | for (i = 0; i != write_nh_len; ++i) | 786 | for (i = 0; i != write_nh_len; ++i) |
762 | { | 787 | { |
763 | fdi->fd = write_nh[i]; | 788 | fdi->fd = GNUNET_NETWORK_socket_box_native (GNUNET_NETWORK_get_fd (write_nh[i])); |
789 | GNUNET_assert (NULL != fdi->fd); | ||
764 | fdi->et = GNUNET_SCHEDULER_ET_OUT; | 790 | fdi->et = GNUNET_SCHEDULER_ET_OUT; |
765 | fdi->sock = GNUNET_NETWORK_get_fd (write_nh[i]); | 791 | fdi->sock = GNUNET_NETWORK_get_fd (write_nh[i]); |
766 | ++fdi; | 792 | ++fdi; |
767 | } | 793 | } |
768 | for (i = 0; i != read_fh_len; ++i) | 794 | for (i = 0; i != read_fh_len; ++i) |
769 | { | 795 | { |
770 | fdi->fh = read_fh[i]; | 796 | fdi->fh = GNUNET_DISK_get_handle_from_int_fd (read_fh[i]->fd); |
797 | GNUNET_assert (NULL != fdi->fh); | ||
771 | fdi->et = GNUNET_SCHEDULER_ET_IN; | 798 | fdi->et = GNUNET_SCHEDULER_ET_IN; |
772 | fdi->sock = (read_fh[i])->fd; // FIXME: does not work under WIN32 | 799 | fdi->sock = (read_fh[i])->fd; // FIXME: does not work under WIN32 |
773 | ++fdi; | 800 | ++fdi; |
774 | } | 801 | } |
775 | for (i = 0; i != write_fh_len; ++i) | 802 | for (i = 0; i != write_fh_len; ++i) |
776 | { | 803 | { |
777 | fdi->fh = write_fh[i]; | 804 | fdi->fh = GNUNET_DISK_get_handle_from_int_fd (write_fh[i]->fd); |
805 | GNUNET_assert (NULL != fdi->fh); | ||
778 | fdi->et = GNUNET_SCHEDULER_ET_OUT; | 806 | fdi->et = GNUNET_SCHEDULER_ET_OUT; |
779 | fdi->sock = (write_fh[i])->fd; // FIXME: does not work under WIN32 | 807 | fdi->sock = (write_fh[i])->fd; // FIXME: does not work under WIN32 |
780 | ++fdi; | 808 | ++fdi; |
@@ -782,86 +810,6 @@ init_fd_info (struct GNUNET_SCHEDULER_Task *t, | |||
782 | } | 810 | } |
783 | } | 811 | } |
784 | 812 | ||
785 | //void | ||
786 | //init_fd_info (struct GNUNET_SCHEDULER_Task *t, | ||
787 | // const struct GNUNET_NETWORK_Handle *read_nh, | ||
788 | // const struct GNUNET_NETWORK_Handle *write_nh, | ||
789 | // const struct GNUNET_DISK_FileHandle *read_fh, | ||
790 | // const struct GNUNET_DISK_FileHandle *write_fh) | ||
791 | //{ | ||
792 | // // either only network handles or only file handles are allowed | ||
793 | // GNUNET_assert (!((NULL != read_nh || NULL != write_nh) && (NULL != read_fh || NULL != write_fh))); | ||
794 | // | ||
795 | // if (NULL != read_nh && NULL != write_nh) | ||
796 | // { | ||
797 | // int read_fd = GNUNET_NETWORK_get_fd (read_nh); | ||
798 | // int write_fd = GNUNET_NETWORK_get_fd (write_nh); | ||
799 | // t->read_fd = read_fd; | ||
800 | // t->write_fd = write_fd; | ||
801 | // struct GNUNET_SCHEDULER_FdInfo *fds = GNUNET_new_array (2, struct GNUNET_SCHEDULER_FdInfo); | ||
802 | // struct GNUNET_SCHEDULER_FdInfo read_fdi = {.fd = read_nh, .et = GNUNET_SCHEDULER_ET_IN, .sock = read_fd}; | ||
803 | // struct GNUNET_SCHEDULER_FdInfo write_fdi = {.fd = write_nh, .et = GNUNET_SCHEDULER_ET_OUT, .sock = write_fd}; | ||
804 | // fds[0] = read_fdi; | ||
805 | // fds[1] = write_fdi; | ||
806 | // t->fds = fds; | ||
807 | // t->fds_len = 2; | ||
808 | // } | ||
809 | // else if (NULL != read_fh && NULL != write_fh) | ||
810 | // { | ||
811 | // int read_fd = read_fh->fd; | ||
812 | // int write_fd = write_fh->fd; | ||
813 | // struct GNUNET_SCHEDULER_FdInfo *fds = GNUNET_new_array (2, struct GNUNET_SCHEDULER_FdInfo); | ||
814 | // struct GNUNET_SCHEDULER_FdInfo read_fdi = {.fh = read_fh, .et = GNUNET_SCHEDULER_ET_IN, .sock = read_fd}; | ||
815 | // struct GNUNET_SCHEDULER_FdInfo write_fdi = {.fh = write_fh, .et = GNUNET_SCHEDULER_ET_OUT, .sock = write_fd}; | ||
816 | // t->read_fd = read_fd; | ||
817 | // t->write_fd = write_fd; | ||
818 | // fds[0] = read_fdi; | ||
819 | // fds[1] = write_fdi; | ||
820 | // t->fds = fds; | ||
821 | // t->fds_len = 2; | ||
822 | // } | ||
823 | // else if (NULL != read_nh) | ||
824 | // { | ||
825 | // int read_fd = GNUNET_NETWORK_get_fd (read_nh); | ||
826 | // struct GNUNET_SCHEDULER_FdInfo read_fdi = {.fd = read_nh, .et = GNUNET_SCHEDULER_ET_IN, .sock = read_fd}; | ||
827 | // t->read_fd = read_fd; | ||
828 | // t->write_fd = -1; | ||
829 | // t->fdx = read_fdi; | ||
830 | // t->fds = &t->fdx; | ||
831 | // t->fds_len = 1; | ||
832 | // } | ||
833 | // else if (NULL != write_nh) | ||
834 | // { | ||
835 | // int write_fd = GNUNET_NETWORK_get_fd (write_nh); | ||
836 | // struct GNUNET_SCHEDULER_FdInfo write_fdi = {.fd = write_nh, .et = GNUNET_SCHEDULER_ET_OUT, .sock = write_fd}; | ||
837 | // t->read_fd = -1; | ||
838 | // t->write_fd = write_fd; | ||
839 | // t->fdx = write_fdi; | ||
840 | // t->fds = &t->fdx; | ||
841 | // t->fds_len = 1; | ||
842 | // } | ||
843 | // else if (NULL != read_fh) | ||
844 | // { | ||
845 | // int read_fd = read_fh->fd; | ||
846 | // struct GNUNET_SCHEDULER_FdInfo read_fdi = {.fh = read_fh, .et = GNUNET_SCHEDULER_ET_IN, .sock = read_fd}; | ||
847 | // t->read_fd = read_fd; | ||
848 | // t->write_fd = -1; | ||
849 | // t->fdx = read_fdi; | ||
850 | // t->fds = &t->fdx; | ||
851 | // t->fds_len = 1; | ||
852 | // } | ||
853 | // else if (NULL != write_fh) | ||
854 | // { | ||
855 | // int write_fd = write_fh->fd; | ||
856 | // struct GNUNET_SCHEDULER_FdInfo write_fdi = {.fh = write_fh, .et = GNUNET_SCHEDULER_ET_OUT, .sock = write_fd}; | ||
857 | // t->read_fd = -1; | ||
858 | // t->write_fd = write_fd; | ||
859 | // t->fdx = write_fdi; | ||
860 | // t->fds = &t->fdx; | ||
861 | // t->fds_len = 1; | ||
862 | // } | ||
863 | //} | ||
864 | |||
865 | 813 | ||
866 | void scheduler_multi_function_call(struct GNUNET_SCHEDULER_Task *t, int (*driver_func)()) | 814 | void scheduler_multi_function_call(struct GNUNET_SCHEDULER_Task *t, int (*driver_func)()) |
867 | { | 815 | { |
@@ -922,10 +870,11 @@ GNUNET_SCHEDULER_cancel (struct GNUNET_SCHEDULER_Task *task) | |||
922 | (GNUNET_NO == task->lifeness) ); | 870 | (GNUNET_NO == task->lifeness) ); |
923 | if (! task->in_ready_list) | 871 | if (! task->in_ready_list) |
924 | { | 872 | { |
925 | if ( (-1 == task->read_fd) && | 873 | //if ( (-1 == task->read_fd) && |
926 | (-1 == task->write_fd) && | 874 | // (-1 == task->write_fd) && |
927 | (NULL == task->read_set) && | 875 | // (NULL == task->read_set) && |
928 | (NULL == task->write_set) ) | 876 | // (NULL == task->write_set) ) |
877 | if (NULL == task->fds) | ||
929 | { | 878 | { |
930 | if (GNUNET_YES == task->on_shutdown) | 879 | if (GNUNET_YES == task->on_shutdown) |
931 | GNUNET_CONTAINER_DLL_remove (shutdown_head, | 880 | GNUNET_CONTAINER_DLL_remove (shutdown_head, |
@@ -1671,6 +1620,92 @@ GNUNET_SCHEDULER_add_file_with_priority (struct GNUNET_TIME_Relative delay, | |||
1671 | } | 1620 | } |
1672 | 1621 | ||
1673 | 1622 | ||
1623 | int | ||
1624 | extract_handles (const struct GNUNET_NETWORK_FDSet *fdset, | ||
1625 | const struct GNUNET_NETWORK_Handle ***ntarget, | ||
1626 | unsigned int *extracted_nhandles, | ||
1627 | const struct GNUNET_DISK_FileHandle ***ftarget, | ||
1628 | unsigned int *extracted_fhandles) | ||
1629 | { | ||
1630 | // FIXME: this implementation only works for unix, for WIN32 the file handles | ||
1631 | // in fdset must be handled separately | ||
1632 | const struct GNUNET_NETWORK_Handle **nhandles; | ||
1633 | const struct GNUNET_DISK_FileHandle **fhandles; | ||
1634 | unsigned int nhandle_count, fhandle_count; | ||
1635 | int sock; | ||
1636 | int ret; | ||
1637 | |||
1638 | nhandles = NULL; | ||
1639 | fhandles = NULL; | ||
1640 | nhandle_count = 0; | ||
1641 | fhandle_count = 0; | ||
1642 | ret = GNUNET_OK; | ||
1643 | for (sock = 0; sock != fdset->nsds; ++sock) | ||
1644 | { | ||
1645 | if (GNUNET_YES == GNUNET_NETWORK_fdset_test_native (fdset, sock)) | ||
1646 | { | ||
1647 | const struct GNUNET_NETWORK_Handle *nhandle; | ||
1648 | const struct GNUNET_DISK_FileHandle *fhandle; | ||
1649 | |||
1650 | nhandle = GNUNET_NETWORK_socket_box_native (sock); | ||
1651 | if (NULL != nhandle) | ||
1652 | { | ||
1653 | GNUNET_array_append (nhandles, nhandle_count, nhandle); | ||
1654 | ++nhandle_count; | ||
1655 | } | ||
1656 | else | ||
1657 | { | ||
1658 | fhandle = GNUNET_DISK_get_handle_from_int_fd (sock); | ||
1659 | if (NULL == fhandle) | ||
1660 | { | ||
1661 | ret = GNUNET_SYSERR; | ||
1662 | // DEBUG | ||
1663 | GNUNET_assert (0); | ||
1664 | } | ||
1665 | else | ||
1666 | { | ||
1667 | GNUNET_array_append (fhandles, fhandle_count, fhandle); | ||
1668 | ++fhandle_count; | ||
1669 | } | ||
1670 | } | ||
1671 | } | ||
1672 | } | ||
1673 | *ntarget = nhandles; | ||
1674 | *ftarget = fhandles; | ||
1675 | *extracted_nhandles = nhandle_count; | ||
1676 | *extracted_fhandles = fhandle_count; | ||
1677 | return ret; | ||
1678 | } | ||
1679 | |||
1680 | |||
1681 | void | ||
1682 | destroy_network_handles (const struct GNUNET_NETWORK_Handle **handles, | ||
1683 | unsigned int handles_len) | ||
1684 | { | ||
1685 | size_t i; | ||
1686 | |||
1687 | for (i = 0; i != handles_len; ++i) | ||
1688 | { | ||
1689 | GNUNET_free ((void *) handles[i]); | ||
1690 | } | ||
1691 | GNUNET_array_grow (handles, handles_len, 0); | ||
1692 | } | ||
1693 | |||
1694 | |||
1695 | void | ||
1696 | destroy_file_handles (const struct GNUNET_DISK_FileHandle **handles, | ||
1697 | unsigned int handles_len) | ||
1698 | { | ||
1699 | size_t i; | ||
1700 | |||
1701 | for (i = 0; i != handles_len; ++i) | ||
1702 | { | ||
1703 | GNUNET_free ((void *) handles[i]); | ||
1704 | } | ||
1705 | GNUNET_array_grow (handles, handles_len, 0); | ||
1706 | } | ||
1707 | |||
1708 | |||
1674 | /** | 1709 | /** |
1675 | * Schedule a new task to be run with a specified delay or when any of | 1710 | * Schedule a new task to be run with a specified delay or when any of |
1676 | * the specified file descriptor sets is ready. The delay can be used | 1711 | * the specified file descriptor sets is ready. The delay can be used |
@@ -1708,6 +1743,14 @@ GNUNET_SCHEDULER_add_select (enum GNUNET_SCHEDULER_Priority prio, | |||
1708 | void *task_cls) | 1743 | void *task_cls) |
1709 | { | 1744 | { |
1710 | struct GNUNET_SCHEDULER_Task *t; | 1745 | struct GNUNET_SCHEDULER_Task *t; |
1746 | const struct GNUNET_NETWORK_Handle **read_nhandles, **write_nhandles; | ||
1747 | const struct GNUNET_DISK_FileHandle **read_fhandles, **write_fhandles; | ||
1748 | unsigned int read_nhandles_len, write_nhandles_len, | ||
1749 | read_fhandles_len, write_fhandles_len; | ||
1750 | |||
1751 | LOG (GNUNET_ERROR_TYPE_WARNING, | ||
1752 | "[%p] GNUNET_SCHDULER_add_select\n", | ||
1753 | sh); | ||
1711 | 1754 | ||
1712 | if ( (NULL == rs) && | 1755 | if ( (NULL == rs) && |
1713 | (NULL == ws) ) | 1756 | (NULL == ws) ) |
@@ -1724,16 +1767,40 @@ GNUNET_SCHEDULER_add_select (enum GNUNET_SCHEDULER_Priority prio, | |||
1724 | t->callback_cls = task_cls; | 1767 | t->callback_cls = task_cls; |
1725 | t->read_fd = -1; | 1768 | t->read_fd = -1; |
1726 | t->write_fd = -1; | 1769 | t->write_fd = -1; |
1770 | read_nhandles_len = 0; | ||
1771 | write_nhandles_len = 0; | ||
1772 | read_fhandles_len = 0; | ||
1773 | write_fhandles_len = 0; | ||
1727 | if (NULL != rs) | 1774 | if (NULL != rs) |
1728 | { | 1775 | { |
1729 | t->read_set = GNUNET_NETWORK_fdset_create (); | 1776 | extract_handles (rs, |
1730 | GNUNET_NETWORK_fdset_copy (t->read_set, rs); | 1777 | &read_nhandles, |
1778 | &read_nhandles_len, | ||
1779 | &read_fhandles, | ||
1780 | &read_fhandles_len); | ||
1731 | } | 1781 | } |
1732 | if (NULL != ws) | 1782 | if (NULL != ws) |
1733 | { | 1783 | { |
1734 | t->write_set = GNUNET_NETWORK_fdset_create (); | 1784 | extract_handles (ws, |
1735 | GNUNET_NETWORK_fdset_copy (t->write_set, ws); | 1785 | &write_nhandles, |
1786 | &write_nhandles_len, | ||
1787 | &write_fhandles, | ||
1788 | &write_fhandles_len); | ||
1736 | } | 1789 | } |
1790 | GNUNET_assert (read_nhandles_len + write_nhandles_len > 0); | ||
1791 | init_fd_info (t, | ||
1792 | read_nhandles, | ||
1793 | read_nhandles_len, | ||
1794 | write_nhandles, | ||
1795 | write_nhandles_len, | ||
1796 | read_fhandles, | ||
1797 | read_fhandles_len, | ||
1798 | write_fhandles, | ||
1799 | write_fhandles_len); | ||
1800 | destroy_network_handles (read_nhandles, read_nhandles_len); | ||
1801 | destroy_network_handles (write_nhandles, write_nhandles_len); | ||
1802 | destroy_file_handles (read_fhandles, read_fhandles_len); | ||
1803 | destroy_file_handles (write_fhandles, write_fhandles_len); | ||
1737 | #if PROFILE_DELAYS | 1804 | #if PROFILE_DELAYS |
1738 | t->start_time = GNUNET_TIME_absolute_get (); | 1805 | t->start_time = GNUNET_TIME_absolute_get (); |
1739 | #endif | 1806 | #endif |
@@ -2238,7 +2305,7 @@ select_loop (void *cls, | |||
2238 | LOG (GNUNET_ERROR_TYPE_WARNING, | 2305 | LOG (GNUNET_ERROR_TYPE_WARNING, |
2239 | "[%p] Looks like we're busy waiting...\n", | 2306 | "[%p] Looks like we're busy waiting...\n", |
2240 | sh); | 2307 | sh); |
2241 | GNUNET_assert (0); | 2308 | //GNUNET_assert (0); |
2242 | short_wait (100); /* mitigate */ | 2309 | short_wait (100); /* mitigate */ |
2243 | } | 2310 | } |
2244 | for (pos = context->scheduled_in_head; NULL != pos; pos = pos->next) | 2311 | for (pos = context->scheduled_in_head; NULL != pos; pos = pos->next) |