cancel pending write if we are just dead anyway
authorChristian Grothoff <christian@grothoff.org>
Fri, 12 Mar 2010 13:29:05 +0000 (13:29 +0000)
committerChristian Grothoff <christian@grothoff.org>
Fri, 12 Mar 2010 13:29:05 +0000 (13:29 +0000)
33 files changed:
src/arm/arm_api.c
src/core/core_api.c
src/core/core_api_peer_get_info.c
src/core/core_api_peer_request.c
src/datastore/datastore_api.c
src/datastore/plugin_datastore_sqlite.c
src/dv/dv_api.c
src/fs/fs.c
src/fs/fs_download.c
src/fs/fs_list_indexed.c
src/fs/fs_publish.c
src/fs/fs_search.c
src/fs/fs_unindex.c
src/include/gnunet_client_lib.h
src/include/gnunet_connection_lib.h
src/peerinfo/peerinfo_api.c
src/statistics/statistics_api.c
src/transport/transport_api.c
src/transport/transport_api_address_lookup.c
src/transport/transport_api_blacklist.c
src/util/client.c
src/util/common_logging.c
src/util/connection.c
src/util/resolver_api.c
src/util/server.c
src/util/test_client.c
src/util/test_connection.c
src/util/test_connection_addressing.c
src/util/test_connection_receive_cancel.c
src/util/test_connection_timeout.c
src/util/test_connection_transmit_cancel.c
src/util/test_server_disconnect.c
src/util/test_server_with_client.c

index 138c95df472b3f89c54d7882a85ac46c37152144..dd48edd5b3423f9dac2bbc744bc64ab6a6cc5f04 100644 (file)
@@ -104,7 +104,7 @@ void
 GNUNET_ARM_disconnect (struct GNUNET_ARM_Handle *h)
 {
   if (h->client != NULL)
-    GNUNET_CLIENT_disconnect (h->client);
+    GNUNET_CLIENT_disconnect (h->client, GNUNET_NO);
   GNUNET_CONFIGURATION_destroy (h->cfg);
   GNUNET_free (h);
 }
@@ -274,7 +274,7 @@ handle_response (void *cls, const struct GNUNET_MessageHeader *msg)
                  ? "START"
                  : "STOP",
                  (const char*) &sc[1]);
-      GNUNET_CLIENT_disconnect (sc->h->client);
+      GNUNET_CLIENT_disconnect (sc->h->client, GNUNET_NO);
       sc->h->client = GNUNET_CLIENT_connect (sc->h->sched, 
                                             "arm", 
                                             sc->h->cfg);
index b597a74244958f70cf109071c6ad462d3a6c3b59..e03971e100599a790bac02e38dd434bd0591f2c9 100644 (file)
@@ -257,7 +257,7 @@ static void
 reconnect (struct GNUNET_CORE_Handle *h)
 {
   if (h->client_notifications != NULL)
-    GNUNET_CLIENT_disconnect (h->client_notifications);
+    GNUNET_CLIENT_disconnect (h->client_notifications, GNUNET_NO);
   h->currently_down = GNUNET_YES;
   h->client_notifications = GNUNET_CLIENT_connect (h->sched, "core", h->cfg);
   if (h->client_notifications == NULL)
@@ -793,7 +793,7 @@ GNUNET_CORE_disconnect (struct GNUNET_CORE_Handle *handle)
   if (handle->reconnect_task != GNUNET_SCHEDULER_NO_TASK)
     GNUNET_SCHEDULER_cancel (handle->sched, handle->reconnect_task);
   if (handle->client_notifications != NULL)
-    GNUNET_CLIENT_disconnect (handle->client_notifications);
+    GNUNET_CLIENT_disconnect (handle->client_notifications, GNUNET_NO);
   GNUNET_free_non_null (handle->solicit_buffer);
   GNUNET_free (handle);
 }
index c28ae2febc9c77599113f6c6188efa4be491c2f2..7ba4abecfe61f64f343b169c47a96446b1a05f3a 100644 (file)
@@ -68,7 +68,7 @@ receive_info (void *cls,
       if (irc->info != NULL)
        irc->info (irc->info_cls, 
                   NULL, zbw, zbw, 0, 0);     
-      GNUNET_CLIENT_disconnect (irc->client);
+      GNUNET_CLIENT_disconnect (irc->client, GNUNET_NO);
       GNUNET_free (irc);
       return;
     }
@@ -79,7 +79,7 @@ receive_info (void *cls,
       if (irc->info != NULL)
        irc->info (irc->info_cls, 
                   NULL, zbw, zbw, 0, 0);     
-      GNUNET_CLIENT_disconnect (irc->client);
+      GNUNET_CLIENT_disconnect (irc->client, GNUNET_NO);
       GNUNET_free (irc);
       return;
     }
@@ -91,7 +91,7 @@ receive_info (void *cls,
               cim->bw_out,
               ntohl (cim->reserved_amount),
               GNUNET_ntohll (cim->preference));  
-  GNUNET_CLIENT_disconnect (irc->client);
+  GNUNET_CLIENT_disconnect (irc->client, GNUNET_NO);
   GNUNET_free (irc);
 }
 
@@ -170,7 +170,7 @@ GNUNET_CORE_peer_change_preference (struct GNUNET_SCHEDULER_Handle *sched,
 void
 GNUNET_CORE_peer_change_preference_cancel (struct GNUNET_CORE_InformationRequestContext *irc)
 {
-  GNUNET_CLIENT_disconnect (irc->client);
+  GNUNET_CLIENT_disconnect (irc->client, GNUNET_NO);
   GNUNET_free (irc);
 }
 
index ec5fae32b68e00cbc692fd94064a0ed3f976ba6f..2ce3ac1c33dc69fb6f5b050026104acf5756b00c 100644 (file)
@@ -95,7 +95,7 @@ send_request (void *cls,
                                         prh->cont,
                                         prh->cont_cls,
                                         GNUNET_SCHEDULER_REASON_TIMEOUT);
-      GNUNET_CLIENT_disconnect (prh->client);
+      GNUNET_CLIENT_disconnect (prh->client, GNUNET_NO);
       GNUNET_free (prh);
       return 0;
     }
@@ -110,7 +110,7 @@ send_request (void *cls,
                                     prh->cont,
                                     prh->cont_cls,
                                     GNUNET_SCHEDULER_REASON_PREREQ_DONE);
-  GNUNET_CLIENT_disconnect (prh->client);
+  GNUNET_CLIENT_disconnect (prh->client, GNUNET_YES);
   GNUNET_free (prh);
   return sizeof (msg);
 }
@@ -176,7 +176,7 @@ GNUNET_CORE_peer_request_connect (struct GNUNET_SCHEDULER_Handle *sched,
 void
 GNUNET_CORE_peer_request_connect_cancel (struct GNUNET_CORE_PeerRequestHandle *req)
 {
-  GNUNET_CLIENT_disconnect (req->client);
+  GNUNET_CLIENT_disconnect (req->client, GNUNET_NO);
   GNUNET_free (req);
 }
 
index 3b7c3a2ed34337d0c99183b24aad0e790345f62b..cb70cc1f3ef726d3eecbf4ab642c1928f1e79750 100644 (file)
@@ -159,7 +159,7 @@ void GNUNET_DATASTORE_disconnect (struct GNUNET_DATASTORE_Handle *h,
       GNUNET_break (0);
     }
   if (h->client != NULL)
-    GNUNET_CLIENT_disconnect (h->client);
+    GNUNET_CLIENT_disconnect (h->client, GNUNET_NO);
   GNUNET_ARM_stop_services (h->cfg, h->sched, "datastore", NULL);
   GNUNET_free (h);
 }
@@ -188,7 +188,7 @@ with_status_response_handler (void *cls,
   if (msg == NULL)
     {
       h->response_proc = NULL;
-      GNUNET_CLIENT_disconnect (h->client);
+      GNUNET_CLIENT_disconnect (h->client, GNUNET_NO);
       h->client = GNUNET_CLIENT_connect (h->sched, "datastore", h->cfg);
       cont (h->response_proc_cls, 
            GNUNET_SYSERR,
@@ -200,7 +200,7 @@ with_status_response_handler (void *cls,
     {
       GNUNET_break (0);
       h->response_proc = NULL;
-      GNUNET_CLIENT_disconnect (h->client);
+      GNUNET_CLIENT_disconnect (h->client, GNUNET_NO);
       h->client = GNUNET_CLIENT_connect (h->sched, "datastore", h->cfg);
       cont (h->response_proc_cls, 
            GNUNET_SYSERR,
@@ -469,7 +469,7 @@ with_result_response_handler (void *cls,
   if (msg == NULL)
     {
       h->response_proc = NULL;
-      GNUNET_CLIENT_disconnect (h->client);
+      GNUNET_CLIENT_disconnect (h->client, GNUNET_NO);
       h->client = GNUNET_CLIENT_connect (h->sched, "datastore", h->cfg);
       cont (h->response_proc_cls, 
            NULL, 0, NULL, 0, 0, 0, 
@@ -493,7 +493,7 @@ with_result_response_handler (void *cls,
        (ntohs(msg->type) != GNUNET_MESSAGE_TYPE_DATASTORE_DATA) ) 
     {
       GNUNET_break (0);
-      GNUNET_CLIENT_disconnect (h->client);
+      GNUNET_CLIENT_disconnect (h->client, GNUNET_NO);
       h->client = GNUNET_CLIENT_connect (h->sched, "datastore", h->cfg);
       h->response_proc = NULL;
       cont (h->response_proc_cls, 
@@ -506,7 +506,7 @@ with_result_response_handler (void *cls,
   if (ntohs(msg->size) != msize + sizeof(struct DataMessage))
     {
       GNUNET_break (0);
-      GNUNET_CLIENT_disconnect (h->client);
+      GNUNET_CLIENT_disconnect (h->client, GNUNET_NO);
       h->client = GNUNET_CLIENT_connect (h->sched, "datastore", h->cfg);
       h->response_proc = NULL;
       cont (h->response_proc_cls, 
@@ -558,7 +558,7 @@ GNUNET_DATASTORE_get_next (struct GNUNET_DATASTORE_Handle *h,
     }
   cont = h->response_proc;
   h->response_proc = NULL;
-  GNUNET_CLIENT_disconnect (h->client);
+  GNUNET_CLIENT_disconnect (h->client, GNUNET_NO);
   h->client = GNUNET_CLIENT_connect (h->sched, "datastore", h->cfg);
   cont (h->response_proc_cls, 
        NULL, 0, NULL, 0, 0, 0, 
index 9356b79edc20eb48bfecfa765ca45243762fd23f..78b4533499d6a9eedc632d67341b5a56f705ca02 100644 (file)
@@ -131,6 +131,11 @@ struct Plugin
    * Handle for pending get request.
    */
   struct GNUNET_STATISTICS_GetHandle *stat_get;
+
+  /**
+   * Pending task with scheduler for running the next request.
+   */
+  GNUNET_SCHEDULER_TaskIdentifier next_task;
   
   /**
    * How much data are we currently storing
@@ -540,9 +545,9 @@ sqlite_next_request_cont (void *cls,
   struct GNUNET_TIME_Absolute expiration;
   const GNUNET_HashCode *key;
   const void *data;
-
+  
   plugin = nc->plugin;
+  plugin->next_task = GNUNET_SCHEDULER_NO_TASK;
   if ( (GNUNET_YES == nc->end_it) ||
        (GNUNET_OK != (nc->prep(nc->prep_cls,
                               nc))) )
@@ -668,10 +673,9 @@ sqlite_next_request (void *next_cls,
 
   if (GNUNET_YES == end_it)
     nc->end_it = GNUNET_YES;
-  GNUNET_SCHEDULER_add_continuation (nc->plugin->env->sched,
-                                    &sqlite_next_request_cont,
-                                    nc,
-                                    GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+  nc->plugin->next_task = GNUNET_SCHEDULER_add_now (nc->plugin->env->sched,
+                                                   &sqlite_next_request_cont,
+                                                   nc);
 }
 
 
@@ -1646,6 +1650,12 @@ libgnunet_plugin_datastore_sqlite_done (void *cls)
       GNUNET_STATISTICS_get_cancel (plugin->stat_get);
       plugin->stat_get = NULL;
     }
+  if (plugin->next_task != GNUNET_SCHEDULER_NO_TASK)
+    {
+      GNUNET_SCHEDULER_cancel (plugin->env->sched,
+                              plugin->next_task);
+      plugin->next_task = GNUNET_SCHEDULER_NO_TASK;
+    }
   fn = NULL;
   if (plugin->drop_on_shutdown)
     fn = GNUNET_strdup (plugin->fn);
index 54cb8720c4a252d4115ddf2c4bf37588d7e2bdc6..15ef822d690b25766dccebbea0527d26bfd2cab3 100644 (file)
@@ -384,7 +384,7 @@ void GNUNET_DV_disconnect(struct GNUNET_DV_Handle *handle)
     }
   if (handle->client != NULL) /* Finally, disconnect from the service */
     {
-      GNUNET_CLIENT_disconnect (handle->client);
+      GNUNET_CLIENT_disconnect (handle->client, GNUNET_NO);
       handle->client = NULL;
     }
 
index 8396fc18f87983e78ad6d7a61ff7d513bb61754f..2d080bfa6d53768a6d03353f9a3d7580db12dfc9 100644 (file)
@@ -97,7 +97,7 @@ GNUNET_FS_stop (struct GNUNET_FS_Handle *h)
 {
   // FIXME: serialize state!? (or is it always serialized???)
   // FIXME: terminate receive-loop with client  
-  GNUNET_CLIENT_disconnect (h->client);
+  GNUNET_CLIENT_disconnect (h->client, GNUNET_NO);
   GNUNET_free (h->client_name);
   GNUNET_free (h);
 }
index 7e5081f6e8ad092c4b4d5c8bc115d809f5b04e00..12d6ff0b6b27fe2384db819f646cfa4de598b69c 100644 (file)
@@ -394,7 +394,7 @@ process_result_with_request (void *cls,
          GNUNET_CLIENT_notify_transmit_ready_cancel (dc->th);
          dc->th = NULL;
        }
-      GNUNET_CLIENT_disconnect (dc->client);
+      GNUNET_CLIENT_disconnect (dc->client, GNUNET_NO);
       dc->client = NULL;
       return GNUNET_NO;
     }
@@ -460,7 +460,7 @@ process_result_with_request (void *cls,
              GNUNET_CLIENT_notify_transmit_ready_cancel (dc->th);
              dc->th = NULL;
            }
-         GNUNET_CLIENT_disconnect (dc->client);
+         GNUNET_CLIENT_disconnect (dc->client, GNUNET_NO);
          dc->client = NULL;
          GNUNET_free (sm);
          return GNUNET_NO;
@@ -776,7 +776,7 @@ try_reconnect (struct GNUNET_FS_DownloadContext *dc)
       GNUNET_CONTAINER_multihashmap_iterate (dc->active,
                                             &retry_entry,
                                             dc);
-      GNUNET_CLIENT_disconnect (dc->client);
+      GNUNET_CLIENT_disconnect (dc->client, GNUNET_NO);
       dc->client = NULL;
     }
   dc->task
@@ -879,7 +879,7 @@ GNUNET_FS_download_start (struct GNUNET_FS_Handle *h,
          GNUNET_CONTAINER_meta_data_destroy (dc->meta);
          GNUNET_FS_uri_destroy (dc->uri);
          GNUNET_free (dc->filename);
-         GNUNET_CLIENT_disconnect (dc->client);
+         GNUNET_CLIENT_disconnect (dc->client, GNUNET_NO);
          GNUNET_free (dc);
          return NULL;
        }
@@ -960,7 +960,7 @@ GNUNET_FS_download_stop (struct GNUNET_FS_DownloadContext *dc,
       dc->th = NULL;
     }
   if (NULL != dc->client)
-    GNUNET_CLIENT_disconnect (dc->client);
+    GNUNET_CLIENT_disconnect (dc->client, GNUNET_NO);
   GNUNET_CONTAINER_multihashmap_iterate (dc->active,
                                         &free_entry,
                                         NULL);
index d182f9aa457e1417cb87da94696be4b00a66e404..775affbc34eecc3de5a9076fe381a12862ee7c7d 100644 (file)
@@ -94,7 +94,7 @@ handle_index_info (void *cls,
                                         gic->cont,
                                         gic->cont_cls,
                                         GNUNET_SCHEDULER_REASON_TIMEOUT);
-      GNUNET_CLIENT_disconnect (gic->client);
+      GNUNET_CLIENT_disconnect (gic->client, GNUNET_NO);
       GNUNET_free (gic);
       return;
     }
@@ -105,7 +105,7 @@ handle_index_info (void *cls,
                                         gic->cont,
                                         gic->cont_cls,
                                         GNUNET_SCHEDULER_REASON_PREREQ_DONE);
-      GNUNET_CLIENT_disconnect (gic->client);
+      GNUNET_CLIENT_disconnect (gic->client, GNUNET_NO);
       GNUNET_free (gic);
       return;
     }
@@ -125,7 +125,7 @@ handle_index_info (void *cls,
                                         gic->cont,
                                         gic->cont_cls,
                                         GNUNET_SCHEDULER_REASON_TIMEOUT);
-      GNUNET_CLIENT_disconnect (gic->client);
+      GNUNET_CLIENT_disconnect (gic->client, GNUNET_NO);
       GNUNET_free (gic);
       return;
     }
@@ -138,7 +138,7 @@ handle_index_info (void *cls,
                                         gic->cont,
                                         gic->cont_cls,
                                         GNUNET_SCHEDULER_REASON_PREREQ_DONE);
-      GNUNET_CLIENT_disconnect (gic->client);
+      GNUNET_CLIENT_disconnect (gic->client, GNUNET_NO);
       GNUNET_free (gic);
       return;
     }
index df566b91765b7ce396121c7e037c6546db6c7c53..db95a610085d07582ad03fd5c3075594b7f3a29e 100644 (file)
@@ -664,7 +664,7 @@ process_index_start_response (void *cls,
   const char *emsg;
   uint16_t msize;
 
-  GNUNET_CLIENT_disconnect (sc->client);
+  GNUNET_CLIENT_disconnect (sc->client, GNUNET_NO);
   sc->client = NULL;
   p = sc->fi_pos;
   if (msg == NULL)
index 90a28052f6232472c711fefff8e2f4398892e572..8d90500516ffd75d440903843d3d68c426c0d3fa 100644 (file)
@@ -715,7 +715,7 @@ try_reconnect (struct GNUNET_FS_SearchContext *sc)
 {
   if (NULL != sc->client)
     {
-      GNUNET_CLIENT_disconnect (sc->client);
+      GNUNET_CLIENT_disconnect (sc->client, GNUNET_NO);
       sc->client = NULL;
     }
   sc->task
@@ -858,7 +858,7 @@ GNUNET_FS_search_pause (struct GNUNET_FS_SearchContext *sc)
                             sc->task);
   sc->task = GNUNET_SCHEDULER_NO_TASK;
   if (NULL != sc->client)
-    GNUNET_CLIENT_disconnect (sc->client);
+    GNUNET_CLIENT_disconnect (sc->client, GNUNET_NO);
   sc->client = NULL;
   // FIXME: make persistent!
   // FIXME: should this freeze all active probes?
@@ -967,7 +967,7 @@ GNUNET_FS_search_stop (struct GNUNET_FS_SearchContext *sc)
     GNUNET_SCHEDULER_cancel (sc->h->sched,
                             sc->task);
   if (NULL != sc->client)
-    GNUNET_CLIENT_disconnect (sc->client);
+    GNUNET_CLIENT_disconnect (sc->client, GNUNET_NO);
   GNUNET_CONTAINER_multihashmap_destroy (sc->master_result_map);
   for (i=0;i<sc->uri->data.ksk.keywordCount;i++)
     GNUNET_CONTAINER_multihashmap_destroy (sc->requests[i].results);
index fc4012464fcbcc490be806c8060b46fc20749d6b..5d1e7c8f09f617ed8a27acb3ab7c98c88970ffd2 100644 (file)
@@ -284,7 +284,7 @@ process_fs_response (void *cls,
 {
   struct GNUNET_FS_UnindexContext *uc = cls;
 
-  GNUNET_CLIENT_disconnect (uc->client);
+  GNUNET_CLIENT_disconnect (uc->client, GNUNET_NO);
   uc->client = NULL;
   if (uc->state != UNINDEX_STATE_FS_NOTIFY) 
     {
index 0b06d45d0056c88a462fbd624867f366b5745507..21487eb04d76dfa575d6b4fb65c7d00eb32df75d 100644 (file)
@@ -75,19 +75,24 @@ GNUNET_CLIENT_ignore_shutdown (struct GNUNET_CLIENT_Connection *h,
                               int do_ignore);
 
 
+
 /**
  * Destroy connection with the service.  This will automatically
  * cancel any pending "receive" request (however, the handler will
  * *NOT* be called, not even with a NULL message).  Any pending
  * transmission request will also be cancelled UNLESS the callback for
  * the transmission request has already been called, in which case the
- * transmission is guaranteed to complete before the socket is fully
- * destroyed  (unless, of course, there is an error with the server
- * in which case the message may still be lost).
+ * transmission 'finish_pending_write' argument determines whether or
+ * not the write is guaranteed to complete before the socket is fully
+ * destroyed (unless, of course, there is an error with the server in
+ * which case the message may still be lost).
  *
  * @param sock handle to the service connection
+ * @param finish_pending_write should a transmission already passed to the
+ *          handle be completed?
  */
-void GNUNET_CLIENT_disconnect (struct GNUNET_CLIENT_Connection *sock);
+void GNUNET_CLIENT_disconnect (struct GNUNET_CLIENT_Connection *sock,
+                              int finish_pending_write);
 
 /**
  * Type of a function to call when we receive a message
index 57043116557a85e613da673aa8a8ae1c297db7de..0f6ae21e35b217ffa4bcb9b3df45042eb8083a79 100644 (file)
@@ -197,15 +197,23 @@ int GNUNET_CONNECTION_get_address (struct
                                            *sock, void **addr,\r
                                            size_t * addrlen);\r
 \r
+\r
 /**\r
- * Close the socket and free associated resources.  Pending\r
- * transmissions are simply dropped.  A pending receive call will be\r
- * called with an error code of "EPIPE".\r
+ * Close the socket and free associated resources. Pending\r
+ * transmissions may be completed or dropped depending on the\r
+ * arguments.   If a receive call is pending and should \r
+ * NOT be completed, 'GNUNET_CONNECTION_receive_cancel'\r
+ * should be called explicitly first.\r
  *\r
  * @param sock socket to destroy\r
+ * @param finish_pending_write should pending writes be completed or aborted?\r
+ *        (this applies to transmissions where the data has already been\r
+ *        read from the application; all other transmissions should be\r
+ *        aborted using 'GNUNET_CONNECTION_notify_transmit_ready_cancel').\r
  */\r
-void GNUNET_CONNECTION_destroy (struct GNUNET_CONNECTION_Handle\r
-                                        *sock);\r
+void\r
+GNUNET_CONNECTION_destroy (struct GNUNET_CONNECTION_Handle *sock,\r
+                          int finish_pending_write);\r
 \r
 \r
 /**\r
index 5531ede977d8425fa3e8f000ef7b10c8d8ee0d7e..2a7c990e4a604c67c174d5b2e22a16dc0be230e5 100644 (file)
@@ -56,7 +56,7 @@ copy_and_free (void *cls, size_t size, void *buf)
                   ntohs (msg->type), "peerinfo");
 #endif
       GNUNET_free (msg);
-      GNUNET_CLIENT_disconnect (cc->client);
+      GNUNET_CLIENT_disconnect (cc->client, GNUNET_NO);
       GNUNET_free (cc);
       return 0;
     }
@@ -64,7 +64,7 @@ copy_and_free (void *cls, size_t size, void *buf)
   GNUNET_assert (size >= msize);
   memcpy (buf, msg, msize);
   GNUNET_free (msg);
-  GNUNET_CLIENT_disconnect (cc->client);
+  GNUNET_CLIENT_disconnect (cc->client, GNUNET_YES);
   GNUNET_free (cc);
   return msize;
 }
@@ -175,7 +175,7 @@ info_handler (void *cls, const struct GNUNET_MessageHeader *msg)
                   _("Failed to receive response from `%s' service.\n"),
                   "peerinfo");
       ic->callback (ic->callback_cls, NULL, NULL, 1);
-      GNUNET_CLIENT_disconnect (ic->client);
+      GNUNET_CLIENT_disconnect (ic->client, GNUNET_NO);
       GNUNET_free (ic);
       return;
     }
@@ -186,7 +186,7 @@ info_handler (void *cls, const struct GNUNET_MessageHeader *msg)
                  "Received end of list of peers from peerinfo database\n");
 #endif
       ic->callback (ic->callback_cls, NULL, NULL, 0);
-      GNUNET_CLIENT_disconnect (ic->client);
+      GNUNET_CLIENT_disconnect (ic->client, GNUNET_NO);
       GNUNET_free (ic);
       return;
     }
@@ -196,7 +196,7 @@ info_handler (void *cls, const struct GNUNET_MessageHeader *msg)
     {
       GNUNET_break (0);
       ic->callback (ic->callback_cls, NULL, NULL, 2);
-      GNUNET_CLIENT_disconnect (ic->client);
+      GNUNET_CLIENT_disconnect (ic->client, GNUNET_NO);
       GNUNET_free (ic);
       return;
     }
@@ -209,7 +209,7 @@ info_handler (void *cls, const struct GNUNET_MessageHeader *msg)
         {
           GNUNET_break (0);
           ic->callback (ic->callback_cls, NULL, NULL, 2);
-          GNUNET_CLIENT_disconnect (ic->client);
+          GNUNET_CLIENT_disconnect (ic->client, GNUNET_NO);
           GNUNET_free (ic);
           return;
         }
@@ -307,7 +307,7 @@ GNUNET_PEERINFO_iterate (const struct GNUNET_CONFIGURATION_Handle *cfg,
                                               ihc))
     {
       GNUNET_break (0);
-      GNUNET_CLIENT_disconnect (ihc->client);
+      GNUNET_CLIENT_disconnect (ihc->client, GNUNET_NO);
       GNUNET_free (ihc);
       return NULL;
     }
@@ -323,7 +323,7 @@ GNUNET_PEERINFO_iterate (const struct GNUNET_CONFIGURATION_Handle *cfg,
 void
 GNUNET_PEERINFO_iterate_cancel (struct GNUNET_PEERINFO_IteratorContext *ic)
 {
-  GNUNET_CLIENT_disconnect (ic->client);
+  GNUNET_CLIENT_disconnect (ic->client, GNUNET_NO);
   GNUNET_free (ic);
 }
 
@@ -406,7 +406,7 @@ process_notification (void *cls,
 
   if (msg == NULL)
     {
-      GNUNET_CLIENT_disconnect (nc->client);
+      GNUNET_CLIENT_disconnect (nc->client, GNUNET_NO);
       nc->client = GNUNET_CLIENT_connect (nc->sched, "peerinfo", nc->cfg);
       request_notifications (nc);
       return;
@@ -416,7 +416,7 @@ process_notification (void *cls,
       (ntohs (msg->type) != GNUNET_MESSAGE_TYPE_PEERINFO_INFO))
     {
       GNUNET_break (0);
-      GNUNET_CLIENT_disconnect (nc->client);
+      GNUNET_CLIENT_disconnect (nc->client, GNUNET_NO);
       nc->client = GNUNET_CLIENT_connect (nc->sched, "peerinfo", nc->cfg);
       request_notifications (nc);
       return;
@@ -429,7 +429,7 @@ process_notification (void *cls,
       if (ms != sizeof (struct InfoMessage) + GNUNET_HELLO_size (hello))
         {
           GNUNET_break (0);
-         GNUNET_CLIENT_disconnect (nc->client);
+         GNUNET_CLIENT_disconnect (nc->client, GNUNET_NO);
          nc->client = GNUNET_CLIENT_connect (nc->sched, "peerinfo", nc->cfg);
          request_notifications (nc);
           return;
@@ -480,7 +480,7 @@ transmit_notify_request (void *cls,
   nc->init = NULL;
   if (buf == NULL)
     {
-      GNUNET_CLIENT_disconnect (nc->client);
+      GNUNET_CLIENT_disconnect (nc->client, GNUNET_NO);
       nc->client = GNUNET_CLIENT_connect (nc->sched, "peerinfo", nc->cfg);
       request_notifications (nc);
       return 0;
@@ -564,7 +564,7 @@ GNUNET_PEERINFO_notify_cancel (struct GNUNET_PEERINFO_NotifyContext *nc)
       GNUNET_CLIENT_notify_transmit_ready_cancel (nc->init);
       nc->init = NULL;
     }
-  GNUNET_CLIENT_disconnect (nc->client);
+  GNUNET_CLIENT_disconnect (nc->client, GNUNET_NO);
   GNUNET_free (nc);
 }
 
index e9ebe7fa6114f2f7e86ac8f2cb8d0008228b5ee8..c8a341b0c8a8d6b69e4d9e8662bad0a781f48b1e 100644 (file)
@@ -304,7 +304,7 @@ receive_stats (void *cls, const struct GNUNET_MessageHeader *msg)
     {
       if (NULL != h->client)
        {
-         GNUNET_CLIENT_disconnect (h->client);
+         GNUNET_CLIENT_disconnect (h->client, GNUNET_NO);
          h->client = NULL;
        }
 #if DEBUG_STATISTICS
@@ -342,7 +342,7 @@ receive_stats (void *cls, const struct GNUNET_MessageHeader *msg)
     }
   if (NULL != h->client)
     {
-      GNUNET_CLIENT_disconnect (h->client);
+      GNUNET_CLIENT_disconnect (h->client, GNUNET_NO);
       h->client = NULL;
     }
   finish (h, GNUNET_SYSERR);
@@ -579,7 +579,7 @@ GNUNET_STATISTICS_destroy (struct GNUNET_STATISTICS_Handle *h,
     }
   if (h->client != NULL)
     {
-      GNUNET_CLIENT_disconnect (h->client);
+      GNUNET_CLIENT_disconnect (h->client, GNUNET_YES);
       h->client = NULL;
     }
   GNUNET_free (h->subsystem);
index 80eda99352dfef3b2ee5e09e1fa03ac0e87f12e4..7889cc71521829a5cf0c6d93979f637ab7d67492 100644 (file)
@@ -1363,7 +1363,7 @@ GNUNET_TRANSPORT_disconnect (struct GNUNET_TRANSPORT_Handle *handle)
                   "Disconnecting from transport service for good.\n");
 #endif
       handle->client = NULL;
-      GNUNET_CLIENT_disconnect (client);
+      GNUNET_CLIENT_disconnect (client, GNUNET_NO);
     }
   GNUNET_free (handle);
 }
@@ -1408,7 +1408,7 @@ demultiplexer (void *cls, const struct GNUNET_MessageHeader *msg)
          GNUNET_CLIENT_notify_transmit_ready_cancel (h->network_handle);
          h->network_handle = NULL;
        }
-      GNUNET_CLIENT_disconnect (h->client);
+      GNUNET_CLIENT_disconnect (h->client, GNUNET_NO);
       h->client = NULL;
       schedule_reconnect (h);
       return;
index d2bc51d471a94384e120b14de2bf755d221f8136..bf0b374429087eada82fb754d25421433ef5a164 100644 (file)
@@ -30,7 +30,7 @@ address_response_processor (void *cls, const struct GNUNET_MessageHeader *msg)
     {
       /* timeout */
       alucb->cb (alucb->cls, NULL);
-      GNUNET_CLIENT_disconnect (alucb->client);
+      GNUNET_CLIENT_disconnect (alucb->client. GNUNET_NO);
       GNUNET_free (alucb);
       return;
     }
@@ -48,7 +48,7 @@ address_response_processor (void *cls, const struct GNUNET_MessageHeader *msg)
           /* invalid reply */
           GNUNET_break_op (0);
           alucb->cb (alucb->cls, NULL);
-          GNUNET_CLIENT_disconnect (alucb->client);
+          GNUNET_CLIENT_disconnect (alucb->client, GNUNET_NO);
           GNUNET_free (alucb);
           return;
         }
@@ -65,7 +65,7 @@ address_response_processor (void *cls, const struct GNUNET_MessageHeader *msg)
   if (address == NULL)
     {
       /* done! */
-      GNUNET_CLIENT_disconnect (alucb->client);
+      GNUNET_CLIENT_disconnect (alucb->client, GNUNET_NO);
       GNUNET_free (alucb);
     }
 }
index d33c4123c87abd2b6bd90739933ff0505c0385bd..c8838f1b65f6f66e5759e60438c3b6d4f023d78e 100644 (file)
@@ -243,7 +243,7 @@ request_notifications (struct GNUNET_TRANSPORT_BlacklistNotification *bn);
 static void
 retry_get_notifications (struct GNUNET_TRANSPORT_BlacklistNotification *bn)
 {
-  GNUNET_CLIENT_disconnect (bn->client);
+  GNUNET_CLIENT_disconnect (bn->client, GNUNET_NO);
   bn->client = GNUNET_CLIENT_connect (bn->sched, "transport", bn->cfg);
   request_notifications (bn);
 }
@@ -379,7 +379,7 @@ GNUNET_TRANSPORT_blacklist_notify_cancel (struct GNUNET_TRANSPORT_BlacklistNotif
 {
   if (bn->th != NULL)
     GNUNET_CLIENT_notify_transmit_ready_cancel (bn->th);
-  GNUNET_CLIENT_disconnect (bn->client);
+  GNUNET_CLIENT_disconnect (bn->client, GNUNET_NO);
   GNUNET_free (bn);
 }
 
index 30c0fcf868680990dcb89032dacbfcb92a4ebea4..86b36bfbba10b0d3c4b2e6849858dec5c973e708 100644 (file)
@@ -350,14 +350,18 @@ GNUNET_CLIENT_ignore_shutdown (struct GNUNET_CLIENT_Connection *h,
  * *NOT* be called, not even with a NULL message).  Any pending
  * transmission request will also be cancelled UNLESS the callback for
  * the transmission request has already been called, in which case the
- * transmission is guaranteed to complete before the socket is fully
- * destroyed (unless, of course, there is an error with the server
- * in which case the message may still be lost).
+ * transmission 'finish_pending_write' argument determines whether or
+ * not the write is guaranteed to complete before the socket is fully
+ * destroyed (unless, of course, there is an error with the server in
+ * which case the message may still be lost).
  *
+ * @param finish_pending_write should a transmission already passed to the
+ *          handle be completed?
  * @param sock handle to the service connection
  */
 void
-GNUNET_CLIENT_disconnect (struct GNUNET_CLIENT_Connection *sock)
+GNUNET_CLIENT_disconnect (struct GNUNET_CLIENT_Connection *sock,
+                         int finish_pending_write)
 {
   GNUNET_assert (sock->sock != NULL);
   if (sock->in_receive == GNUNET_YES)
@@ -365,7 +369,7 @@ GNUNET_CLIENT_disconnect (struct GNUNET_CLIENT_Connection *sock)
       GNUNET_CONNECTION_receive_cancel (sock->sock);
       sock->in_receive = GNUNET_NO;
     }
-  GNUNET_CONNECTION_destroy (sock->sock);
+  GNUNET_CONNECTION_destroy (sock->sock, finish_pending_write);
   sock->sock = NULL;
   if (sock->tag != NULL)
     {
@@ -551,7 +555,7 @@ write_shutdown (void *cls, size_t size, void *buf)
   struct GNUNET_MessageHeader *msg;
   struct GNUNET_CLIENT_Connection *sock = cls;
 
-  GNUNET_CLIENT_disconnect (sock);
+  GNUNET_CLIENT_disconnect (sock, GNUNET_YES);
   if (size < sizeof (struct GNUNET_MessageHeader))
     {
       GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@@ -627,7 +631,7 @@ confirm_handler (void *cls, const struct GNUNET_MessageHeader *msg)
     {
       service_test_error (conn->sched, conn->test_cb, conn->test_cb_cls);
     }
-  GNUNET_CLIENT_disconnect (conn);
+  GNUNET_CLIENT_disconnect (conn, GNUNET_NO);
 }
 
 
@@ -710,7 +714,7 @@ GNUNET_CLIENT_service_test (struct GNUNET_SCHEDULER_Handle *sched,
                   _("Failure to transmit request to service `%s'\n"),
                   service);
       service_test_error (sched, task, task_cls);
-      GNUNET_CLIENT_disconnect (conn);
+      GNUNET_CLIENT_disconnect (conn, GNUNET_NO);
       return;
     }
 }
@@ -806,7 +810,7 @@ client_notify (void *cls, size_t size, void *buf)
           return 0;
         }
       /* auto-retry */
-      GNUNET_CONNECTION_destroy (th->sock->sock);
+      GNUNET_CONNECTION_destroy (th->sock->sock, GNUNET_NO);
       th->sock->sock = do_connect (th->sock->sched,
                                    th->sock->service_name, th->sock->cfg);
       GNUNET_assert (NULL != th->sock->sock);
index 6936558845e7aabb39a8a2056586f00a7ad05d6b..a19821511143447e5d2879a1a8f1b76c9d18e100 100644 (file)
@@ -162,6 +162,7 @@ int
 GNUNET_log_setup (const char *comp, const char *loglevel, const char *logfile)
 {
   FILE *altlog;
+  int dirwarn;
 
   GNUNET_free_non_null (component);
   GNUNET_asprintf (&component,
@@ -171,15 +172,15 @@ GNUNET_log_setup (const char *comp, const char *loglevel, const char *logfile)
   min_level = get_type (loglevel);
   if (logfile == NULL)
     return GNUNET_OK;
-  if (GNUNET_OK !=
-      GNUNET_DISK_directory_create_for_file (logfile))    
-    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-               _("Failed to create or access directory for log file `%s'"), 
-               logfile);
+  dirwarn = (GNUNET_OK !=  GNUNET_DISK_directory_create_for_file (logfile));
   altlog = FOPEN (logfile, "a");
   if (altlog == NULL)
     {
       GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "fopen", logfile);
+      if (dirwarn) 
+       GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+                   _("Failed to create or access directory for log file `%s'\n"), 
+                   logfile);
       return GNUNET_SYSERR;
     }
   if (GNUNET_stderr != NULL)
index b1e13a66385e66607be3b73b3f1fc510004f1027..c572d02de71427d09a8c089555dec50bd9aac814 100644 (file)
@@ -916,19 +916,35 @@ GNUNET_CONNECTION_check (struct GNUNET_CONNECTION_Handle *sock)
 
 /**
  * Close the socket and free associated resources. Pending
- * transmissions are simply dropped.  A pending receive call will be
- * called with an error code of "EPIPE".
+ * transmissions may be completed or dropped depending on the
+ * arguments.   If a receive call is pending and should 
+ * NOT be completed, 'GNUNET_CONNECTION_receive_cancel'
+ * should be called explicitly first.
  *
  * @param sock socket to destroy
+ * @param finish_pending_write should pending writes be completed or aborted?
+ *        (this applies to transmissions where the data has already been
+ *        read from the application; all other transmissions should be
+ *        aborted using 'GNUNET_CONNECTION_notify_transmit_ready_cancel').
  */
 void
-GNUNET_CONNECTION_destroy (struct GNUNET_CONNECTION_Handle *sock)
+GNUNET_CONNECTION_destroy (struct GNUNET_CONNECTION_Handle *sock,
+                          int finish_pending_write)
 {
   if ((sock->write_buffer_off == 0) && (sock->dns_active != NULL))
     {
       GNUNET_RESOLVER_request_cancel (sock->dns_active);
       sock->dns_active = NULL;
     }
+  if (GNUNET_NO == finish_pending_write)
+    {
+      if (sock->write_task != GNUNET_SCHEDULER_NO_TASK)
+       {
+         GNUNET_SCHEDULER_cancel (sock->sched,
+                                  sock->write_task);
+         sock->write_task = GNUNET_SCHEDULER_NO_TASK;
+       }
+    }
   GNUNET_assert (sock->sched != NULL);
   GNUNET_SCHEDULER_add_now (sock->sched,
                            &destroy_continuation, sock);
@@ -1316,6 +1332,20 @@ transmit_ready (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   GNUNET_assert (sock->write_task != GNUNET_SCHEDULER_NO_TASK);
   sock->write_task = GNUNET_SCHEDULER_NO_TASK;
   GNUNET_assert (sock->nth.timeout_task == GNUNET_SCHEDULER_NO_TASK);
+  if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) 
+    {
+      if (sock->ignore_shutdown == GNUNET_YES)
+       goto SCHEDULE_WRITE;    /* ignore shutdown, go again immediately */
+#if DEBUG_CONNECTION
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                  "Transmit to `%s' fails, shutdown happened (%p).\n",
+                  GNUNET_a2s (sock->addr, sock->addrlen), sock);
+#endif
+      notify = sock->nth.notify_ready;
+      sock->nth.notify_ready = NULL;
+      notify (sock->nth.notify_ready_cls, 0, NULL);
+      return;
+    }
   if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_TIMEOUT))
     {
 #if DEBUG_CONNECTION
index f04db13c3798773f52abee6e722ee2d5ea75fd23..ecd3789f437ba9dbf3d994af3b7ea45c497c1baf 100644 (file)
@@ -231,7 +231,7 @@ handle_address_response (void *cls, const struct GNUNET_MessageHeader *msg)
                   _("Timeout trying to resolve hostname `%s'.\n"),
                  rh->hostname);
       rh->addr_callback (rh->cls, NULL, 0);
-      GNUNET_CLIENT_disconnect (rh->client);
+      GNUNET_CLIENT_disconnect (rh->client, GNUNET_NO);
       GNUNET_free (rh);
       return;
     }
@@ -239,7 +239,7 @@ handle_address_response (void *cls, const struct GNUNET_MessageHeader *msg)
     {
       GNUNET_break (0);
       rh->addr_callback (rh->cls, NULL, 0);
-      GNUNET_CLIENT_disconnect (rh->client);
+      GNUNET_CLIENT_disconnect (rh->client, GNUNET_NO);
       GNUNET_free (rh);
       return;
     }
@@ -253,7 +253,7 @@ handle_address_response (void *cls, const struct GNUNET_MessageHeader *msg)
                  rh->hostname);
 #endif
       rh->addr_callback (rh->cls, NULL, 0);
-      GNUNET_CLIENT_disconnect (rh->client);
+      GNUNET_CLIENT_disconnect (rh->client, GNUNET_NO);
       GNUNET_free (rh);
       return;
     }
@@ -263,7 +263,7 @@ handle_address_response (void *cls, const struct GNUNET_MessageHeader *msg)
     {
       GNUNET_break (0);
       rh->addr_callback (rh->cls, NULL, 0);
-      GNUNET_CLIENT_disconnect (rh->client);
+      GNUNET_CLIENT_disconnect (rh->client, GNUNET_NO);
       GNUNET_free (rh);
       return;
     }
@@ -488,7 +488,7 @@ GNUNET_RESOLVER_ip_get (struct GNUNET_SCHEDULER_Handle *sched,
                                                &handle_address_response, rh))
     {
       GNUNET_free (rh);
-      GNUNET_CLIENT_disconnect (client);
+      GNUNET_CLIENT_disconnect (client, GNUNET_NO);
       return NULL;
     }
   return rh;
@@ -514,7 +514,7 @@ handle_hostname_response (void *cls, const struct GNUNET_MessageHeader *msg)
                   _("Timeout trying to resolve IP address `%s'.\n"),
                  GNUNET_a2s ((const void*) &rh[1], rh->salen));
       rh->name_callback (rh->cls, NULL);
-      GNUNET_CLIENT_disconnect (rh->client);
+      GNUNET_CLIENT_disconnect (rh->client, GNUNET_NO);
       GNUNET_free (rh);
       return;
     }
@@ -527,7 +527,7 @@ handle_hostname_response (void *cls, const struct GNUNET_MessageHeader *msg)
                  GNUNET_a2s ((const void*) &rh[1], rh->salen));
 #endif
       rh->name_callback (rh->cls, NULL);
-      GNUNET_CLIENT_disconnect (rh->client);
+      GNUNET_CLIENT_disconnect (rh->client, GNUNET_NO);
       GNUNET_free (rh);
       return;
     }
@@ -536,7 +536,7 @@ handle_hostname_response (void *cls, const struct GNUNET_MessageHeader *msg)
     {
       GNUNET_break (0);
       rh->name_callback (rh->cls, NULL);
-      GNUNET_CLIENT_disconnect (rh->client);
+      GNUNET_CLIENT_disconnect (rh->client, GNUNET_NO);
       GNUNET_free (rh);
       return;
     }
@@ -659,7 +659,7 @@ GNUNET_RESOLVER_hostname_get (struct GNUNET_SCHEDULER_Handle *sched,
                                                GNUNET_YES,
                                                &handle_hostname_response, rh))
     {
-      GNUNET_CLIENT_disconnect (client);
+      GNUNET_CLIENT_disconnect (client, GNUNET_NO);
       GNUNET_free (rh);
       return NULL;
     }
@@ -717,7 +717,7 @@ void
 GNUNET_RESOLVER_request_cancel (struct GNUNET_RESOLVER_RequestHandle *h)
 {
   if (h->client != NULL)
-    GNUNET_CLIENT_disconnect (h->client);
+    GNUNET_CLIENT_disconnect (h->client, GNUNET_NO);
   if (h->task != GNUNET_SCHEDULER_NO_TASK)
     GNUNET_SCHEDULER_cancel (h->sched, h->task);
   GNUNET_free (h);
index 2237911515e989d2bac223657cb5172a3ae73f1d..5fda7ae818567cd83e55500e3526259e9ca98668 100644 (file)
@@ -937,7 +937,7 @@ sock_check (void *cls)
 static void
 sock_destroy (void *cls)
 {
-  GNUNET_CONNECTION_destroy (cls);
+  GNUNET_CONNECTION_destroy (cls, GNUNET_NO);
 }
 
 
index aa8b93a826d67d86f5b9217a5ec20c6df8ffd4a4..d51424aea1129bc91e14415b54f9541bce14ca31 100644 (file)
@@ -113,7 +113,7 @@ recv_bounce (void *cls, const struct GNUNET_MessageHeader *got)
   msg.size = htons (sizeof (struct GNUNET_MessageHeader));
   GNUNET_assert (0 ==
                  memcmp (got, &msg, sizeof (struct GNUNET_MessageHeader)));
-  GNUNET_CLIENT_disconnect (client);
+  GNUNET_CLIENT_disconnect (client, GNUNET_YES);
   client = NULL;
   GNUNET_SERVER_destroy (server);
   server = NULL;
index 07b5e843dd7792fc3b5fefd1dbf1de3c176ece8e..bec3a5619380211676d949cc106a6a0ffa1d3767 100644 (file)
@@ -107,7 +107,7 @@ receive_check (void *cls,
                   "Receive closes accepted socket\n");
 #endif
       *ok = 0;
-      GNUNET_CONNECTION_destroy (asock);
+      GNUNET_CONNECTION_destroy (asock, GNUNET_YES);
     }
 }
 
@@ -125,7 +125,7 @@ run_accept (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 #if VERBOSE
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test destroys listen socket\n");
 #endif
-  GNUNET_CONNECTION_destroy (lsock);
+  GNUNET_CONNECTION_destroy (lsock, GNUNET_YES);
 #if VERBOSE
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Test asks to receive on accepted socket\n");
@@ -149,7 +149,7 @@ make_hello (void *cls, size_t size, void *buf)
 #if VERBOSE
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test destroys client socket\n");
 #endif
-  GNUNET_CONNECTION_destroy (csock);
+  GNUNET_CONNECTION_destroy (csock, GNUNET_YES);
   return 12;
 }
 
index 8f76b8e74ee81250a1f7606f5d3bb29a78d4a651..e900e2ed7b64577bc2b94d099506aabee5a6f66e 100644 (file)
@@ -102,7 +102,7 @@ receive_check (void *cls,
   else
     {
       *ok = 0;
-      GNUNET_CONNECTION_destroy (asock);
+      GNUNET_CONNECTION_destroy (asock, GNUNET_YES);
     }
 }
 
@@ -132,7 +132,7 @@ run_accept (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   expect.sin_addr.s_addr = htonl (INADDR_LOOPBACK);
   GNUNET_assert (0 == memcmp (&expect, v4, alen));
   GNUNET_free (addr);
-  GNUNET_CONNECTION_destroy (lsock);
+  GNUNET_CONNECTION_destroy (lsock, GNUNET_YES);
   GNUNET_CONNECTION_receive (asock,
                              1024,
                              GNUNET_TIME_relative_multiply
@@ -172,7 +172,7 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
                                                           12,
                                                           GNUNET_TIME_UNIT_SECONDS,
                                                           &make_hello, NULL));
-  GNUNET_CONNECTION_destroy (csock);
+  GNUNET_CONNECTION_destroy (csock, GNUNET_YES);
   GNUNET_SCHEDULER_add_read_net (tc->sched,
                                  GNUNET_TIME_UNIT_FOREVER_REL,
                                  ls, &run_accept, cls);
index 9b00bbdf7a84299d0a8eff1ced62274f6aa4a514..f3bd40438b744708dd08d920bf159e46212b05fe 100644 (file)
@@ -94,7 +94,7 @@ run_accept_cancel (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
                                                 NULL, NULL, ls, 1024);
   GNUNET_assert (asock != NULL);
   GNUNET_assert (GNUNET_YES == GNUNET_CONNECTION_check (asock));
-  GNUNET_CONNECTION_destroy (lsock);
+  GNUNET_CONNECTION_destroy (lsock, GNUNET_YES);
   GNUNET_CONNECTION_receive (asock,
                              1024,
                              GNUNET_TIME_relative_multiply
@@ -108,8 +108,8 @@ receive_cancel_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   int *ok = cls;
   GNUNET_CONNECTION_receive_cancel (asock);
-  GNUNET_CONNECTION_destroy (csock);
-  GNUNET_CONNECTION_destroy (asock);
+  GNUNET_CONNECTION_destroy (csock, GNUNET_YES);
+  GNUNET_CONNECTION_destroy (asock, GNUNET_YES);
   *ok = 0;
 }
 
index 44609fffeec11dda39ccafa57e35667fed983753..c1d9c4c4d4b36b6ff05cf6bdfd2a889ef4c464da 100644 (file)
@@ -83,8 +83,8 @@ send_kilo (void *cls, size_t size, void *buf)
 #endif
       GNUNET_assert (buf == NULL);
       *ok = 0;
-      GNUNET_CONNECTION_destroy (lsock);
-      GNUNET_CONNECTION_destroy (csock);
+      GNUNET_CONNECTION_destroy (lsock, GNUNET_YES);
+      GNUNET_CONNECTION_destroy (csock, GNUNET_YES);
       return 0;
     }
 #if VERBOSE
index afdca68b5a7a0303393d8812bc6de000bc64e95a..bb5415d61a42acc3368bd56e8fed40f9f018aa0e 100644 (file)
@@ -58,7 +58,7 @@ task_transmit_cancel (void *cls,
                                                 GNUNET_TIME_UNIT_MINUTES,
                                                 &not_run, cls);
   GNUNET_CONNECTION_notify_transmit_ready_cancel (th);
-  GNUNET_CONNECTION_destroy (csock);
+  GNUNET_CONNECTION_destroy (csock, GNUNET_YES);
   *ok = 0;
 }
 
index b10719e7397badc04defe4ee6c32685ceafc97d5..faaca968d0db0269d02f2320e6ccdab1e366e467 100644 (file)
@@ -119,7 +119,7 @@ disconnect_notify (void *cls, const struct GNUNET_MessageHeader *msg)
   GNUNET_assert (msg == NULL);
   GNUNET_assert (ok == 7);
   ok = 0;
-  GNUNET_CLIENT_disconnect (client);
+  GNUNET_CLIENT_disconnect (client, GNUNET_YES);
   client = NULL;
   GNUNET_SERVER_destroy (server);
   server = NULL;
index adce0b43272d19d8a9c15b04fb79d064eca885eb..b28b3b69f0705f0c4e82981bca9191e767194b2d 100644 (file)
@@ -93,7 +93,7 @@ recv_cb (void *cls,
       break;
     case 4:
       ok++;
-      GNUNET_CLIENT_disconnect (client);
+      GNUNET_CLIENT_disconnect (client, GNUNET_YES);
       GNUNET_SERVER_receive_done (argclient, GNUNET_OK);
       break;
     default: