diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-08-15 11:09:13 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-08-15 11:09:13 +0000 |
commit | 58c354d3adc37da2ccb7af1fbcb398f53a61a9ef (patch) | |
tree | 1f7bffa07c80fa89a8cdc58a30c682e860bf5aca /src/gns/gnunet-service-gns.c | |
parent | 3288af4a4651156c01bdf6ffe1b20c6fbedf4bd8 (diff) | |
download | gnunet-58c354d3adc37da2ccb7af1fbcb398f53a61a9ef.tar.gz gnunet-58c354d3adc37da2ccb7af1fbcb398f53a61a9ef.zip |
-handle client disconnects in GNS
Diffstat (limited to 'src/gns/gnunet-service-gns.c')
-rw-r--r-- | src/gns/gnunet-service-gns.c | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/src/gns/gnunet-service-gns.c b/src/gns/gnunet-service-gns.c index 7a6f8e277..6b4e63914 100644 --- a/src/gns/gnunet-service-gns.c +++ b/src/gns/gnunet-service-gns.c | |||
@@ -26,8 +26,6 @@ | |||
26 | * TODO: | 26 | * TODO: |
27 | * - conversion of private to public records does NOT check if the | 27 | * - conversion of private to public records does NOT check if the |
28 | * records are actually public | 28 | * records are actually public |
29 | * - need to watch for client disconnects and abort operations on | ||
30 | * disconnect | ||
31 | */ | 29 | */ |
32 | #include "platform.h" | 30 | #include "platform.h" |
33 | #include "gnunet_util_lib.h" | 31 | #include "gnunet_util_lib.h" |
@@ -550,6 +548,7 @@ handle_lookup (void *cls, | |||
550 | GNUNET_STRINGS_utf8_tolower (utf_in, &nameptr); | 548 | GNUNET_STRINGS_utf8_tolower (utf_in, &nameptr); |
551 | 549 | ||
552 | clh = GNUNET_new (struct ClientLookupHandle); | 550 | clh = GNUNET_new (struct ClientLookupHandle); |
551 | GNUNET_SERVER_client_set_user_context (client, clh); | ||
553 | GNUNET_CONTAINER_DLL_insert (clh_head, clh_tail, clh); | 552 | GNUNET_CONTAINER_DLL_insert (clh_head, clh_tail, clh); |
554 | clh->client = client; | 553 | clh->client = client; |
555 | clh->request_id = sh_msg->id; | 554 | clh->request_id = sh_msg->id; |
@@ -582,6 +581,29 @@ handle_lookup (void *cls, | |||
582 | 581 | ||
583 | 582 | ||
584 | /** | 583 | /** |
584 | * One of our clients disconnected, clean up after it. | ||
585 | * | ||
586 | * @param cls NULL | ||
587 | * @param client the client that disconnected | ||
588 | */ | ||
589 | static void | ||
590 | notify_client_disconnect (void *cls, | ||
591 | struct GNUNET_SERVER_Client *client) | ||
592 | { | ||
593 | struct ClientLookupHandle *clh; | ||
594 | |||
595 | if (NULL == client) | ||
596 | return; | ||
597 | clh = GNUNET_SERVER_client_get_user_context (client, struct ClientLookupHandle); | ||
598 | if (NULL == clh) | ||
599 | return; | ||
600 | GNS_resolver_lookup_cancel (clh->lookup); | ||
601 | GNUNET_CONTAINER_DLL_remove (clh_head, clh_tail, clh); | ||
602 | GNUNET_free (clh); | ||
603 | } | ||
604 | |||
605 | |||
606 | /** | ||
585 | * Process GNS requests. | 607 | * Process GNS requests. |
586 | * | 608 | * |
587 | * @param cls closure | 609 | * @param cls closure |
@@ -687,8 +709,10 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
687 | GNS_resolver_init (namestore_handle, dht_handle, | 709 | GNS_resolver_init (namestore_handle, dht_handle, |
688 | c, | 710 | c, |
689 | max_parallel_bg_queries); | 711 | max_parallel_bg_queries); |
690 | 712 | GNUNET_SERVER_disconnect_notify (server, | |
691 | /* Schedule periodic put for our records. */ | 713 | ¬ify_client_disconnect, |
714 | NULL); | ||
715 | /* Schedule periodic put for our records. */ | ||
692 | first_zone_iteration = GNUNET_YES; | 716 | first_zone_iteration = GNUNET_YES; |
693 | GNUNET_SERVER_add_handlers (server, handlers); | 717 | GNUNET_SERVER_add_handlers (server, handlers); |
694 | statistics = GNUNET_STATISTICS_create ("gns", c); | 718 | statistics = GNUNET_STATISTICS_create ("gns", c); |