- fix for 2192
authorMatthias Wachs <wachs@net.in.tum.de>
Mon, 5 Mar 2012 09:48:41 +0000 (09:48 +0000)
committerMatthias Wachs <wachs@net.in.tum.de>
Mon, 5 Mar 2012 09:48:41 +0000 (09:48 +0000)
src/namestore/namestore_api.c

index fa681c566ecd8363ba830f9ceffa63d8bebad7d9..e4dae859bfd3b61159eddeda1cd35bfeb4850b47 100644 (file)
@@ -834,16 +834,26 @@ GNUNET_NAMESTORE_disconnect (struct GNUNET_NAMESTORE_Handle *h, int drop)
   if (h->th != NULL)
   {
     GNUNET_CLIENT_notify_transmit_ready_cancel(h->th);
+    h->th = NULL;
   }
+  if (h->client != NULL)
+  {
+    struct DisconnectContext *d_ctx = GNUNET_malloc (sizeof (struct DisconnectContext));
+    d_ctx->h = h;
+    d_ctx->drop = drop;
 
-  struct DisconnectContext *d_ctx = GNUNET_malloc (sizeof (struct DisconnectContext));
-  d_ctx->h = h;
-  d_ctx->drop = drop;
-
-  h->th = GNUNET_CLIENT_notify_transmit_ready (h->client, sizeof (struct DisconnectMessage),
+    h->th = GNUNET_CLIENT_notify_transmit_ready (h->client, sizeof (struct DisconnectMessage),
                                            GNUNET_TIME_UNIT_FOREVER_REL,
                                            GNUNET_NO, &transmit_disconnect_to_namestore,
                                            d_ctx);
+  }
+  else
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Could not send disconnect notification to namestore service, we are not connected!\n");
+    if (GNUNET_YES == drop)
+      GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "NAMESTORE will not drop content\n");
+    GNUNET_SCHEDULER_add_now (&clean_up_task, h);
+  }
 }