diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-04-30 08:17:37 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-04-30 08:17:37 +0000 |
commit | 95f9076a2139f5fb042b944a0658b6cda2fa35db (patch) | |
tree | b0826a2a1dcf812e6b4450fe6b05d47cd53ae49d /src/identity-provider | |
parent | 7746f68db77b9ca3c4aaca24ab2ce5253461240b (diff) | |
download | gnunet-95f9076a2139f5fb042b944a0658b6cda2fa35db.tar.gz gnunet-95f9076a2139f5fb042b944a0658b6cda2fa35db.zip |
implementing new scheduler shutdown semantics
Diffstat (limited to 'src/identity-provider')
-rw-r--r-- | src/identity-provider/gnunet-service-identity-provider.c | 38 | ||||
-rw-r--r-- | src/identity-provider/plugin_rest_identity_provider.c | 60 |
2 files changed, 65 insertions, 33 deletions
diff --git a/src/identity-provider/gnunet-service-identity-provider.c b/src/identity-provider/gnunet-service-identity-provider.c index 59e678b24..0bb400e07 100644 --- a/src/identity-provider/gnunet-service-identity-provider.c +++ b/src/identity-provider/gnunet-service-identity-provider.c | |||
@@ -105,13 +105,12 @@ static struct GNUNET_NAMESTORE_ZoneIterator *ns_it; | |||
105 | /** | 105 | /** |
106 | * Timeout task | 106 | * Timeout task |
107 | */ | 107 | */ |
108 | static struct GNUNET_SCHEDULER_Task * timeout_task; | 108 | static struct GNUNET_SCHEDULER_Task *timeout_task; |
109 | |||
110 | 109 | ||
111 | /** | 110 | /** |
112 | * Update task | 111 | * Update task |
113 | */ | 112 | */ |
114 | static struct GNUNET_SCHEDULER_Task * update_task; | 113 | static struct GNUNET_SCHEDULER_Task *update_task; |
115 | 114 | ||
116 | /** | 115 | /** |
117 | * Timeout for next update pass | 116 | * Timeout for next update pass |
@@ -494,9 +493,11 @@ handle_token_update (void *cls) | |||
494 | scopes = NULL; | 493 | scopes = NULL; |
495 | } | 494 | } |
496 | 495 | ||
496 | |||
497 | static void | 497 | static void |
498 | update_identities(void *cls); | 498 | update_identities(void *cls); |
499 | 499 | ||
500 | |||
500 | /** | 501 | /** |
501 | * | 502 | * |
502 | * Cleanup attr_map | 503 | * Cleanup attr_map |
@@ -504,7 +505,7 @@ update_identities(void *cls); | |||
504 | * @param cls NULL | 505 | * @param cls NULL |
505 | * @param key the key | 506 | * @param key the key |
506 | * @param value the json_t attribute value | 507 | * @param value the json_t attribute value |
507 | * @return GNUNET_YES | 508 | * @return #GNUNET_YES |
508 | */ | 509 | */ |
509 | static int | 510 | static int |
510 | clear_ego_attrs (void *cls, | 511 | clear_ego_attrs (void *cls, |
@@ -530,6 +531,7 @@ clear_ego_attrs (void *cls, | |||
530 | return GNUNET_YES; | 531 | return GNUNET_YES; |
531 | } | 532 | } |
532 | 533 | ||
534 | |||
533 | /** | 535 | /** |
534 | * | 536 | * |
535 | * Update all ID_TOKEN records for an identity and store them | 537 | * Update all ID_TOKEN records for an identity and store them |
@@ -539,7 +541,6 @@ clear_ego_attrs (void *cls, | |||
539 | * @param lbl the name of the record | 541 | * @param lbl the name of the record |
540 | * @param rd_count number of records | 542 | * @param rd_count number of records |
541 | * @param rd record data | 543 | * @param rd record data |
542 | * | ||
543 | */ | 544 | */ |
544 | static void | 545 | static void |
545 | token_collect (void *cls, | 546 | token_collect (void *cls, |
@@ -579,7 +580,9 @@ token_collect (void *cls, | |||
579 | { | 580 | { |
580 | token_metadata_record = &rd[0]; | 581 | token_metadata_record = &rd[0]; |
581 | token_record = &rd[1]; | 582 | token_record = &rd[1]; |
582 | } else { | 583 | } |
584 | else | ||
585 | { | ||
583 | token_record = &rd[0]; | 586 | token_record = &rd[0]; |
584 | token_metadata_record = &rd[1]; | 587 | token_metadata_record = &rd[1]; |
585 | } | 588 | } |
@@ -607,7 +610,8 @@ token_collect (void *cls, | |||
607 | label = GNUNET_strdup (lbl); | 610 | label = GNUNET_strdup (lbl); |
608 | rd_exp = token_record->expiration_time; | 611 | rd_exp = token_record->expiration_time; |
609 | 612 | ||
610 | GNUNET_SCHEDULER_add_now (&handle_token_update, ego_entry); | 613 | GNUNET_SCHEDULER_add_now (&handle_token_update, |
614 | ego_entry); | ||
611 | } | 615 | } |
612 | 616 | ||
613 | 617 | ||
@@ -642,7 +646,8 @@ attribute_collect (void *cls, | |||
642 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 646 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
643 | ">>> Updating Attributes finished\n"); | 647 | ">>> Updating Attributes finished\n"); |
644 | ego_entry->attributes_dirty = GNUNET_NO; | 648 | ego_entry->attributes_dirty = GNUNET_NO; |
645 | update_task = GNUNET_SCHEDULER_add_now (&update_identities, ego_entry); | 649 | update_task = GNUNET_SCHEDULER_add_now (&update_identities, |
650 | ego_entry); | ||
646 | return; | 651 | return; |
647 | } | 652 | } |
648 | 653 | ||
@@ -752,7 +757,6 @@ update_identities(void *cls) | |||
752 | } | 757 | } |
753 | 758 | ||
754 | 759 | ||
755 | |||
756 | /** | 760 | /** |
757 | * Function called initially to start update task | 761 | * Function called initially to start update task |
758 | */ | 762 | */ |
@@ -761,9 +765,11 @@ init_cont () | |||
761 | { | 765 | { |
762 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, ">>> Starting Service\n"); | 766 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, ">>> Starting Service\n"); |
763 | //Initially iterate all itenties and refresh all tokens | 767 | //Initially iterate all itenties and refresh all tokens |
764 | update_task = GNUNET_SCHEDULER_add_now (&update_identities, ego_head); | 768 | update_task = GNUNET_SCHEDULER_add_now (&update_identities, |
769 | ego_head); | ||
765 | } | 770 | } |
766 | 771 | ||
772 | |||
767 | /** | 773 | /** |
768 | * Initial ego collection function. | 774 | * Initial ego collection function. |
769 | * | 775 | * |
@@ -934,6 +940,7 @@ store_token_issue_cont (void *cls, | |||
934 | struct GNUNET_IDENTITY_PROVIDER_IssueResultMessage *irm; | 940 | struct GNUNET_IDENTITY_PROVIDER_IssueResultMessage *irm; |
935 | char *ticket_str; | 941 | char *ticket_str; |
936 | char *token_str; | 942 | char *token_str; |
943 | |||
937 | handle->ns_qe = NULL; | 944 | handle->ns_qe = NULL; |
938 | if (GNUNET_SYSERR == success) | 945 | if (GNUNET_SYSERR == success) |
939 | { | 946 | { |
@@ -964,7 +971,9 @@ store_token_issue_cont (void *cls, | |||
964 | GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | 971 | GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); |
965 | return; | 972 | return; |
966 | } | 973 | } |
967 | irm = create_issue_result_message (handle->label, ticket_str, token_str); | 974 | irm = create_issue_result_message (handle->label, |
975 | ticket_str, | ||
976 | token_str); | ||
968 | GNUNET_SERVER_notification_context_unicast (nc, | 977 | GNUNET_SERVER_notification_context_unicast (nc, |
969 | handle->client, | 978 | handle->client, |
970 | &irm->header, | 979 | &irm->header, |
@@ -1528,19 +1537,16 @@ run (void *cls, | |||
1528 | token_expiration_interval = DEFAULT_TOKEN_EXPIRATION_INTERVAL; | 1537 | token_expiration_interval = DEFAULT_TOKEN_EXPIRATION_INTERVAL; |
1529 | } | 1538 | } |
1530 | 1539 | ||
1531 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 1540 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL); |
1532 | &do_shutdown, NULL); | ||
1533 | } | 1541 | } |
1534 | 1542 | ||
1535 | 1543 | ||
1536 | /** | 1544 | /** |
1537 | * | ||
1538 | * The main function | 1545 | * The main function |
1539 | * | 1546 | * |
1540 | * @param argc number of arguments from the cli | 1547 | * @param argc number of arguments from the cli |
1541 | * @param argv command line arguments | 1548 | * @param argv command line arguments |
1542 | * @return 0 ok, 1 on error | 1549 | * @return 0 ok, 1 on error |
1543 | * | ||
1544 | */ | 1550 | */ |
1545 | int | 1551 | int |
1546 | main (int argc, char *const *argv) | 1552 | main (int argc, char *const *argv) |
@@ -1551,4 +1557,4 @@ main (int argc, char *const *argv) | |||
1551 | &run, NULL)) ? 0 : 1; | 1557 | &run, NULL)) ? 0 : 1; |
1552 | } | 1558 | } |
1553 | 1559 | ||
1554 | /* end of gnunet-rest-server.c */ | 1560 | /* end of gnunet-service-identity-provider.c */ |
diff --git a/src/identity-provider/plugin_rest_identity_provider.c b/src/identity-provider/plugin_rest_identity_provider.c index b104950ba..376110a6d 100644 --- a/src/identity-provider/plugin_rest_identity_provider.c +++ b/src/identity-provider/plugin_rest_identity_provider.c | |||
@@ -248,7 +248,7 @@ struct RequestHandle | |||
248 | /** | 248 | /** |
249 | * ID of a task associated with the resolution process. | 249 | * ID of a task associated with the resolution process. |
250 | */ | 250 | */ |
251 | struct GNUNET_SCHEDULER_Task * timeout_task; | 251 | struct GNUNET_SCHEDULER_Task *timeout_task; |
252 | 252 | ||
253 | /** | 253 | /** |
254 | * The plugin result processor | 254 | * The plugin result processor |
@@ -321,9 +321,9 @@ cleanup_handle (struct RequestHandle *handle) | |||
321 | 321 | ||
322 | 322 | ||
323 | /** | 323 | /** |
324 | * Task run on shutdown. Cleans up everything. | 324 | * Task run on error, sends error message. Cleans up everything. |
325 | * | 325 | * |
326 | * @param cls unused | 326 | * @param cls the `struct RequestHandle` |
327 | */ | 327 | */ |
328 | static void | 328 | static void |
329 | do_error (void *cls) | 329 | do_error (void *cls) |
@@ -342,6 +342,21 @@ do_error (void *cls) | |||
342 | } | 342 | } |
343 | 343 | ||
344 | /** | 344 | /** |
345 | * Task run on timeout, sends error message. Cleans up everything. | ||
346 | * | ||
347 | * @param cls the `struct RequestHandle` | ||
348 | */ | ||
349 | static void | ||
350 | do_timeout (void *cls) | ||
351 | { | ||
352 | struct RequestHandle *handle = cls; | ||
353 | |||
354 | handle->timeout_task = NULL; | ||
355 | do_error (handle); | ||
356 | } | ||
357 | |||
358 | |||
359 | /** | ||
345 | * Task run on shutdown. Cleans up everything. | 360 | * Task run on shutdown. Cleans up everything. |
346 | * | 361 | * |
347 | * @param cls unused | 362 | * @param cls unused |
@@ -350,7 +365,8 @@ static void | |||
350 | do_cleanup_handle_delayed (void *cls) | 365 | do_cleanup_handle_delayed (void *cls) |
351 | { | 366 | { |
352 | struct RequestHandle *handle = cls; | 367 | struct RequestHandle *handle = cls; |
353 | cleanup_handle(handle); | 368 | |
369 | cleanup_handle (handle); | ||
354 | } | 370 | } |
355 | 371 | ||
356 | 372 | ||
@@ -406,10 +422,9 @@ token_creat_cont (void *cls, | |||
406 | handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); | 422 | handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); |
407 | GNUNET_free (result_str); | 423 | GNUNET_free (result_str); |
408 | GNUNET_SCHEDULER_add_now (&do_cleanup_handle_delayed, handle); | 424 | GNUNET_SCHEDULER_add_now (&do_cleanup_handle_delayed, handle); |
409 | |||
410 | |||
411 | } | 425 | } |
412 | 426 | ||
427 | |||
413 | /** | 428 | /** |
414 | * Continueationf for token issue request | 429 | * Continueationf for token issue request |
415 | * | 430 | * |
@@ -459,7 +474,8 @@ issue_token_cont (struct RestConnectionDataHandle *con, | |||
459 | GNUNET_CONTAINER_multihashmap_contains (handle->conndata_handle->url_param_map, | 474 | GNUNET_CONTAINER_multihashmap_contains (handle->conndata_handle->url_param_map, |
460 | &key) ) | 475 | &key) ) |
461 | { | 476 | { |
462 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Issuer not found\n"); | 477 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
478 | "Issuer not found\n"); | ||
463 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 479 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
464 | return; | 480 | return; |
465 | } | 481 | } |
@@ -468,7 +484,9 @@ issue_token_cont (struct RestConnectionDataHandle *con, | |||
468 | if (NULL == ego_val) | 484 | if (NULL == ego_val) |
469 | { | 485 | { |
470 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 486 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
471 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Ego invalid: %s\n", ego_val); | 487 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
488 | "Ego invalid: %s\n", | ||
489 | ego_val); | ||
472 | return; | 490 | return; |
473 | } | 491 | } |
474 | for (ego_entry = handle->ego_head; | 492 | for (ego_entry = handle->ego_head; |
@@ -480,13 +498,18 @@ issue_token_cont (struct RestConnectionDataHandle *con, | |||
480 | egoname = ego_entry->identifier; | 498 | egoname = ego_entry->identifier; |
481 | break; | 499 | break; |
482 | } | 500 | } |
483 | if (NULL == egoname || NULL == ego_entry) | 501 | if ( (NULL == egoname) || |
502 | (NULL == ego_entry) ) | ||
484 | { | 503 | { |
485 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Ego not found: %s\n", ego_val); | 504 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
505 | "Ego not found: %s\n", | ||
506 | ego_val); | ||
486 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 507 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
487 | return; | 508 | return; |
488 | } | 509 | } |
489 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ego to issue token for: %s\n", egoname); | 510 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
511 | "Ego to issue token for: %s\n", | ||
512 | egoname); | ||
490 | 513 | ||
491 | 514 | ||
492 | //Meta info | 515 | //Meta info |
@@ -516,13 +539,16 @@ issue_token_cont (struct RestConnectionDataHandle *con, | |||
516 | GNUNET_CONTAINER_multihashmap_contains (handle->conndata_handle->url_param_map, | 539 | GNUNET_CONTAINER_multihashmap_contains (handle->conndata_handle->url_param_map, |
517 | &key) ) | 540 | &key) ) |
518 | { | 541 | { |
519 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Audience missing!\n"); | 542 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
543 | "Audience missing!\n"); | ||
520 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 544 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
521 | return; | 545 | return; |
522 | } | 546 | } |
523 | audience = GNUNET_CONTAINER_multihashmap_get (handle->conndata_handle->url_param_map, | 547 | audience = GNUNET_CONTAINER_multihashmap_get (handle->conndata_handle->url_param_map, |
524 | &key); | 548 | &key); |
525 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Audience to issue token for: %s\n", audience); | 549 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
550 | "Audience to issue token for: %s\n", | ||
551 | audience); | ||
526 | 552 | ||
527 | priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego); | 553 | priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego); |
528 | GNUNET_IDENTITY_ego_get_public_key (ego_entry->ego, | 554 | GNUNET_IDENTITY_ego_get_public_key (ego_entry->ego, |
@@ -547,7 +573,9 @@ issue_token_cont (struct RestConnectionDataHandle *con, | |||
547 | } | 573 | } |
548 | nonce_str = GNUNET_CONTAINER_multihashmap_get (handle->conndata_handle->url_param_map, | 574 | nonce_str = GNUNET_CONTAINER_multihashmap_get (handle->conndata_handle->url_param_map, |
549 | &key); | 575 | &key); |
550 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Request nonce: %s\n", nonce_str); | 576 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
577 | "Request nonce: %s\n", | ||
578 | nonce_str); | ||
551 | sscanf (nonce_str, "%"SCNu64, &nonce); | 579 | sscanf (nonce_str, "%"SCNu64, &nonce); |
552 | 580 | ||
553 | //Get expiration for token from URL parameter | 581 | //Get expiration for token from URL parameter |
@@ -1048,10 +1076,8 @@ rest_identity_process_request(struct RestConnectionDataHandle *conndata_handle, | |||
1048 | handle); | 1076 | handle); |
1049 | handle->timeout_task = | 1077 | handle->timeout_task = |
1050 | GNUNET_SCHEDULER_add_delayed (handle->timeout, | 1078 | GNUNET_SCHEDULER_add_delayed (handle->timeout, |
1051 | &do_error, | 1079 | &do_timeout, |
1052 | handle); | 1080 | handle); |
1053 | |||
1054 | |||
1055 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1081 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1056 | "Connected\n"); | 1082 | "Connected\n"); |
1057 | } | 1083 | } |