gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r28648 - gnunet/src/gns


From: gnunet
Subject: [GNUnet-SVN] r28648 - gnunet/src/gns
Date: Thu, 15 Aug 2013 13:09:13 +0200

Author: grothoff
Date: 2013-08-15 13:09:13 +0200 (Thu, 15 Aug 2013)
New Revision: 28648

Modified:
   gnunet/src/gns/gnunet-service-gns.c
Log:
-handle client disconnects in GNS

Modified: gnunet/src/gns/gnunet-service-gns.c
===================================================================
--- gnunet/src/gns/gnunet-service-gns.c 2013-08-15 10:52:06 UTC (rev 28647)
+++ gnunet/src/gns/gnunet-service-gns.c 2013-08-15 11:09:13 UTC (rev 28648)
@@ -26,8 +26,6 @@
  * TODO:
  * - conversion of private to public records does NOT check if the
  *   records are actually public 
- * - need to watch for client disconnects and abort operations on
- *   disconnect
  */
 #include "platform.h"
 #include "gnunet_util_lib.h"
@@ -550,6 +548,7 @@
   GNUNET_STRINGS_utf8_tolower (utf_in, &nameptr);
   
   clh = GNUNET_new (struct ClientLookupHandle);
+  GNUNET_SERVER_client_set_user_context (client, clh);
   GNUNET_CONTAINER_DLL_insert (clh_head, clh_tail, clh);
   clh->client = client;
   clh->request_id = sh_msg->id;
@@ -582,6 +581,29 @@
 
 
 /**
+ * One of our clients disconnected, clean up after it.
+ *
+ * @param cls NULL
+ * @param client the client that disconnected
+ */
+static void
+notify_client_disconnect (void *cls,
+                         struct GNUNET_SERVER_Client *client)
+{
+  struct ClientLookupHandle *clh;
+
+  if (NULL == client)
+    return;
+  clh = GNUNET_SERVER_client_get_user_context (client, struct 
ClientLookupHandle);
+  if (NULL == clh)
+    return;
+  GNS_resolver_lookup_cancel (clh->lookup);
+  GNUNET_CONTAINER_DLL_remove (clh_head, clh_tail, clh);
+  GNUNET_free (clh);
+}
+
+
+/**
  * Process GNS requests.
  *
  * @param cls closure
@@ -687,8 +709,10 @@
   GNS_resolver_init (namestore_handle, dht_handle, 
                     c,
                     max_parallel_bg_queries);
-  
-  /* Schedule periodic put for our records. */  
+  GNUNET_SERVER_disconnect_notify (server,
+                                  &notify_client_disconnect,
+                                  NULL);
+  /* Schedule periodic put for our records. */    
   first_zone_iteration = GNUNET_YES;
   GNUNET_SERVER_add_handlers (server, handlers);
   statistics = GNUNET_STATISTICS_create ("gns", c);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]