gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r24225 - gnunet/src/util


From: gnunet
Subject: [GNUnet-SVN] r24225 - gnunet/src/util
Date: Mon, 8 Oct 2012 15:30:02 +0200

Author: grothoff
Date: 2012-10-08 15:30:01 +0200 (Mon, 08 Oct 2012)
New Revision: 24225

Modified:
   gnunet/src/util/connection.c
Log:
-trying to fix #2572

Modified: gnunet/src/util/connection.c
===================================================================
--- gnunet/src/util/connection.c        2012-10-08 13:28:11 UTC (rev 24224)
+++ gnunet/src/util/connection.c        2012-10-08 13:30:01 UTC (rev 24225)
@@ -247,8 +247,15 @@
    * termination as a signal (because only then will the leaked
    * socket be freed!)
    */
-  int16_t persist;
+  int8_t persist;
 
+  /**
+   * Usually 0.  Set to 1 if this handle is in used and should
+   * 'GNUNET_CONNECTION_destroy' be called right now, the action needs
+   * to be deferred by setting it to -1.
+   */
+  int8_t destroy_later;
+
 };
 
 
@@ -556,6 +563,7 @@
   GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == connection->write_task);
 
   /* signal errors for jobs that used to wait on the connection */
+  connection->destroy_later = 1;
   if (NULL != connection->receiver)
     signal_receive_error (connection, ECONNREFUSED);
   if (NULL != connection->nth.notify_ready)
@@ -565,6 +573,14 @@
     connection->nth.timeout_task = GNUNET_SCHEDULER_NO_TASK;
     signal_transmit_error (connection, ECONNREFUSED);
   }
+  if (-1 == connection->destroy_later)
+  {
+    /* do it now */
+    connection->destroy_later = 0;
+    GNUNET_CONNECTION_destroy (connection);
+    return;
+  }
+  connection->destroy_later = 0;
 }
 
 
@@ -937,6 +953,11 @@
 {
   struct AddressProbe *pos;
 
+  if (0 != connection->destroy_later)
+  {
+    connection->destroy_later = -1;
+    return;
+  }
   LOG (GNUNET_ERROR_TYPE_DEBUG, "Shutting down connection (%p)\n", connection);
   GNUNET_assert (NULL == connection->nth.notify_ready);
   GNUNET_assert (NULL == connection->receiver);




reply via email to

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