diff options
author | lurchi <lurchi@strangeplace.net> | 2017-08-12 17:39:21 +0200 |
---|---|---|
committer | lurchi <lurchi@strangeplace.net> | 2017-08-12 17:39:21 +0200 |
commit | 6ee6dbd04d1e3d0e8c0cb5701e381eb4c22287c1 (patch) | |
tree | cb77fc0aed3330e2062d3c6a79adcffb22672b14 /src | |
parent | 7289071d2aa0e5795e78d3dd0433f82dde7d90ac (diff) | |
download | gnunet-6ee6dbd04d1e3d0e8c0cb5701e381eb4c22287c1.tar.gz gnunet-6ee6dbd04d1e3d0e8c0cb5701e381eb4c22287c1.zip |
init_fd_info now completely initializes fd information; Allow calling add/cancel functions only when the scheduler is running
Diffstat (limited to 'src')
-rw-r--r-- | src/util/program.c | 12 | ||||
-rw-r--r-- | src/util/scheduler.c | 100 |
2 files changed, 91 insertions, 21 deletions
diff --git a/src/util/program.c b/src/util/program.c index 92a9750f3..233792387 100644 --- a/src/util/program.c +++ b/src/util/program.c | |||
@@ -69,6 +69,16 @@ struct CommandContext | |||
69 | 69 | ||
70 | 70 | ||
71 | /** | 71 | /** |
72 | * task run when the scheduler shuts down | ||
73 | */ | ||
74 | static void | ||
75 | shutdown_task (void *cls) | ||
76 | { | ||
77 | GNUNET_SPEEDUP_stop_ (); | ||
78 | } | ||
79 | |||
80 | |||
81 | /** | ||
72 | * Initial task called by the scheduler for each | 82 | * Initial task called by the scheduler for each |
73 | * program. Runs the program-specific main task. | 83 | * program. Runs the program-specific main task. |
74 | */ | 84 | */ |
@@ -78,6 +88,7 @@ program_main (void *cls) | |||
78 | struct CommandContext *cc = cls; | 88 | struct CommandContext *cc = cls; |
79 | 89 | ||
80 | GNUNET_SPEEDUP_start_(cc->cfg); | 90 | GNUNET_SPEEDUP_start_(cc->cfg); |
91 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL); | ||
81 | GNUNET_RESOLVER_connect (cc->cfg); | 92 | GNUNET_RESOLVER_connect (cc->cfg); |
82 | cc->task (cc->task_cls, cc->args, cc->cfgfile, cc->cfg); | 93 | cc->task (cc->task_cls, cc->args, cc->cfgfile, cc->cfg); |
83 | } | 94 | } |
@@ -306,7 +317,6 @@ GNUNET_PROGRAM_run2 (int argc, char *const *argv, const char *binaryName, | |||
306 | } | 317 | } |
307 | ret = GNUNET_OK; | 318 | ret = GNUNET_OK; |
308 | cleanup: | 319 | cleanup: |
309 | GNUNET_SPEEDUP_stop_ (); | ||
310 | GNUNET_CONFIGURATION_destroy (cfg); | 320 | GNUNET_CONFIGURATION_destroy (cfg); |
311 | GNUNET_free_non_null (cc.cfgfile); | 321 | GNUNET_free_non_null (cc.cfgfile); |
312 | GNUNET_free (cfg_fn); | 322 | GNUNET_free (cfg_fn); |
diff --git a/src/util/scheduler.c b/src/util/scheduler.c index 89b6e41f3..1f5fe3f61 100644 --- a/src/util/scheduler.c +++ b/src/util/scheduler.c | |||
@@ -606,6 +606,8 @@ GNUNET_SCHEDULER_check_lifeness () | |||
606 | if (NULL != shutdown_head) | 606 | if (NULL != shutdown_head) |
607 | { | 607 | { |
608 | GNUNET_SCHEDULER_shutdown (); | 608 | GNUNET_SCHEDULER_shutdown (); |
609 | scheduler_driver->set_wakeup (scheduler_driver->cls, | ||
610 | GNUNET_TIME_absolute_get ()); | ||
609 | return GNUNET_YES; | 611 | return GNUNET_YES; |
610 | } | 612 | } |
611 | return GNUNET_NO; | 613 | return GNUNET_NO; |
@@ -699,9 +701,13 @@ init_fd_info (struct GNUNET_SCHEDULER_Task *t, | |||
699 | 701 | ||
700 | if (NULL != read_nh && NULL != write_nh) | 702 | if (NULL != read_nh && NULL != write_nh) |
701 | { | 703 | { |
704 | int read_fd = GNUNET_NETWORK_get_fd (read_nh); | ||
705 | int write_fd = GNUNET_NETWORK_get_fd (write_nh); | ||
706 | t->read_fd = read_fd; | ||
707 | t->write_fd = write_fd; | ||
702 | struct GNUNET_SCHEDULER_FdInfo *fds = GNUNET_new_array (2, struct GNUNET_SCHEDULER_FdInfo); | 708 | struct GNUNET_SCHEDULER_FdInfo *fds = GNUNET_new_array (2, struct GNUNET_SCHEDULER_FdInfo); |
703 | struct GNUNET_SCHEDULER_FdInfo read_fdi = {.fd = read_nh, .et = GNUNET_SCHEDULER_ET_IN, .sock = GNUNET_NETWORK_get_fd (read_nh)}; | 709 | struct GNUNET_SCHEDULER_FdInfo read_fdi = {.fd = read_nh, .et = GNUNET_SCHEDULER_ET_IN, .sock = read_fd}; |
704 | struct GNUNET_SCHEDULER_FdInfo write_fdi = {.fd = write_nh, .et = GNUNET_SCHEDULER_ET_OUT, .sock = GNUNET_NETWORK_get_fd (write_nh)}; | 710 | struct GNUNET_SCHEDULER_FdInfo write_fdi = {.fd = write_nh, .et = GNUNET_SCHEDULER_ET_OUT, .sock = write_fd}; |
705 | fds[0] = read_fdi; | 711 | fds[0] = read_fdi; |
706 | fds[1] = write_fdi; | 712 | fds[1] = write_fdi; |
707 | t->fds = fds; | 713 | t->fds = fds; |
@@ -709,9 +715,13 @@ init_fd_info (struct GNUNET_SCHEDULER_Task *t, | |||
709 | } | 715 | } |
710 | else if (NULL != read_fh && NULL != write_fh) | 716 | else if (NULL != read_fh && NULL != write_fh) |
711 | { | 717 | { |
718 | int read_fd = read_fh->fd; | ||
719 | int write_fd = write_fh->fd; | ||
712 | struct GNUNET_SCHEDULER_FdInfo *fds = GNUNET_new_array (2, struct GNUNET_SCHEDULER_FdInfo); | 720 | struct GNUNET_SCHEDULER_FdInfo *fds = GNUNET_new_array (2, struct GNUNET_SCHEDULER_FdInfo); |
713 | struct GNUNET_SCHEDULER_FdInfo read_fdi = {.fh = read_fh, .et = GNUNET_SCHEDULER_ET_IN, .sock = read_fh->fd}; | 721 | struct GNUNET_SCHEDULER_FdInfo read_fdi = {.fh = read_fh, .et = GNUNET_SCHEDULER_ET_IN, .sock = read_fd}; |
714 | struct GNUNET_SCHEDULER_FdInfo write_fdi = {.fh = write_fh, .et = GNUNET_SCHEDULER_ET_OUT, .sock = write_fh->fd}; | 722 | struct GNUNET_SCHEDULER_FdInfo write_fdi = {.fh = write_fh, .et = GNUNET_SCHEDULER_ET_OUT, .sock = write_fd}; |
723 | t->read_fd = read_fd; | ||
724 | t->write_fd = write_fd; | ||
715 | fds[0] = read_fdi; | 725 | fds[0] = read_fdi; |
716 | fds[1] = write_fdi; | 726 | fds[1] = write_fdi; |
717 | t->fds = fds; | 727 | t->fds = fds; |
@@ -719,53 +729,65 @@ init_fd_info (struct GNUNET_SCHEDULER_Task *t, | |||
719 | } | 729 | } |
720 | else if (NULL != read_nh) | 730 | else if (NULL != read_nh) |
721 | { | 731 | { |
722 | struct GNUNET_SCHEDULER_FdInfo read_fdi = {.fd = read_nh, .et = GNUNET_SCHEDULER_ET_IN, .sock = GNUNET_NETWORK_get_fd (read_nh)}; | 732 | int read_fd = GNUNET_NETWORK_get_fd (read_nh); |
733 | struct GNUNET_SCHEDULER_FdInfo read_fdi = {.fd = read_nh, .et = GNUNET_SCHEDULER_ET_IN, .sock = read_fd}; | ||
734 | t->read_fd = read_fd; | ||
735 | t->write_fd = -1; | ||
723 | t->fdx = read_fdi; | 736 | t->fdx = read_fdi; |
724 | t->fds = &t->fdx; | 737 | t->fds = &t->fdx; |
725 | t->fds_len = 1; | 738 | t->fds_len = 1; |
726 | t->read_fd = t->fdx.sock; | ||
727 | } | 739 | } |
728 | else if (NULL != write_nh) | 740 | else if (NULL != write_nh) |
729 | { | 741 | { |
730 | struct GNUNET_SCHEDULER_FdInfo write_fdi = {.fd = write_nh, .et = GNUNET_SCHEDULER_ET_OUT, .sock = GNUNET_NETWORK_get_fd (write_nh)}; | 742 | int write_fd = GNUNET_NETWORK_get_fd (write_nh); |
743 | struct GNUNET_SCHEDULER_FdInfo write_fdi = {.fd = write_nh, .et = GNUNET_SCHEDULER_ET_OUT, .sock = write_fd}; | ||
744 | t->read_fd = -1; | ||
745 | t->write_fd = write_fd; | ||
731 | t->fdx = write_fdi; | 746 | t->fdx = write_fdi; |
732 | t->fds = &t->fdx; | 747 | t->fds = &t->fdx; |
733 | t->fds_len = 1; | 748 | t->fds_len = 1; |
734 | t->write_fd = t->fdx.sock; | ||
735 | } | 749 | } |
736 | else if (NULL != read_fh) | 750 | else if (NULL != read_fh) |
737 | { | 751 | { |
738 | struct GNUNET_SCHEDULER_FdInfo read_fdi = {.fh = read_fh, .et = GNUNET_SCHEDULER_ET_IN, .sock = read_fh->fd}; | 752 | int read_fd = read_fh->fd; |
753 | struct GNUNET_SCHEDULER_FdInfo read_fdi = {.fh = read_fh, .et = GNUNET_SCHEDULER_ET_IN, .sock = read_fd}; | ||
754 | t->read_fd = read_fd; | ||
755 | t->write_fd = -1; | ||
739 | t->fdx = read_fdi; | 756 | t->fdx = read_fdi; |
740 | t->fds = &t->fdx; | 757 | t->fds = &t->fdx; |
741 | t->fds_len = 1; | 758 | t->fds_len = 1; |
742 | t->read_fd = t->fdx.sock; | ||
743 | } | 759 | } |
744 | else if (NULL != write_fh) | 760 | else if (NULL != write_fh) |
745 | { | 761 | { |
746 | struct GNUNET_SCHEDULER_FdInfo write_fdi = {.fh = write_fh, .et = GNUNET_SCHEDULER_ET_OUT, .sock = write_fh->fd}; | 762 | int write_fd = write_fh->fd; |
763 | struct GNUNET_SCHEDULER_FdInfo write_fdi = {.fh = write_fh, .et = GNUNET_SCHEDULER_ET_OUT, .sock = write_fd}; | ||
764 | t->read_fd = -1; | ||
765 | t->write_fd = write_fd; | ||
747 | t->fdx = write_fdi; | 766 | t->fdx = write_fdi; |
748 | t->fds = &t->fdx; | 767 | t->fds = &t->fdx; |
749 | t->fds_len = 1; | 768 | t->fds_len = 1; |
750 | t->write_fd = t->fdx.sock; | ||
751 | } | 769 | } |
752 | } | 770 | } |
753 | 771 | ||
754 | 772 | ||
755 | int scheduler_multi_function_call(struct GNUNET_SCHEDULER_Task *t, int (*driver_func)()) | 773 | void scheduler_multi_function_call(struct GNUNET_SCHEDULER_Task *t, int (*driver_func)()) |
756 | { | 774 | { |
775 | int success = GNUNET_YES; | ||
757 | if (t->fds_len > 1) | 776 | if (t->fds_len > 1) |
758 | { | 777 | { |
759 | int success = GNUNET_YES; | ||
760 | for (int i = 0; i < t->fds_len;i++) | 778 | for (int i = 0; i < t->fds_len;i++) |
761 | { | 779 | { |
762 | success = driver_func (scheduler_driver->cls, t , t->fds+i) && success; | 780 | success = driver_func (scheduler_driver->cls, t , t->fds+i) && success; |
763 | } | 781 | } |
764 | return success; | ||
765 | } | 782 | } |
766 | else | 783 | else |
767 | { | 784 | { |
768 | return driver_func (scheduler_driver->cls, t , t->fds); | 785 | success = driver_func (scheduler_driver->cls, t , t->fds); |
786 | } | ||
787 | if (GNUNET_YES != success) | ||
788 | { | ||
789 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
790 | "driver call not successful"); | ||
769 | } | 791 | } |
770 | } | 792 | } |
771 | 793 | ||
@@ -788,7 +810,9 @@ shutdown_task (void *cls) | |||
788 | 810 | ||
789 | /** | 811 | /** |
790 | * Cancel the task with the specified identifier. | 812 | * Cancel the task with the specified identifier. |
791 | * The task must not yet have run. | 813 | * The task must not yet have run. Only allowed to be called as long as the |
814 | * scheduler is running (#GNUNET_SCHEDULER_run or | ||
815 | * #GNUNET_SCHEDULER_run_with_driver has been called and has not returned yet). | ||
792 | * | 816 | * |
793 | * @param task id of the task to cancel | 817 | * @param task id of the task to cancel |
794 | * @return original closure of the task | 818 | * @return original closure of the task |
@@ -799,6 +823,8 @@ GNUNET_SCHEDULER_cancel (struct GNUNET_SCHEDULER_Task *task) | |||
799 | enum GNUNET_SCHEDULER_Priority p; | 823 | enum GNUNET_SCHEDULER_Priority p; |
800 | void *ret; | 824 | void *ret; |
801 | 825 | ||
826 | /* scheduler must be running */ | ||
827 | GNUNET_assert (NULL != scheduler_driver); | ||
802 | GNUNET_assert ( (NULL != active_task) || | 828 | GNUNET_assert ( (NULL != active_task) || |
803 | (GNUNET_NO == task->lifeness) ); | 829 | (GNUNET_NO == task->lifeness) ); |
804 | if (! task->in_ready_list) | 830 | if (! task->in_ready_list) |
@@ -1133,7 +1159,7 @@ GNUNET_SCHEDULER_add_shutdown (GNUNET_SCHEDULER_TaskCallback task, | |||
1133 | t->timeout = GNUNET_TIME_UNIT_FOREVER_ABS; | 1159 | t->timeout = GNUNET_TIME_UNIT_FOREVER_ABS; |
1134 | t->priority = GNUNET_SCHEDULER_PRIORITY_SHUTDOWN; | 1160 | t->priority = GNUNET_SCHEDULER_PRIORITY_SHUTDOWN; |
1135 | t->on_shutdown = GNUNET_YES; | 1161 | t->on_shutdown = GNUNET_YES; |
1136 | t->lifeness = GNUNET_YES; | 1162 | t->lifeness = GNUNET_NO; |
1137 | GNUNET_CONTAINER_DLL_insert (shutdown_head, | 1163 | GNUNET_CONTAINER_DLL_insert (shutdown_head, |
1138 | shutdown_tail, | 1164 | shutdown_tail, |
1139 | t); | 1165 | t); |
@@ -1258,7 +1284,7 @@ add_without_sets (struct GNUNET_TIME_Relative delay, | |||
1258 | GNUNET_CONTAINER_DLL_insert (pending_head, | 1284 | GNUNET_CONTAINER_DLL_insert (pending_head, |
1259 | pending_tail, | 1285 | pending_tail, |
1260 | t); | 1286 | t); |
1261 | scheduler_multi_function_call(t, scheduler_driver->add); | 1287 | scheduler_multi_function_call (t, scheduler_driver->add); |
1262 | max_priority_added = GNUNET_MAX (max_priority_added, | 1288 | max_priority_added = GNUNET_MAX (max_priority_added, |
1263 | t->priority); | 1289 | t->priority); |
1264 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1290 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
@@ -1276,6 +1302,9 @@ add_without_sets (struct GNUNET_TIME_Relative delay, | |||
1276 | * used as a timeout on the socket being ready. The task will be | 1302 | * used as a timeout on the socket being ready. The task will be |
1277 | * scheduled for execution once either the delay has expired or the | 1303 | * scheduled for execution once either the delay has expired or the |
1278 | * socket operation is ready. It will be run with the DEFAULT priority. | 1304 | * socket operation is ready. It will be run with the DEFAULT priority. |
1305 | * Only allowed to be called as long as the scheduler is running | ||
1306 | * (#GNUNET_SCHEDULER_run or #GNUNET_SCHEDULER_run_with_driver has been | ||
1307 | * called and has not returned yet). | ||
1279 | * | 1308 | * |
1280 | * @param delay when should this operation time out? | 1309 | * @param delay when should this operation time out? |
1281 | * @param rfd read file-descriptor | 1310 | * @param rfd read file-descriptor |
@@ -1303,6 +1332,9 @@ GNUNET_SCHEDULER_add_read_net (struct GNUNET_TIME_Relative delay, | |||
1303 | * socket being ready. The task will be scheduled for execution once | 1332 | * socket being ready. The task will be scheduled for execution once |
1304 | * either the delay has expired or the socket operation is ready. It | 1333 | * either the delay has expired or the socket operation is ready. It |
1305 | * will be run with the DEFAULT priority. | 1334 | * will be run with the DEFAULT priority. |
1335 | * Only allowed to be called as long as the scheduler is running | ||
1336 | * (#GNUNET_SCHEDULER_run or #GNUNET_SCHEDULER_run_with_driver has been | ||
1337 | * called and has not returned yet). | ||
1306 | * | 1338 | * |
1307 | * @param delay when should this operation time out? | 1339 | * @param delay when should this operation time out? |
1308 | * @param priority priority to use for the task | 1340 | * @param priority priority to use for the task |
@@ -1334,6 +1366,9 @@ GNUNET_SCHEDULER_add_read_net_with_priority (struct GNUNET_TIME_Relative delay, | |||
1334 | * scheduled for execution once either the delay has expired or the | 1366 | * scheduled for execution once either the delay has expired or the |
1335 | * socket operation is ready. It will be run with the priority of | 1367 | * socket operation is ready. It will be run with the priority of |
1336 | * the calling task. | 1368 | * the calling task. |
1369 | * Only allowed to be called as long as the scheduler is running | ||
1370 | * (#GNUNET_SCHEDULER_run or #GNUNET_SCHEDULER_run_with_driver has been | ||
1371 | * called and has not returned yet). | ||
1337 | * | 1372 | * |
1338 | * @param delay when should this operation time out? | 1373 | * @param delay when should this operation time out? |
1339 | * @param wfd write file-descriptor | 1374 | * @param wfd write file-descriptor |
@@ -1361,6 +1396,9 @@ GNUNET_SCHEDULER_add_write_net (struct GNUNET_TIME_Relative delay, | |||
1361 | * used as a timeout on the socket being ready. The task will be | 1396 | * used as a timeout on the socket being ready. The task will be |
1362 | * scheduled for execution once either the delay has expired or the | 1397 | * scheduled for execution once either the delay has expired or the |
1363 | * socket operation is ready. | 1398 | * socket operation is ready. |
1399 | * Only allowed to be called as long as the scheduler is running | ||
1400 | * (#GNUNET_SCHEDULER_run or #GNUNET_SCHEDULER_run_with_driver has been | ||
1401 | * called and has not returned yet). | ||
1364 | * | 1402 | * |
1365 | * @param delay when should this operation time out? | 1403 | * @param delay when should this operation time out? |
1366 | * @param priority priority of the task | 1404 | * @param priority priority of the task |
@@ -1381,6 +1419,9 @@ GNUNET_SCHEDULER_add_net_with_priority (struct GNUNET_TIME_Relative delay, | |||
1381 | GNUNET_SCHEDULER_TaskCallback task, | 1419 | GNUNET_SCHEDULER_TaskCallback task, |
1382 | void *task_cls) | 1420 | void *task_cls) |
1383 | { | 1421 | { |
1422 | /* scheduler must be running */ | ||
1423 | GNUNET_assert (NULL != scheduler_driver); | ||
1424 | |||
1384 | #if MINGW | 1425 | #if MINGW |
1385 | struct GNUNET_NETWORK_FDSet *s; | 1426 | struct GNUNET_NETWORK_FDSet *s; |
1386 | struct GNUNET_SCHEDULER_Task * ret; | 1427 | struct GNUNET_SCHEDULER_Task * ret; |
@@ -1414,6 +1455,9 @@ GNUNET_SCHEDULER_add_net_with_priority (struct GNUNET_TIME_Relative delay, | |||
1414 | * used as a timeout on the socket being ready. The task will be | 1455 | * used as a timeout on the socket being ready. The task will be |
1415 | * scheduled for execution once either the delay has expired or the | 1456 | * scheduled for execution once either the delay has expired or the |
1416 | * socket operation is ready. It will be run with the DEFAULT priority. | 1457 | * socket operation is ready. It will be run with the DEFAULT priority. |
1458 | * Only allowed to be called as long as the scheduler is running | ||
1459 | * (#GNUNET_SCHEDULER_run or #GNUNET_SCHEDULER_run_with_driver has been | ||
1460 | * called and has not returned yet). | ||
1417 | * | 1461 | * |
1418 | * @param delay when should this operation time out? | 1462 | * @param delay when should this operation time out? |
1419 | * @param rfd read file-descriptor | 1463 | * @param rfd read file-descriptor |
@@ -1440,6 +1484,9 @@ GNUNET_SCHEDULER_add_read_file (struct GNUNET_TIME_Relative delay, | |||
1440 | * used as a timeout on the socket being ready. The task will be | 1484 | * used as a timeout on the socket being ready. The task will be |
1441 | * scheduled for execution once either the delay has expired or the | 1485 | * scheduled for execution once either the delay has expired or the |
1442 | * socket operation is ready. It will be run with the DEFAULT priority. | 1486 | * socket operation is ready. It will be run with the DEFAULT priority. |
1487 | * Only allowed to be called as long as the scheduler is running | ||
1488 | * (#GNUNET_SCHEDULER_run or #GNUNET_SCHEDULER_run_with_driver has been | ||
1489 | * called and has not returned yet). | ||
1443 | * | 1490 | * |
1444 | * @param delay when should this operation time out? | 1491 | * @param delay when should this operation time out? |
1445 | * @param wfd write file-descriptor | 1492 | * @param wfd write file-descriptor |
@@ -1466,6 +1513,9 @@ GNUNET_SCHEDULER_add_write_file (struct GNUNET_TIME_Relative delay, | |||
1466 | * used as a timeout on the socket being ready. The task will be | 1513 | * used as a timeout on the socket being ready. The task will be |
1467 | * scheduled for execution once either the delay has expired or the | 1514 | * scheduled for execution once either the delay has expired or the |
1468 | * socket operation is ready. | 1515 | * socket operation is ready. |
1516 | * Only allowed to be called as long as the scheduler is running | ||
1517 | * (#GNUNET_SCHEDULER_run or #GNUNET_SCHEDULER_run_with_driver has been | ||
1518 | * called and has not returned yet). | ||
1469 | * | 1519 | * |
1470 | * @param delay when should this operation time out? | 1520 | * @param delay when should this operation time out? |
1471 | * @param priority priority of the task | 1521 | * @param priority priority of the task |
@@ -1484,6 +1534,9 @@ GNUNET_SCHEDULER_add_file_with_priority (struct GNUNET_TIME_Relative delay, | |||
1484 | int on_read, int on_write, | 1534 | int on_read, int on_write, |
1485 | GNUNET_SCHEDULER_TaskCallback task, void *task_cls) | 1535 | GNUNET_SCHEDULER_TaskCallback task, void *task_cls) |
1486 | { | 1536 | { |
1537 | /* scheduler must be running */ | ||
1538 | GNUNET_assert (NULL != scheduler_driver); | ||
1539 | |||
1487 | #if MINGW | 1540 | #if MINGW |
1488 | struct GNUNET_NETWORK_FDSet *s; | 1541 | struct GNUNET_NETWORK_FDSet *s; |
1489 | struct GNUNET_SCHEDULER_Task * ret; | 1542 | struct GNUNET_SCHEDULER_Task * ret; |
@@ -1526,6 +1579,9 @@ GNUNET_SCHEDULER_add_file_with_priority (struct GNUNET_TIME_Relative delay, | |||
1526 | * || any-rs-ready | 1579 | * || any-rs-ready |
1527 | * || any-ws-ready) ) | 1580 | * || any-ws-ready) ) |
1528 | * </code> | 1581 | * </code> |
1582 | * Only allowed to be called as long as the scheduler is running | ||
1583 | * (#GNUNET_SCHEDULER_run or #GNUNET_SCHEDULER_run_with_driver has been | ||
1584 | * called and has not returned yet). | ||
1529 | * | 1585 | * |
1530 | * @param prio how important is this task? | 1586 | * @param prio how important is this task? |
1531 | * @param delay how long should we wait? | 1587 | * @param delay how long should we wait? |
@@ -1552,6 +1608,8 @@ GNUNET_SCHEDULER_add_select (enum GNUNET_SCHEDULER_Priority prio, | |||
1552 | prio, | 1608 | prio, |
1553 | task, | 1609 | task, |
1554 | task_cls); | 1610 | task_cls); |
1611 | /* scheduler must be running */ | ||
1612 | GNUNET_assert (NULL != scheduler_driver); | ||
1555 | GNUNET_assert (NULL != active_task); | 1613 | GNUNET_assert (NULL != active_task); |
1556 | GNUNET_assert (NULL != task); | 1614 | GNUNET_assert (NULL != task); |
1557 | t = GNUNET_new (struct GNUNET_SCHEDULER_Task); | 1615 | t = GNUNET_new (struct GNUNET_SCHEDULER_Task); |
@@ -1581,7 +1639,7 @@ GNUNET_SCHEDULER_add_select (enum GNUNET_SCHEDULER_Priority prio, | |||
1581 | GNUNET_CONTAINER_DLL_insert (pending_head, | 1639 | GNUNET_CONTAINER_DLL_insert (pending_head, |
1582 | pending_tail, | 1640 | pending_tail, |
1583 | t); | 1641 | t); |
1584 | scheduler_multi_function_call(t, scheduler_driver->add); | 1642 | scheduler_multi_function_call (t, scheduler_driver->add); |
1585 | max_priority_added = GNUNET_MAX (max_priority_added, | 1643 | max_priority_added = GNUNET_MAX (max_priority_added, |
1586 | t->priority); | 1644 | t->priority); |
1587 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1645 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
@@ -1868,6 +1926,8 @@ select_add (void *cls, | |||
1868 | { | 1926 | { |
1869 | struct DriverContext *context = cls; | 1927 | struct DriverContext *context = cls; |
1870 | GNUNET_assert (NULL != context); | 1928 | GNUNET_assert (NULL != context); |
1929 | GNUNET_assert (NULL != task); | ||
1930 | GNUNET_assert (NULL != fdi); | ||
1871 | 1931 | ||
1872 | if (!((NULL != fdi->fd) ^ (NULL != fdi->fh)) || (0 >= fdi->sock)) | 1932 | if (!((NULL != fdi->fd) ^ (NULL != fdi->fh)) || (0 >= fdi->sock)) |
1873 | { | 1933 | { |