diff options
Diffstat (limited to 'src/util')
29 files changed, 326 insertions, 552 deletions
diff --git a/src/util/client.c b/src/util/client.c index 13c4062a5..171e9e957 100644 --- a/src/util/client.c +++ b/src/util/client.c | |||
@@ -151,11 +151,6 @@ struct GNUNET_CLIENT_Connection | |||
151 | struct GNUNET_CONNECTION_Handle *sock; | 151 | struct GNUNET_CONNECTION_Handle *sock; |
152 | 152 | ||
153 | /** | 153 | /** |
154 | * Our scheduler. | ||
155 | */ | ||
156 | struct GNUNET_SCHEDULER_Handle *sched; | ||
157 | |||
158 | /** | ||
159 | * Our configuration. | 154 | * Our configuration. |
160 | * FIXME: why do we DUP the configuration? Avoid this! | 155 | * FIXME: why do we DUP the configuration? Avoid this! |
161 | */ | 156 | */ |
@@ -262,15 +257,13 @@ struct GNUNET_CLIENT_Connection | |||
262 | /** | 257 | /** |
263 | * Try to connect to the service. | 258 | * Try to connect to the service. |
264 | * | 259 | * |
265 | * @param sched scheduler to use | ||
266 | * @param service_name name of service to connect to | 260 | * @param service_name name of service to connect to |
267 | * @param cfg configuration to use | 261 | * @param cfg configuration to use |
268 | * @param attempt counter used to alternate between IP and UNIX domain sockets | 262 | * @param attempt counter used to alternate between IP and UNIX domain sockets |
269 | * @return NULL on error | 263 | * @return NULL on error |
270 | */ | 264 | */ |
271 | static struct GNUNET_CONNECTION_Handle * | 265 | static struct GNUNET_CONNECTION_Handle * |
272 | do_connect (struct GNUNET_SCHEDULER_Handle *sched, | 266 | do_connect (const char *service_name, |
273 | const char *service_name, | ||
274 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 267 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
275 | unsigned int attempt) | 268 | unsigned int attempt) |
276 | { | 269 | { |
@@ -288,8 +281,7 @@ do_connect (struct GNUNET_SCHEDULER_Handle *sched, | |||
288 | service_name, | 281 | service_name, |
289 | "UNIXPATH", &unixpath)) | 282 | "UNIXPATH", &unixpath)) |
290 | { | 283 | { |
291 | sock = GNUNET_CONNECTION_create_from_connect_to_unixpath (sched, | 284 | sock = GNUNET_CONNECTION_create_from_connect_to_unixpath (cfg, |
292 | cfg, | ||
293 | unixpath); | 285 | unixpath); |
294 | GNUNET_free (unixpath); | 286 | GNUNET_free (unixpath); |
295 | if (sock != NULL) | 287 | if (sock != NULL) |
@@ -323,8 +315,7 @@ do_connect (struct GNUNET_SCHEDULER_Handle *sched, | |||
323 | service_name); | 315 | service_name); |
324 | return NULL; | 316 | return NULL; |
325 | } | 317 | } |
326 | sock = GNUNET_CONNECTION_create_from_connect (sched, | 318 | sock = GNUNET_CONNECTION_create_from_connect (cfg, |
327 | cfg, | ||
328 | hostname, | 319 | hostname, |
329 | port); | 320 | port); |
330 | GNUNET_free (hostname); | 321 | GNUNET_free (hostname); |
@@ -335,28 +326,24 @@ do_connect (struct GNUNET_SCHEDULER_Handle *sched, | |||
335 | /** | 326 | /** |
336 | * Get a connection with a service. | 327 | * Get a connection with a service. |
337 | * | 328 | * |
338 | * @param sched scheduler to use | ||
339 | * @param service_name name of the service | 329 | * @param service_name name of the service |
340 | * @param cfg configuration to use | 330 | * @param cfg configuration to use |
341 | * @return NULL on error (service unknown to configuration) | 331 | * @return NULL on error (service unknown to configuration) |
342 | */ | 332 | */ |
343 | struct GNUNET_CLIENT_Connection * | 333 | struct GNUNET_CLIENT_Connection * |
344 | GNUNET_CLIENT_connect (struct GNUNET_SCHEDULER_Handle *sched, | 334 | GNUNET_CLIENT_connect (const char *service_name, |
345 | const char *service_name, | ||
346 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 335 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
347 | { | 336 | { |
348 | struct GNUNET_CLIENT_Connection *ret; | 337 | struct GNUNET_CLIENT_Connection *ret; |
349 | struct GNUNET_CONNECTION_Handle *sock; | 338 | struct GNUNET_CONNECTION_Handle *sock; |
350 | 339 | ||
351 | sock = do_connect (sched, | 340 | sock = do_connect (service_name, |
352 | service_name, | ||
353 | cfg, 0); | 341 | cfg, 0); |
354 | if (sock == NULL) | 342 | if (sock == NULL) |
355 | return NULL; | 343 | return NULL; |
356 | ret = GNUNET_malloc (sizeof (struct GNUNET_CLIENT_Connection)); | 344 | ret = GNUNET_malloc (sizeof (struct GNUNET_CLIENT_Connection)); |
357 | ret->attempts = 1; | 345 | ret->attempts = 1; |
358 | ret->sock = sock; | 346 | ret->sock = sock; |
359 | ret->sched = sched; | ||
360 | ret->service_name = GNUNET_strdup (service_name); | 347 | ret->service_name = GNUNET_strdup (service_name); |
361 | ret->cfg = GNUNET_CONFIGURATION_dup (cfg); | 348 | ret->cfg = GNUNET_CONFIGURATION_dup (cfg); |
362 | ret->back_off = GNUNET_TIME_UNIT_MILLISECONDS; | 349 | ret->back_off = GNUNET_TIME_UNIT_MILLISECONDS; |
@@ -418,7 +405,7 @@ GNUNET_CLIENT_disconnect (struct GNUNET_CLIENT_Connection *sock, | |||
418 | GNUNET_CLIENT_notify_transmit_ready_cancel (sock->th); | 405 | GNUNET_CLIENT_notify_transmit_ready_cancel (sock->th); |
419 | if (sock->receive_task != GNUNET_SCHEDULER_NO_TASK) | 406 | if (sock->receive_task != GNUNET_SCHEDULER_NO_TASK) |
420 | { | 407 | { |
421 | GNUNET_SCHEDULER_cancel (sock->sched, sock->receive_task); | 408 | GNUNET_SCHEDULER_cancel (sock->receive_task); |
422 | sock->receive_task = GNUNET_SCHEDULER_NO_TASK; | 409 | sock->receive_task = GNUNET_SCHEDULER_NO_TASK; |
423 | } | 410 | } |
424 | GNUNET_array_grow (sock->received_buf, sock->received_size, 0); | 411 | GNUNET_array_grow (sock->received_buf, sock->received_size, 0); |
@@ -569,8 +556,7 @@ GNUNET_CLIENT_receive (struct GNUNET_CLIENT_Connection *sock, | |||
569 | sock->receive_timeout = GNUNET_TIME_relative_to_absolute (timeout); | 556 | sock->receive_timeout = GNUNET_TIME_relative_to_absolute (timeout); |
570 | if (GNUNET_YES == sock->msg_complete) | 557 | if (GNUNET_YES == sock->msg_complete) |
571 | { | 558 | { |
572 | sock->receive_task = GNUNET_SCHEDULER_add_after (sock->sched, | 559 | sock->receive_task = GNUNET_SCHEDULER_add_after (GNUNET_SCHEDULER_NO_TASK, |
573 | GNUNET_SCHEDULER_NO_TASK, | ||
574 | &receive_task, sock); | 560 | &receive_task, sock); |
575 | } | 561 | } |
576 | else | 562 | else |
@@ -588,11 +574,9 @@ GNUNET_CLIENT_receive (struct GNUNET_CLIENT_Connection *sock, | |||
588 | * Report service unavailable. | 574 | * Report service unavailable. |
589 | */ | 575 | */ |
590 | static void | 576 | static void |
591 | service_test_error (struct GNUNET_SCHEDULER_Handle *s, | 577 | service_test_error (GNUNET_SCHEDULER_Task task, void *task_cls) |
592 | GNUNET_SCHEDULER_Task task, void *task_cls) | ||
593 | { | 578 | { |
594 | GNUNET_SCHEDULER_add_continuation (s, | 579 | GNUNET_SCHEDULER_add_continuation (task, |
595 | task, | ||
596 | task_cls, | 580 | task_cls, |
597 | GNUNET_SCHEDULER_REASON_TIMEOUT); | 581 | GNUNET_SCHEDULER_REASON_TIMEOUT); |
598 | } | 582 | } |
@@ -617,14 +601,13 @@ confirm_handler (void *cls, const struct GNUNET_MessageHeader *msg) | |||
617 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 601 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
618 | "Received confirmation that service is running.\n"); | 602 | "Received confirmation that service is running.\n"); |
619 | #endif | 603 | #endif |
620 | GNUNET_SCHEDULER_add_continuation (conn->sched, | 604 | GNUNET_SCHEDULER_add_continuation (conn->test_cb, |
621 | conn->test_cb, | ||
622 | conn->test_cb_cls, | 605 | conn->test_cb_cls, |
623 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); | 606 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); |
624 | } | 607 | } |
625 | else | 608 | else |
626 | { | 609 | { |
627 | service_test_error (conn->sched, conn->test_cb, conn->test_cb_cls); | 610 | service_test_error (conn->test_cb, conn->test_cb_cls); |
628 | } | 611 | } |
629 | GNUNET_CLIENT_disconnect (conn, GNUNET_NO); | 612 | GNUNET_CLIENT_disconnect (conn, GNUNET_NO); |
630 | } | 613 | } |
@@ -642,7 +625,7 @@ write_test (void *cls, size_t size, void *buf) | |||
642 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 625 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
643 | _("Failure to transmit TEST request.\n")); | 626 | _("Failure to transmit TEST request.\n")); |
644 | #endif | 627 | #endif |
645 | service_test_error (conn->sched, conn->test_cb, conn->test_cb_cls); | 628 | service_test_error (conn->test_cb, conn->test_cb_cls); |
646 | GNUNET_CLIENT_disconnect (conn, GNUNET_NO); | 629 | GNUNET_CLIENT_disconnect (conn, GNUNET_NO); |
647 | return 0; /* client disconnected */ | 630 | return 0; /* client disconnected */ |
648 | } | 631 | } |
@@ -664,7 +647,6 @@ write_test (void *cls, size_t size, void *buf) | |||
664 | /** | 647 | /** |
665 | * Wait until the service is running. | 648 | * Wait until the service is running. |
666 | * | 649 | * |
667 | * @param sched scheduler to use | ||
668 | * @param service name of the service to wait for | 650 | * @param service name of the service to wait for |
669 | * @param cfg configuration to use | 651 | * @param cfg configuration to use |
670 | * @param timeout how long to wait at most in ms | 652 | * @param timeout how long to wait at most in ms |
@@ -674,8 +656,7 @@ write_test (void *cls, size_t size, void *buf) | |||
674 | * @param task_cls closure for task | 656 | * @param task_cls closure for task |
675 | */ | 657 | */ |
676 | void | 658 | void |
677 | GNUNET_CLIENT_service_test (struct GNUNET_SCHEDULER_Handle *sched, | 659 | GNUNET_CLIENT_service_test (const char *service, |
678 | const char *service, | ||
679 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 660 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
680 | struct GNUNET_TIME_Relative timeout, | 661 | struct GNUNET_TIME_Relative timeout, |
681 | GNUNET_SCHEDULER_Task task, void *task_cls) | 662 | GNUNET_SCHEDULER_Task task, void *task_cls) |
@@ -686,14 +667,14 @@ GNUNET_CLIENT_service_test (struct GNUNET_SCHEDULER_Handle *sched, | |||
686 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 667 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
687 | "Testing if service `%s' is running.\n", service); | 668 | "Testing if service `%s' is running.\n", service); |
688 | #endif | 669 | #endif |
689 | conn = GNUNET_CLIENT_connect (sched, service, cfg); | 670 | conn = GNUNET_CLIENT_connect (service, cfg); |
690 | if (conn == NULL) | 671 | if (conn == NULL) |
691 | { | 672 | { |
692 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 673 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
693 | _ | 674 | _ |
694 | ("Could not connect to service `%s', must not be running.\n"), | 675 | ("Could not connect to service `%s', must not be running.\n"), |
695 | service); | 676 | service); |
696 | service_test_error (sched, task, task_cls); | 677 | service_test_error (task, task_cls); |
697 | return; | 678 | return; |
698 | } | 679 | } |
699 | conn->test_cb = task; | 680 | conn->test_cb = task; |
@@ -709,7 +690,7 @@ GNUNET_CLIENT_service_test (struct GNUNET_SCHEDULER_Handle *sched, | |||
709 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 690 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
710 | _("Failure to transmit request to service `%s'\n"), | 691 | _("Failure to transmit request to service `%s'\n"), |
711 | service); | 692 | service); |
712 | service_test_error (sched, task, task_cls); | 693 | service_test_error (task, task_cls); |
713 | GNUNET_CLIENT_disconnect (conn, GNUNET_NO); | 694 | GNUNET_CLIENT_disconnect (conn, GNUNET_NO); |
714 | return; | 695 | return; |
715 | } | 696 | } |
@@ -791,7 +772,7 @@ client_notify (void *cls, size_t size, void *buf) | |||
791 | { | 772 | { |
792 | delay = GNUNET_TIME_absolute_get_remaining (th->timeout); | 773 | delay = GNUNET_TIME_absolute_get_remaining (th->timeout); |
793 | delay.rel_value /= 2; | 774 | delay.rel_value /= 2; |
794 | if ( (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & GNUNET_SCHEDULER_get_reason (th->sock->sched))) || | 775 | if ( (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & GNUNET_SCHEDULER_get_reason ())) || |
795 | (GNUNET_YES != th->auto_retry) || | 776 | (GNUNET_YES != th->auto_retry) || |
796 | (0 == --th->attempts_left) || | 777 | (0 == --th->attempts_left) || |
797 | (delay.rel_value < 1) ) | 778 | (delay.rel_value < 1) ) |
@@ -807,8 +788,7 @@ client_notify (void *cls, size_t size, void *buf) | |||
807 | } | 788 | } |
808 | /* auto-retry */ | 789 | /* auto-retry */ |
809 | GNUNET_CONNECTION_destroy (th->sock->sock, GNUNET_NO); | 790 | GNUNET_CONNECTION_destroy (th->sock->sock, GNUNET_NO); |
810 | th->sock->sock = do_connect (th->sock->sched, | 791 | th->sock->sock = do_connect (th->sock->service_name, |
811 | th->sock->service_name, | ||
812 | th->sock->cfg, | 792 | th->sock->cfg, |
813 | th->sock->attempts++); | 793 | th->sock->attempts++); |
814 | GNUNET_assert (NULL != th->sock->sock); | 794 | GNUNET_assert (NULL != th->sock->sock); |
@@ -824,8 +804,7 @@ client_notify (void *cls, size_t size, void *buf) | |||
824 | MAX_ATTEMPTS - th->attempts_left, | 804 | MAX_ATTEMPTS - th->attempts_left, |
825 | (unsigned long long) delay.rel_value); | 805 | (unsigned long long) delay.rel_value); |
826 | #endif | 806 | #endif |
827 | th->reconnect_task = GNUNET_SCHEDULER_add_delayed (th->sock->sched, | 807 | th->reconnect_task = GNUNET_SCHEDULER_add_delayed (delay, |
828 | delay, | ||
829 | &client_delayed_retry, | 808 | &client_delayed_retry, |
830 | th); | 809 | th); |
831 | th->sock->th = th; | 810 | th->sock->th = th; |
@@ -904,7 +883,7 @@ GNUNET_CLIENT_notify_transmit_ready_cancel (struct | |||
904 | if (th->reconnect_task != GNUNET_SCHEDULER_NO_TASK) | 883 | if (th->reconnect_task != GNUNET_SCHEDULER_NO_TASK) |
905 | { | 884 | { |
906 | GNUNET_break (NULL == th->th); | 885 | GNUNET_break (NULL == th->th); |
907 | GNUNET_SCHEDULER_cancel (th->sock->sched, th->reconnect_task); | 886 | GNUNET_SCHEDULER_cancel (th->reconnect_task); |
908 | th->reconnect_task = GNUNET_SCHEDULER_NO_TASK; | 887 | th->reconnect_task = GNUNET_SCHEDULER_NO_TASK; |
909 | } | 888 | } |
910 | else | 889 | else |
diff --git a/src/util/connection.c b/src/util/connection.c index 04d0c864d..a25dc0350 100644 --- a/src/util/connection.c +++ b/src/util/connection.c | |||
@@ -161,11 +161,6 @@ struct GNUNET_CONNECTION_Handle | |||
161 | { | 161 | { |
162 | 162 | ||
163 | /** | 163 | /** |
164 | * Scheduler that was used for the connect task. | ||
165 | */ | ||
166 | struct GNUNET_SCHEDULER_Handle *sched; | ||
167 | |||
168 | /** | ||
169 | * Configuration to use. | 164 | * Configuration to use. |
170 | */ | 165 | */ |
171 | const struct GNUNET_CONFIGURATION_Handle *cfg; | 166 | const struct GNUNET_CONFIGURATION_Handle *cfg; |
@@ -312,14 +307,11 @@ void GNUNET_CONNECTION_persist_(struct GNUNET_CONNECTION_Handle *sock) | |||
312 | * socket should henceforth be no longer used directly. | 307 | * socket should henceforth be no longer used directly. |
313 | * GNUNET_socket_destroy will close it. | 308 | * GNUNET_socket_destroy will close it. |
314 | * | 309 | * |
315 | * @param sched scheduler to use | ||
316 | * @param osSocket existing socket to box | 310 | * @param osSocket existing socket to box |
317 | * @return the boxed socket handle | 311 | * @return the boxed socket handle |
318 | */ | 312 | */ |
319 | struct GNUNET_CONNECTION_Handle * | 313 | struct GNUNET_CONNECTION_Handle * |
320 | GNUNET_CONNECTION_create_from_existing (struct GNUNET_SCHEDULER_Handle | 314 | GNUNET_CONNECTION_create_from_existing (struct GNUNET_NETWORK_Handle |
321 | *sched, | ||
322 | struct GNUNET_NETWORK_Handle | ||
323 | *osSocket) | 315 | *osSocket) |
324 | { | 316 | { |
325 | struct GNUNET_CONNECTION_Handle *ret; | 317 | struct GNUNET_CONNECTION_Handle *ret; |
@@ -327,7 +319,6 @@ GNUNET_CONNECTION_create_from_existing (struct GNUNET_SCHEDULER_Handle | |||
327 | ret->write_buffer_size = GNUNET_SERVER_MIN_BUFFER_SIZE; | 319 | ret->write_buffer_size = GNUNET_SERVER_MIN_BUFFER_SIZE; |
328 | ret->write_buffer = GNUNET_malloc(ret->write_buffer_size); | 320 | ret->write_buffer = GNUNET_malloc(ret->write_buffer_size); |
329 | ret->sock = osSocket; | 321 | ret->sock = osSocket; |
330 | ret->sched = sched; | ||
331 | return ret; | 322 | return ret; |
332 | } | 323 | } |
333 | 324 | ||
@@ -336,16 +327,13 @@ GNUNET_CONNECTION_create_from_existing (struct GNUNET_SCHEDULER_Handle | |||
336 | * Create a socket handle by accepting on a listen socket. This | 327 | * Create a socket handle by accepting on a listen socket. This |
337 | * function may block if the listen socket has no connection ready. | 328 | * function may block if the listen socket has no connection ready. |
338 | * | 329 | * |
339 | * @param sched scheduler to use | ||
340 | * @param access function to use to check if access is allowed | 330 | * @param access function to use to check if access is allowed |
341 | * @param access_cls closure for access | 331 | * @param access_cls closure for access |
342 | * @param lsock listen socket | 332 | * @param lsock listen socket |
343 | * @return the socket handle, NULL on error | 333 | * @return the socket handle, NULL on error |
344 | */ | 334 | */ |
345 | struct GNUNET_CONNECTION_Handle * | 335 | struct GNUNET_CONNECTION_Handle * |
346 | GNUNET_CONNECTION_create_from_accept (struct GNUNET_SCHEDULER_Handle | 336 | GNUNET_CONNECTION_create_from_accept (GNUNET_CONNECTION_AccessCheck access, |
347 | *sched, | ||
348 | GNUNET_CONNECTION_AccessCheck access, | ||
349 | void *access_cls, | 337 | void *access_cls, |
350 | struct GNUNET_NETWORK_Handle *lsock) | 338 | struct GNUNET_NETWORK_Handle *lsock) |
351 | { | 339 | { |
@@ -416,7 +404,6 @@ GNUNET_CONNECTION_create_from_accept (struct GNUNET_SCHEDULER_Handle | |||
416 | ret->addr = uaddr; | 404 | ret->addr = uaddr; |
417 | ret->addrlen = addrlen; | 405 | ret->addrlen = addrlen; |
418 | ret->sock = sock; | 406 | ret->sock = sock; |
419 | ret->sched = sched; | ||
420 | #if DEBUG_CONNECTION | 407 | #if DEBUG_CONNECTION |
421 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 408 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
422 | _("Accepting connection from `%s': %p\n"), | 409 | _("Accepting connection from `%s': %p\n"), |
@@ -494,8 +481,7 @@ destroy_continuation (void *cls, | |||
494 | #endif | 481 | #endif |
495 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == sock->destroy_task); | 482 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == sock->destroy_task); |
496 | sock->destroy_task | 483 | sock->destroy_task |
497 | = GNUNET_SCHEDULER_add_after (sock->sched, | 484 | = GNUNET_SCHEDULER_add_after (sock->write_task, |
498 | sock->write_task, | ||
499 | &destroy_continuation, sock); | 485 | &destroy_continuation, sock); |
500 | return; | 486 | return; |
501 | } | 487 | } |
@@ -517,8 +503,7 @@ destroy_continuation (void *cls, | |||
517 | { | 503 | { |
518 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == sock->destroy_task); | 504 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == sock->destroy_task); |
519 | sock->destroy_task | 505 | sock->destroy_task |
520 | = GNUNET_SCHEDULER_add_after (sock->sched, | 506 | = GNUNET_SCHEDULER_add_after (sock->read_task, |
521 | sock->read_task, | ||
522 | &destroy_continuation, sock); | 507 | &destroy_continuation, sock); |
523 | return; | 508 | return; |
524 | } | 509 | } |
@@ -529,7 +514,7 @@ destroy_continuation (void *cls, | |||
529 | while (NULL != (pos = sock->ap_head)) | 514 | while (NULL != (pos = sock->ap_head)) |
530 | { | 515 | { |
531 | GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (pos->sock)); | 516 | GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (pos->sock)); |
532 | GNUNET_SCHEDULER_cancel (sock->sched, pos->task); | 517 | GNUNET_SCHEDULER_cancel (pos->task); |
533 | GNUNET_CONTAINER_DLL_remove (sock->ap_head, sock->ap_tail, pos); | 518 | GNUNET_CONTAINER_DLL_remove (sock->ap_head, sock->ap_tail, pos); |
534 | GNUNET_free (pos); | 519 | GNUNET_free (pos); |
535 | } | 520 | } |
@@ -606,8 +591,7 @@ connect_fail_continuation (struct GNUNET_CONNECTION_Handle *h) | |||
606 | h); | 591 | h); |
607 | #endif | 592 | #endif |
608 | h->ccs -= COCO_RECEIVE_AGAIN; | 593 | h->ccs -= COCO_RECEIVE_AGAIN; |
609 | h->read_task = GNUNET_SCHEDULER_add_after (h->sched, | 594 | h->read_task = GNUNET_SCHEDULER_add_after (GNUNET_SCHEDULER_NO_TASK, |
610 | GNUNET_SCHEDULER_NO_TASK, | ||
611 | &receive_again, h); | 595 | &receive_again, h); |
612 | } | 596 | } |
613 | if (0 != (h->ccs & COCO_TRANSMIT_READY)) | 597 | if (0 != (h->ccs & COCO_TRANSMIT_READY)) |
@@ -618,12 +602,11 @@ connect_fail_continuation (struct GNUNET_CONNECTION_Handle *h) | |||
618 | h); | 602 | h); |
619 | #endif | 603 | #endif |
620 | GNUNET_assert (h->nth.timeout_task != GNUNET_SCHEDULER_NO_TASK); | 604 | GNUNET_assert (h->nth.timeout_task != GNUNET_SCHEDULER_NO_TASK); |
621 | GNUNET_SCHEDULER_cancel (h->sched, h->nth.timeout_task); | 605 | GNUNET_SCHEDULER_cancel (h->nth.timeout_task); |
622 | h->nth.timeout_task = GNUNET_SCHEDULER_NO_TASK; | 606 | h->nth.timeout_task = GNUNET_SCHEDULER_NO_TASK; |
623 | h->ccs -= COCO_TRANSMIT_READY; | 607 | h->ccs -= COCO_TRANSMIT_READY; |
624 | GNUNET_assert (h->write_task == GNUNET_SCHEDULER_NO_TASK); | 608 | GNUNET_assert (h->write_task == GNUNET_SCHEDULER_NO_TASK); |
625 | h->write_task = GNUNET_SCHEDULER_add_after (h->sched, | 609 | h->write_task = GNUNET_SCHEDULER_add_after (GNUNET_SCHEDULER_NO_TASK, |
626 | GNUNET_SCHEDULER_NO_TASK, | ||
627 | &transmit_ready, h); | 610 | &transmit_ready, h); |
628 | } | 611 | } |
629 | if (0 != (h->ccs & COCO_DESTROY_CONTINUATION)) | 612 | if (0 != (h->ccs & COCO_DESTROY_CONTINUATION)) |
@@ -636,8 +619,7 @@ connect_fail_continuation (struct GNUNET_CONNECTION_Handle *h) | |||
636 | h->ccs -= COCO_DESTROY_CONTINUATION; | 619 | h->ccs -= COCO_DESTROY_CONTINUATION; |
637 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == h->destroy_task); | 620 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == h->destroy_task); |
638 | h->destroy_task | 621 | h->destroy_task |
639 | = GNUNET_SCHEDULER_add_now (h->sched, | 622 | = GNUNET_SCHEDULER_add_now (&destroy_continuation, |
640 | &destroy_continuation, | ||
641 | h); | 623 | h); |
642 | } | 624 | } |
643 | } | 625 | } |
@@ -665,8 +647,7 @@ connect_success_continuation (struct GNUNET_CONNECTION_Handle *h) | |||
665 | h); | 647 | h); |
666 | #endif | 648 | #endif |
667 | h->ccs -= COCO_RECEIVE_AGAIN; | 649 | h->ccs -= COCO_RECEIVE_AGAIN; |
668 | h->read_task = GNUNET_SCHEDULER_add_after (h->sched, | 650 | h->read_task = GNUNET_SCHEDULER_add_after (GNUNET_SCHEDULER_NO_TASK, |
669 | GNUNET_SCHEDULER_NO_TASK, | ||
670 | &receive_again, h); | 651 | &receive_again, h); |
671 | } | 652 | } |
672 | if (0 != (h->ccs & COCO_TRANSMIT_READY)) | 653 | if (0 != (h->ccs & COCO_TRANSMIT_READY)) |
@@ -677,13 +658,12 @@ connect_success_continuation (struct GNUNET_CONNECTION_Handle *h) | |||
677 | h); | 658 | h); |
678 | #endif | 659 | #endif |
679 | GNUNET_assert (h->nth.timeout_task != GNUNET_SCHEDULER_NO_TASK); | 660 | GNUNET_assert (h->nth.timeout_task != GNUNET_SCHEDULER_NO_TASK); |
680 | GNUNET_SCHEDULER_cancel (h->sched, h->nth.timeout_task); | 661 | GNUNET_SCHEDULER_cancel (h->nth.timeout_task); |
681 | h->nth.timeout_task = GNUNET_SCHEDULER_NO_TASK; | 662 | h->nth.timeout_task = GNUNET_SCHEDULER_NO_TASK; |
682 | h->ccs -= COCO_TRANSMIT_READY; | 663 | h->ccs -= COCO_TRANSMIT_READY; |
683 | GNUNET_assert (h->write_task == GNUNET_SCHEDULER_NO_TASK); | 664 | GNUNET_assert (h->write_task == GNUNET_SCHEDULER_NO_TASK); |
684 | h->write_task = | 665 | h->write_task = |
685 | GNUNET_SCHEDULER_add_write_net (h->sched, | 666 | GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_absolute_get_remaining |
686 | GNUNET_TIME_absolute_get_remaining | ||
687 | (h->nth.transmit_timeout), h->sock, | 667 | (h->nth.transmit_timeout), h->sock, |
688 | &transmit_ready, h); | 668 | &transmit_ready, h); |
689 | } | 669 | } |
@@ -697,9 +677,8 @@ connect_success_continuation (struct GNUNET_CONNECTION_Handle *h) | |||
697 | h->ccs -= COCO_DESTROY_CONTINUATION; | 677 | h->ccs -= COCO_DESTROY_CONTINUATION; |
698 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == h->destroy_task); | 678 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == h->destroy_task); |
699 | h->destroy_task | 679 | h->destroy_task |
700 | = GNUNET_SCHEDULER_add_now (h->sched, | 680 | = GNUNET_SCHEDULER_add_now (&destroy_continuation, |
701 | &destroy_continuation, | 681 | h); |
702 | h); | ||
703 | } | 682 | } |
704 | } | 683 | } |
705 | 684 | ||
@@ -749,7 +728,7 @@ connect_probe_continuation (void *cls, | |||
749 | while (NULL != (pos = h->ap_head)) | 728 | while (NULL != (pos = h->ap_head)) |
750 | { | 729 | { |
751 | GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (pos->sock)); | 730 | GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (pos->sock)); |
752 | GNUNET_SCHEDULER_cancel (h->sched, pos->task); | 731 | GNUNET_SCHEDULER_cancel (pos->task); |
753 | GNUNET_CONTAINER_DLL_remove (h->ap_head, h->ap_tail, pos); | 732 | GNUNET_CONTAINER_DLL_remove (h->ap_head, h->ap_tail, pos); |
754 | GNUNET_free (pos); | 733 | GNUNET_free (pos); |
755 | } | 734 | } |
@@ -842,7 +821,7 @@ try_connect_using_address (void *cls, | |||
842 | GNUNET_TIME_absolute_get_remaining | 821 | GNUNET_TIME_absolute_get_remaining |
843 | (h->receive_timeout)); | 822 | (h->receive_timeout)); |
844 | ap->task = | 823 | ap->task = |
845 | GNUNET_SCHEDULER_add_write_net (h->sched, delay, ap->sock, | 824 | GNUNET_SCHEDULER_add_write_net (delay, ap->sock, |
846 | &connect_probe_continuation, ap); | 825 | &connect_probe_continuation, ap); |
847 | } | 826 | } |
848 | 827 | ||
@@ -852,15 +831,13 @@ try_connect_using_address (void *cls, | |||
852 | * This function returns immediately, even if the connection has not | 831 | * This function returns immediately, even if the connection has not |
853 | * yet been established. This function only creates TCP connections. | 832 | * yet been established. This function only creates TCP connections. |
854 | * | 833 | * |
855 | * @param sched scheduler to use | ||
856 | * @param cfg configuration to use | 834 | * @param cfg configuration to use |
857 | * @param hostname name of the host to connect to | 835 | * @param hostname name of the host to connect to |
858 | * @param port port to connect to | 836 | * @param port port to connect to |
859 | * @return the socket handle | 837 | * @return the socket handle |
860 | */ | 838 | */ |
861 | struct GNUNET_CONNECTION_Handle * | 839 | struct GNUNET_CONNECTION_Handle * |
862 | GNUNET_CONNECTION_create_from_connect (struct GNUNET_SCHEDULER_Handle *sched, | 840 | GNUNET_CONNECTION_create_from_connect (const struct |
863 | const struct | ||
864 | GNUNET_CONFIGURATION_Handle *cfg, | 841 | GNUNET_CONFIGURATION_Handle *cfg, |
865 | const char *hostname, uint16_t port) | 842 | const char *hostname, uint16_t port) |
866 | { | 843 | { |
@@ -869,13 +846,11 @@ GNUNET_CONNECTION_create_from_connect (struct GNUNET_SCHEDULER_Handle *sched, | |||
869 | GNUNET_assert (0 < strlen (hostname)); /* sanity check */ | 846 | GNUNET_assert (0 < strlen (hostname)); /* sanity check */ |
870 | ret = GNUNET_malloc (sizeof (struct GNUNET_CONNECTION_Handle)); | 847 | ret = GNUNET_malloc (sizeof (struct GNUNET_CONNECTION_Handle)); |
871 | ret->cfg = cfg; | 848 | ret->cfg = cfg; |
872 | ret->sched = sched; | ||
873 | ret->write_buffer_size = GNUNET_SERVER_MIN_BUFFER_SIZE; | 849 | ret->write_buffer_size = GNUNET_SERVER_MIN_BUFFER_SIZE; |
874 | ret->write_buffer = GNUNET_malloc(ret->write_buffer_size); | 850 | ret->write_buffer = GNUNET_malloc(ret->write_buffer_size); |
875 | ret->port = port; | 851 | ret->port = port; |
876 | ret->hostname = GNUNET_strdup (hostname); | 852 | ret->hostname = GNUNET_strdup (hostname); |
877 | ret->dns_active = GNUNET_RESOLVER_ip_get (sched, | 853 | ret->dns_active = GNUNET_RESOLVER_ip_get (cfg, |
878 | cfg, | ||
879 | ret->hostname, | 854 | ret->hostname, |
880 | AF_UNSPEC, | 855 | AF_UNSPEC, |
881 | GNUNET_CONNECTION_CONNECT_RETRY_TIMEOUT, | 856 | GNUNET_CONNECTION_CONNECT_RETRY_TIMEOUT, |
@@ -889,14 +864,12 @@ GNUNET_CONNECTION_create_from_connect (struct GNUNET_SCHEDULER_Handle *sched, | |||
889 | * This function returns immediately, even if the connection has not | 864 | * This function returns immediately, even if the connection has not |
890 | * yet been established. This function only creates UNIX connections. | 865 | * yet been established. This function only creates UNIX connections. |
891 | * | 866 | * |
892 | * @param sched scheduler to use | ||
893 | * @param cfg configuration to use | 867 | * @param cfg configuration to use |
894 | * @param unixpath path to connect to | 868 | * @param unixpath path to connect to |
895 | * @return the socket handle, NULL on systems without UNIX support | 869 | * @return the socket handle, NULL on systems without UNIX support |
896 | */ | 870 | */ |
897 | struct GNUNET_CONNECTION_Handle * | 871 | struct GNUNET_CONNECTION_Handle * |
898 | GNUNET_CONNECTION_create_from_connect_to_unixpath (struct GNUNET_SCHEDULER_Handle *sched, | 872 | GNUNET_CONNECTION_create_from_connect_to_unixpath (const struct |
899 | const struct | ||
900 | GNUNET_CONFIGURATION_Handle *cfg, | 873 | GNUNET_CONFIGURATION_Handle *cfg, |
901 | const char *unixpath) | 874 | const char *unixpath) |
902 | { | 875 | { |
@@ -922,7 +895,6 @@ GNUNET_CONNECTION_create_from_connect_to_unixpath (struct GNUNET_SCHEDULER_Handl | |||
922 | #endif | 895 | #endif |
923 | ret = GNUNET_malloc (sizeof (struct GNUNET_CONNECTION_Handle)); | 896 | ret = GNUNET_malloc (sizeof (struct GNUNET_CONNECTION_Handle)); |
924 | ret->cfg = cfg; | 897 | ret->cfg = cfg; |
925 | ret->sched = sched; | ||
926 | ret->write_buffer_size = GNUNET_SERVER_MIN_BUFFER_SIZE; | 898 | ret->write_buffer_size = GNUNET_SERVER_MIN_BUFFER_SIZE; |
927 | ret->write_buffer = GNUNET_malloc(ret->write_buffer_size); | 899 | ret->write_buffer = GNUNET_malloc(ret->write_buffer_size); |
928 | ret->port = 0; | 900 | ret->port = 0; |
@@ -960,15 +932,13 @@ GNUNET_CONNECTION_create_from_connect_to_unixpath (struct GNUNET_SCHEDULER_Handl | |||
960 | * This function returns immediately, even if the connection has not | 932 | * This function returns immediately, even if the connection has not |
961 | * yet been established. This function only creates TCP connections. | 933 | * yet been established. This function only creates TCP connections. |
962 | * | 934 | * |
963 | * @param sched scheduler to use | ||
964 | * @param af_family address family to use | 935 | * @param af_family address family to use |
965 | * @param serv_addr server address | 936 | * @param serv_addr server address |
966 | * @param addrlen length of server address | 937 | * @param addrlen length of server address |
967 | * @return the socket handle | 938 | * @return the socket handle |
968 | */ | 939 | */ |
969 | struct GNUNET_CONNECTION_Handle * | 940 | struct GNUNET_CONNECTION_Handle * |
970 | GNUNET_CONNECTION_create_from_sockaddr (struct GNUNET_SCHEDULER_Handle | 941 | GNUNET_CONNECTION_create_from_sockaddr (int af_family, |
971 | *sched, int af_family, | ||
972 | const struct sockaddr *serv_addr, | 942 | const struct sockaddr *serv_addr, |
973 | socklen_t addrlen) | 943 | socklen_t addrlen) |
974 | { | 944 | { |
@@ -990,7 +960,7 @@ GNUNET_CONNECTION_create_from_sockaddr (struct GNUNET_SCHEDULER_Handle | |||
990 | GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (s)); | 960 | GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (s)); |
991 | return NULL; | 961 | return NULL; |
992 | } | 962 | } |
993 | ret = GNUNET_CONNECTION_create_from_existing (sched, s); | 963 | ret = GNUNET_CONNECTION_create_from_existing (s); |
994 | ret->addr = GNUNET_malloc (addrlen); | 964 | ret->addr = GNUNET_malloc (addrlen); |
995 | memcpy (ret->addr, serv_addr, addrlen); | 965 | memcpy (ret->addr, serv_addr, addrlen); |
996 | ret->addrlen = addrlen; | 966 | ret->addrlen = addrlen; |
@@ -1041,8 +1011,7 @@ GNUNET_CONNECTION_destroy (struct GNUNET_CONNECTION_Handle *sock, | |||
1041 | { | 1011 | { |
1042 | if (sock->write_task != GNUNET_SCHEDULER_NO_TASK) | 1012 | if (sock->write_task != GNUNET_SCHEDULER_NO_TASK) |
1043 | { | 1013 | { |
1044 | GNUNET_SCHEDULER_cancel (sock->sched, | 1014 | GNUNET_SCHEDULER_cancel (sock->write_task); |
1045 | sock->write_task); | ||
1046 | sock->write_task = GNUNET_SCHEDULER_NO_TASK; | 1015 | sock->write_task = GNUNET_SCHEDULER_NO_TASK; |
1047 | sock->write_buffer_off = 0; | 1016 | sock->write_buffer_off = 0; |
1048 | } | 1017 | } |
@@ -1052,11 +1021,10 @@ GNUNET_CONNECTION_destroy (struct GNUNET_CONNECTION_Handle *sock, | |||
1052 | GNUNET_RESOLVER_request_cancel (sock->dns_active); | 1021 | GNUNET_RESOLVER_request_cancel (sock->dns_active); |
1053 | sock->dns_active = NULL; | 1022 | sock->dns_active = NULL; |
1054 | } | 1023 | } |
1055 | GNUNET_assert (sock->sched != NULL); | 1024 | |
1056 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == sock->destroy_task); | 1025 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == sock->destroy_task); |
1057 | sock->destroy_task | 1026 | sock->destroy_task |
1058 | = GNUNET_SCHEDULER_add_now (sock->sched, | 1027 | = GNUNET_SCHEDULER_add_now (&destroy_continuation, sock); |
1059 | &destroy_continuation, sock); | ||
1060 | } | 1028 | } |
1061 | 1029 | ||
1062 | 1030 | ||
@@ -1113,8 +1081,7 @@ receive_ready (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1113 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1081 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1114 | "Ignoring shutdown signal per configuration\n"); | 1082 | "Ignoring shutdown signal per configuration\n"); |
1115 | #endif | 1083 | #endif |
1116 | sh->read_task = GNUNET_SCHEDULER_add_read_net (tc->sched, | 1084 | sh->read_task = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_absolute_get_remaining |
1117 | GNUNET_TIME_absolute_get_remaining | ||
1118 | (sh->receive_timeout), | 1085 | (sh->receive_timeout), |
1119 | sh->sock, | 1086 | sh->sock, |
1120 | &receive_ready, sh); | 1087 | &receive_ready, sh); |
@@ -1212,8 +1179,7 @@ receive_again (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1212 | } | 1179 | } |
1213 | GNUNET_assert (sh->sock != NULL); | 1180 | GNUNET_assert (sh->sock != NULL); |
1214 | /* connect succeeded, wait for data! */ | 1181 | /* connect succeeded, wait for data! */ |
1215 | sh->read_task = GNUNET_SCHEDULER_add_read_net (tc->sched, | 1182 | sh->read_task = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_absolute_get_remaining |
1216 | GNUNET_TIME_absolute_get_remaining | ||
1217 | (sh->receive_timeout), | 1183 | (sh->receive_timeout), |
1218 | sh->sock, | 1184 | sh->sock, |
1219 | &receive_ready, sh); | 1185 | &receive_ready, sh); |
@@ -1252,7 +1218,6 @@ GNUNET_CONNECTION_receive (struct GNUNET_CONNECTION_Handle *sock, | |||
1252 | if (sock->sock != NULL) | 1218 | if (sock->sock != NULL) |
1253 | { | 1219 | { |
1254 | memset (&tc, 0, sizeof (tc)); | 1220 | memset (&tc, 0, sizeof (tc)); |
1255 | tc.sched = sock->sched; | ||
1256 | tc.reason = GNUNET_SCHEDULER_REASON_PREREQ_DONE; | 1221 | tc.reason = GNUNET_SCHEDULER_REASON_PREREQ_DONE; |
1257 | receive_again (sock, &tc); | 1222 | receive_again (sock, &tc); |
1258 | return; | 1223 | return; |
@@ -1293,8 +1258,7 @@ GNUNET_CONNECTION_receive_cancel (struct GNUNET_CONNECTION_Handle *sock) | |||
1293 | { | 1258 | { |
1294 | if (sock->read_task != GNUNET_SCHEDULER_NO_TASK) | 1259 | if (sock->read_task != GNUNET_SCHEDULER_NO_TASK) |
1295 | { | 1260 | { |
1296 | GNUNET_assert (sock == GNUNET_SCHEDULER_cancel (sock->sched, | 1261 | GNUNET_assert (sock == GNUNET_SCHEDULER_cancel (sock->read_task)); |
1297 | sock->read_task)); | ||
1298 | sock->read_task = GNUNET_SCHEDULER_NO_TASK; | 1262 | sock->read_task = GNUNET_SCHEDULER_NO_TASK; |
1299 | } | 1263 | } |
1300 | else | 1264 | else |
@@ -1421,8 +1385,7 @@ transmit_error (struct GNUNET_CONNECTION_Handle *sock) | |||
1421 | } | 1385 | } |
1422 | if (sock->read_task != GNUNET_SCHEDULER_NO_TASK) | 1386 | if (sock->read_task != GNUNET_SCHEDULER_NO_TASK) |
1423 | { | 1387 | { |
1424 | GNUNET_SCHEDULER_cancel (sock->sched, | 1388 | GNUNET_SCHEDULER_cancel (sock->read_task); |
1425 | sock->read_task); | ||
1426 | sock->read_task = GNUNET_SCHEDULER_NO_TASK; | 1389 | sock->read_task = GNUNET_SCHEDULER_NO_TASK; |
1427 | signal_timeout (sock); | 1390 | signal_timeout (sock); |
1428 | return; | 1391 | return; |
@@ -1567,8 +1530,7 @@ SCHEDULE_WRITE: | |||
1567 | #endif | 1530 | #endif |
1568 | if (sock->write_task == GNUNET_SCHEDULER_NO_TASK) | 1531 | if (sock->write_task == GNUNET_SCHEDULER_NO_TASK) |
1569 | sock->write_task = | 1532 | sock->write_task = |
1570 | GNUNET_SCHEDULER_add_write_net (tc->sched, | 1533 | GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_absolute_get_remaining |
1571 | GNUNET_TIME_absolute_get_remaining | ||
1572 | (sock->nth.transmit_timeout), | 1534 | (sock->nth.transmit_timeout), |
1573 | sock->sock, &transmit_ready, sock); | 1535 | sock->sock, &transmit_ready, sock); |
1574 | } | 1536 | } |
@@ -1612,10 +1574,8 @@ GNUNET_CONNECTION_notify_transmit_ready (struct GNUNET_CONNECTION_Handle | |||
1612 | (sock->ap_head == NULL) && (sock->dns_active == NULL)) | 1574 | (sock->ap_head == NULL) && (sock->dns_active == NULL)) |
1613 | { | 1575 | { |
1614 | if (sock->write_task != GNUNET_SCHEDULER_NO_TASK) | 1576 | if (sock->write_task != GNUNET_SCHEDULER_NO_TASK) |
1615 | GNUNET_SCHEDULER_cancel (sock->sched, | 1577 | GNUNET_SCHEDULER_cancel (sock->write_task); |
1616 | sock->write_task); | 1578 | sock->write_task = GNUNET_SCHEDULER_add_now (&connect_error, sock); |
1617 | sock->write_task = GNUNET_SCHEDULER_add_now (sock->sched, | ||
1618 | &connect_error, sock); | ||
1619 | return &sock->nth; | 1579 | return &sock->nth; |
1620 | } | 1580 | } |
1621 | if (GNUNET_SCHEDULER_NO_TASK != sock->write_task) | 1581 | if (GNUNET_SCHEDULER_NO_TASK != sock->write_task) |
@@ -1626,8 +1586,7 @@ GNUNET_CONNECTION_notify_transmit_ready (struct GNUNET_CONNECTION_Handle | |||
1626 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1586 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1627 | "Scheduling transmit_ready (%p).\n", sock); | 1587 | "Scheduling transmit_ready (%p).\n", sock); |
1628 | #endif | 1588 | #endif |
1629 | sock->write_task = GNUNET_SCHEDULER_add_write_net (sock->sched, | 1589 | sock->write_task = GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_absolute_get_remaining |
1630 | GNUNET_TIME_absolute_get_remaining | ||
1631 | (sock->nth. | 1590 | (sock->nth. |
1632 | transmit_timeout), | 1591 | transmit_timeout), |
1633 | sock->sock, | 1592 | sock->sock, |
@@ -1642,8 +1601,7 @@ GNUNET_CONNECTION_notify_transmit_ready (struct GNUNET_CONNECTION_Handle | |||
1642 | sock); | 1601 | sock); |
1643 | #endif | 1602 | #endif |
1644 | sock->ccs |= COCO_TRANSMIT_READY; | 1603 | sock->ccs |= COCO_TRANSMIT_READY; |
1645 | sock->nth.timeout_task = GNUNET_SCHEDULER_add_delayed (sock->sched, | 1604 | sock->nth.timeout_task = GNUNET_SCHEDULER_add_delayed (timeout, |
1646 | timeout, | ||
1647 | &transmit_timeout, | 1605 | &transmit_timeout, |
1648 | sock); | 1606 | sock); |
1649 | } | 1607 | } |
@@ -1668,7 +1626,7 @@ GNUNET_CONNECTION_notify_transmit_ready_cancel (struct | |||
1668 | "notify_transmit_ready_cancel cancels timeout_task (%p)\n", | 1626 | "notify_transmit_ready_cancel cancels timeout_task (%p)\n", |
1669 | h); | 1627 | h); |
1670 | #endif | 1628 | #endif |
1671 | GNUNET_SCHEDULER_cancel (h->sh->sched, h->timeout_task); | 1629 | GNUNET_SCHEDULER_cancel (h->timeout_task); |
1672 | h->timeout_task = GNUNET_SCHEDULER_NO_TASK; | 1630 | h->timeout_task = GNUNET_SCHEDULER_NO_TASK; |
1673 | h->sh->ccs -= COCO_TRANSMIT_READY; | 1631 | h->sh->ccs -= COCO_TRANSMIT_READY; |
1674 | } | 1632 | } |
@@ -1676,7 +1634,7 @@ GNUNET_CONNECTION_notify_transmit_ready_cancel (struct | |||
1676 | { | 1634 | { |
1677 | if (h->sh->write_task != GNUNET_SCHEDULER_NO_TASK) | 1635 | if (h->sh->write_task != GNUNET_SCHEDULER_NO_TASK) |
1678 | { | 1636 | { |
1679 | GNUNET_SCHEDULER_cancel (h->sh->sched, h->sh->write_task); | 1637 | GNUNET_SCHEDULER_cancel (h->sh->write_task); |
1680 | h->sh->write_task = GNUNET_SCHEDULER_NO_TASK; | 1638 | h->sh->write_task = GNUNET_SCHEDULER_NO_TASK; |
1681 | } | 1639 | } |
1682 | } | 1640 | } |
diff --git a/src/util/crypto_hash.c b/src/util/crypto_hash.c index ab6fc28cf..9e5af4ab5 100644 --- a/src/util/crypto_hash.c +++ b/src/util/crypto_hash.c | |||
@@ -83,11 +83,6 @@ struct GNUNET_CRYPTO_FileHashContext | |||
83 | struct GNUNET_DISK_FileHandle *fh; | 83 | struct GNUNET_DISK_FileHandle *fh; |
84 | 84 | ||
85 | /** | 85 | /** |
86 | * Our scheduler. | ||
87 | */ | ||
88 | struct GNUNET_SCHEDULER_Handle *sched; | ||
89 | |||
90 | /** | ||
91 | * Cummulated hash. | 86 | * Cummulated hash. |
92 | */ | 87 | */ |
93 | gcry_md_hd_t md; | 88 | gcry_md_hd_t md; |
@@ -166,8 +161,7 @@ file_hash_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
166 | return; | 161 | return; |
167 | } | 162 | } |
168 | fhc->task | 163 | fhc->task |
169 | = GNUNET_SCHEDULER_add_after (tc->sched, | 164 | = GNUNET_SCHEDULER_add_after (GNUNET_SCHEDULER_NO_TASK, |
170 | GNUNET_SCHEDULER_NO_TASK, | ||
171 | &file_hash_task, fhc); | 165 | &file_hash_task, fhc); |
172 | } | 166 | } |
173 | 167 | ||
@@ -175,7 +169,6 @@ file_hash_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
175 | /** | 169 | /** |
176 | * Compute the hash of an entire file. | 170 | * Compute the hash of an entire file. |
177 | * | 171 | * |
178 | * @param sched scheduler to use | ||
179 | * @param priority scheduling priority to use | 172 | * @param priority scheduling priority to use |
180 | * @param filename name of file to hash | 173 | * @param filename name of file to hash |
181 | * @param blocksize number of bytes to process in one task | 174 | * @param blocksize number of bytes to process in one task |
@@ -184,8 +177,7 @@ file_hash_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
184 | * @return NULL on (immediate) errror | 177 | * @return NULL on (immediate) errror |
185 | */ | 178 | */ |
186 | struct GNUNET_CRYPTO_FileHashContext * | 179 | struct GNUNET_CRYPTO_FileHashContext * |
187 | GNUNET_CRYPTO_hash_file (struct GNUNET_SCHEDULER_Handle *sched, | 180 | GNUNET_CRYPTO_hash_file (enum GNUNET_SCHEDULER_Priority priority, |
188 | enum GNUNET_SCHEDULER_Priority priority, | ||
189 | const char *filename, | 181 | const char *filename, |
190 | size_t blocksize, | 182 | size_t blocksize, |
191 | GNUNET_CRYPTO_HashCompletedCallback callback, | 183 | GNUNET_CRYPTO_HashCompletedCallback callback, |
@@ -197,7 +189,6 @@ GNUNET_CRYPTO_hash_file (struct GNUNET_SCHEDULER_Handle *sched, | |||
197 | fhc = GNUNET_malloc (sizeof (struct GNUNET_CRYPTO_FileHashContext) + blocksize); | 189 | fhc = GNUNET_malloc (sizeof (struct GNUNET_CRYPTO_FileHashContext) + blocksize); |
198 | fhc->callback = callback; | 190 | fhc->callback = callback; |
199 | fhc->callback_cls = callback_cls; | 191 | fhc->callback_cls = callback_cls; |
200 | fhc->sched = sched; | ||
201 | fhc->buffer = (unsigned char *) &fhc[1]; | 192 | fhc->buffer = (unsigned char *) &fhc[1]; |
202 | fhc->filename = GNUNET_strdup (filename); | 193 | fhc->filename = GNUNET_strdup (filename); |
203 | if (GPG_ERR_NO_ERROR != gcry_md_open (&fhc->md, GCRY_MD_SHA512, 0)) | 194 | if (GPG_ERR_NO_ERROR != gcry_md_open (&fhc->md, GCRY_MD_SHA512, 0)) |
@@ -223,7 +214,7 @@ GNUNET_CRYPTO_hash_file (struct GNUNET_SCHEDULER_Handle *sched, | |||
223 | return NULL; | 214 | return NULL; |
224 | } | 215 | } |
225 | fhc->task | 216 | fhc->task |
226 | = GNUNET_SCHEDULER_add_with_priority (sched, priority, | 217 | = GNUNET_SCHEDULER_add_with_priority (priority, |
227 | &file_hash_task, fhc); | 218 | &file_hash_task, fhc); |
228 | return fhc; | 219 | return fhc; |
229 | } | 220 | } |
@@ -237,8 +228,7 @@ GNUNET_CRYPTO_hash_file (struct GNUNET_SCHEDULER_Handle *sched, | |||
237 | void | 228 | void |
238 | GNUNET_CRYPTO_hash_file_cancel (struct GNUNET_CRYPTO_FileHashContext *fhc) | 229 | GNUNET_CRYPTO_hash_file_cancel (struct GNUNET_CRYPTO_FileHashContext *fhc) |
239 | { | 230 | { |
240 | GNUNET_SCHEDULER_cancel (fhc->sched, | 231 | GNUNET_SCHEDULER_cancel (fhc->task); |
241 | fhc->task); | ||
242 | GNUNET_free (fhc->filename); | 232 | GNUNET_free (fhc->filename); |
243 | GNUNET_break (GNUNET_OK == GNUNET_DISK_file_close (fhc->fh)); | 233 | GNUNET_break (GNUNET_OK == GNUNET_DISK_file_close (fhc->fh)); |
244 | GNUNET_free (fhc); | 234 | GNUNET_free (fhc); |
diff --git a/src/util/disk.c b/src/util/disk.c index 265295922..307c4535b 100644 --- a/src/util/disk.c +++ b/src/util/disk.c | |||
@@ -810,10 +810,6 @@ GNUNET_DISK_directory_scan (const char *dirName, | |||
810 | */ | 810 | */ |
811 | struct GNUNET_DISK_DirectoryIterator | 811 | struct GNUNET_DISK_DirectoryIterator |
812 | { | 812 | { |
813 | /** | ||
814 | * Our scheduler. | ||
815 | */ | ||
816 | struct GNUNET_SCHEDULER_Handle *sched; | ||
817 | 813 | ||
818 | /** | 814 | /** |
819 | * Function to call on directory entries. | 815 | * Function to call on directory entries. |
@@ -906,8 +902,7 @@ GNUNET_DISK_directory_iterator_next (struct GNUNET_DISK_DirectoryIterator | |||
906 | GNUNET_DISK_directory_iterator_next (iter, GNUNET_YES); | 902 | GNUNET_DISK_directory_iterator_next (iter, GNUNET_YES); |
907 | return GNUNET_NO; | 903 | return GNUNET_NO; |
908 | } | 904 | } |
909 | GNUNET_SCHEDULER_add_with_priority (iter->sched, | 905 | GNUNET_SCHEDULER_add_with_priority (iter->priority, |
910 | iter->priority, | ||
911 | &directory_iterator_task, iter); | 906 | &directory_iterator_task, iter); |
912 | return GNUNET_YES; | 907 | return GNUNET_YES; |
913 | } | 908 | } |
@@ -919,15 +914,13 @@ GNUNET_DISK_directory_iterator_next (struct GNUNET_DISK_DirectoryIterator | |||
919 | * If a scheduler does not need to be used, GNUNET_DISK_directory_scan | 914 | * If a scheduler does not need to be used, GNUNET_DISK_directory_scan |
920 | * may provide a simpler API. | 915 | * may provide a simpler API. |
921 | * | 916 | * |
922 | * @param sched scheduler to use | ||
923 | * @param prio priority to use | 917 | * @param prio priority to use |
924 | * @param dirName the name of the directory | 918 | * @param dirName the name of the directory |
925 | * @param callback the method to call for each file | 919 | * @param callback the method to call for each file |
926 | * @param callback_cls closure for callback | 920 | * @param callback_cls closure for callback |
927 | */ | 921 | */ |
928 | void | 922 | void |
929 | GNUNET_DISK_directory_iterator_start (struct GNUNET_SCHEDULER_Handle *sched, | 923 | GNUNET_DISK_directory_iterator_start (enum GNUNET_SCHEDULER_Priority prio, |
930 | enum GNUNET_SCHEDULER_Priority prio, | ||
931 | const char *dirName, | 924 | const char *dirName, |
932 | GNUNET_DISK_DirectoryIteratorCallback | 925 | GNUNET_DISK_DirectoryIteratorCallback |
933 | callback, void *callback_cls) | 926 | callback, void *callback_cls) |
@@ -935,7 +928,6 @@ GNUNET_DISK_directory_iterator_start (struct GNUNET_SCHEDULER_Handle *sched, | |||
935 | struct GNUNET_DISK_DirectoryIterator *di; | 928 | struct GNUNET_DISK_DirectoryIterator *di; |
936 | 929 | ||
937 | di = GNUNET_malloc (sizeof (struct GNUNET_DISK_DirectoryIterator)); | 930 | di = GNUNET_malloc (sizeof (struct GNUNET_DISK_DirectoryIterator)); |
938 | di->sched = sched; | ||
939 | di->callback = callback; | 931 | di->callback = callback; |
940 | di->callback_cls = callback_cls; | 932 | di->callback_cls = callback_cls; |
941 | di->directory = OPENDIR (dirName); | 933 | di->directory = OPENDIR (dirName); |
diff --git a/src/util/gnunet-resolver.c b/src/util/gnunet-resolver.c index 9686d3a06..18ce232f2 100644 --- a/src/util/gnunet-resolver.c +++ b/src/util/gnunet-resolver.c | |||
@@ -49,21 +49,19 @@ printer (void *cls, | |||
49 | * Main function that will be run by the scheduler. | 49 | * Main function that will be run by the scheduler. |
50 | * | 50 | * |
51 | * @param cls closure | 51 | * @param cls closure |
52 | * @param sched the scheduler to use | ||
53 | * @param args remaining command-line arguments | 52 | * @param args remaining command-line arguments |
54 | * @param cfgfile name of the configuration file used (for saving, can be NULL!) | 53 | * @param cfgfile name of the configuration file used (for saving, can be NULL!) |
55 | * @param cfg configuration | 54 | * @param cfg configuration |
56 | */ | 55 | */ |
57 | static void | 56 | static void |
58 | run (void *cls, | 57 | run (void *cls, |
59 | struct GNUNET_SCHEDULER_Handle *sched, | ||
60 | char *const *args, | 58 | char *const *args, |
61 | const char *cfgfile, | 59 | const char *cfgfile, |
62 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 60 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
63 | { | 61 | { |
64 | if (args[0] == NULL) | 62 | if (args[0] == NULL) |
65 | return; | 63 | return; |
66 | GNUNET_RESOLVER_ip_get (sched, cfg, | 64 | GNUNET_RESOLVER_ip_get (cfg, |
67 | args[0], | 65 | args[0], |
68 | AF_UNSPEC, | 66 | AF_UNSPEC, |
69 | GET_TIMEOUT, | 67 | GET_TIMEOUT, |
diff --git a/src/util/gnunet-service-resolver.c b/src/util/gnunet-service-resolver.c index b0e2f0be4..68d2daae7 100644 --- a/src/util/gnunet-service-resolver.c +++ b/src/util/gnunet-service-resolver.c | |||
@@ -477,13 +477,11 @@ handle_get (void *cls, | |||
477 | * Process resolver requests. | 477 | * Process resolver requests. |
478 | * | 478 | * |
479 | * @param cls closure | 479 | * @param cls closure |
480 | * @param sched scheduler to use | ||
481 | * @param server the initialized server | 480 | * @param server the initialized server |
482 | * @param cfg configuration to use | 481 | * @param cfg configuration to use |
483 | */ | 482 | */ |
484 | static void | 483 | static void |
485 | run (void *cls, | 484 | run (void *cls, |
486 | struct GNUNET_SCHEDULER_Handle *sched, | ||
487 | struct GNUNET_SERVER_Handle *server, | 485 | struct GNUNET_SERVER_Handle *server, |
488 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 486 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
489 | { | 487 | { |
diff --git a/src/util/program.c b/src/util/program.c index 9a5ee8833..6f8467837 100644 --- a/src/util/program.c +++ b/src/util/program.c | |||
@@ -77,7 +77,7 @@ program_main (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
77 | { | 77 | { |
78 | struct CommandContext *cc = cls; | 78 | struct CommandContext *cc = cls; |
79 | 79 | ||
80 | cc->task (cc->task_cls, tc->sched, cc->args, cc->cfgfile, cc->cfg); | 80 | cc->task (cc->task_cls, cc->args, cc->cfgfile, cc->cfg); |
81 | } | 81 | } |
82 | 82 | ||
83 | 83 | ||
diff --git a/src/util/resolver_api.c b/src/util/resolver_api.c index f4832ed9c..7daaaf1cc 100644 --- a/src/util/resolver_api.c +++ b/src/util/resolver_api.c | |||
@@ -80,11 +80,6 @@ struct GNUNET_RESOLVER_RequestHandle | |||
80 | struct GNUNET_CLIENT_Connection *client; | 80 | struct GNUNET_CLIENT_Connection *client; |
81 | 81 | ||
82 | /** | 82 | /** |
83 | * Our scheduler. | ||
84 | */ | ||
85 | struct GNUNET_SCHEDULER_Handle *sched; | ||
86 | |||
87 | /** | ||
88 | * Name of the host that we are resolving. | 83 | * Name of the host that we are resolving. |
89 | */ | 84 | */ |
90 | const char *hostname; | 85 | const char *hostname; |
@@ -401,7 +396,6 @@ loopback_resolution (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
401 | /** | 396 | /** |
402 | * Convert a string to one or more IP addresses. | 397 | * Convert a string to one or more IP addresses. |
403 | * | 398 | * |
404 | * @param sched scheduler to use | ||
405 | * @param cfg configuration to use | 399 | * @param cfg configuration to use |
406 | * @param hostname the hostname to resolve | 400 | * @param hostname the hostname to resolve |
407 | * @param domain AF_INET or AF_INET6; use AF_UNSPEC for "any" | 401 | * @param domain AF_INET or AF_INET6; use AF_UNSPEC for "any" |
@@ -411,8 +405,7 @@ loopback_resolution (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
411 | * @return handle that can be used to cancel the request, NULL on error | 405 | * @return handle that can be used to cancel the request, NULL on error |
412 | */ | 406 | */ |
413 | struct GNUNET_RESOLVER_RequestHandle * | 407 | struct GNUNET_RESOLVER_RequestHandle * |
414 | GNUNET_RESOLVER_ip_get (struct GNUNET_SCHEDULER_Handle *sched, | 408 | GNUNET_RESOLVER_ip_get (const struct GNUNET_CONFIGURATION_Handle *cfg, |
415 | const struct GNUNET_CONFIGURATION_Handle *cfg, | ||
416 | const char *hostname, | 409 | const char *hostname, |
417 | int domain, | 410 | int domain, |
418 | struct GNUNET_TIME_Relative timeout, | 411 | struct GNUNET_TIME_Relative timeout, |
@@ -436,7 +429,6 @@ GNUNET_RESOLVER_ip_get (struct GNUNET_SCHEDULER_Handle *sched, | |||
436 | return NULL; | 429 | return NULL; |
437 | } | 430 | } |
438 | rh = GNUNET_malloc (sizeof (struct GNUNET_RESOLVER_RequestHandle) + slen); | 431 | rh = GNUNET_malloc (sizeof (struct GNUNET_RESOLVER_RequestHandle) + slen); |
439 | rh->sched = sched; | ||
440 | rh->domain = domain; | 432 | rh->domain = domain; |
441 | rh->addr_callback = callback; | 433 | rh->addr_callback = callback; |
442 | rh->cls = callback_cls; | 434 | rh->cls = callback_cls; |
@@ -454,8 +446,7 @@ GNUNET_RESOLVER_ip_get (struct GNUNET_SCHEDULER_Handle *sched, | |||
454 | &v6)) && | 446 | &v6)) && |
455 | ((domain == AF_INET6) || (domain == AF_UNSPEC)))) | 447 | ((domain == AF_INET6) || (domain == AF_UNSPEC)))) |
456 | { | 448 | { |
457 | rh->task = GNUNET_SCHEDULER_add_now (sched, | 449 | rh->task = GNUNET_SCHEDULER_add_now (&numeric_resolution, rh); |
458 | &numeric_resolution, rh); | ||
459 | return rh; | 450 | return rh; |
460 | } | 451 | } |
461 | /* then, check if this is a loopback address */ | 452 | /* then, check if this is a loopback address */ |
@@ -463,12 +454,11 @@ GNUNET_RESOLVER_ip_get (struct GNUNET_SCHEDULER_Handle *sched, | |||
463 | while (loopback[i] != NULL) | 454 | while (loopback[i] != NULL) |
464 | if (0 == strcasecmp (loopback[i++], hostname)) | 455 | if (0 == strcasecmp (loopback[i++], hostname)) |
465 | { | 456 | { |
466 | rh->task = GNUNET_SCHEDULER_add_now (sched, | 457 | rh->task = GNUNET_SCHEDULER_add_now (&loopback_resolution, rh); |
467 | &loopback_resolution, rh); | ||
468 | return rh; | 458 | return rh; |
469 | } | 459 | } |
470 | 460 | ||
471 | client = GNUNET_CLIENT_connect (sched, "resolver", cfg); | 461 | client = GNUNET_CLIENT_connect ("resolver", cfg); |
472 | if (client == NULL) | 462 | if (client == NULL) |
473 | { | 463 | { |
474 | GNUNET_free (rh); | 464 | GNUNET_free (rh); |
@@ -595,7 +585,6 @@ numeric_reverse (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
595 | /** | 585 | /** |
596 | * Get an IP address as a string. | 586 | * Get an IP address as a string. |
597 | * | 587 | * |
598 | * @param sched scheduler to use | ||
599 | * @param cfg configuration to use | 588 | * @param cfg configuration to use |
600 | * @param sa host address | 589 | * @param sa host address |
601 | * @param salen length of host address | 590 | * @param salen length of host address |
@@ -606,8 +595,7 @@ numeric_reverse (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
606 | * @return handle that can be used to cancel the request | 595 | * @return handle that can be used to cancel the request |
607 | */ | 596 | */ |
608 | struct GNUNET_RESOLVER_RequestHandle * | 597 | struct GNUNET_RESOLVER_RequestHandle * |
609 | GNUNET_RESOLVER_hostname_get (struct GNUNET_SCHEDULER_Handle *sched, | 598 | GNUNET_RESOLVER_hostname_get (const struct GNUNET_CONFIGURATION_Handle *cfg, |
610 | const struct GNUNET_CONFIGURATION_Handle *cfg, | ||
611 | const struct sockaddr *sa, | 599 | const struct sockaddr *sa, |
612 | socklen_t salen, | 600 | socklen_t salen, |
613 | int do_resolve, | 601 | int do_resolve, |
@@ -625,14 +613,12 @@ GNUNET_RESOLVER_hostname_get (struct GNUNET_SCHEDULER_Handle *sched, | |||
625 | rh->name_callback = callback; | 613 | rh->name_callback = callback; |
626 | rh->cls = cls; | 614 | rh->cls = cls; |
627 | rh->timeout = GNUNET_TIME_relative_to_absolute (timeout); | 615 | rh->timeout = GNUNET_TIME_relative_to_absolute (timeout); |
628 | rh->sched = sched; | ||
629 | rh->salen = salen; | 616 | rh->salen = salen; |
630 | memcpy (&rh[1], sa, salen); | 617 | memcpy (&rh[1], sa, salen); |
631 | 618 | ||
632 | if (GNUNET_NO == do_resolve) | 619 | if (GNUNET_NO == do_resolve) |
633 | { | 620 | { |
634 | rh->task = GNUNET_SCHEDULER_add_now (sched, | 621 | rh->task = GNUNET_SCHEDULER_add_now (&numeric_reverse, rh); |
635 | &numeric_reverse, rh); | ||
636 | return rh; | 622 | return rh; |
637 | } | 623 | } |
638 | if (salen + sizeof (struct GNUNET_RESOLVER_GetMessage) >= GNUNET_SERVER_MAX_MESSAGE_SIZE) | 624 | if (salen + sizeof (struct GNUNET_RESOLVER_GetMessage) >= GNUNET_SERVER_MAX_MESSAGE_SIZE) |
@@ -641,7 +627,7 @@ GNUNET_RESOLVER_hostname_get (struct GNUNET_SCHEDULER_Handle *sched, | |||
641 | GNUNET_free (rh); | 627 | GNUNET_free (rh); |
642 | return NULL; | 628 | return NULL; |
643 | } | 629 | } |
644 | client = GNUNET_CLIENT_connect (sched, "resolver", cfg); | 630 | client = GNUNET_CLIENT_connect ("resolver", cfg); |
645 | if (client == NULL) | 631 | if (client == NULL) |
646 | { | 632 | { |
647 | GNUNET_free (rh); | 633 | GNUNET_free (rh); |
@@ -710,7 +696,6 @@ GNUNET_RESOLVER_local_fqdn_get ( void ) | |||
710 | /** | 696 | /** |
711 | * Looking our own hostname. | 697 | * Looking our own hostname. |
712 | * | 698 | * |
713 | * @param sched scheduler to use | ||
714 | * @param cfg configuration to use | 699 | * @param cfg configuration to use |
715 | * @param domain AF_INET or AF_INET6; use AF_UNSPEC for "any" | 700 | * @param domain AF_INET or AF_INET6; use AF_UNSPEC for "any" |
716 | * @param callback function to call with addresses | 701 | * @param callback function to call with addresses |
@@ -719,8 +704,7 @@ GNUNET_RESOLVER_local_fqdn_get ( void ) | |||
719 | * @return handle that can be used to cancel the request, NULL on error | 704 | * @return handle that can be used to cancel the request, NULL on error |
720 | */ | 705 | */ |
721 | struct GNUNET_RESOLVER_RequestHandle * | 706 | struct GNUNET_RESOLVER_RequestHandle * |
722 | GNUNET_RESOLVER_hostname_resolve (struct GNUNET_SCHEDULER_Handle *sched, | 707 | GNUNET_RESOLVER_hostname_resolve (const struct GNUNET_CONFIGURATION_Handle |
723 | const struct GNUNET_CONFIGURATION_Handle | ||
724 | *cfg, int domain, | 708 | *cfg, int domain, |
725 | struct GNUNET_TIME_Relative timeout, | 709 | struct GNUNET_TIME_Relative timeout, |
726 | GNUNET_RESOLVER_AddressCallback callback, | 710 | GNUNET_RESOLVER_AddressCallback callback, |
@@ -739,8 +723,7 @@ GNUNET_RESOLVER_hostname_resolve (struct GNUNET_SCHEDULER_Handle *sched, | |||
739 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 723 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
740 | _("Resolving our hostname `%s'\n"), hostname); | 724 | _("Resolving our hostname `%s'\n"), hostname); |
741 | #endif | 725 | #endif |
742 | return GNUNET_RESOLVER_ip_get (sched, | 726 | return GNUNET_RESOLVER_ip_get (cfg, hostname, domain, timeout, callback, |
743 | cfg, hostname, domain, timeout, callback, | ||
744 | cls); | 727 | cls); |
745 | } | 728 | } |
746 | 729 | ||
@@ -759,7 +742,7 @@ GNUNET_RESOLVER_request_cancel (struct GNUNET_RESOLVER_RequestHandle *h) | |||
759 | if (h->client != NULL) | 742 | if (h->client != NULL) |
760 | GNUNET_CLIENT_disconnect (h->client, GNUNET_NO); | 743 | GNUNET_CLIENT_disconnect (h->client, GNUNET_NO); |
761 | if (h->task != GNUNET_SCHEDULER_NO_TASK) | 744 | if (h->task != GNUNET_SCHEDULER_NO_TASK) |
762 | GNUNET_SCHEDULER_cancel (h->sched, h->task); | 745 | GNUNET_SCHEDULER_cancel (h->task); |
763 | GNUNET_free (h); | 746 | GNUNET_free (h); |
764 | } | 747 | } |
765 | 748 | ||
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 | */ |
168 | struct GNUNET_SCHEDULER_Handle | 168 | struct 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 | */ | ||
177 | struct 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 | */ |
183 | struct 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 | */ | 188 | struct 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 | */ | 194 | struct 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; | 201 | GNUNET_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 | */ | ||
208 | GNUNET_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; | 213 | unsigned 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 | */ | 218 | unsigned 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; | 224 | enum 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 | */ |
230 | enum GNUNET_SCHEDULER_Priority max_priority_added; | ||
242 | 231 | ||
243 | }; | 232 | /** |
233 | * How 'nice' are we right now? | ||
234 | */ | ||
235 | int 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 | */ |
272 | static int | 264 | static int |
273 | is_pending (struct GNUNET_SCHEDULER_Handle *sched, | 265 | is_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 | */ |
326 | static void | 317 | static void |
327 | update_sets (struct GNUNET_SCHEDULER_Handle *sched, | 318 | update_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 | */ |
413 | static int | 403 | static int |
414 | is_ready (struct GNUNET_SCHEDULER_Handle *sched, | 404 | is_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 | */ |
457 | static void | 446 | static void |
458 | queue_ready_task (struct GNUNET_SCHEDULER_Handle *handle, | 447 | queue_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 | */ |
478 | static void | 466 | static void |
479 | check_ready (struct GNUNET_SCHEDULER_Handle *handle, | 467 | check_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 | */ |
538 | void | 525 | void |
539 | GNUNET_SCHEDULER_shutdown (struct GNUNET_SCHEDULER_Handle *sched) | 526 | GNUNET_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 | */ |
607 | static void | 594 | static void |
608 | run_ready (struct GNUNET_SCHEDULER_Handle *sched, | 595 | run_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 () | |||
732 | void | 717 | void |
733 | GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_Task task, void *task_cls) | 718 | GNUNET_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 | */ |
854 | enum GNUNET_SCHEDULER_Reason | 836 | enum GNUNET_SCHEDULER_Reason |
855 | GNUNET_SCHEDULER_get_reason (struct GNUNET_SCHEDULER_Handle *sched) | 837 | GNUNET_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 | */ |
871 | unsigned int | 853 | unsigned int |
872 | GNUNET_SCHEDULER_get_load (struct GNUNET_SCHEDULER_Handle *sched, | 854 | GNUNET_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 | */ |
901 | void * | 882 | void * |
902 | GNUNET_SCHEDULER_cancel (struct GNUNET_SCHEDULER_Handle *sched, | 883 | GNUNET_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 | */ |
996 | void | 976 | void |
997 | GNUNET_SCHEDULER_add_continuation (struct GNUNET_SCHEDULER_Handle *sched, | 977 | GNUNET_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 | */ |
1048 | GNUNET_SCHEDULER_TaskIdentifier | 1027 | GNUNET_SCHEDULER_TaskIdentifier |
1049 | GNUNET_SCHEDULER_add_after (struct GNUNET_SCHEDULER_Handle *sched, | 1028 | GNUNET_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 | */ |
1071 | GNUNET_SCHEDULER_TaskIdentifier | 1048 | GNUNET_SCHEDULER_TaskIdentifier |
1072 | GNUNET_SCHEDULER_add_with_priority (struct GNUNET_SCHEDULER_Handle * sched, | 1049 | GNUNET_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 | */ |
1099 | GNUNET_SCHEDULER_TaskIdentifier | 1074 | GNUNET_SCHEDULER_TaskIdentifier |
1100 | GNUNET_SCHEDULER_add_delayed (struct GNUNET_SCHEDULER_Handle * sched, | 1075 | GNUNET_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 | */ |
1196 | GNUNET_SCHEDULER_TaskIdentifier | 1170 | GNUNET_SCHEDULER_TaskIdentifier |
1197 | GNUNET_SCHEDULER_add_now (struct GNUNET_SCHEDULER_Handle *sched, | 1171 | GNUNET_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 | */ |
1238 | GNUNET_SCHEDULER_TaskIdentifier | 1210 | GNUNET_SCHEDULER_TaskIdentifier |
1239 | add_without_sets (struct GNUNET_SCHEDULER_Handle * sched, | 1211 | add_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 | */ |
1307 | GNUNET_SCHEDULER_TaskIdentifier | 1278 | GNUNET_SCHEDULER_TaskIdentifier |
1308 | GNUNET_SCHEDULER_add_read_net (struct GNUNET_SCHEDULER_Handle * sched, | 1279 | GNUNET_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 | */ |
1339 | GNUNET_SCHEDULER_TaskIdentifier | 1308 | GNUNET_SCHEDULER_TaskIdentifier |
1340 | GNUNET_SCHEDULER_add_write_net (struct GNUNET_SCHEDULER_Handle * sched, | 1309 | GNUNET_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 | */ |
1371 | GNUNET_SCHEDULER_TaskIdentifier | 1338 | GNUNET_SCHEDULER_TaskIdentifier |
1372 | GNUNET_SCHEDULER_add_read_file (struct GNUNET_SCHEDULER_Handle * sched, | 1339 | GNUNET_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 | */ |
1422 | GNUNET_SCHEDULER_TaskIdentifier | 1387 | GNUNET_SCHEDULER_TaskIdentifier |
1423 | GNUNET_SCHEDULER_add_write_file (struct GNUNET_SCHEDULER_Handle * sched, | 1388 | GNUNET_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 | */ |
1490 | GNUNET_SCHEDULER_TaskIdentifier | 1453 | GNUNET_SCHEDULER_TaskIdentifier |
1491 | GNUNET_SCHEDULER_add_select (struct GNUNET_SCHEDULER_Handle * sched, | 1454 | GNUNET_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, |
diff --git a/src/util/server.c b/src/util/server.c index 516885fed..f586e4204 100644 --- a/src/util/server.c +++ b/src/util/server.c | |||
@@ -80,11 +80,6 @@ struct NotifyList | |||
80 | struct GNUNET_SERVER_Handle | 80 | struct GNUNET_SERVER_Handle |
81 | { | 81 | { |
82 | /** | 82 | /** |
83 | * My scheduler. | ||
84 | */ | ||
85 | struct GNUNET_SCHEDULER_Handle *sched; | ||
86 | |||
87 | /** | ||
88 | * List of handlers for incoming messages. | 83 | * List of handlers for incoming messages. |
89 | */ | 84 | */ |
90 | struct HandlerList *handlers; | 85 | struct HandlerList *handlers; |
@@ -249,8 +244,7 @@ process_listen_socket (void *cls, | |||
249 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | 244 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) |
250 | { | 245 | { |
251 | /* ignore shutdown, someone else will take care of it! */ | 246 | /* ignore shutdown, someone else will take care of it! */ |
252 | server->listen_task = GNUNET_SCHEDULER_add_select (server->sched, | 247 | server->listen_task = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_HIGH, |
253 | GNUNET_SCHEDULER_PRIORITY_HIGH, | ||
254 | GNUNET_SCHEDULER_NO_TASK, | 248 | GNUNET_SCHEDULER_NO_TASK, |
255 | GNUNET_TIME_UNIT_FOREVER_REL, | 249 | GNUNET_TIME_UNIT_FOREVER_REL, |
256 | r, NULL, | 250 | r, NULL, |
@@ -266,7 +260,7 @@ process_listen_socket (void *cls, | |||
266 | (tc->read_ready, server->listen_sockets[i])) | 260 | (tc->read_ready, server->listen_sockets[i])) |
267 | { | 261 | { |
268 | sock = | 262 | sock = |
269 | GNUNET_CONNECTION_create_from_accept (tc->sched, server->access, | 263 | GNUNET_CONNECTION_create_from_accept (server->access, |
270 | server->access_cls, | 264 | server->access_cls, |
271 | server->listen_sockets[i]); | 265 | server->listen_sockets[i]); |
272 | if (sock != NULL) | 266 | if (sock != NULL) |
@@ -285,8 +279,7 @@ process_listen_socket (void *cls, | |||
285 | i++; | 279 | i++; |
286 | } | 280 | } |
287 | /* listen for more! */ | 281 | /* listen for more! */ |
288 | server->listen_task = GNUNET_SCHEDULER_add_select (server->sched, | 282 | server->listen_task = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_HIGH, |
289 | GNUNET_SCHEDULER_PRIORITY_HIGH, | ||
290 | GNUNET_SCHEDULER_NO_TASK, | 283 | GNUNET_SCHEDULER_NO_TASK, |
291 | GNUNET_TIME_UNIT_FOREVER_REL, | 284 | GNUNET_TIME_UNIT_FOREVER_REL, |
292 | r, NULL, | 285 | r, NULL, |
@@ -386,7 +379,6 @@ open_listen_socket (const struct sockaddr *serverAddr, socklen_t socklen) | |||
386 | /** | 379 | /** |
387 | * Create a new server. | 380 | * Create a new server. |
388 | * | 381 | * |
389 | * @param sched scheduler to use | ||
390 | * @param access function for access control | 382 | * @param access function for access control |
391 | * @param access_cls closure for access | 383 | * @param access_cls closure for access |
392 | * @param lsocks NULL-terminated array of listen sockets | 384 | * @param lsocks NULL-terminated array of listen sockets |
@@ -397,8 +389,7 @@ open_listen_socket (const struct sockaddr *serverAddr, socklen_t socklen) | |||
397 | * (typically, "port" already in use) | 389 | * (typically, "port" already in use) |
398 | */ | 390 | */ |
399 | struct GNUNET_SERVER_Handle * | 391 | struct GNUNET_SERVER_Handle * |
400 | GNUNET_SERVER_create_with_sockets (struct GNUNET_SCHEDULER_Handle *sched, | 392 | GNUNET_SERVER_create_with_sockets (GNUNET_CONNECTION_AccessCheck access, void *access_cls, |
401 | GNUNET_CONNECTION_AccessCheck access, void *access_cls, | ||
402 | struct GNUNET_NETWORK_Handle **lsocks, | 393 | struct GNUNET_NETWORK_Handle **lsocks, |
403 | struct GNUNET_TIME_Relative | 394 | struct GNUNET_TIME_Relative |
404 | idle_timeout, | 395 | idle_timeout, |
@@ -409,7 +400,6 @@ GNUNET_SERVER_create_with_sockets (struct GNUNET_SCHEDULER_Handle *sched, | |||
409 | int i; | 400 | int i; |
410 | 401 | ||
411 | ret = GNUNET_malloc (sizeof (struct GNUNET_SERVER_Handle)); | 402 | ret = GNUNET_malloc (sizeof (struct GNUNET_SERVER_Handle)); |
412 | ret->sched = sched; | ||
413 | ret->idle_timeout = idle_timeout; | 403 | ret->idle_timeout = idle_timeout; |
414 | ret->listen_sockets = lsocks; | 404 | ret->listen_sockets = lsocks; |
415 | ret->access = access; | 405 | ret->access = access; |
@@ -421,8 +411,7 @@ GNUNET_SERVER_create_with_sockets (struct GNUNET_SCHEDULER_Handle *sched, | |||
421 | i = 0; | 411 | i = 0; |
422 | while (NULL != ret->listen_sockets[i]) | 412 | while (NULL != ret->listen_sockets[i]) |
423 | GNUNET_NETWORK_fdset_set (r, ret->listen_sockets[i++]); | 413 | GNUNET_NETWORK_fdset_set (r, ret->listen_sockets[i++]); |
424 | ret->listen_task = GNUNET_SCHEDULER_add_select (sched, | 414 | ret->listen_task = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_HIGH, |
425 | GNUNET_SCHEDULER_PRIORITY_HIGH, | ||
426 | GNUNET_SCHEDULER_NO_TASK, | 415 | GNUNET_SCHEDULER_NO_TASK, |
427 | GNUNET_TIME_UNIT_FOREVER_REL, | 416 | GNUNET_TIME_UNIT_FOREVER_REL, |
428 | r, NULL, | 417 | r, NULL, |
@@ -437,7 +426,6 @@ GNUNET_SERVER_create_with_sockets (struct GNUNET_SCHEDULER_Handle *sched, | |||
437 | /** | 426 | /** |
438 | * Create a new server. | 427 | * Create a new server. |
439 | * | 428 | * |
440 | * @param sched scheduler to use | ||
441 | * @param access function for access control | 429 | * @param access function for access control |
442 | * @param access_cls closure for access | 430 | * @param access_cls closure for access |
443 | * @param serverAddr address to listen on (including port), NULL terminated array | 431 | * @param serverAddr address to listen on (including port), NULL terminated array |
@@ -449,8 +437,7 @@ GNUNET_SERVER_create_with_sockets (struct GNUNET_SCHEDULER_Handle *sched, | |||
449 | * (typically, "port" already in use) | 437 | * (typically, "port" already in use) |
450 | */ | 438 | */ |
451 | struct GNUNET_SERVER_Handle * | 439 | struct GNUNET_SERVER_Handle * |
452 | GNUNET_SERVER_create (struct GNUNET_SCHEDULER_Handle *sched, | 440 | GNUNET_SERVER_create (GNUNET_CONNECTION_AccessCheck access, |
453 | GNUNET_CONNECTION_AccessCheck access, | ||
454 | void *access_cls, | 441 | void *access_cls, |
455 | struct sockaddr *const *serverAddr, | 442 | struct sockaddr *const *serverAddr, |
456 | const socklen_t * socklen, | 443 | const socklen_t * socklen, |
@@ -489,8 +476,7 @@ GNUNET_SERVER_create (struct GNUNET_SCHEDULER_Handle *sched, | |||
489 | { | 476 | { |
490 | lsocks = NULL; | 477 | lsocks = NULL; |
491 | } | 478 | } |
492 | return GNUNET_SERVER_create_with_sockets (sched, | 479 | return GNUNET_SERVER_create_with_sockets (access, access_cls, |
493 | access, access_cls, | ||
494 | lsocks, | 480 | lsocks, |
495 | idle_timeout, | 481 | idle_timeout, |
496 | require_found); | 482 | require_found); |
@@ -514,7 +500,7 @@ GNUNET_SERVER_destroy (struct GNUNET_SERVER_Handle *s) | |||
514 | #endif | 500 | #endif |
515 | if (GNUNET_SCHEDULER_NO_TASK != s->listen_task) | 501 | if (GNUNET_SCHEDULER_NO_TASK != s->listen_task) |
516 | { | 502 | { |
517 | GNUNET_SCHEDULER_cancel (s->sched, s->listen_task); | 503 | GNUNET_SCHEDULER_cancel (s->listen_task); |
518 | s->listen_task = GNUNET_SCHEDULER_NO_TASK; | 504 | s->listen_task = GNUNET_SCHEDULER_NO_TASK; |
519 | } | 505 | } |
520 | if (s->listen_sockets != NULL) | 506 | if (s->listen_sockets != NULL) |
@@ -1023,8 +1009,7 @@ GNUNET_SERVER_client_disconnect (struct GNUNET_SERVER_Client *client) | |||
1023 | #endif | 1009 | #endif |
1024 | if (client->restart_task != GNUNET_SCHEDULER_NO_TASK) | 1010 | if (client->restart_task != GNUNET_SCHEDULER_NO_TASK) |
1025 | { | 1011 | { |
1026 | GNUNET_SCHEDULER_cancel (client->server->sched, | 1012 | GNUNET_SCHEDULER_cancel (client->restart_task); |
1027 | client->restart_task); | ||
1028 | client->restart_task = GNUNET_SCHEDULER_NO_TASK; | 1013 | client->restart_task = GNUNET_SCHEDULER_NO_TASK; |
1029 | } | 1014 | } |
1030 | if (GNUNET_YES == client->receive_pending) | 1015 | if (GNUNET_YES == client->receive_pending) |
@@ -1053,8 +1038,7 @@ GNUNET_SERVER_client_disconnect (struct GNUNET_SERVER_Client *client) | |||
1053 | prev->next = pos->next; | 1038 | prev->next = pos->next; |
1054 | if (client->restart_task != GNUNET_SCHEDULER_NO_TASK) | 1039 | if (client->restart_task != GNUNET_SCHEDULER_NO_TASK) |
1055 | { | 1040 | { |
1056 | GNUNET_SCHEDULER_cancel (server->sched, | 1041 | GNUNET_SCHEDULER_cancel (client->restart_task); |
1057 | client->restart_task); | ||
1058 | client->restart_task = GNUNET_SCHEDULER_NO_TASK; | 1042 | client->restart_task = GNUNET_SCHEDULER_NO_TASK; |
1059 | } | 1043 | } |
1060 | n = server->disconnect_notify_list; | 1044 | n = server->disconnect_notify_list; |
@@ -1182,8 +1166,7 @@ GNUNET_SERVER_receive_done (struct GNUNET_SERVER_Client *client, int success) | |||
1182 | "GNUNET_SERVER_receive_done causes restart in reading from the socket\n"); | 1166 | "GNUNET_SERVER_receive_done causes restart in reading from the socket\n"); |
1183 | #endif | 1167 | #endif |
1184 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == client->restart_task); | 1168 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == client->restart_task); |
1185 | client->restart_task = GNUNET_SCHEDULER_add_now (client->server->sched, | 1169 | client->restart_task = GNUNET_SCHEDULER_add_now (&restart_processing, |
1186 | &restart_processing, | ||
1187 | client); | 1170 | client); |
1188 | } | 1171 | } |
1189 | 1172 | ||
diff --git a/src/util/service.c b/src/util/service.c index d18d4e9e3..3423b58cb 100644 --- a/src/util/service.c +++ b/src/util/service.c | |||
@@ -430,11 +430,6 @@ struct GNUNET_SERVICE_Context | |||
430 | struct GNUNET_SERVER_Handle *server; | 430 | struct GNUNET_SERVER_Handle *server; |
431 | 431 | ||
432 | /** | 432 | /** |
433 | * Scheduler for the server. | ||
434 | */ | ||
435 | struct GNUNET_SCHEDULER_Handle *sched; | ||
436 | |||
437 | /** | ||
438 | * NULL-terminated array of addresses to bind to, NULL if we got pre-bound | 433 | * NULL-terminated array of addresses to bind to, NULL if we got pre-bound |
439 | * listen sockets. | 434 | * listen sockets. |
440 | */ | 435 | */ |
@@ -1290,16 +1285,13 @@ service_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1290 | struct GNUNET_SERVICE_Context *sctx = cls; | 1285 | struct GNUNET_SERVICE_Context *sctx = cls; |
1291 | unsigned int i; | 1286 | unsigned int i; |
1292 | 1287 | ||
1293 | sctx->sched = tc->sched; | ||
1294 | if (sctx->lsocks != NULL) | 1288 | if (sctx->lsocks != NULL) |
1295 | sctx->server = GNUNET_SERVER_create_with_sockets (tc->sched, | 1289 | sctx->server = GNUNET_SERVER_create_with_sockets (&check_access, |
1296 | &check_access, | ||
1297 | sctx, | 1290 | sctx, |
1298 | sctx->lsocks, | 1291 | sctx->lsocks, |
1299 | sctx->timeout, sctx->require_found); | 1292 | sctx->timeout, sctx->require_found); |
1300 | else | 1293 | else |
1301 | sctx->server = GNUNET_SERVER_create (tc->sched, | 1294 | sctx->server = GNUNET_SERVER_create (&check_access, |
1302 | &check_access, | ||
1303 | sctx, | 1295 | sctx, |
1304 | sctx->addrs, | 1296 | sctx->addrs, |
1305 | sctx->addrlens, | 1297 | sctx->addrlens, |
@@ -1325,8 +1317,7 @@ service_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1325 | { | 1317 | { |
1326 | /* install a task that will kill the server | 1318 | /* install a task that will kill the server |
1327 | process if the scheduler ever gets a shutdown signal */ | 1319 | process if the scheduler ever gets a shutdown signal */ |
1328 | GNUNET_SCHEDULER_add_delayed (tc->sched, | 1320 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, |
1329 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
1330 | &shutdown_task, sctx->server); | 1321 | &shutdown_task, sctx->server); |
1331 | } | 1322 | } |
1332 | sctx->my_handlers = GNUNET_malloc (sizeof (defhandlers)); | 1323 | sctx->my_handlers = GNUNET_malloc (sizeof (defhandlers)); |
@@ -1354,7 +1345,7 @@ service_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1354 | i++; | 1345 | i++; |
1355 | } | 1346 | } |
1356 | } | 1347 | } |
1357 | sctx->task (sctx->task_cls, tc->sched, sctx->server, sctx->cfg); | 1348 | sctx->task (sctx->task_cls, sctx->server, sctx->cfg); |
1358 | } | 1349 | } |
1359 | 1350 | ||
1360 | 1351 | ||
@@ -1612,13 +1603,11 @@ shutdown: | |||
1612 | * initialized system. | 1603 | * initialized system. |
1613 | * | 1604 | * |
1614 | * @param serviceName our service name | 1605 | * @param serviceName our service name |
1615 | * @param sched scheduler to use | ||
1616 | * @param cfg configuration to use | 1606 | * @param cfg configuration to use |
1617 | * @return NULL on error, service handle | 1607 | * @return NULL on error, service handle |
1618 | */ | 1608 | */ |
1619 | struct GNUNET_SERVICE_Context * | 1609 | struct GNUNET_SERVICE_Context * |
1620 | GNUNET_SERVICE_start (const char *serviceName, | 1610 | GNUNET_SERVICE_start (const char *serviceName, |
1621 | struct GNUNET_SCHEDULER_Handle *sched, | ||
1622 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 1611 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
1623 | { | 1612 | { |
1624 | int i; | 1613 | int i; |
@@ -1630,7 +1619,6 @@ GNUNET_SERVICE_start (const char *serviceName, | |||
1630 | sctx->timeout = GNUNET_TIME_UNIT_FOREVER_REL; | 1619 | sctx->timeout = GNUNET_TIME_UNIT_FOREVER_REL; |
1631 | sctx->serviceName = serviceName; | 1620 | sctx->serviceName = serviceName; |
1632 | sctx->cfg = cfg; | 1621 | sctx->cfg = cfg; |
1633 | sctx->sched = sched; | ||
1634 | 1622 | ||
1635 | /* setup subsystems */ | 1623 | /* setup subsystems */ |
1636 | if (GNUNET_OK != setup_service (sctx)) | 1624 | if (GNUNET_OK != setup_service (sctx)) |
@@ -1639,14 +1627,12 @@ GNUNET_SERVICE_start (const char *serviceName, | |||
1639 | return NULL; | 1627 | return NULL; |
1640 | } | 1628 | } |
1641 | if (sctx->lsocks != NULL) | 1629 | if (sctx->lsocks != NULL) |
1642 | sctx->server = GNUNET_SERVER_create_with_sockets (sched, | 1630 | sctx->server = GNUNET_SERVER_create_with_sockets (&check_access, |
1643 | &check_access, | ||
1644 | sctx, | 1631 | sctx, |
1645 | sctx->lsocks, | 1632 | sctx->lsocks, |
1646 | sctx->timeout, sctx->require_found); | 1633 | sctx->timeout, sctx->require_found); |
1647 | else | 1634 | else |
1648 | sctx->server = GNUNET_SERVER_create (sched, | 1635 | sctx->server = GNUNET_SERVER_create (&check_access, |
1649 | &check_access, | ||
1650 | sctx, | 1636 | sctx, |
1651 | sctx->addrs, | 1637 | sctx->addrs, |
1652 | sctx->addrlens, | 1638 | sctx->addrlens, |
diff --git a/src/util/test_client.c b/src/util/test_client.c index ead6751a4..3851744c2 100644 --- a/src/util/test_client.c +++ b/src/util/test_client.c | |||
@@ -150,8 +150,7 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
150 | #endif | 150 | #endif |
151 | sa.sin_family = AF_INET; | 151 | sa.sin_family = AF_INET; |
152 | sa.sin_port = htons (PORT); | 152 | sa.sin_port = htons (PORT); |
153 | server = GNUNET_SERVER_create (tc->sched, | 153 | server = GNUNET_SERVER_create (NULL, |
154 | NULL, | ||
155 | NULL, | 154 | NULL, |
156 | sap, | 155 | sap, |
157 | slens, | 156 | slens, |
@@ -162,7 +161,7 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
162 | handlers[0].callback_cls = cls; | 161 | handlers[0].callback_cls = cls; |
163 | handlers[1].callback_cls = cls; | 162 | handlers[1].callback_cls = cls; |
164 | GNUNET_SERVER_add_handlers (server, handlers); | 163 | GNUNET_SERVER_add_handlers (server, handlers); |
165 | client = GNUNET_CLIENT_connect (tc->sched, MYNAME, cfg); | 164 | client = GNUNET_CLIENT_connect (MYNAME, cfg); |
166 | GNUNET_assert (client != NULL); | 165 | GNUNET_assert (client != NULL); |
167 | GNUNET_assert (NULL != | 166 | GNUNET_assert (NULL != |
168 | GNUNET_CLIENT_notify_transmit_ready (client, | 167 | GNUNET_CLIENT_notify_transmit_ready (client, |
diff --git a/src/util/test_connection.c b/src/util/test_connection.c index 0cc02059d..71b37c8ac 100644 --- a/src/util/test_connection.c +++ b/src/util/test_connection.c | |||
@@ -118,8 +118,7 @@ run_accept (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
118 | #if VERBOSE | 118 | #if VERBOSE |
119 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test accepts connection\n"); | 119 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test accepts connection\n"); |
120 | #endif | 120 | #endif |
121 | asock = GNUNET_CONNECTION_create_from_accept (tc->sched, | 121 | asock = GNUNET_CONNECTION_create_from_accept (NULL, NULL, ls); |
122 | NULL, NULL, ls); | ||
123 | GNUNET_assert (asock != NULL); | 122 | GNUNET_assert (asock != NULL); |
124 | GNUNET_assert (GNUNET_YES == GNUNET_CONNECTION_check (asock)); | 123 | GNUNET_assert (GNUNET_YES == GNUNET_CONNECTION_check (asock)); |
125 | #if VERBOSE | 124 | #if VERBOSE |
@@ -157,10 +156,9 @@ static void | |||
157 | task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 156 | task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
158 | { | 157 | { |
159 | ls = open_listen_socket (); | 158 | ls = open_listen_socket (); |
160 | lsock = GNUNET_CONNECTION_create_from_existing (tc->sched, ls); | 159 | lsock = GNUNET_CONNECTION_create_from_existing (ls); |
161 | GNUNET_assert (lsock != NULL); | 160 | GNUNET_assert (lsock != NULL); |
162 | csock = GNUNET_CONNECTION_create_from_connect (tc->sched, | 161 | csock = GNUNET_CONNECTION_create_from_connect (cfg, |
163 | cfg, | ||
164 | "localhost", PORT); | 162 | "localhost", PORT); |
165 | GNUNET_assert (csock != NULL); | 163 | GNUNET_assert (csock != NULL); |
166 | #if VERBOSE | 164 | #if VERBOSE |
@@ -174,8 +172,7 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
174 | #if VERBOSE | 172 | #if VERBOSE |
175 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test prepares to accept\n"); | 173 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test prepares to accept\n"); |
176 | #endif | 174 | #endif |
177 | GNUNET_SCHEDULER_add_read_net (tc->sched, | 175 | GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, |
178 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
179 | ls, &run_accept, cls); | 176 | ls, &run_accept, cls); |
180 | } | 177 | } |
181 | 178 | ||
diff --git a/src/util/test_connection_addressing.c b/src/util/test_connection_addressing.c index 4c10bd074..f5328be92 100644 --- a/src/util/test_connection_addressing.c +++ b/src/util/test_connection_addressing.c | |||
@@ -115,8 +115,7 @@ run_accept (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
115 | struct sockaddr_in *v4; | 115 | struct sockaddr_in *v4; |
116 | struct sockaddr_in expect; | 116 | struct sockaddr_in expect; |
117 | 117 | ||
118 | asock = GNUNET_CONNECTION_create_from_accept (tc->sched, | 118 | asock = GNUNET_CONNECTION_create_from_accept (NULL, NULL, ls); |
119 | NULL, NULL, ls); | ||
120 | GNUNET_assert (asock != NULL); | 119 | GNUNET_assert (asock != NULL); |
121 | GNUNET_assert (GNUNET_YES == GNUNET_CONNECTION_check (asock)); | 120 | GNUNET_assert (GNUNET_YES == GNUNET_CONNECTION_check (asock)); |
122 | GNUNET_assert (GNUNET_OK == | 121 | GNUNET_assert (GNUNET_OK == |
@@ -153,7 +152,7 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
153 | { | 152 | { |
154 | struct sockaddr_in v4; | 153 | struct sockaddr_in v4; |
155 | ls = open_listen_socket (); | 154 | ls = open_listen_socket (); |
156 | lsock = GNUNET_CONNECTION_create_from_existing (tc->sched, ls); | 155 | lsock = GNUNET_CONNECTION_create_from_existing (ls); |
157 | GNUNET_assert (lsock != NULL); | 156 | GNUNET_assert (lsock != NULL); |
158 | 157 | ||
159 | #if HAVE_SOCKADDR_IN_SIN_LEN | 158 | #if HAVE_SOCKADDR_IN_SIN_LEN |
@@ -162,8 +161,7 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
162 | v4.sin_family = AF_INET; | 161 | v4.sin_family = AF_INET; |
163 | v4.sin_port = htons (PORT); | 162 | v4.sin_port = htons (PORT); |
164 | v4.sin_addr.s_addr = htonl (INADDR_LOOPBACK); | 163 | v4.sin_addr.s_addr = htonl (INADDR_LOOPBACK); |
165 | csock = GNUNET_CONNECTION_create_from_sockaddr (tc->sched, | 164 | csock = GNUNET_CONNECTION_create_from_sockaddr (AF_INET, |
166 | AF_INET, | ||
167 | (const struct sockaddr | 165 | (const struct sockaddr |
168 | *) &v4, sizeof (v4)); | 166 | *) &v4, sizeof (v4)); |
169 | GNUNET_assert (csock != NULL); | 167 | GNUNET_assert (csock != NULL); |
@@ -173,8 +171,7 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
173 | GNUNET_TIME_UNIT_SECONDS, | 171 | GNUNET_TIME_UNIT_SECONDS, |
174 | &make_hello, NULL)); | 172 | &make_hello, NULL)); |
175 | GNUNET_CONNECTION_destroy (csock, GNUNET_YES); | 173 | GNUNET_CONNECTION_destroy (csock, GNUNET_YES); |
176 | GNUNET_SCHEDULER_add_read_net (tc->sched, | 174 | GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, |
177 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
178 | ls, &run_accept, cls); | 175 | ls, &run_accept, cls); |
179 | } | 176 | } |
180 | 177 | ||
diff --git a/src/util/test_connection_receive_cancel.c b/src/util/test_connection_receive_cancel.c index e4d7111d4..1e6720235 100644 --- a/src/util/test_connection_receive_cancel.c +++ b/src/util/test_connection_receive_cancel.c | |||
@@ -90,8 +90,7 @@ static void | |||
90 | run_accept_cancel (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 90 | run_accept_cancel (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
91 | { | 91 | { |
92 | 92 | ||
93 | asock = GNUNET_CONNECTION_create_from_accept (tc->sched, | 93 | asock = GNUNET_CONNECTION_create_from_accept (NULL, NULL, ls); |
94 | NULL, NULL, ls); | ||
95 | GNUNET_assert (asock != NULL); | 94 | GNUNET_assert (asock != NULL); |
96 | GNUNET_assert (GNUNET_YES == GNUNET_CONNECTION_check (asock)); | 95 | GNUNET_assert (GNUNET_YES == GNUNET_CONNECTION_check (asock)); |
97 | GNUNET_CONNECTION_destroy (lsock, GNUNET_YES); | 96 | GNUNET_CONNECTION_destroy (lsock, GNUNET_YES); |
@@ -119,16 +118,14 @@ static void | |||
119 | task_receive_cancel (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 118 | task_receive_cancel (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
120 | { | 119 | { |
121 | ls = open_listen_socket (); | 120 | ls = open_listen_socket (); |
122 | lsock = GNUNET_CONNECTION_create_from_existing (tc->sched, ls); | 121 | lsock = GNUNET_CONNECTION_create_from_existing (ls); |
123 | GNUNET_assert (lsock != NULL); | 122 | GNUNET_assert (lsock != NULL); |
124 | csock = GNUNET_CONNECTION_create_from_connect (tc->sched, cfg, | 123 | csock = GNUNET_CONNECTION_create_from_connect (cfg, |
125 | "localhost", PORT); | 124 | "localhost", PORT); |
126 | GNUNET_assert (csock != NULL); | 125 | GNUNET_assert (csock != NULL); |
127 | GNUNET_SCHEDULER_add_read_net (tc->sched, | 126 | GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, |
128 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
129 | ls, &run_accept_cancel, cls); | 127 | ls, &run_accept_cancel, cls); |
130 | GNUNET_SCHEDULER_add_delayed (tc->sched, | 128 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, |
131 | GNUNET_TIME_UNIT_SECONDS, | ||
132 | &receive_cancel_task, cls); | 129 | &receive_cancel_task, cls); |
133 | } | 130 | } |
134 | 131 | ||
diff --git a/src/util/test_connection_timeout.c b/src/util/test_connection_timeout.c index 5291ad3c4..0e2190e41 100644 --- a/src/util/test_connection_timeout.c +++ b/src/util/test_connection_timeout.c | |||
@@ -107,9 +107,9 @@ task_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
107 | { | 107 | { |
108 | 108 | ||
109 | ls = open_listen_socket (); | 109 | ls = open_listen_socket (); |
110 | lsock = GNUNET_CONNECTION_create_from_existing (tc->sched, ls); | 110 | lsock = GNUNET_CONNECTION_create_from_existing (ls); |
111 | GNUNET_assert (lsock != NULL); | 111 | GNUNET_assert (lsock != NULL); |
112 | csock = GNUNET_CONNECTION_create_from_connect (tc->sched, cfg, | 112 | csock = GNUNET_CONNECTION_create_from_connect (cfg, |
113 | "localhost", PORT); | 113 | "localhost", PORT); |
114 | GNUNET_assert (csock != NULL); | 114 | GNUNET_assert (csock != NULL); |
115 | GNUNET_assert (NULL != | 115 | GNUNET_assert (NULL != |
diff --git a/src/util/test_connection_timeout_no_connect.c b/src/util/test_connection_timeout_no_connect.c index 468e965ca..3519f197b 100644 --- a/src/util/test_connection_timeout_no_connect.c +++ b/src/util/test_connection_timeout_no_connect.c | |||
@@ -53,7 +53,7 @@ handle_timeout (void *cls, size_t size, void *buf) | |||
53 | static void | 53 | static void |
54 | task_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 54 | task_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
55 | { | 55 | { |
56 | csock = GNUNET_CONNECTION_create_from_connect (tc->sched, cfg, | 56 | csock = GNUNET_CONNECTION_create_from_connect (cfg, |
57 | "localhost", PORT); | 57 | "localhost", PORT); |
58 | GNUNET_assert (csock != NULL); | 58 | GNUNET_assert (csock != NULL); |
59 | GNUNET_assert (NULL != | 59 | GNUNET_assert (NULL != |
diff --git a/src/util/test_connection_transmit_cancel.c b/src/util/test_connection_transmit_cancel.c index d4456b00d..72e27243b 100644 --- a/src/util/test_connection_transmit_cancel.c +++ b/src/util/test_connection_transmit_cancel.c | |||
@@ -50,7 +50,7 @@ task_transmit_cancel (void *cls, | |||
50 | struct GNUNET_CONNECTION_TransmitHandle *th; | 50 | struct GNUNET_CONNECTION_TransmitHandle *th; |
51 | struct GNUNET_CONNECTION_Handle *csock; | 51 | struct GNUNET_CONNECTION_Handle *csock; |
52 | 52 | ||
53 | csock = GNUNET_CONNECTION_create_from_connect (tc->sched, cfg, | 53 | csock = GNUNET_CONNECTION_create_from_connect (cfg, |
54 | "localhost", PORT); | 54 | "localhost", PORT); |
55 | GNUNET_assert (csock != NULL); | 55 | GNUNET_assert (csock != NULL); |
56 | th = GNUNET_CONNECTION_notify_transmit_ready (csock, | 56 | th = GNUNET_CONNECTION_notify_transmit_ready (csock, |
diff --git a/src/util/test_crypto_hash.c b/src/util/test_crypto_hash.c index 33f19c804..85de9fbbb 100644 --- a/src/util/test_crypto_hash.c +++ b/src/util/test_crypto_hash.c | |||
@@ -123,8 +123,7 @@ static void | |||
123 | file_hasher (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 123 | file_hasher (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
124 | { | 124 | { |
125 | GNUNET_assert (NULL != | 125 | GNUNET_assert (NULL != |
126 | GNUNET_CRYPTO_hash_file (tc->sched, | 126 | GNUNET_CRYPTO_hash_file (GNUNET_SCHEDULER_PRIORITY_DEFAULT, |
127 | GNUNET_SCHEDULER_PRIORITY_DEFAULT, | ||
128 | FILENAME, 1024, | 127 | FILENAME, 1024, |
129 | &finished_task, cls)); | 128 | &finished_task, cls)); |
130 | } | 129 | } |
diff --git a/src/util/test_disk.c b/src/util/test_disk.c index 9a5ea3a57..fb79e7cd8 100644 --- a/src/util/test_disk.c +++ b/src/util/test_disk.c | |||
@@ -169,8 +169,7 @@ iter_callback (void *cls, | |||
169 | static void | 169 | static void |
170 | iter_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 170 | iter_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
171 | { | 171 | { |
172 | GNUNET_DISK_directory_iterator_start (tc->sched, | 172 | GNUNET_DISK_directory_iterator_start (GNUNET_SCHEDULER_PRIORITY_DEFAULT, |
173 | GNUNET_SCHEDULER_PRIORITY_DEFAULT, | ||
174 | "test", &iter_callback, cls); | 173 | "test", &iter_callback, cls); |
175 | } | 174 | } |
176 | 175 | ||
diff --git a/src/util/test_os_start_process.c b/src/util/test_os_start_process.c index bce1c7151..f82860e83 100644 --- a/src/util/test_os_start_process.c +++ b/src/util/test_os_start_process.c | |||
@@ -78,8 +78,8 @@ read_call (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
78 | { | 78 | { |
79 | GNUNET_break (0); | 79 | GNUNET_break (0); |
80 | ok = 1; | 80 | ok = 1; |
81 | GNUNET_SCHEDULER_cancel(tc->sched, die_task); | 81 | GNUNET_SCHEDULER_cancel(die_task); |
82 | GNUNET_SCHEDULER_add_now(tc->sched, &end_task, NULL); | 82 | GNUNET_SCHEDULER_add_now(&end_task, NULL); |
83 | return; | 83 | return; |
84 | } | 84 | } |
85 | 85 | ||
@@ -89,13 +89,12 @@ read_call (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
89 | #endif | 89 | #endif |
90 | if (ok == 0) | 90 | if (ok == 0) |
91 | { | 91 | { |
92 | GNUNET_SCHEDULER_cancel(tc->sched, die_task); | 92 | GNUNET_SCHEDULER_cancel(die_task); |
93 | GNUNET_SCHEDULER_add_now(tc->sched, &end_task, NULL); | 93 | GNUNET_SCHEDULER_add_now(&end_task, NULL); |
94 | return; | 94 | return; |
95 | } | 95 | } |
96 | 96 | ||
97 | GNUNET_SCHEDULER_add_read_file (tc->sched, | 97 | GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, |
98 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
99 | stdout_read_handle, &read_call, stdout_read_handle); | 98 | stdout_read_handle, &read_call, stdout_read_handle); |
100 | 99 | ||
101 | } | 100 | } |
@@ -145,10 +144,9 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
145 | 144 | ||
146 | stdout_read_handle = GNUNET_DISK_pipe_handle(hello_pipe_stdout, GNUNET_DISK_PIPE_END_READ); | 145 | stdout_read_handle = GNUNET_DISK_pipe_handle(hello_pipe_stdout, GNUNET_DISK_PIPE_END_READ); |
147 | 146 | ||
148 | die_task = GNUNET_SCHEDULER_add_delayed(tc->sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 1), &end_task, NULL); | 147 | die_task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 1), &end_task, NULL); |
149 | 148 | ||
150 | GNUNET_SCHEDULER_add_read_file (tc->sched, | 149 | GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, |
151 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
152 | stdout_read_handle, &read_call, (void *)stdout_read_handle); | 150 | stdout_read_handle, &read_call, (void *)stdout_read_handle); |
153 | 151 | ||
154 | } | 152 | } |
diff --git a/src/util/test_program.c b/src/util/test_program.c index e7745abff..33a6b50ea 100644 --- a/src/util/test_program.c +++ b/src/util/test_program.c | |||
@@ -58,13 +58,11 @@ static struct GNUNET_GETOPT_CommandLineOption options4[] = { | |||
58 | 58 | ||
59 | static void | 59 | static void |
60 | runner (void *cls, | 60 | runner (void *cls, |
61 | struct GNUNET_SCHEDULER_Handle *sched, | ||
62 | char *const *args, | 61 | char *const *args, |
63 | const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) | 62 | const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) |
64 | { | 63 | { |
65 | int *ok = cls; | 64 | int *ok = cls; |
66 | GNUNET_assert (setme1 == 1); | 65 | GNUNET_assert (setme1 == 1); |
67 | GNUNET_assert (sched != NULL); | ||
68 | GNUNET_assert (0 == strcmp (args[0], "extra")); | 66 | GNUNET_assert (0 == strcmp (args[0], "extra")); |
69 | GNUNET_assert (args[1] == NULL); | 67 | GNUNET_assert (args[1] == NULL); |
70 | GNUNET_assert (0 == strcmp (cfgfile, "test_program_data.conf")); | 68 | GNUNET_assert (0 == strcmp (cfgfile, "test_program_data.conf")); |
diff --git a/src/util/test_resolver_api.c b/src/util/test_resolver_api.c index 734420e84..bf2f8f00f 100644 --- a/src/util/test_resolver_api.c +++ b/src/util/test_resolver_api.c | |||
@@ -219,7 +219,7 @@ check_rootserver_name(void *cls, const char *hostname) | |||
219 | } | 219 | } |
220 | 220 | ||
221 | static void | 221 | static void |
222 | run(void *cls, struct GNUNET_SCHEDULER_Handle *sched, char * const *args, | 222 | run(void *cls, char * const *args, |
223 | const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) | 223 | const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) |
224 | { | 224 | { |
225 | int *ok = cls; | 225 | int *ok = cls; |
@@ -232,13 +232,13 @@ run(void *cls, struct GNUNET_SCHEDULER_Handle *sched, char * const *args, | |||
232 | memset(&sa, 0, sizeof(sa)); | 232 | memset(&sa, 0, sizeof(sa)); |
233 | sa.sin_family = AF_INET; | 233 | sa.sin_family = AF_INET; |
234 | sa.sin_addr.s_addr = htonl(INADDR_LOOPBACK); | 234 | sa.sin_addr.s_addr = htonl(INADDR_LOOPBACK); |
235 | GNUNET_RESOLVER_ip_get(sched, cfg, "localhost", AF_INET, timeout, &check_127, | 235 | GNUNET_RESOLVER_ip_get(cfg, "localhost", AF_INET, timeout, &check_127, |
236 | cls); | 236 | cls); |
237 | GNUNET_RESOLVER_hostname_get(sched, cfg, (const struct sockaddr *) &sa, | 237 | GNUNET_RESOLVER_hostname_get(cfg, (const struct sockaddr *) &sa, |
238 | sizeof(struct sockaddr), GNUNET_YES, timeout, &check_localhost, cls); | 238 | sizeof(struct sockaddr), GNUNET_YES, timeout, &check_localhost, cls); |
239 | GNUNET_RESOLVER_hostname_get(sched, cfg, (const struct sockaddr *) &sa, | 239 | GNUNET_RESOLVER_hostname_get(cfg, (const struct sockaddr *) &sa, |
240 | sizeof(struct sockaddr), GNUNET_NO, timeout, &check_localhost_num, cls); | 240 | sizeof(struct sockaddr), GNUNET_NO, timeout, &check_localhost_num, cls); |
241 | GNUNET_RESOLVER_hostname_resolve(sched, cfg, AF_UNSPEC, timeout, | 241 | GNUNET_RESOLVER_hostname_resolve(cfg, AF_UNSPEC, timeout, |
242 | &check_hostname, cls); | 242 | &check_hostname, cls); |
243 | 243 | ||
244 | 244 | ||
@@ -297,7 +297,7 @@ run(void *cls, struct GNUNET_SCHEDULER_Handle *sched, char * const *args, | |||
297 | #endif | 297 | #endif |
298 | 298 | ||
299 | /* Resolve the same using GNUNET */ | 299 | /* Resolve the same using GNUNET */ |
300 | GNUNET_RESOLVER_ip_get(sched, cfg, ROOTSERVER_NAME, AF_INET, timeout, | 300 | GNUNET_RESOLVER_ip_get(cfg, ROOTSERVER_NAME, AF_INET, timeout, |
301 | &check_rootserver_ip, cls); | 301 | &check_rootserver_ip, cls); |
302 | 302 | ||
303 | /* | 303 | /* |
@@ -350,7 +350,7 @@ run(void *cls, struct GNUNET_SCHEDULER_Handle *sched, char * const *args, | |||
350 | #else | 350 | #else |
351 | sa.sin_addr.S_un.S_addr = inet_addr(ROOTSERVER_IP); | 351 | sa.sin_addr.S_un.S_addr = inet_addr(ROOTSERVER_IP); |
352 | #endif | 352 | #endif |
353 | GNUNET_RESOLVER_hostname_get(sched, cfg, (const struct sockaddr *) &sa, | 353 | GNUNET_RESOLVER_hostname_get(cfg, (const struct sockaddr *) &sa, |
354 | sizeof(struct sockaddr), GNUNET_YES, timeout, &check_rootserver_name, cls); | 354 | sizeof(struct sockaddr), GNUNET_YES, timeout, &check_rootserver_name, cls); |
355 | } | 355 | } |
356 | 356 | ||
diff --git a/src/util/test_scheduler.c b/src/util/test_scheduler.c index 0ac186588..f0c908d7d 100644 --- a/src/util/test_scheduler.c +++ b/src/util/test_scheduler.c | |||
@@ -34,8 +34,7 @@ task3 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
34 | { | 34 | { |
35 | int *ok = cls; | 35 | int *ok = cls; |
36 | /* t4 should be ready (albeit with lower priority) */ | 36 | /* t4 should be ready (albeit with lower priority) */ |
37 | GNUNET_assert (1 == GNUNET_SCHEDULER_get_load (tc->sched, | 37 | GNUNET_assert (1 == GNUNET_SCHEDULER_get_load (GNUNET_SCHEDULER_PRIORITY_COUNT)); |
38 | GNUNET_SCHEDULER_PRIORITY_COUNT)); | ||
39 | GNUNET_assert (3 == *ok); | 38 | GNUNET_assert (3 == *ok); |
40 | (*ok) = 4; | 39 | (*ok) = 4; |
41 | } | 40 | } |
@@ -48,8 +47,7 @@ task2 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
48 | GNUNET_assert (2 == *ok); | 47 | GNUNET_assert (2 == *ok); |
49 | (*ok) = 3; | 48 | (*ok) = 3; |
50 | /* t3 will go before t4: higher priority */ | 49 | /* t3 will go before t4: higher priority */ |
51 | GNUNET_SCHEDULER_add_with_priority (tc->sched, | 50 | GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_UI, |
52 | GNUNET_SCHEDULER_PRIORITY_UI, | ||
53 | &task3, cls); | 51 | &task3, cls); |
54 | } | 52 | } |
55 | 53 | ||
@@ -101,10 +99,9 @@ taskRd (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
101 | GNUNET_assert (GNUNET_NETWORK_fdset_handle_isset (tc->read_ready, fds[0])); | 99 | GNUNET_assert (GNUNET_NETWORK_fdset_handle_isset (tc->read_ready, fds[0])); |
102 | GNUNET_assert (1 == GNUNET_DISK_file_read (fds[0], &c, 1)); | 100 | GNUNET_assert (1 == GNUNET_DISK_file_read (fds[0], &c, 1)); |
103 | (*ok) = 8; | 101 | (*ok) = 8; |
104 | GNUNET_SCHEDULER_add_with_priority (tc->sched, | 102 | GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE, |
105 | GNUNET_SCHEDULER_PRIORITY_IDLE, | ||
106 | &taskLast, cls); | 103 | &taskLast, cls); |
107 | GNUNET_SCHEDULER_shutdown (tc->sched); | 104 | GNUNET_SCHEDULER_shutdown (); |
108 | } | 105 | } |
109 | 106 | ||
110 | 107 | ||
@@ -118,11 +115,9 @@ task5 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
118 | GNUNET_assert (NULL != p); | 115 | GNUNET_assert (NULL != p); |
119 | fds[0] = GNUNET_DISK_pipe_handle (p, GNUNET_DISK_PIPE_END_READ); | 116 | fds[0] = GNUNET_DISK_pipe_handle (p, GNUNET_DISK_PIPE_END_READ); |
120 | fds[1] = GNUNET_DISK_pipe_handle (p, GNUNET_DISK_PIPE_END_WRITE); | 117 | fds[1] = GNUNET_DISK_pipe_handle (p, GNUNET_DISK_PIPE_END_WRITE); |
121 | GNUNET_SCHEDULER_add_read_file (tc->sched, | 118 | GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, |
122 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
123 | fds[0], &taskRd, cls); | 119 | fds[0], &taskRd, cls); |
124 | GNUNET_SCHEDULER_add_write_file (tc->sched, | 120 | GNUNET_SCHEDULER_add_write_file (GNUNET_TIME_UNIT_FOREVER_REL, |
125 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
126 | fds[1], &taskWrt, cls); | 121 | fds[1], &taskWrt, cls); |
127 | } | 122 | } |
128 | 123 | ||
@@ -137,12 +132,11 @@ task1 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
137 | GNUNET_assert (1 == *ok); | 132 | GNUNET_assert (1 == *ok); |
138 | (*ok) = 2; | 133 | (*ok) = 2; |
139 | /* t2 will go first -- prereq for all */ | 134 | /* t2 will go first -- prereq for all */ |
140 | t2 = GNUNET_SCHEDULER_add_after (tc->sched, | 135 | t2 = GNUNET_SCHEDULER_add_after (GNUNET_SCHEDULER_NO_TASK, &task2, cls); |
141 | GNUNET_SCHEDULER_NO_TASK, &task2, cls); | ||
142 | /* t4 will go after t2 ('add after') and after t3 (priority) */ | 136 | /* t4 will go after t2 ('add after') and after t3 (priority) */ |
143 | t4 = GNUNET_SCHEDULER_add_after (tc->sched, t2, &task4, cls); | 137 | t4 = GNUNET_SCHEDULER_add_after (t2, &task4, cls); |
144 | /* t5 will go last (after p4) */ | 138 | /* t5 will go last (after p4) */ |
145 | GNUNET_SCHEDULER_add_after (tc->sched, t4, &task5, cls); | 139 | GNUNET_SCHEDULER_add_after (t4, &task5, cls); |
146 | } | 140 | } |
147 | 141 | ||
148 | 142 | ||
@@ -168,9 +162,8 @@ taskShutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
168 | int *ok = cls; | 162 | int *ok = cls; |
169 | GNUNET_assert (1 == *ok); | 163 | GNUNET_assert (1 == *ok); |
170 | *ok = 8; | 164 | *ok = 8; |
171 | GNUNET_SCHEDULER_add_delayed (tc->sched, | 165 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &taskLast, cls); |
172 | GNUNET_TIME_UNIT_FOREVER_REL, &taskLast, cls); | 166 | GNUNET_SCHEDULER_shutdown (); |
173 | GNUNET_SCHEDULER_shutdown (tc->sched); | ||
174 | } | 167 | } |
175 | 168 | ||
176 | 169 | ||
@@ -195,8 +188,7 @@ taskSig (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
195 | int *ok = cls; | 188 | int *ok = cls; |
196 | GNUNET_assert (1 == *ok); | 189 | GNUNET_assert (1 == *ok); |
197 | *ok = 8; | 190 | *ok = 8; |
198 | GNUNET_SCHEDULER_add_delayed (tc->sched, | 191 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &taskLast, cls); |
199 | GNUNET_TIME_UNIT_FOREVER_REL, &taskLast, cls); | ||
200 | GNUNET_break (0 == PLIBC_KILL (getpid (), SIGTERM)); | 192 | GNUNET_break (0 == PLIBC_KILL (getpid (), SIGTERM)); |
201 | } | 193 | } |
202 | 194 | ||
@@ -223,9 +215,7 @@ taskCancel (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
223 | 215 | ||
224 | GNUNET_assert (1 == *ok); | 216 | GNUNET_assert (1 == *ok); |
225 | *ok = 0; | 217 | *ok = 0; |
226 | GNUNET_SCHEDULER_cancel (tc->sched, | 218 | GNUNET_SCHEDULER_cancel (GNUNET_SCHEDULER_add_after (GNUNET_SCHEDULER_NO_TASK, |
227 | GNUNET_SCHEDULER_add_after (tc->sched, | ||
228 | GNUNET_SCHEDULER_NO_TASK, | ||
229 | &taskNeverRun, NULL)); | 219 | &taskNeverRun, NULL)); |
230 | } | 220 | } |
231 | 221 | ||
diff --git a/src/util/test_scheduler_delay.c b/src/util/test_scheduler_delay.c index 24d30be99..1f60ca9fd 100644 --- a/src/util/test_scheduler_delay.c +++ b/src/util/test_scheduler_delay.c | |||
@@ -65,8 +65,7 @@ test_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
65 | fprintf (stderr, "\n"); | 65 | fprintf (stderr, "\n"); |
66 | return; | 66 | return; |
67 | } | 67 | } |
68 | GNUNET_SCHEDULER_add_delayed (tc->sched, | 68 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply |
69 | GNUNET_TIME_relative_multiply | ||
70 | (GNUNET_TIME_UNIT_MILLISECONDS, i), | 69 | (GNUNET_TIME_UNIT_MILLISECONDS, i), |
71 | &test_task, NULL); | 70 | &test_task, NULL); |
72 | i += INCR; | 71 | i += INCR; |
diff --git a/src/util/test_server.c b/src/util/test_server.c index 78e2d52bf..00d4352f8 100644 --- a/src/util/test_server.c +++ b/src/util/test_server.c | |||
@@ -45,8 +45,6 @@ static struct GNUNET_SERVER_Client *argclient; | |||
45 | 45 | ||
46 | static struct GNUNET_CONFIGURATION_Handle *cfg; | 46 | static struct GNUNET_CONFIGURATION_Handle *cfg; |
47 | 47 | ||
48 | static struct GNUNET_SCHEDULER_Handle *sched; | ||
49 | |||
50 | static int ok; | 48 | static int ok; |
51 | 49 | ||
52 | 50 | ||
@@ -70,8 +68,7 @@ recv_fin_cb (void *cls, | |||
70 | GNUNET_assert (ok == 5); | 68 | GNUNET_assert (ok == 5); |
71 | ok = 6; | 69 | ok = 6; |
72 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 70 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
73 | GNUNET_SCHEDULER_add_now (sched, | 71 | GNUNET_SCHEDULER_add_now (&finish_up, |
74 | &finish_up, | ||
75 | NULL); | 72 | NULL); |
76 | } | 73 | } |
77 | 74 | ||
@@ -181,15 +178,13 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
181 | slens[0] = sizeof (sa); | 178 | slens[0] = sizeof (sa); |
182 | sap[1] = NULL; | 179 | sap[1] = NULL; |
183 | slens[1] = 0; | 180 | slens[1] = 0; |
184 | sched = tc->sched; | ||
185 | memset (&sa, 0, sizeof (sa)); | 181 | memset (&sa, 0, sizeof (sa)); |
186 | #if HAVE_SOCKADDR_IN_SIN_LEN | 182 | #if HAVE_SOCKADDR_IN_SIN_LEN |
187 | sa.sin_len = sizeof (sa); | 183 | sa.sin_len = sizeof (sa); |
188 | #endif | 184 | #endif |
189 | sa.sin_family = AF_INET; | 185 | sa.sin_family = AF_INET; |
190 | sa.sin_port = htons (PORT); | 186 | sa.sin_port = htons (PORT); |
191 | server = GNUNET_SERVER_create (tc->sched, | 187 | server = GNUNET_SERVER_create (NULL, |
192 | NULL, | ||
193 | NULL, | 188 | NULL, |
194 | sap, | 189 | sap, |
195 | slens, | 190 | slens, |
@@ -201,8 +196,7 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
201 | GNUNET_CONFIGURATION_set_value_number (cfg, "test-server", "PORT", PORT); | 196 | GNUNET_CONFIGURATION_set_value_number (cfg, "test-server", "PORT", PORT); |
202 | GNUNET_CONFIGURATION_set_value_string (cfg, "test-server", "HOSTNAME", "localhost"); | 197 | GNUNET_CONFIGURATION_set_value_string (cfg, "test-server", "HOSTNAME", "localhost"); |
203 | GNUNET_CONFIGURATION_set_value_string (cfg, "resolver", "HOSTNAME", "localhost"); | 198 | GNUNET_CONFIGURATION_set_value_string (cfg, "resolver", "HOSTNAME", "localhost"); |
204 | cc = GNUNET_CLIENT_connect (tc->sched, | 199 | cc = GNUNET_CLIENT_connect ("test-server", |
205 | "test-server", | ||
206 | cfg); | 200 | cfg); |
207 | GNUNET_assert (cc != NULL); | 201 | GNUNET_assert (cc != NULL); |
208 | GNUNET_assert (NULL != | 202 | GNUNET_assert (NULL != |
diff --git a/src/util/test_server_disconnect.c b/src/util/test_server_disconnect.c index 2fef5642e..8ab8ef35b 100644 --- a/src/util/test_server_disconnect.c +++ b/src/util/test_server_disconnect.c | |||
@@ -42,8 +42,6 @@ static struct GNUNET_CLIENT_Connection *cc; | |||
42 | 42 | ||
43 | static struct GNUNET_CONFIGURATION_Handle *cfg; | 43 | static struct GNUNET_CONFIGURATION_Handle *cfg; |
44 | 44 | ||
45 | static struct GNUNET_SCHEDULER_Handle *sched; | ||
46 | |||
47 | static int ok; | 45 | static int ok; |
48 | 46 | ||
49 | 47 | ||
@@ -66,8 +64,7 @@ notify_disconnect (void *cls, struct GNUNET_SERVER_Client *clientarg) | |||
66 | return; | 64 | return; |
67 | GNUNET_assert (ok == 4); | 65 | GNUNET_assert (ok == 4); |
68 | ok = 5; | 66 | ok = 5; |
69 | GNUNET_SCHEDULER_add_now (sched, | 67 | GNUNET_SCHEDULER_add_now (&finish_up, |
70 | &finish_up, | ||
71 | NULL); | 68 | NULL); |
72 | } | 69 | } |
73 | 70 | ||
@@ -91,8 +88,7 @@ recv_cb (void *cls, | |||
91 | GNUNET_assert (ok == 2); | 88 | GNUNET_assert (ok == 2); |
92 | ok = 3; | 89 | ok = 3; |
93 | GNUNET_SERVER_client_keep (client); | 90 | GNUNET_SERVER_client_keep (client); |
94 | GNUNET_SCHEDULER_add_now (sched, | 91 | GNUNET_SCHEDULER_add_now (&server_disconnect, client); |
95 | &server_disconnect, client); | ||
96 | GNUNET_assert (sizeof (struct GNUNET_MessageHeader) == | 92 | GNUNET_assert (sizeof (struct GNUNET_MessageHeader) == |
97 | ntohs (message->size)); | 93 | ntohs (message->size)); |
98 | GNUNET_assert (MY_TYPE == ntohs (message->type)); | 94 | GNUNET_assert (MY_TYPE == ntohs (message->type)); |
@@ -134,15 +130,13 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
134 | slens[0] = sizeof (sa); | 130 | slens[0] = sizeof (sa); |
135 | sap[1] = NULL; | 131 | sap[1] = NULL; |
136 | slens[1] = 0; | 132 | slens[1] = 0; |
137 | sched = tc->sched; | ||
138 | memset (&sa, 0, sizeof (sa)); | 133 | memset (&sa, 0, sizeof (sa)); |
139 | #if HAVE_SOCKADDR_IN_SIN_LEN | 134 | #if HAVE_SOCKADDR_IN_SIN_LEN |
140 | sa.sin_len = sizeof (sa); | 135 | sa.sin_len = sizeof (sa); |
141 | #endif | 136 | #endif |
142 | sa.sin_family = AF_INET; | 137 | sa.sin_family = AF_INET; |
143 | sa.sin_port = htons (PORT); | 138 | sa.sin_port = htons (PORT); |
144 | server = GNUNET_SERVER_create (tc->sched, | 139 | server = GNUNET_SERVER_create (NULL, |
145 | NULL, | ||
146 | NULL, | 140 | NULL, |
147 | sap, | 141 | sap, |
148 | slens, | 142 | slens, |
@@ -155,8 +149,7 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
155 | GNUNET_CONFIGURATION_set_value_number (cfg, "test-server", "PORT", PORT); | 149 | GNUNET_CONFIGURATION_set_value_number (cfg, "test-server", "PORT", PORT); |
156 | GNUNET_CONFIGURATION_set_value_string (cfg, "test-server", "HOSTNAME", "localhost"); | 150 | GNUNET_CONFIGURATION_set_value_string (cfg, "test-server", "HOSTNAME", "localhost"); |
157 | GNUNET_CONFIGURATION_set_value_string (cfg, "resolver", "HOSTNAME", "localhost"); | 151 | GNUNET_CONFIGURATION_set_value_string (cfg, "resolver", "HOSTNAME", "localhost"); |
158 | cc = GNUNET_CLIENT_connect (tc->sched, | 152 | cc = GNUNET_CLIENT_connect ("test-server", |
159 | "test-server", | ||
160 | cfg); | 153 | cfg); |
161 | GNUNET_assert (cc != NULL); | 154 | GNUNET_assert (cc != NULL); |
162 | GNUNET_assert (NULL != | 155 | GNUNET_assert (NULL != |
diff --git a/src/util/test_server_with_client.c b/src/util/test_server_with_client.c index 4157be250..5c36b7b03 100644 --- a/src/util/test_server_with_client.c +++ b/src/util/test_server_with_client.c | |||
@@ -41,8 +41,6 @@ static struct GNUNET_SERVER_Handle *server; | |||
41 | 41 | ||
42 | static struct GNUNET_CLIENT_Connection *client; | 42 | static struct GNUNET_CLIENT_Connection *client; |
43 | 43 | ||
44 | static struct GNUNET_SCHEDULER_Handle *sched; | ||
45 | |||
46 | static struct GNUNET_CONFIGURATION_Handle *cfg; | 44 | static struct GNUNET_CONFIGURATION_Handle *cfg; |
47 | 45 | ||
48 | static int ok; | 46 | static int ok; |
@@ -86,8 +84,7 @@ recv_cb (void *cls, | |||
86 | { | 84 | { |
87 | case 2: | 85 | case 2: |
88 | ok++; | 86 | ok++; |
89 | GNUNET_SCHEDULER_add_delayed (sched, | 87 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply |
90 | GNUNET_TIME_relative_multiply | ||
91 | (GNUNET_TIME_UNIT_MILLISECONDS, 50), | 88 | (GNUNET_TIME_UNIT_MILLISECONDS, 50), |
92 | &send_done, argclient); | 89 | &send_done, argclient); |
93 | break; | 90 | break; |
@@ -127,8 +124,7 @@ notify_disconnect (void *cls, struct GNUNET_SERVER_Client *client) | |||
127 | return; | 124 | return; |
128 | GNUNET_assert (ok == 5); | 125 | GNUNET_assert (ok == 5); |
129 | ok = 0; | 126 | ok = 0; |
130 | GNUNET_SCHEDULER_add_now (sched, | 127 | GNUNET_SCHEDULER_add_now (&clean_up, NULL); |
131 | &clean_up, NULL); | ||
132 | } | 128 | } |
133 | 129 | ||
134 | 130 | ||
@@ -167,15 +163,13 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
167 | slens[0] = sizeof (sa); | 163 | slens[0] = sizeof (sa); |
168 | sap[1] = NULL; | 164 | sap[1] = NULL; |
169 | slens[1] = 0; | 165 | slens[1] = 0; |
170 | sched = tc->sched; | ||
171 | memset (&sa, 0, sizeof (sa)); | 166 | memset (&sa, 0, sizeof (sa)); |
172 | #if HAVE_SOCKADDR_IN_SIN_LEN | 167 | #if HAVE_SOCKADDR_IN_SIN_LEN |
173 | sa.sin_len = sizeof (sa); | 168 | sa.sin_len = sizeof (sa); |
174 | #endif | 169 | #endif |
175 | sa.sin_family = AF_INET; | 170 | sa.sin_family = AF_INET; |
176 | sa.sin_port = htons (PORT); | 171 | sa.sin_port = htons (PORT); |
177 | server = GNUNET_SERVER_create (tc->sched, | 172 | server = GNUNET_SERVER_create (NULL, |
178 | NULL, | ||
179 | NULL, | 173 | NULL, |
180 | sap, | 174 | sap, |
181 | slens, | 175 | slens, |
@@ -192,7 +186,7 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
192 | "localhost"); | 186 | "localhost"); |
193 | GNUNET_CONFIGURATION_set_value_string (cfg, "resolver", "HOSTNAME", | 187 | GNUNET_CONFIGURATION_set_value_string (cfg, "resolver", "HOSTNAME", |
194 | "localhost"); | 188 | "localhost"); |
195 | client = GNUNET_CLIENT_connect (tc->sched, "test", cfg); | 189 | client = GNUNET_CLIENT_connect ("test", cfg); |
196 | GNUNET_assert (client != NULL); | 190 | GNUNET_assert (client != NULL); |
197 | GNUNET_CLIENT_notify_transmit_ready (client, | 191 | GNUNET_CLIENT_notify_transmit_ready (client, |
198 | 256, | 192 | 256, |
diff --git a/src/util/test_service.c b/src/util/test_service.c index 6c78a4eb9..9bd58352b 100644 --- a/src/util/test_service.c +++ b/src/util/test_service.c | |||
@@ -37,8 +37,6 @@ | |||
37 | 37 | ||
38 | #define MY_TYPE 256 | 38 | #define MY_TYPE 256 |
39 | 39 | ||
40 | static struct GNUNET_SCHEDULER_Handle *sched; | ||
41 | |||
42 | static struct GNUNET_SERVICE_Context *sctx; | 40 | static struct GNUNET_SERVICE_Context *sctx; |
43 | 41 | ||
44 | static int ok = 1; | 42 | static int ok = 1; |
@@ -67,8 +65,7 @@ ready (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
67 | 65 | ||
68 | GNUNET_assert (0 != (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE)); | 66 | GNUNET_assert (0 != (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE)); |
69 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Service confirmed running\n"); | 67 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Service confirmed running\n"); |
70 | sched = tc->sched; | 68 | client = GNUNET_CLIENT_connect ("test_service", cfg); |
71 | client = GNUNET_CLIENT_connect (tc->sched, "test_service", cfg); | ||
72 | GNUNET_assert (client != NULL); | 69 | GNUNET_assert (client != NULL); |
73 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 70 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
74 | "Client connecting, waiting to transmit\n"); | 71 | "Client connecting, waiting to transmit\n"); |
@@ -94,9 +91,9 @@ recv_cb (void *cls, | |||
94 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Receiving client message...\n"); | 91 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Receiving client message...\n"); |
95 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 92 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
96 | if (sctx != NULL) | 93 | if (sctx != NULL) |
97 | GNUNET_SCHEDULER_add_now (sched, &do_stop, NULL); | 94 | GNUNET_SCHEDULER_add_now (&do_stop, NULL); |
98 | else | 95 | else |
99 | GNUNET_SCHEDULER_shutdown (sched); | 96 | GNUNET_SCHEDULER_shutdown (); |
100 | ok = 0; | 97 | ok = 0; |
101 | } | 98 | } |
102 | 99 | ||
@@ -110,14 +107,12 @@ static struct GNUNET_SERVER_MessageHandler myhandlers[] = { | |||
110 | 107 | ||
111 | static void | 108 | static void |
112 | runner (void *cls, | 109 | runner (void *cls, |
113 | struct GNUNET_SCHEDULER_Handle *sched, | ||
114 | struct GNUNET_SERVER_Handle *server, | 110 | struct GNUNET_SERVER_Handle *server, |
115 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 111 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
116 | { | 112 | { |
117 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Service initializing\n"); | 113 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Service initializing\n"); |
118 | GNUNET_SERVER_add_handlers (server, myhandlers); | 114 | GNUNET_SERVER_add_handlers (server, myhandlers); |
119 | GNUNET_CLIENT_service_test (sched, | 115 | GNUNET_CLIENT_service_test ("test_service", |
120 | "test_service", | ||
121 | cfg, GNUNET_TIME_UNIT_SECONDS, &ready, | 116 | cfg, GNUNET_TIME_UNIT_SECONDS, &ready, |
122 | (void *) cfg); | 117 | (void *) cfg); |
123 | } | 118 | } |
@@ -161,9 +156,8 @@ ready6 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
161 | struct GNUNET_CLIENT_Connection *client; | 156 | struct GNUNET_CLIENT_Connection *client; |
162 | 157 | ||
163 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "V6 ready\n"); | 158 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "V6 ready\n"); |
164 | sched = tc->sched; | ||
165 | GNUNET_assert (0 != (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE)); | 159 | GNUNET_assert (0 != (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE)); |
166 | client = GNUNET_CLIENT_connect (tc->sched, "test_service6", cfg); | 160 | client = GNUNET_CLIENT_connect ("test_service6", cfg); |
167 | GNUNET_assert (client != NULL); | 161 | GNUNET_assert (client != NULL); |
168 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "V6 client connected\n"); | 162 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "V6 client connected\n"); |
169 | GNUNET_CLIENT_notify_transmit_ready (client, | 163 | GNUNET_CLIENT_notify_transmit_ready (client, |
@@ -174,14 +168,12 @@ ready6 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
174 | 168 | ||
175 | static void | 169 | static void |
176 | runner6 (void *cls, | 170 | runner6 (void *cls, |
177 | struct GNUNET_SCHEDULER_Handle *sched, | ||
178 | struct GNUNET_SERVER_Handle *server, | 171 | struct GNUNET_SERVER_Handle *server, |
179 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 172 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
180 | { | 173 | { |
181 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Initializing v6 service\n"); | 174 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Initializing v6 service\n"); |
182 | GNUNET_SERVER_add_handlers (server, myhandlers); | 175 | GNUNET_SERVER_add_handlers (server, myhandlers); |
183 | GNUNET_CLIENT_service_test (sched, | 176 | GNUNET_CLIENT_service_test ("test_service6", |
184 | "test_service6", | ||
185 | cfg, GNUNET_TIME_UNIT_SECONDS, &ready6, | 177 | cfg, GNUNET_TIME_UNIT_SECONDS, &ready6, |
186 | (void *) cfg); | 178 | (void *) cfg); |
187 | } | 179 | } |
@@ -220,7 +212,6 @@ check6 () | |||
220 | 212 | ||
221 | static void | 213 | static void |
222 | start_stop_main (void *cls, | 214 | start_stop_main (void *cls, |
223 | struct GNUNET_SCHEDULER_Handle *sched, | ||
224 | char *const *args, | 215 | char *const *args, |
225 | const char *cfgfile, | 216 | const char *cfgfile, |
226 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 217 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
@@ -228,9 +219,9 @@ start_stop_main (void *cls, | |||
228 | int *ret = cls; | 219 | int *ret = cls; |
229 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 220 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
230 | "Starting service using start method\n"); | 221 | "Starting service using start method\n"); |
231 | sctx = GNUNET_SERVICE_start ("test_service", sched, cfg); | 222 | sctx = GNUNET_SERVICE_start ("test_service", cfg); |
232 | GNUNET_assert (NULL != sctx); | 223 | GNUNET_assert (NULL != sctx); |
233 | runner (cls, sched, GNUNET_SERVICE_get_server (sctx), cfg); | 224 | runner (cls, GNUNET_SERVICE_get_server (sctx), cfg); |
234 | *ret = 0; | 225 | *ret = 0; |
235 | } | 226 | } |
236 | 227 | ||