aboutsummaryrefslogtreecommitdiff
path: root/src/util/scheduler.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/scheduler.c')
-rw-r--r--src/util/scheduler.c374
1 files changed, 168 insertions, 206 deletions
diff --git a/src/util/scheduler.c b/src/util/scheduler.c
index 9b8ab4b29..341400bba 100644
--- a/src/util/scheduler.c
+++ b/src/util/scheduler.c
@@ -163,84 +163,76 @@ struct Task
163 163
164 164
165/** 165/**
166 * Handle for the scheduling service. 166* List of tasks waiting for an event.
167 */ 167*/
168struct GNUNET_SCHEDULER_Handle 168struct Task *pending;
169{
170
171 /**
172 * List of tasks waiting for an event.
173 */
174 struct Task *pending;
175
176 /**
177 * List of tasks waiting ONLY for a timeout event.
178 * Sorted by timeout (earliest first). Used so that
179 * we do not traverse the list of these tasks when
180 * building select sets (we just look at the head
181 * to determine the respective timeout ONCE).
182 */
183 struct Task *pending_timeout;
184 169
185 /** 170/**
186 * Last inserted task waiting ONLY for a timeout event. 171* List of tasks waiting ONLY for a timeout event.
187 * Used to (heuristically) speed up insertion. 172* Sorted by timeout (earliest first). Used so that
188 */ 173* we do not traverse the list of these tasks when
189 struct Task *pending_timeout_last; 174* building select sets (we just look at the head
175* to determine the respective timeout ONCE).
176*/
177struct Task *pending_timeout;
190 178
191 /** 179/**
192 * ID of the task that is running right now. 180* Last inserted task waiting ONLY for a timeout event.
193 */ 181* Used to (heuristically) speed up insertion.
194 struct Task *active_task; 182*/
183struct Task *pending_timeout_last;
195 184
196 /** 185/**
197 * List of tasks ready to run right now, 186* ID of the task that is running right now.
198 * grouped by importance. 187*/
199 */ 188struct Task *active_task;
200 struct Task *ready[GNUNET_SCHEDULER_PRIORITY_COUNT];
201 189
202 /** 190/**
203 * Identity of the last task queued. Incremented for each task to 191* List of tasks ready to run right now,
204 * generate a unique task ID (it is virtually impossible to start 192* grouped by importance.
205 * more than 2^64 tasks during the lifetime of a process). 193*/
206 */ 194struct Task *ready[GNUNET_SCHEDULER_PRIORITY_COUNT];
207 GNUNET_SCHEDULER_TaskIdentifier last_id;
208 195
209 /** 196/**
210 * Highest number so that all tasks with smaller identifiers 197* Identity of the last task queued. Incremented for each task to
211 * have already completed. Also the lowest number of a task 198* generate a unique task ID (it is virtually impossible to start
212 * still waiting to be executed. 199* more than 2^64 tasks during the lifetime of a process).
213 */ 200*/
214 GNUNET_SCHEDULER_TaskIdentifier lowest_pending_id; 201GNUNET_SCHEDULER_TaskIdentifier last_id;
215 202
216 /** 203/**
217 * Number of tasks on the ready list. 204* Highest number so that all tasks with smaller identifiers
218 */ 205* have already completed. Also the lowest number of a task
219 unsigned int ready_count; 206* still waiting to be executed.
207*/
208GNUNET_SCHEDULER_TaskIdentifier lowest_pending_id;
220 209
221 /** 210/**
222 * How many tasks have we run so far? 211* Number of tasks on the ready list.
223 */ 212*/
224 unsigned long long tasks_run; 213unsigned int ready_count;
225 214
226 /** 215/**
227 * Priority of the task running right now. Only 216* How many tasks have we run so far?
228 * valid while a task is running. 217*/
229 */ 218unsigned long long tasks_run;
230 enum GNUNET_SCHEDULER_Priority current_priority;
231 219
232 /** 220/**
233 * Priority of the highest task added in the current select 221* Priority of the task running right now. Only
234 * iteration. 222* valid while a task is running.
235 */ 223*/
236 enum GNUNET_SCHEDULER_Priority max_priority_added; 224enum GNUNET_SCHEDULER_Priority current_priority;
237 225
238 /** 226/**
239 * How 'nice' are we right now? 227* Priority of the highest task added in the current select
240 */ 228* iteration.
241 int nice_level; 229*/
230enum GNUNET_SCHEDULER_Priority max_priority_added;
242 231
243}; 232/**
233* How 'nice' are we right now?
234*/
235int nice_level;
244 236
245 237
246/** 238/**
@@ -270,17 +262,16 @@ check_priority (enum GNUNET_SCHEDULER_Priority p)
270 * @return GNUNET_YES if so, GNUNET_NO if not 262 * @return GNUNET_YES if so, GNUNET_NO if not
271 */ 263 */
272static int 264static int
273is_pending (struct GNUNET_SCHEDULER_Handle *sched, 265is_pending (GNUNET_SCHEDULER_TaskIdentifier id)
274 GNUNET_SCHEDULER_TaskIdentifier id)
275{ 266{
276 struct Task *pos; 267 struct Task *pos;
277 enum GNUNET_SCHEDULER_Priority p; 268 enum GNUNET_SCHEDULER_Priority p;
278 GNUNET_SCHEDULER_TaskIdentifier min; 269 GNUNET_SCHEDULER_TaskIdentifier min;
279 270
280 if (id < sched->lowest_pending_id) 271 if (id < lowest_pending_id)
281 return GNUNET_NO; 272 return GNUNET_NO;
282 min = -1; /* maximum value */ 273 min = -1; /* maximum value */
283 pos = sched->pending; 274 pos = pending;
284 while (pos != NULL) 275 while (pos != NULL)
285 { 276 {
286 if (pos->id == id) 277 if (pos->id == id)
@@ -289,7 +280,7 @@ is_pending (struct GNUNET_SCHEDULER_Handle *sched,
289 min = pos->id; 280 min = pos->id;
290 pos = pos->next; 281 pos = pos->next;
291 } 282 }
292 pos = sched->pending_timeout; 283 pos = pending_timeout;
293 while (pos != NULL) 284 while (pos != NULL)
294 { 285 {
295 if (pos->id == id) 286 if (pos->id == id)
@@ -300,7 +291,7 @@ is_pending (struct GNUNET_SCHEDULER_Handle *sched,
300 } 291 }
301 for (p = 0; p < GNUNET_SCHEDULER_PRIORITY_COUNT; p++) 292 for (p = 0; p < GNUNET_SCHEDULER_PRIORITY_COUNT; p++)
302 { 293 {
303 pos = sched->ready[p]; 294 pos = ready[p];
304 while (pos != NULL) 295 while (pos != NULL)
305 { 296 {
306 if (pos->id == id) 297 if (pos->id == id)
@@ -310,7 +301,7 @@ is_pending (struct GNUNET_SCHEDULER_Handle *sched,
310 pos = pos->next; 301 pos = pos->next;
311 } 302 }
312 } 303 }
313 sched->lowest_pending_id = min; 304 lowest_pending_id = min;
314 return GNUNET_NO; 305 return GNUNET_NO;
315} 306}
316 307
@@ -324,8 +315,7 @@ is_pending (struct GNUNET_SCHEDULER_Handle *sched,
324 * @param timeout next timeout (updated) 315 * @param timeout next timeout (updated)
325 */ 316 */
326static void 317static void
327update_sets (struct GNUNET_SCHEDULER_Handle *sched, 318update_sets (struct GNUNET_NETWORK_FDSet *rs,
328 struct GNUNET_NETWORK_FDSet *rs,
329 struct GNUNET_NETWORK_FDSet *ws, 319 struct GNUNET_NETWORK_FDSet *ws,
330 struct GNUNET_TIME_Relative *timeout) 320 struct GNUNET_TIME_Relative *timeout)
331{ 321{
@@ -334,7 +324,7 @@ update_sets (struct GNUNET_SCHEDULER_Handle *sched,
334 struct GNUNET_TIME_Relative to; 324 struct GNUNET_TIME_Relative to;
335 325
336 now = GNUNET_TIME_absolute_get (); 326 now = GNUNET_TIME_absolute_get ();
337 pos = sched->pending_timeout; 327 pos = pending_timeout;
338 if (pos != NULL) 328 if (pos != NULL)
339 { 329 {
340 to = GNUNET_TIME_absolute_get_difference (now, pos->timeout); 330 to = GNUNET_TIME_absolute_get_difference (now, pos->timeout);
@@ -343,11 +333,11 @@ update_sets (struct GNUNET_SCHEDULER_Handle *sched,
343 if (pos->reason != 0) 333 if (pos->reason != 0)
344 *timeout = GNUNET_TIME_UNIT_ZERO; 334 *timeout = GNUNET_TIME_UNIT_ZERO;
345 } 335 }
346 pos = sched->pending; 336 pos = pending;
347 while (pos != NULL) 337 while (pos != NULL)
348 { 338 {
349 if ((pos->prereq_id != GNUNET_SCHEDULER_NO_TASK) && 339 if ((pos->prereq_id != GNUNET_SCHEDULER_NO_TASK) &&
350 (GNUNET_YES == is_pending (sched, pos->prereq_id))) 340 (GNUNET_YES == is_pending (pos->prereq_id)))
351 { 341 {
352 pos = pos->next; 342 pos = pos->next;
353 continue; 343 continue;
@@ -411,8 +401,7 @@ set_overlaps (const struct GNUNET_NETWORK_FDSet *ready,
411 * @return GNUNET_YES if we can run it, GNUNET_NO if not. 401 * @return GNUNET_YES if we can run it, GNUNET_NO if not.
412 */ 402 */
413static int 403static int
414is_ready (struct GNUNET_SCHEDULER_Handle *sched, 404is_ready (struct Task *task,
415 struct Task *task,
416 struct GNUNET_TIME_Absolute now, 405 struct GNUNET_TIME_Absolute now,
417 const struct GNUNET_NETWORK_FDSet *rs, 406 const struct GNUNET_NETWORK_FDSet *rs,
418 const struct GNUNET_NETWORK_FDSet *ws) 407 const struct GNUNET_NETWORK_FDSet *ws)
@@ -436,7 +425,7 @@ is_ready (struct GNUNET_SCHEDULER_Handle *sched,
436 return GNUNET_NO; /* not ready */ 425 return GNUNET_NO; /* not ready */
437 if (task->prereq_id != GNUNET_SCHEDULER_NO_TASK) 426 if (task->prereq_id != GNUNET_SCHEDULER_NO_TASK)
438 { 427 {
439 if (GNUNET_YES == is_pending (sched, task->prereq_id)) 428 if (GNUNET_YES == is_pending (task->prereq_id))
440 { 429 {
441 task->reason = reason; 430 task->reason = reason;
442 return GNUNET_NO; /* prereq waiting */ 431 return GNUNET_NO; /* prereq waiting */
@@ -455,15 +444,14 @@ is_ready (struct GNUNET_SCHEDULER_Handle *sched,
455 * @param task task ready for execution 444 * @param task task ready for execution
456 */ 445 */
457static void 446static void
458queue_ready_task (struct GNUNET_SCHEDULER_Handle *handle, 447queue_ready_task (struct Task *task)
459 struct Task *task)
460{ 448{
461 enum GNUNET_SCHEDULER_Priority p = task->priority; 449 enum GNUNET_SCHEDULER_Priority p = task->priority;
462 if (0 != (task->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) 450 if (0 != (task->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
463 p = GNUNET_SCHEDULER_PRIORITY_SHUTDOWN; 451 p = GNUNET_SCHEDULER_PRIORITY_SHUTDOWN;
464 task->next = handle->ready[check_priority (p)]; 452 task->next = ready[check_priority (p)];
465 handle->ready[check_priority (p)] = task; 453 ready[check_priority (p)] = task;
466 handle->ready_count++; 454 ready_count++;
467} 455}
468 456
469 457
@@ -476,8 +464,7 @@ queue_ready_task (struct GNUNET_SCHEDULER_Handle *handle,
476 * @param ws FDs ready for writing 464 * @param ws FDs ready for writing
477 */ 465 */
478static void 466static void
479check_ready (struct GNUNET_SCHEDULER_Handle *handle, 467check_ready (const struct GNUNET_NETWORK_FDSet *rs,
480 const struct GNUNET_NETWORK_FDSet *rs,
481 const struct GNUNET_NETWORK_FDSet *ws) 468 const struct GNUNET_NETWORK_FDSet *ws)
482{ 469{
483 struct Task *pos; 470 struct Task *pos;
@@ -487,7 +474,7 @@ check_ready (struct GNUNET_SCHEDULER_Handle *handle,
487 474
488 now = GNUNET_TIME_absolute_get (); 475 now = GNUNET_TIME_absolute_get ();
489 prev = NULL; 476 prev = NULL;
490 pos = handle->pending_timeout; 477 pos = pending_timeout;
491 while (pos != NULL) 478 while (pos != NULL)
492 { 479 {
493 next = pos->next; 480 next = pos->next;
@@ -495,13 +482,13 @@ check_ready (struct GNUNET_SCHEDULER_Handle *handle,
495 pos->reason |= GNUNET_SCHEDULER_REASON_TIMEOUT; 482 pos->reason |= GNUNET_SCHEDULER_REASON_TIMEOUT;
496 if (0 == pos->reason) 483 if (0 == pos->reason)
497 break; 484 break;
498 handle->pending_timeout = next; 485 pending_timeout = next;
499 if (handle->pending_timeout_last == pos) 486 if (pending_timeout_last == pos)
500 handle->pending_timeout_last = NULL; 487 pending_timeout_last = NULL;
501 queue_ready_task (handle, pos); 488 queue_ready_task (pos);
502 pos = next; 489 pos = next;
503 } 490 }
504 pos = handle->pending; 491 pos = pending;
505 while (pos != NULL) 492 while (pos != NULL)
506 { 493 {
507#if DEBUG_TASKS 494#if DEBUG_TASKS
@@ -510,13 +497,13 @@ check_ready (struct GNUNET_SCHEDULER_Handle *handle,
510 pos->id, pos->callback_cls); 497 pos->id, pos->callback_cls);
511#endif 498#endif
512 next = pos->next; 499 next = pos->next;
513 if (GNUNET_YES == is_ready (handle, pos, now, rs, ws)) 500 if (GNUNET_YES == is_ready (pos, now, rs, ws))
514 { 501 {
515 if (prev == NULL) 502 if (prev == NULL)
516 handle->pending = next; 503 pending = next;
517 else 504 else
518 prev->next = next; 505 prev->next = next;
519 queue_ready_task (handle, pos); 506 queue_ready_task (pos);
520 pos = next; 507 pos = next;
521 continue; 508 continue;
522 } 509 }
@@ -536,12 +523,12 @@ check_ready (struct GNUNET_SCHEDULER_Handle *handle,
536 * @param sched the scheduler 523 * @param sched the scheduler
537 */ 524 */
538void 525void
539GNUNET_SCHEDULER_shutdown (struct GNUNET_SCHEDULER_Handle *sched) 526GNUNET_SCHEDULER_shutdown ()
540{ 527{
541 struct Task *pos; 528 struct Task *pos;
542 int i; 529 int i;
543 530
544 pos = sched->pending_timeout; 531 pos = pending_timeout;
545 while (pos != NULL) 532 while (pos != NULL)
546 { 533 {
547 pos->reason |= GNUNET_SCHEDULER_REASON_SHUTDOWN; 534 pos->reason |= GNUNET_SCHEDULER_REASON_SHUTDOWN;
@@ -550,7 +537,7 @@ GNUNET_SCHEDULER_shutdown (struct GNUNET_SCHEDULER_Handle *sched)
550 readiness-factors */ 537 readiness-factors */
551 pos = pos->next; 538 pos = pos->next;
552 } 539 }
553 pos = sched->pending; 540 pos = pending;
554 while (pos != NULL) 541 while (pos != NULL)
555 { 542 {
556 pos->reason |= GNUNET_SCHEDULER_REASON_SHUTDOWN; 543 pos->reason |= GNUNET_SCHEDULER_REASON_SHUTDOWN;
@@ -561,7 +548,7 @@ GNUNET_SCHEDULER_shutdown (struct GNUNET_SCHEDULER_Handle *sched)
561 } 548 }
562 for (i=0;i<GNUNET_SCHEDULER_PRIORITY_COUNT;i++) 549 for (i=0;i<GNUNET_SCHEDULER_PRIORITY_COUNT;i++)
563 { 550 {
564 pos = sched->ready[i]; 551 pos = ready[i];
565 while (pos != NULL) 552 while (pos != NULL)
566 { 553 {
567 pos->reason |= GNUNET_SCHEDULER_REASON_SHUTDOWN; 554 pos->reason |= GNUNET_SCHEDULER_REASON_SHUTDOWN;
@@ -605,37 +592,36 @@ destroy_task (struct Task *t)
605 * @param ws FDs ready for writing 592 * @param ws FDs ready for writing
606 */ 593 */
607static void 594static void
608run_ready (struct GNUNET_SCHEDULER_Handle *sched, 595run_ready (struct GNUNET_NETWORK_FDSet *rs,
609 struct GNUNET_NETWORK_FDSet *rs,
610 struct GNUNET_NETWORK_FDSet *ws) 596 struct GNUNET_NETWORK_FDSet *ws)
611{ 597{
612 enum GNUNET_SCHEDULER_Priority p; 598 enum GNUNET_SCHEDULER_Priority p;
613 struct Task *pos; 599 struct Task *pos;
614 struct GNUNET_SCHEDULER_TaskContext tc; 600 struct GNUNET_SCHEDULER_TaskContext tc;
615 601
616 sched->max_priority_added = GNUNET_SCHEDULER_PRIORITY_KEEP; 602 max_priority_added = GNUNET_SCHEDULER_PRIORITY_KEEP;
617 do 603 do
618 { 604 {
619 if (sched->ready_count == 0) 605 if (ready_count == 0)
620 return; 606 return;
621 GNUNET_assert (sched->ready[GNUNET_SCHEDULER_PRIORITY_KEEP] == NULL); 607 GNUNET_assert (ready[GNUNET_SCHEDULER_PRIORITY_KEEP] == NULL);
622 /* yes, p>0 is correct, 0 is "KEEP" which should 608 /* yes, p>0 is correct, 0 is "KEEP" which should
623 always be an empty queue (see assertion)! */ 609 always be an empty queue (see assertion)! */
624 for (p = GNUNET_SCHEDULER_PRIORITY_COUNT - 1; p > 0; p--) 610 for (p = GNUNET_SCHEDULER_PRIORITY_COUNT - 1; p > 0; p--)
625 { 611 {
626 pos = sched->ready[p]; 612 pos = ready[p];
627 if (pos != NULL) 613 if (pos != NULL)
628 break; 614 break;
629 } 615 }
630 GNUNET_assert (pos != NULL); /* ready_count wrong? */ 616 GNUNET_assert (pos != NULL); /* ready_count wrong? */
631 sched->ready[p] = pos->next; 617 ready[p] = pos->next;
632 sched->ready_count--; 618 ready_count--;
633 if (sched->current_priority != pos->priority) 619 if (current_priority != pos->priority)
634 { 620 {
635 sched->current_priority = pos->priority; 621 current_priority = pos->priority;
636 (void) GNUNET_OS_set_process_priority (GNUNET_OS_process_current (), pos->priority); 622 (void) GNUNET_OS_set_process_priority (GNUNET_OS_process_current (), pos->priority);
637 } 623 }
638 sched->active_task = pos; 624 active_task = pos;
639#if PROFILE_DELAYS 625#if PROFILE_DELAYS
640 if (GNUNET_TIME_absolute_get_duration (pos->start_time).rel_value > 626 if (GNUNET_TIME_absolute_get_duration (pos->start_time).rel_value >
641 DELAY_THRESHOLD.rel_value) 627 DELAY_THRESHOLD.rel_value)
@@ -646,7 +632,6 @@ run_ready (struct GNUNET_SCHEDULER_Handle *sched,
646 (unsigned long long) GNUNET_TIME_absolute_get_duration (pos->start_time).rel_value); 632 (unsigned long long) GNUNET_TIME_absolute_get_duration (pos->start_time).rel_value);
647 } 633 }
648#endif 634#endif
649 tc.sched = sched;
650 tc.reason = pos->reason; 635 tc.reason = pos->reason;
651 tc.read_ready = (pos->read_set == NULL) ? rs : pos->read_set; 636 tc.read_ready = (pos->read_set == NULL) ? rs : pos->read_set;
652 if ( (pos->read_fd != -1) && 637 if ( (pos->read_fd != -1) &&
@@ -677,11 +662,11 @@ run_ready (struct GNUNET_SCHEDULER_Handle *sched,
677 i, 662 i,
678 pos->backtrace_strings[i]); 663 pos->backtrace_strings[i]);
679#endif 664#endif
680 sched->active_task = NULL; 665 active_task = NULL;
681 destroy_task (pos); 666 destroy_task (pos);
682 sched->tasks_run++; 667 tasks_run++;
683 } 668 }
684 while ( (sched->pending == NULL) || (p >= sched->max_priority_added) ); 669 while ( (pending == NULL) || (p >= max_priority_added) );
685} 670}
686 671
687/** 672/**
@@ -732,7 +717,6 @@ sighandler_shutdown ()
732void 717void
733GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_Task task, void *task_cls) 718GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_Task task, void *task_cls)
734{ 719{
735 struct GNUNET_SCHEDULER_Handle sched;
736 struct GNUNET_NETWORK_FDSet *rs; 720 struct GNUNET_NETWORK_FDSet *rs;
737 struct GNUNET_NETWORK_FDSet *ws; 721 struct GNUNET_NETWORK_FDSet *ws;
738 struct GNUNET_TIME_Relative timeout; 722 struct GNUNET_TIME_Relative timeout;
@@ -763,24 +747,22 @@ GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_Task task, void *task_cls)
763 shc_quit = GNUNET_SIGNAL_handler_install (SIGQUIT, &sighandler_shutdown); 747 shc_quit = GNUNET_SIGNAL_handler_install (SIGQUIT, &sighandler_shutdown);
764 shc_hup = GNUNET_SIGNAL_handler_install (SIGHUP, &sighandler_shutdown); 748 shc_hup = GNUNET_SIGNAL_handler_install (SIGHUP, &sighandler_shutdown);
765#endif 749#endif
766 memset (&sched, 0, sizeof (sched)); 750 current_priority = GNUNET_SCHEDULER_PRIORITY_DEFAULT;
767 sched.current_priority = GNUNET_SCHEDULER_PRIORITY_DEFAULT; 751 GNUNET_SCHEDULER_add_continuation (task,
768 GNUNET_SCHEDULER_add_continuation (&sched,
769 task,
770 task_cls, 752 task_cls,
771 GNUNET_SCHEDULER_REASON_STARTUP); 753 GNUNET_SCHEDULER_REASON_STARTUP);
772 last_tr = 0; 754 last_tr = 0;
773 busy_wait_warning = 0; 755 busy_wait_warning = 0;
774 while ((sched.pending != NULL) || 756 while ((pending != NULL) ||
775 (sched.pending_timeout != NULL) || 757 (pending_timeout != NULL) ||
776 (sched.ready_count > 0)) 758 (ready_count > 0))
777 { 759 {
778 GNUNET_NETWORK_fdset_zero (rs); 760 GNUNET_NETWORK_fdset_zero (rs);
779 GNUNET_NETWORK_fdset_zero (ws); 761 GNUNET_NETWORK_fdset_zero (ws);
780 timeout = GNUNET_TIME_UNIT_FOREVER_REL; 762 timeout = GNUNET_TIME_UNIT_FOREVER_REL;
781 update_sets (&sched, rs, ws, &timeout); 763 update_sets (rs, ws, &timeout);
782 GNUNET_NETWORK_fdset_handle_set (rs, pr); 764 GNUNET_NETWORK_fdset_handle_set (rs, pr);
783 if (sched.ready_count > 0) 765 if (ready_count > 0)
784 { 766 {
785 /* no blocking, more work already ready! */ 767 /* no blocking, more work already ready! */
786 timeout = GNUNET_TIME_UNIT_ZERO; 768 timeout = GNUNET_TIME_UNIT_ZERO;
@@ -810,22 +792,22 @@ GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_Task task, void *task_cls)
810 _("Looks like we're busy waiting...\n")); 792 _("Looks like we're busy waiting...\n"));
811 sleep (1); /* mitigate */ 793 sleep (1); /* mitigate */
812 } 794 }
813 check_ready (&sched, rs, ws); 795 check_ready (rs, ws);
814 run_ready (&sched, rs, ws); 796 run_ready (rs, ws);
815 if (GNUNET_NETWORK_fdset_handle_isset (rs, pr)) 797 if (GNUNET_NETWORK_fdset_handle_isset (rs, pr))
816 { 798 {
817 /* consume the signal */ 799 /* consume the signal */
818 GNUNET_DISK_file_read (pr, &c, sizeof (c)); 800 GNUNET_DISK_file_read (pr, &c, sizeof (c));
819 /* mark all active tasks as ready due to shutdown */ 801 /* mark all active tasks as ready due to shutdown */
820 GNUNET_SCHEDULER_shutdown (&sched); 802 GNUNET_SCHEDULER_shutdown ();
821 } 803 }
822 if (last_tr == sched.tasks_run) 804 if (last_tr == tasks_run)
823 { 805 {
824 busy_wait_warning++; 806 busy_wait_warning++;
825 } 807 }
826 else 808 else
827 { 809 {
828 last_tr = sched.tasks_run; 810 last_tr = tasks_run;
829 busy_wait_warning = 0; 811 busy_wait_warning = 0;
830 } 812 }
831 } 813 }
@@ -852,9 +834,9 @@ GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_Task task, void *task_cls)
852 * @return reason(s) why the current task is run 834 * @return reason(s) why the current task is run
853 */ 835 */
854enum GNUNET_SCHEDULER_Reason 836enum GNUNET_SCHEDULER_Reason
855GNUNET_SCHEDULER_get_reason (struct GNUNET_SCHEDULER_Handle *sched) 837GNUNET_SCHEDULER_get_reason ()
856{ 838{
857 return sched->active_task->reason; 839 return active_task->reason;
858} 840}
859 841
860 842
@@ -869,18 +851,17 @@ GNUNET_SCHEDULER_get_reason (struct GNUNET_SCHEDULER_Handle *sched)
869 * @return number of tasks pending right now 851 * @return number of tasks pending right now
870 */ 852 */
871unsigned int 853unsigned int
872GNUNET_SCHEDULER_get_load (struct GNUNET_SCHEDULER_Handle *sched, 854GNUNET_SCHEDULER_get_load (enum GNUNET_SCHEDULER_Priority p)
873 enum GNUNET_SCHEDULER_Priority p)
874{ 855{
875 struct Task *pos; 856 struct Task *pos;
876 unsigned int ret; 857 unsigned int ret;
877 858
878 if (p == GNUNET_SCHEDULER_PRIORITY_COUNT) 859 if (p == GNUNET_SCHEDULER_PRIORITY_COUNT)
879 return sched->ready_count; 860 return ready_count;
880 if (p == GNUNET_SCHEDULER_PRIORITY_KEEP) 861 if (p == GNUNET_SCHEDULER_PRIORITY_KEEP)
881 p = sched->current_priority; 862 p = current_priority;
882 ret = 0; 863 ret = 0;
883 pos = sched->ready[check_priority (p)]; 864 pos = ready[check_priority (p)];
884 while (pos != NULL) 865 while (pos != NULL)
885 { 866 {
886 pos = pos->next; 867 pos = pos->next;
@@ -899,8 +880,7 @@ GNUNET_SCHEDULER_get_load (struct GNUNET_SCHEDULER_Handle *sched,
899 * @return original closure of the task 880 * @return original closure of the task
900 */ 881 */
901void * 882void *
902GNUNET_SCHEDULER_cancel (struct GNUNET_SCHEDULER_Handle *sched, 883GNUNET_SCHEDULER_cancel (GNUNET_SCHEDULER_TaskIdentifier task)
903 GNUNET_SCHEDULER_TaskIdentifier task)
904{ 884{
905 struct Task *t; 885 struct Task *t;
906 struct Task *prev; 886 struct Task *prev;
@@ -910,7 +890,7 @@ GNUNET_SCHEDULER_cancel (struct GNUNET_SCHEDULER_Handle *sched,
910 890
911 to = 0; 891 to = 0;
912 prev = NULL; 892 prev = NULL;
913 t = sched->pending; 893 t = pending;
914 while (t != NULL) 894 while (t != NULL)
915 { 895 {
916 if (t->id == task) 896 if (t->id == task)
@@ -922,7 +902,7 @@ GNUNET_SCHEDULER_cancel (struct GNUNET_SCHEDULER_Handle *sched,
922 { 902 {
923 prev = NULL; 903 prev = NULL;
924 to = 1; 904 to = 1;
925 t = sched->pending_timeout; 905 t = pending_timeout;
926 while (t != NULL) 906 while (t != NULL)
927 { 907 {
928 if (t->id == task) 908 if (t->id == task)
@@ -930,8 +910,8 @@ GNUNET_SCHEDULER_cancel (struct GNUNET_SCHEDULER_Handle *sched,
930 prev = t; 910 prev = t;
931 t = t->next; 911 t = t->next;
932 } 912 }
933 if (sched->pending_timeout_last == t) 913 if (pending_timeout_last == t)
934 sched->pending_timeout_last = NULL; 914 pending_timeout_last = NULL;
935 } 915 }
936 p = 0; 916 p = 0;
937 while (t == NULL) 917 while (t == NULL)
@@ -939,12 +919,12 @@ GNUNET_SCHEDULER_cancel (struct GNUNET_SCHEDULER_Handle *sched,
939 p++; 919 p++;
940 GNUNET_assert (p < GNUNET_SCHEDULER_PRIORITY_COUNT); 920 GNUNET_assert (p < GNUNET_SCHEDULER_PRIORITY_COUNT);
941 prev = NULL; 921 prev = NULL;
942 t = sched->ready[p]; 922 t = ready[p];
943 while (t != NULL) 923 while (t != NULL)
944 { 924 {
945 if (t->id == task) 925 if (t->id == task)
946 { 926 {
947 sched->ready_count--; 927 ready_count--;
948 break; 928 break;
949 } 929 }
950 prev = t; 930 prev = t;
@@ -957,16 +937,16 @@ GNUNET_SCHEDULER_cancel (struct GNUNET_SCHEDULER_Handle *sched,
957 { 937 {
958 if (to == 0) 938 if (to == 0)
959 { 939 {
960 sched->pending = t->next; 940 pending = t->next;
961 } 941 }
962 else 942 else
963 { 943 {
964 sched->pending_timeout = t->next; 944 pending_timeout = t->next;
965 } 945 }
966 } 946 }
967 else 947 else
968 { 948 {
969 sched->ready[p] = t->next; 949 ready[p] = t->next;
970 } 950 }
971 } 951 }
972 else 952 else
@@ -994,8 +974,7 @@ GNUNET_SCHEDULER_cancel (struct GNUNET_SCHEDULER_Handle *sched,
994 * @param reason reason for task invocation 974 * @param reason reason for task invocation
995 */ 975 */
996void 976void
997GNUNET_SCHEDULER_add_continuation (struct GNUNET_SCHEDULER_Handle *sched, 977GNUNET_SCHEDULER_add_continuation (GNUNET_SCHEDULER_Task task,
998 GNUNET_SCHEDULER_Task task,
999 void *task_cls, 978 void *task_cls,
1000 enum GNUNET_SCHEDULER_Reason reason) 979 enum GNUNET_SCHEDULER_Reason reason)
1001{ 980{
@@ -1012,18 +991,18 @@ GNUNET_SCHEDULER_add_continuation (struct GNUNET_SCHEDULER_Handle *sched,
1012 t->write_fd = -1; 991 t->write_fd = -1;
1013 t->callback = task; 992 t->callback = task;
1014 t->callback_cls = task_cls; 993 t->callback_cls = task_cls;
1015 t->id = ++sched->last_id; 994 t->id = ++last_id;
1016#if PROFILE_DELAYS 995#if PROFILE_DELAYS
1017 t->start_time = GNUNET_TIME_absolute_get (); 996 t->start_time = GNUNET_TIME_absolute_get ();
1018#endif 997#endif
1019 t->reason = reason; 998 t->reason = reason;
1020 t->priority = sched->current_priority; 999 t->priority = current_priority;
1021#if DEBUG_TASKS 1000#if DEBUG_TASKS
1022 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1001 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1023 "Adding continuation task: %llu / %p\n", 1002 "Adding continuation task: %llu / %p\n",
1024 t->id, t->callback_cls); 1003 t->id, t->callback_cls);
1025#endif 1004#endif
1026 queue_ready_task (sched, t); 1005 queue_ready_task (t);
1027} 1006}
1028 1007
1029 1008
@@ -1046,12 +1025,10 @@ GNUNET_SCHEDULER_add_continuation (struct GNUNET_SCHEDULER_Handle *sched,
1046 * only valid until "task" is started! 1025 * only valid until "task" is started!
1047 */ 1026 */
1048GNUNET_SCHEDULER_TaskIdentifier 1027GNUNET_SCHEDULER_TaskIdentifier
1049GNUNET_SCHEDULER_add_after (struct GNUNET_SCHEDULER_Handle *sched, 1028GNUNET_SCHEDULER_add_after (GNUNET_SCHEDULER_TaskIdentifier prerequisite_task,
1050 GNUNET_SCHEDULER_TaskIdentifier prerequisite_task,
1051 GNUNET_SCHEDULER_Task task, void *task_cls) 1029 GNUNET_SCHEDULER_Task task, void *task_cls)
1052{ 1030{
1053 return GNUNET_SCHEDULER_add_select (sched, 1031 return GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_KEEP,
1054 GNUNET_SCHEDULER_PRIORITY_KEEP,
1055 prerequisite_task, 1032 prerequisite_task,
1056 GNUNET_TIME_UNIT_ZERO, 1033 GNUNET_TIME_UNIT_ZERO,
1057 NULL, NULL, task, task_cls); 1034 NULL, NULL, task, task_cls);
@@ -1069,13 +1046,11 @@ GNUNET_SCHEDULER_add_after (struct GNUNET_SCHEDULER_Handle *sched,
1069 * only valid until "task" is started! 1046 * only valid until "task" is started!
1070 */ 1047 */
1071GNUNET_SCHEDULER_TaskIdentifier 1048GNUNET_SCHEDULER_TaskIdentifier
1072GNUNET_SCHEDULER_add_with_priority (struct GNUNET_SCHEDULER_Handle * sched, 1049GNUNET_SCHEDULER_add_with_priority (enum GNUNET_SCHEDULER_Priority prio,
1073 enum GNUNET_SCHEDULER_Priority prio,
1074 GNUNET_SCHEDULER_Task task, 1050 GNUNET_SCHEDULER_Task task,
1075 void *task_cls) 1051 void *task_cls)
1076{ 1052{
1077 return GNUNET_SCHEDULER_add_select (sched, 1053 return GNUNET_SCHEDULER_add_select (prio,
1078 prio,
1079 GNUNET_SCHEDULER_NO_TASK, 1054 GNUNET_SCHEDULER_NO_TASK,
1080 GNUNET_TIME_UNIT_ZERO, 1055 GNUNET_TIME_UNIT_ZERO,
1081 NULL, NULL, task, task_cls); 1056 NULL, NULL, task, task_cls);
@@ -1097,8 +1072,7 @@ GNUNET_SCHEDULER_add_with_priority (struct GNUNET_SCHEDULER_Handle * sched,
1097 * only valid until "task" is started! 1072 * only valid until "task" is started!
1098 */ 1073 */
1099GNUNET_SCHEDULER_TaskIdentifier 1074GNUNET_SCHEDULER_TaskIdentifier
1100GNUNET_SCHEDULER_add_delayed (struct GNUNET_SCHEDULER_Handle * sched, 1075GNUNET_SCHEDULER_add_delayed (struct GNUNET_TIME_Relative delay,
1101 struct GNUNET_TIME_Relative delay,
1102 GNUNET_SCHEDULER_Task task, void *task_cls) 1076 GNUNET_SCHEDULER_Task task, void *task_cls)
1103{ 1077{
1104#if 1 1078#if 1
@@ -1120,15 +1094,15 @@ GNUNET_SCHEDULER_add_delayed (struct GNUNET_SCHEDULER_Handle * sched,
1120#endif 1094#endif
1121 t->read_fd = -1; 1095 t->read_fd = -1;
1122 t->write_fd = -1; 1096 t->write_fd = -1;
1123 t->id = ++sched->last_id; 1097 t->id = ++last_id;
1124#if PROFILE_DELAYS 1098#if PROFILE_DELAYS
1125 t->start_time = GNUNET_TIME_absolute_get (); 1099 t->start_time = GNUNET_TIME_absolute_get ();
1126#endif 1100#endif
1127 t->timeout = GNUNET_TIME_relative_to_absolute (delay); 1101 t->timeout = GNUNET_TIME_relative_to_absolute (delay);
1128 t->priority = sched->current_priority; 1102 t->priority = current_priority;
1129 /* try tail first (optimization in case we are 1103 /* try tail first (optimization in case we are
1130 appending to a long list of tasks with timeouts) */ 1104 appending to a long list of tasks with timeouts) */
1131 prev = sched->pending_timeout_last; 1105 prev = pending_timeout_last;
1132 if (prev != NULL) 1106 if (prev != NULL)
1133 { 1107 {
1134 if (prev->timeout.abs_value > t->timeout.abs_value) 1108 if (prev->timeout.abs_value > t->timeout.abs_value)
@@ -1139,7 +1113,7 @@ GNUNET_SCHEDULER_add_delayed (struct GNUNET_SCHEDULER_Handle * sched,
1139 if (prev == NULL) 1113 if (prev == NULL)
1140 { 1114 {
1141 /* heuristic failed, do traversal of timeout list */ 1115 /* heuristic failed, do traversal of timeout list */
1142 pos = sched->pending_timeout; 1116 pos = pending_timeout;
1143 } 1117 }
1144 while ( (pos != NULL) && 1118 while ( (pos != NULL) &&
1145 ( (pos->timeout.abs_value <= t->timeout.abs_value) || 1119 ( (pos->timeout.abs_value <= t->timeout.abs_value) ||
@@ -1149,12 +1123,12 @@ GNUNET_SCHEDULER_add_delayed (struct GNUNET_SCHEDULER_Handle * sched,
1149 pos = pos->next; 1123 pos = pos->next;
1150 } 1124 }
1151 if (prev == NULL) 1125 if (prev == NULL)
1152 sched->pending_timeout = t; 1126 pending_timeout = t;
1153 else 1127 else
1154 prev->next = t; 1128 prev->next = t;
1155 t->next = pos; 1129 t->next = pos;
1156 /* hyper-optimization... */ 1130 /* hyper-optimization... */
1157 sched->pending_timeout_last = t; 1131 pending_timeout_last = t;
1158 1132
1159#if DEBUG_TASKS 1133#if DEBUG_TASKS
1160 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1134 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -1194,12 +1168,10 @@ GNUNET_SCHEDULER_add_delayed (struct GNUNET_SCHEDULER_Handle * sched,
1194 * only valid until "task" is started! 1168 * only valid until "task" is started!
1195 */ 1169 */
1196GNUNET_SCHEDULER_TaskIdentifier 1170GNUNET_SCHEDULER_TaskIdentifier
1197GNUNET_SCHEDULER_add_now (struct GNUNET_SCHEDULER_Handle *sched, 1171GNUNET_SCHEDULER_add_now (GNUNET_SCHEDULER_Task task,
1198 GNUNET_SCHEDULER_Task task, 1172 void *task_cls)
1199 void *task_cls)
1200{ 1173{
1201 return GNUNET_SCHEDULER_add_select (sched, 1174 return GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_KEEP,
1202 GNUNET_SCHEDULER_PRIORITY_KEEP,
1203 GNUNET_SCHEDULER_NO_TASK, 1175 GNUNET_SCHEDULER_NO_TASK,
1204 GNUNET_TIME_UNIT_ZERO, 1176 GNUNET_TIME_UNIT_ZERO,
1205 NULL, NULL, task, task_cls); 1177 NULL, NULL, task, task_cls);
@@ -1236,8 +1208,7 @@ GNUNET_SCHEDULER_add_now (struct GNUNET_SCHEDULER_Handle *sched,
1236 * only valid until "task" is started! 1208 * only valid until "task" is started!
1237 */ 1209 */
1238GNUNET_SCHEDULER_TaskIdentifier 1210GNUNET_SCHEDULER_TaskIdentifier
1239add_without_sets (struct GNUNET_SCHEDULER_Handle * sched, 1211add_without_sets (struct GNUNET_TIME_Relative delay,
1240 struct GNUNET_TIME_Relative delay,
1241 int rfd, 1212 int rfd,
1242 int wfd, 1213 int wfd,
1243 GNUNET_SCHEDULER_Task task, void *task_cls) 1214 GNUNET_SCHEDULER_Task task, void *task_cls)
@@ -1257,16 +1228,16 @@ add_without_sets (struct GNUNET_SCHEDULER_Handle * sched,
1257#endif 1228#endif
1258 t->read_fd = rfd; 1229 t->read_fd = rfd;
1259 t->write_fd = wfd; 1230 t->write_fd = wfd;
1260 t->id = ++sched->last_id; 1231 t->id = ++last_id;
1261#if PROFILE_DELAYS 1232#if PROFILE_DELAYS
1262 t->start_time = GNUNET_TIME_absolute_get (); 1233 t->start_time = GNUNET_TIME_absolute_get ();
1263#endif 1234#endif
1264 t->prereq_id = GNUNET_SCHEDULER_NO_TASK; 1235 t->prereq_id = GNUNET_SCHEDULER_NO_TASK;
1265 t->timeout = GNUNET_TIME_relative_to_absolute (delay); 1236 t->timeout = GNUNET_TIME_relative_to_absolute (delay);
1266 t->priority = check_priority (sched->current_priority); 1237 t->priority = check_priority (current_priority);
1267 t->next = sched->pending; 1238 t->next = pending;
1268 sched->pending = t; 1239 pending = t;
1269 sched->max_priority_added = GNUNET_MAX (sched->max_priority_added, 1240 max_priority_added = GNUNET_MAX (max_priority_added,
1270 t->priority); 1241 t->priority);
1271#if DEBUG_TASKS 1242#if DEBUG_TASKS
1272 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1243 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -1305,13 +1276,11 @@ add_without_sets (struct GNUNET_SCHEDULER_Handle * sched,
1305 * only valid until "task" is started! 1276 * only valid until "task" is started!
1306 */ 1277 */
1307GNUNET_SCHEDULER_TaskIdentifier 1278GNUNET_SCHEDULER_TaskIdentifier
1308GNUNET_SCHEDULER_add_read_net (struct GNUNET_SCHEDULER_Handle * sched, 1279GNUNET_SCHEDULER_add_read_net (struct GNUNET_TIME_Relative delay,
1309 struct GNUNET_TIME_Relative delay,
1310 struct GNUNET_NETWORK_Handle * rfd, 1280 struct GNUNET_NETWORK_Handle * rfd,
1311 GNUNET_SCHEDULER_Task task, void *task_cls) 1281 GNUNET_SCHEDULER_Task task, void *task_cls)
1312{ 1282{
1313 return add_without_sets (sched, 1283 return add_without_sets (delay,
1314 delay,
1315 GNUNET_NETWORK_get_fd (rfd), 1284 GNUNET_NETWORK_get_fd (rfd),
1316 -1, 1285 -1,
1317 task, 1286 task,
@@ -1337,13 +1306,11 @@ GNUNET_SCHEDULER_add_read_net (struct GNUNET_SCHEDULER_Handle * sched,
1337 * only valid until "task" is started! 1306 * only valid until "task" is started!
1338 */ 1307 */
1339GNUNET_SCHEDULER_TaskIdentifier 1308GNUNET_SCHEDULER_TaskIdentifier
1340GNUNET_SCHEDULER_add_write_net (struct GNUNET_SCHEDULER_Handle * sched, 1309GNUNET_SCHEDULER_add_write_net (struct GNUNET_TIME_Relative delay,
1341 struct GNUNET_TIME_Relative delay,
1342 struct GNUNET_NETWORK_Handle * wfd, 1310 struct GNUNET_NETWORK_Handle * wfd,
1343 GNUNET_SCHEDULER_Task task, void *task_cls) 1311 GNUNET_SCHEDULER_Task task, void *task_cls)
1344{ 1312{
1345 return add_without_sets (sched, 1313 return add_without_sets (delay,
1346 delay,
1347 -1, 1314 -1,
1348 GNUNET_NETWORK_get_fd (wfd), 1315 GNUNET_NETWORK_get_fd (wfd),
1349 task, 1316 task,
@@ -1369,8 +1336,7 @@ GNUNET_SCHEDULER_add_write_net (struct GNUNET_SCHEDULER_Handle * sched,
1369 * only valid until "task" is started! 1336 * only valid until "task" is started!
1370 */ 1337 */
1371GNUNET_SCHEDULER_TaskIdentifier 1338GNUNET_SCHEDULER_TaskIdentifier
1372GNUNET_SCHEDULER_add_read_file (struct GNUNET_SCHEDULER_Handle * sched, 1339GNUNET_SCHEDULER_add_read_file (struct GNUNET_TIME_Relative delay,
1373 struct GNUNET_TIME_Relative delay,
1374 const struct GNUNET_DISK_FileHandle * rfd, 1340 const struct GNUNET_DISK_FileHandle * rfd,
1375 GNUNET_SCHEDULER_Task task, void *task_cls) 1341 GNUNET_SCHEDULER_Task task, void *task_cls)
1376{ 1342{
@@ -1391,8 +1357,7 @@ GNUNET_SCHEDULER_add_read_file (struct GNUNET_SCHEDULER_Handle * sched,
1391 int fd; 1357 int fd;
1392 1358
1393 GNUNET_DISK_internal_file_handle_ (rfd, &fd, sizeof (int)); 1359 GNUNET_DISK_internal_file_handle_ (rfd, &fd, sizeof (int));
1394 return add_without_sets (sched, 1360 return add_without_sets (delay,
1395 delay,
1396 fd, 1361 fd,
1397 -1, 1362 -1,
1398 task, 1363 task,
@@ -1420,8 +1385,7 @@ GNUNET_SCHEDULER_add_read_file (struct GNUNET_SCHEDULER_Handle * sched,
1420 * only valid until "task" is started! 1385 * only valid until "task" is started!
1421 */ 1386 */
1422GNUNET_SCHEDULER_TaskIdentifier 1387GNUNET_SCHEDULER_TaskIdentifier
1423GNUNET_SCHEDULER_add_write_file (struct GNUNET_SCHEDULER_Handle * sched, 1388GNUNET_SCHEDULER_add_write_file (struct GNUNET_TIME_Relative delay,
1424 struct GNUNET_TIME_Relative delay,
1425 const struct GNUNET_DISK_FileHandle * wfd, 1389 const struct GNUNET_DISK_FileHandle * wfd,
1426 GNUNET_SCHEDULER_Task task, void *task_cls) 1390 GNUNET_SCHEDULER_Task task, void *task_cls)
1427{ 1391{
@@ -1442,8 +1406,7 @@ GNUNET_SCHEDULER_add_write_file (struct GNUNET_SCHEDULER_Handle * sched,
1442 int fd; 1406 int fd;
1443 1407
1444 GNUNET_DISK_internal_file_handle_ (wfd, &fd, sizeof (int)); 1408 GNUNET_DISK_internal_file_handle_ (wfd, &fd, sizeof (int));
1445 return add_without_sets (sched, 1409 return add_without_sets (delay,
1446 delay,
1447 -1, 1410 -1,
1448 fd, 1411 fd,
1449 task, 1412 task,
@@ -1488,8 +1451,7 @@ GNUNET_SCHEDULER_add_write_file (struct GNUNET_SCHEDULER_Handle * sched,
1488 * only valid until "task" is started! 1451 * only valid until "task" is started!
1489 */ 1452 */
1490GNUNET_SCHEDULER_TaskIdentifier 1453GNUNET_SCHEDULER_TaskIdentifier
1491GNUNET_SCHEDULER_add_select (struct GNUNET_SCHEDULER_Handle * sched, 1454GNUNET_SCHEDULER_add_select (enum GNUNET_SCHEDULER_Priority prio,
1492 enum GNUNET_SCHEDULER_Priority prio,
1493 GNUNET_SCHEDULER_TaskIdentifier 1455 GNUNET_SCHEDULER_TaskIdentifier
1494 prerequisite_task, 1456 prerequisite_task,
1495 struct GNUNET_TIME_Relative delay, 1457 struct GNUNET_TIME_Relative delay,
@@ -1522,7 +1484,7 @@ GNUNET_SCHEDULER_add_select (struct GNUNET_SCHEDULER_Handle * sched,
1522 t->write_set = GNUNET_NETWORK_fdset_create (); 1484 t->write_set = GNUNET_NETWORK_fdset_create ();
1523 GNUNET_NETWORK_fdset_copy (t->write_set, ws); 1485 GNUNET_NETWORK_fdset_copy (t->write_set, ws);
1524 } 1486 }
1525 t->id = ++sched->last_id; 1487 t->id = ++last_id;
1526#if PROFILE_DELAYS 1488#if PROFILE_DELAYS
1527 t->start_time = GNUNET_TIME_absolute_get (); 1489 t->start_time = GNUNET_TIME_absolute_get ();
1528#endif 1490#endif
@@ -1530,11 +1492,11 @@ GNUNET_SCHEDULER_add_select (struct GNUNET_SCHEDULER_Handle * sched,
1530 t->timeout = GNUNET_TIME_relative_to_absolute (delay); 1492 t->timeout = GNUNET_TIME_relative_to_absolute (delay);
1531 t->priority = 1493 t->priority =
1532 check_priority ((prio == 1494 check_priority ((prio ==
1533 GNUNET_SCHEDULER_PRIORITY_KEEP) ? sched->current_priority 1495 GNUNET_SCHEDULER_PRIORITY_KEEP) ? current_priority
1534 : prio); 1496 : prio);
1535 t->next = sched->pending; 1497 t->next = pending;
1536 sched->pending = t; 1498 pending = t;
1537 sched->max_priority_added = GNUNET_MAX (sched->max_priority_added, 1499 max_priority_added = GNUNET_MAX (max_priority_added,
1538 t->priority); 1500 t->priority);
1539#if DEBUG_TASKS 1501#if DEBUG_TASKS
1540 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1502 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,