diff options
Diffstat (limited to 'src/util/scheduler.c')
-rw-r--r-- | src/util/scheduler.c | 149 |
1 files changed, 73 insertions, 76 deletions
diff --git a/src/util/scheduler.c b/src/util/scheduler.c index 9412457f6..844531b37 100644 --- a/src/util/scheduler.c +++ b/src/util/scheduler.c | |||
@@ -349,8 +349,7 @@ is_pending (GNUNET_SCHEDULER_TaskIdentifier id) | |||
349 | * @param timeout next timeout (updated) | 349 | * @param timeout next timeout (updated) |
350 | */ | 350 | */ |
351 | static void | 351 | static void |
352 | update_sets (struct GNUNET_NETWORK_FDSet *rs, | 352 | update_sets (struct GNUNET_NETWORK_FDSet *rs, struct GNUNET_NETWORK_FDSet *ws, |
353 | struct GNUNET_NETWORK_FDSet *ws, | ||
354 | struct GNUNET_TIME_Relative *timeout) | 353 | struct GNUNET_TIME_Relative *timeout) |
355 | { | 354 | { |
356 | struct Task *pos; | 355 | struct Task *pos; |
@@ -434,8 +433,7 @@ set_overlaps (const struct GNUNET_NETWORK_FDSet *ready, | |||
434 | * @return GNUNET_YES if we can run it, GNUNET_NO if not. | 433 | * @return GNUNET_YES if we can run it, GNUNET_NO if not. |
435 | */ | 434 | */ |
436 | static int | 435 | static int |
437 | is_ready (struct Task *task, | 436 | is_ready (struct Task *task, struct GNUNET_TIME_Absolute now, |
438 | struct GNUNET_TIME_Absolute now, | ||
439 | const struct GNUNET_NETWORK_FDSet *rs, | 437 | const struct GNUNET_NETWORK_FDSet *rs, |
440 | const struct GNUNET_NETWORK_FDSet *ws) | 438 | const struct GNUNET_NETWORK_FDSet *ws) |
441 | { | 439 | { |
@@ -525,8 +523,8 @@ check_ready (const struct GNUNET_NETWORK_FDSet *rs, | |||
525 | { | 523 | { |
526 | #if DEBUG_TASKS | 524 | #if DEBUG_TASKS |
527 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 525 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
528 | "Checking readiness of task: %llu / %p\n", | 526 | "Checking readiness of task: %llu / %p\n", pos->id, |
529 | pos->id, pos->callback_cls); | 527 | pos->callback_cls); |
530 | #endif | 528 | #endif |
531 | next = pos->next; | 529 | next = pos->next; |
532 | if (GNUNET_YES == is_ready (pos, now, rs, ws)) | 530 | if (GNUNET_YES == is_ready (pos, now, rs, ws)) |
@@ -657,11 +655,10 @@ run_ready (struct GNUNET_NETWORK_FDSet *rs, struct GNUNET_NETWORK_FDSet *ws) | |||
657 | DELAY_THRESHOLD.rel_value) | 655 | DELAY_THRESHOLD.rel_value) |
658 | { | 656 | { |
659 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 657 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
660 | "Task %llu took %llums to be scheduled\n", | 658 | "Task %llu took %llums to be scheduled\n", pos->id, |
661 | pos->id, | 659 | (unsigned long long) GNUNET_TIME_absolute_get_duration (pos-> |
662 | (unsigned long long) | 660 | start_time). |
663 | GNUNET_TIME_absolute_get_duration | 661 | rel_value); |
664 | (pos->start_time).rel_value); | ||
665 | } | 662 | } |
666 | #endif | 663 | #endif |
667 | tc.reason = pos->reason; | 664 | tc.reason = pos->reason; |
@@ -678,17 +675,16 @@ run_ready (struct GNUNET_NETWORK_FDSet *rs, struct GNUNET_NETWORK_FDSet *ws) | |||
678 | (!GNUNET_NETWORK_fdset_test_native (ws, pos->write_fd))) | 675 | (!GNUNET_NETWORK_fdset_test_native (ws, pos->write_fd))) |
679 | abort (); // added to ready in previous select loop! | 676 | abort (); // added to ready in previous select loop! |
680 | #if DEBUG_TASKS | 677 | #if DEBUG_TASKS |
681 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 678 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Running task: %llu / %p\n", pos->id, |
682 | "Running task: %llu / %p\n", pos->id, pos->callback_cls); | 679 | pos->callback_cls); |
683 | #endif | 680 | #endif |
684 | pos->callback (pos->callback_cls, &tc); | 681 | pos->callback (pos->callback_cls, &tc); |
685 | #if EXECINFO | 682 | #if EXECINFO |
686 | int i; | 683 | int i; |
687 | 684 | ||
688 | for (i = 0; i < pos->num_backtrace_strings; i++) | 685 | for (i = 0; i < pos->num_backtrace_strings; i++) |
689 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 686 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Task %llu trace %d: %s\n", pos->id, |
690 | "Task %llu trace %d: %s\n", | 687 | i, pos->backtrace_strings[i]); |
691 | pos->id, i, pos->backtrace_strings[i]); | ||
692 | #endif | 688 | #endif |
693 | active_task = NULL; | 689 | active_task = NULL; |
694 | destroy_task (pos); | 690 | destroy_task (pos); |
@@ -809,8 +805,8 @@ GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_Task task, void *task_cls) | |||
809 | #endif | 805 | #endif |
810 | current_priority = GNUNET_SCHEDULER_PRIORITY_DEFAULT; | 806 | current_priority = GNUNET_SCHEDULER_PRIORITY_DEFAULT; |
811 | current_lifeness = GNUNET_YES; | 807 | current_lifeness = GNUNET_YES; |
812 | GNUNET_SCHEDULER_add_continuation (task, | 808 | GNUNET_SCHEDULER_add_continuation (task, task_cls, |
813 | task_cls, GNUNET_SCHEDULER_REASON_STARTUP); | 809 | GNUNET_SCHEDULER_REASON_STARTUP); |
814 | #if ENABLE_WINDOWS_WORKAROUNDS | 810 | #if ENABLE_WINDOWS_WORKAROUNDS |
815 | active_task = (void *) (long) -1; /* force passing of sanity check */ | 811 | active_task = (void *) (long) -1; /* force passing of sanity check */ |
816 | GNUNET_SCHEDULER_add_now_with_lifeness (GNUNET_NO, | 812 | GNUNET_SCHEDULER_add_now_with_lifeness (GNUNET_NO, |
@@ -1031,8 +1027,8 @@ GNUNET_SCHEDULER_cancel (GNUNET_SCHEDULER_TaskIdentifier task) | |||
1031 | } | 1027 | } |
1032 | ret = t->callback_cls; | 1028 | ret = t->callback_cls; |
1033 | #if DEBUG_TASKS | 1029 | #if DEBUG_TASKS |
1034 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1030 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Canceling task: %llu / %p\n", task, |
1035 | "Canceling task: %llu / %p\n", task, t->callback_cls); | 1031 | t->callback_cls); |
1036 | #endif | 1032 | #endif |
1037 | destroy_task (t); | 1033 | destroy_task (t); |
1038 | return ret; | 1034 | return ret; |
@@ -1049,8 +1045,7 @@ GNUNET_SCHEDULER_cancel (GNUNET_SCHEDULER_TaskIdentifier task) | |||
1049 | * @param reason reason for task invocation | 1045 | * @param reason reason for task invocation |
1050 | */ | 1046 | */ |
1051 | void | 1047 | void |
1052 | GNUNET_SCHEDULER_add_continuation (GNUNET_SCHEDULER_Task task, | 1048 | GNUNET_SCHEDULER_add_continuation (GNUNET_SCHEDULER_Task task, void *task_cls, |
1053 | void *task_cls, | ||
1054 | enum GNUNET_SCHEDULER_Reason reason) | 1049 | enum GNUNET_SCHEDULER_Reason reason) |
1055 | { | 1050 | { |
1056 | struct Task *t; | 1051 | struct Task *t; |
@@ -1080,8 +1075,8 @@ GNUNET_SCHEDULER_add_continuation (GNUNET_SCHEDULER_Task task, | |||
1080 | t->priority = current_priority; | 1075 | t->priority = current_priority; |
1081 | t->lifeness = current_lifeness; | 1076 | t->lifeness = current_lifeness; |
1082 | #if DEBUG_TASKS | 1077 | #if DEBUG_TASKS |
1083 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1078 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding continuation task: %llu / %p\n", |
1084 | "Adding continuation task: %llu / %p\n", t->id, t->callback_cls); | 1079 | t->id, t->callback_cls); |
1085 | #endif | 1080 | #endif |
1086 | queue_ready_task (t); | 1081 | queue_ready_task (t); |
1087 | } | 1082 | } |
@@ -1109,8 +1104,7 @@ GNUNET_SCHEDULER_add_after (GNUNET_SCHEDULER_TaskIdentifier prerequisite_task, | |||
1109 | GNUNET_SCHEDULER_Task task, void *task_cls) | 1104 | GNUNET_SCHEDULER_Task task, void *task_cls) |
1110 | { | 1105 | { |
1111 | return GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_KEEP, | 1106 | return GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_KEEP, |
1112 | prerequisite_task, | 1107 | prerequisite_task, GNUNET_TIME_UNIT_ZERO, |
1113 | GNUNET_TIME_UNIT_ZERO, | ||
1114 | NULL, NULL, task, task_cls); | 1108 | NULL, NULL, task, task_cls); |
1115 | } | 1109 | } |
1116 | 1110 | ||
@@ -1128,10 +1122,9 @@ GNUNET_SCHEDULER_TaskIdentifier | |||
1128 | GNUNET_SCHEDULER_add_with_priority (enum GNUNET_SCHEDULER_Priority prio, | 1122 | GNUNET_SCHEDULER_add_with_priority (enum GNUNET_SCHEDULER_Priority prio, |
1129 | GNUNET_SCHEDULER_Task task, void *task_cls) | 1123 | GNUNET_SCHEDULER_Task task, void *task_cls) |
1130 | { | 1124 | { |
1131 | return GNUNET_SCHEDULER_add_select (prio, | 1125 | return GNUNET_SCHEDULER_add_select (prio, GNUNET_SCHEDULER_NO_TASK, |
1132 | GNUNET_SCHEDULER_NO_TASK, | 1126 | GNUNET_TIME_UNIT_ZERO, NULL, NULL, task, |
1133 | GNUNET_TIME_UNIT_ZERO, | 1127 | task_cls); |
1134 | NULL, NULL, task, task_cls); | ||
1135 | } | 1128 | } |
1136 | 1129 | ||
1137 | 1130 | ||
@@ -1212,23 +1205,23 @@ GNUNET_SCHEDULER_add_delayed (struct GNUNET_TIME_Relative delay, | |||
1212 | pending_timeout_last = t; | 1205 | pending_timeout_last = t; |
1213 | 1206 | ||
1214 | #if DEBUG_TASKS | 1207 | #if DEBUG_TASKS |
1215 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1208 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding task: %llu / %p\n", t->id, |
1216 | "Adding task: %llu / %p\n", t->id, t->callback_cls); | 1209 | t->callback_cls); |
1217 | #endif | 1210 | #endif |
1218 | #if EXECINFO | 1211 | #if EXECINFO |
1219 | int i; | 1212 | int i; |
1220 | 1213 | ||
1221 | for (i = 0; i < t->num_backtrace_strings; i++) | 1214 | for (i = 0; i < t->num_backtrace_strings; i++) |
1222 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1215 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Task %llu trace %d: %s\n", t->id, i, |
1223 | "Task %llu trace %d: %s\n", t->id, i, t->backtrace_strings[i]); | 1216 | t->backtrace_strings[i]); |
1224 | #endif | 1217 | #endif |
1225 | return t->id; | 1218 | return t->id; |
1226 | 1219 | ||
1227 | #else | 1220 | #else |
1228 | /* unoptimized version */ | 1221 | /* unoptimized version */ |
1229 | return GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_KEEP, | 1222 | return GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_KEEP, |
1230 | GNUNET_SCHEDULER_NO_TASK, delay, | 1223 | GNUNET_SCHEDULER_NO_TASK, delay, NULL, |
1231 | NULL, NULL, task, task_cls); | 1224 | NULL, task, task_cls); |
1232 | #endif | 1225 | #endif |
1233 | } | 1226 | } |
1234 | 1227 | ||
@@ -1248,8 +1241,8 @@ GNUNET_SCHEDULER_add_now (GNUNET_SCHEDULER_Task task, void *task_cls) | |||
1248 | { | 1241 | { |
1249 | return GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_KEEP, | 1242 | return GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_KEEP, |
1250 | GNUNET_SCHEDULER_NO_TASK, | 1243 | GNUNET_SCHEDULER_NO_TASK, |
1251 | GNUNET_TIME_UNIT_ZERO, | 1244 | GNUNET_TIME_UNIT_ZERO, NULL, NULL, task, |
1252 | NULL, NULL, task, task_cls); | 1245 | task_cls); |
1253 | } | 1246 | } |
1254 | 1247 | ||
1255 | 1248 | ||
@@ -1274,10 +1267,11 @@ GNUNET_SCHEDULER_add_now_with_lifeness (int lifeness, | |||
1274 | { | 1267 | { |
1275 | GNUNET_SCHEDULER_TaskIdentifier ret; | 1268 | GNUNET_SCHEDULER_TaskIdentifier ret; |
1276 | 1269 | ||
1277 | ret = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_KEEP, | 1270 | ret = |
1278 | GNUNET_SCHEDULER_NO_TASK, | 1271 | GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_KEEP, |
1279 | GNUNET_TIME_UNIT_ZERO, | 1272 | GNUNET_SCHEDULER_NO_TASK, |
1280 | NULL, NULL, task, task_cls); | 1273 | GNUNET_TIME_UNIT_ZERO, NULL, NULL, task, |
1274 | task_cls); | ||
1281 | GNUNET_assert (pending->id == ret); | 1275 | GNUNET_assert (pending->id == ret); |
1282 | pending->lifeness = lifeness; | 1276 | pending->lifeness = lifeness; |
1283 | return ret; | 1277 | return ret; |
@@ -1314,8 +1308,8 @@ GNUNET_SCHEDULER_add_now_with_lifeness (int lifeness, | |||
1314 | */ | 1308 | */ |
1315 | #ifndef MINGW | 1309 | #ifndef MINGW |
1316 | GNUNET_SCHEDULER_TaskIdentifier | 1310 | GNUNET_SCHEDULER_TaskIdentifier |
1317 | add_without_sets (struct GNUNET_TIME_Relative delay, | 1311 | add_without_sets (struct GNUNET_TIME_Relative delay, int rfd, int wfd, |
1318 | int rfd, int wfd, GNUNET_SCHEDULER_Task task, void *task_cls) | 1312 | GNUNET_SCHEDULER_Task task, void *task_cls) |
1319 | { | 1313 | { |
1320 | struct Task *t; | 1314 | struct Task *t; |
1321 | 1315 | ||
@@ -1346,8 +1340,8 @@ add_without_sets (struct GNUNET_TIME_Relative delay, | |||
1346 | int i; | 1340 | int i; |
1347 | 1341 | ||
1348 | for (i = 0; i < t->num_backtrace_strings; i++) | 1342 | for (i = 0; i < t->num_backtrace_strings; i++) |
1349 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1343 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Trace: %s\n", |
1350 | "Trace: %s\n", t->backtrace_strings[i]); | 1344 | t->backtrace_strings[i]); |
1351 | #endif | 1345 | #endif |
1352 | GNUNET_assert (0); | 1346 | GNUNET_assert (0); |
1353 | } | 1347 | } |
@@ -1364,8 +1358,8 @@ add_without_sets (struct GNUNET_TIME_Relative delay, | |||
1364 | int i; | 1358 | int i; |
1365 | 1359 | ||
1366 | for (i = 0; i < t->num_backtrace_strings; i++) | 1360 | for (i = 0; i < t->num_backtrace_strings; i++) |
1367 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1361 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Trace: %s\n", |
1368 | "Trace: %s\n", t->backtrace_strings[i]); | 1362 | t->backtrace_strings[i]); |
1369 | #endif | 1363 | #endif |
1370 | GNUNET_assert (0); | 1364 | GNUNET_assert (0); |
1371 | } | 1365 | } |
@@ -1386,15 +1380,15 @@ add_without_sets (struct GNUNET_TIME_Relative delay, | |||
1386 | pending = t; | 1380 | pending = t; |
1387 | max_priority_added = GNUNET_MAX (max_priority_added, t->priority); | 1381 | max_priority_added = GNUNET_MAX (max_priority_added, t->priority); |
1388 | #if DEBUG_TASKS | 1382 | #if DEBUG_TASKS |
1389 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1383 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding task: %llu / %p\n", t->id, |
1390 | "Adding task: %llu / %p\n", t->id, t->callback_cls); | 1384 | t->callback_cls); |
1391 | #endif | 1385 | #endif |
1392 | #if EXECINFO | 1386 | #if EXECINFO |
1393 | int i; | 1387 | int i; |
1394 | 1388 | ||
1395 | for (i = 0; i < t->num_backtrace_strings; i++) | 1389 | for (i = 0; i < t->num_backtrace_strings; i++) |
1396 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1390 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Task %llu trace %d: %s\n", t->id, i, |
1397 | "Task %llu trace %d: %s\n", t->id, i, t->backtrace_strings[i]); | 1391 | t->backtrace_strings[i]); |
1398 | #endif | 1392 | #endif |
1399 | return t->id; | 1393 | return t->id; |
1400 | } | 1394 | } |
@@ -1430,14 +1424,15 @@ GNUNET_SCHEDULER_add_read_net (struct GNUNET_TIME_Relative delay, | |||
1430 | GNUNET_assert (rfd != NULL); | 1424 | GNUNET_assert (rfd != NULL); |
1431 | rs = GNUNET_NETWORK_fdset_create (); | 1425 | rs = GNUNET_NETWORK_fdset_create (); |
1432 | GNUNET_NETWORK_fdset_set (rs, rfd); | 1426 | GNUNET_NETWORK_fdset_set (rs, rfd); |
1433 | ret = GNUNET_SCHEDULER_add_select (check_priority (current_priority), | 1427 | ret = |
1434 | GNUNET_SCHEDULER_NO_TASK, delay, | 1428 | GNUNET_SCHEDULER_add_select (check_priority (current_priority), |
1435 | rs, NULL, task, task_cls); | 1429 | GNUNET_SCHEDULER_NO_TASK, delay, rs, NULL, |
1430 | task, task_cls); | ||
1436 | GNUNET_NETWORK_fdset_destroy (rs); | 1431 | GNUNET_NETWORK_fdset_destroy (rs); |
1437 | return ret; | 1432 | return ret; |
1438 | #else | 1433 | #else |
1439 | return add_without_sets (delay, | 1434 | return add_without_sets (delay, GNUNET_NETWORK_get_fd (rfd), -1, task, |
1440 | GNUNET_NETWORK_get_fd (rfd), -1, task, task_cls); | 1435 | task_cls); |
1441 | #endif | 1436 | #endif |
1442 | } | 1437 | } |
1443 | 1438 | ||
@@ -1470,15 +1465,16 @@ GNUNET_SCHEDULER_add_write_net (struct GNUNET_TIME_Relative delay, | |||
1470 | GNUNET_assert (wfd != NULL); | 1465 | GNUNET_assert (wfd != NULL); |
1471 | ws = GNUNET_NETWORK_fdset_create (); | 1466 | ws = GNUNET_NETWORK_fdset_create (); |
1472 | GNUNET_NETWORK_fdset_set (ws, wfd); | 1467 | GNUNET_NETWORK_fdset_set (ws, wfd); |
1473 | ret = GNUNET_SCHEDULER_add_select (check_priority (current_priority), | 1468 | ret = |
1474 | GNUNET_SCHEDULER_NO_TASK, delay, | 1469 | GNUNET_SCHEDULER_add_select (check_priority (current_priority), |
1475 | NULL, ws, task, task_cls); | 1470 | GNUNET_SCHEDULER_NO_TASK, delay, NULL, ws, |
1471 | task, task_cls); | ||
1476 | GNUNET_NETWORK_fdset_destroy (ws); | 1472 | GNUNET_NETWORK_fdset_destroy (ws); |
1477 | return ret; | 1473 | return ret; |
1478 | #else | 1474 | #else |
1479 | GNUNET_assert (GNUNET_NETWORK_get_fd (wfd) >= 0); | 1475 | GNUNET_assert (GNUNET_NETWORK_get_fd (wfd) >= 0); |
1480 | return add_without_sets (delay, | 1476 | return add_without_sets (delay, -1, GNUNET_NETWORK_get_fd (wfd), task, |
1481 | -1, GNUNET_NETWORK_get_fd (wfd), task, task_cls); | 1477 | task_cls); |
1482 | #endif | 1478 | #endif |
1483 | } | 1479 | } |
1484 | 1480 | ||
@@ -1511,9 +1507,10 @@ GNUNET_SCHEDULER_add_read_file (struct GNUNET_TIME_Relative delay, | |||
1511 | GNUNET_assert (rfd != NULL); | 1507 | GNUNET_assert (rfd != NULL); |
1512 | rs = GNUNET_NETWORK_fdset_create (); | 1508 | rs = GNUNET_NETWORK_fdset_create (); |
1513 | GNUNET_NETWORK_fdset_handle_set (rs, rfd); | 1509 | GNUNET_NETWORK_fdset_handle_set (rs, rfd); |
1514 | ret = GNUNET_SCHEDULER_add_select (check_priority (current_priority), | 1510 | ret = |
1515 | GNUNET_SCHEDULER_NO_TASK, delay, | 1511 | GNUNET_SCHEDULER_add_select (check_priority (current_priority), |
1516 | rs, NULL, task, task_cls); | 1512 | GNUNET_SCHEDULER_NO_TASK, delay, rs, NULL, |
1513 | task, task_cls); | ||
1517 | GNUNET_NETWORK_fdset_destroy (rs); | 1514 | GNUNET_NETWORK_fdset_destroy (rs); |
1518 | return ret; | 1515 | return ret; |
1519 | #else | 1516 | #else |
@@ -1554,9 +1551,10 @@ GNUNET_SCHEDULER_add_write_file (struct GNUNET_TIME_Relative delay, | |||
1554 | GNUNET_assert (wfd != NULL); | 1551 | GNUNET_assert (wfd != NULL); |
1555 | ws = GNUNET_NETWORK_fdset_create (); | 1552 | ws = GNUNET_NETWORK_fdset_create (); |
1556 | GNUNET_NETWORK_fdset_handle_set (ws, wfd); | 1553 | GNUNET_NETWORK_fdset_handle_set (ws, wfd); |
1557 | ret = GNUNET_SCHEDULER_add_select (check_priority (current_priority), | 1554 | ret = |
1558 | GNUNET_SCHEDULER_NO_TASK, | 1555 | GNUNET_SCHEDULER_add_select (check_priority (current_priority), |
1559 | delay, NULL, ws, task, task_cls); | 1556 | GNUNET_SCHEDULER_NO_TASK, delay, NULL, ws, |
1557 | task, task_cls); | ||
1560 | GNUNET_NETWORK_fdset_destroy (ws); | 1558 | GNUNET_NETWORK_fdset_destroy (ws); |
1561 | return ret; | 1559 | return ret; |
1562 | #else | 1560 | #else |
@@ -1605,8 +1603,7 @@ GNUNET_SCHEDULER_add_write_file (struct GNUNET_TIME_Relative delay, | |||
1605 | */ | 1603 | */ |
1606 | GNUNET_SCHEDULER_TaskIdentifier | 1604 | GNUNET_SCHEDULER_TaskIdentifier |
1607 | GNUNET_SCHEDULER_add_select (enum GNUNET_SCHEDULER_Priority prio, | 1605 | GNUNET_SCHEDULER_add_select (enum GNUNET_SCHEDULER_Priority prio, |
1608 | GNUNET_SCHEDULER_TaskIdentifier | 1606 | GNUNET_SCHEDULER_TaskIdentifier prerequisite_task, |
1609 | prerequisite_task, | ||
1610 | struct GNUNET_TIME_Relative delay, | 1607 | struct GNUNET_TIME_Relative delay, |
1611 | const struct GNUNET_NETWORK_FDSet *rs, | 1608 | const struct GNUNET_NETWORK_FDSet *rs, |
1612 | const struct GNUNET_NETWORK_FDSet *ws, | 1609 | const struct GNUNET_NETWORK_FDSet *ws, |
@@ -1648,22 +1645,22 @@ GNUNET_SCHEDULER_add_select (enum GNUNET_SCHEDULER_Priority prio, | |||
1648 | t->timeout = GNUNET_TIME_relative_to_absolute (delay); | 1645 | t->timeout = GNUNET_TIME_relative_to_absolute (delay); |
1649 | t->priority = | 1646 | t->priority = |
1650 | check_priority ((prio == | 1647 | check_priority ((prio == |
1651 | GNUNET_SCHEDULER_PRIORITY_KEEP) ? current_priority | 1648 | GNUNET_SCHEDULER_PRIORITY_KEEP) ? current_priority : |
1652 | : prio); | 1649 | prio); |
1653 | t->lifeness = current_lifeness; | 1650 | t->lifeness = current_lifeness; |
1654 | t->next = pending; | 1651 | t->next = pending; |
1655 | pending = t; | 1652 | pending = t; |
1656 | max_priority_added = GNUNET_MAX (max_priority_added, t->priority); | 1653 | max_priority_added = GNUNET_MAX (max_priority_added, t->priority); |
1657 | #if DEBUG_TASKS | 1654 | #if DEBUG_TASKS |
1658 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1655 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding task: %llu / %p\n", t->id, |
1659 | "Adding task: %llu / %p\n", t->id, t->callback_cls); | 1656 | t->callback_cls); |
1660 | #endif | 1657 | #endif |
1661 | #if EXECINFO | 1658 | #if EXECINFO |
1662 | int i; | 1659 | int i; |
1663 | 1660 | ||
1664 | for (i = 0; i < t->num_backtrace_strings; i++) | 1661 | for (i = 0; i < t->num_backtrace_strings; i++) |
1665 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1662 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Task %llu trace %d: %s\n", t->id, i, |
1666 | "Task %llu trace %d: %s\n", t->id, i, t->backtrace_strings[i]); | 1663 | t->backtrace_strings[i]); |
1667 | #endif | 1664 | #endif |
1668 | return t->id; | 1665 | return t->id; |
1669 | } | 1666 | } |