diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-10-08 13:30:01 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-10-08 13:30:01 +0000 |
commit | 71db17488a21f8e45c8a1aa932e7edb983ff2a70 (patch) | |
tree | c2b58ac44cbc54865401570b0a9f63e2ce9f848e /src/util/connection.c | |
parent | 4fc3b5b308c49be68aff6cf99b4f6033ee680137 (diff) | |
download | gnunet-71db17488a21f8e45c8a1aa932e7edb983ff2a70.tar.gz gnunet-71db17488a21f8e45c8a1aa932e7edb983ff2a70.zip |
-trying to fix #2572
Diffstat (limited to 'src/util/connection.c')
-rw-r--r-- | src/util/connection.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/util/connection.c b/src/util/connection.c index 0d31e7f56..d7ae12fb3 100644 --- a/src/util/connection.c +++ b/src/util/connection.c | |||
@@ -247,7 +247,14 @@ struct GNUNET_CONNECTION_Handle | |||
247 | * termination as a signal (because only then will the leaked | 247 | * termination as a signal (because only then will the leaked |
248 | * socket be freed!) | 248 | * socket be freed!) |
249 | */ | 249 | */ |
250 | int16_t persist; | 250 | int8_t persist; |
251 | |||
252 | /** | ||
253 | * Usually 0. Set to 1 if this handle is in used and should | ||
254 | * 'GNUNET_CONNECTION_destroy' be called right now, the action needs | ||
255 | * to be deferred by setting it to -1. | ||
256 | */ | ||
257 | int8_t destroy_later; | ||
251 | 258 | ||
252 | }; | 259 | }; |
253 | 260 | ||
@@ -556,6 +563,7 @@ connect_fail_continuation (struct GNUNET_CONNECTION_Handle *connection) | |||
556 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == connection->write_task); | 563 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == connection->write_task); |
557 | 564 | ||
558 | /* signal errors for jobs that used to wait on the connection */ | 565 | /* signal errors for jobs that used to wait on the connection */ |
566 | connection->destroy_later = 1; | ||
559 | if (NULL != connection->receiver) | 567 | if (NULL != connection->receiver) |
560 | signal_receive_error (connection, ECONNREFUSED); | 568 | signal_receive_error (connection, ECONNREFUSED); |
561 | if (NULL != connection->nth.notify_ready) | 569 | if (NULL != connection->nth.notify_ready) |
@@ -565,6 +573,14 @@ connect_fail_continuation (struct GNUNET_CONNECTION_Handle *connection) | |||
565 | connection->nth.timeout_task = GNUNET_SCHEDULER_NO_TASK; | 573 | connection->nth.timeout_task = GNUNET_SCHEDULER_NO_TASK; |
566 | signal_transmit_error (connection, ECONNREFUSED); | 574 | signal_transmit_error (connection, ECONNREFUSED); |
567 | } | 575 | } |
576 | if (-1 == connection->destroy_later) | ||
577 | { | ||
578 | /* do it now */ | ||
579 | connection->destroy_later = 0; | ||
580 | GNUNET_CONNECTION_destroy (connection); | ||
581 | return; | ||
582 | } | ||
583 | connection->destroy_later = 0; | ||
568 | } | 584 | } |
569 | 585 | ||
570 | 586 | ||
@@ -937,6 +953,11 @@ GNUNET_CONNECTION_destroy (struct GNUNET_CONNECTION_Handle *connection) | |||
937 | { | 953 | { |
938 | struct AddressProbe *pos; | 954 | struct AddressProbe *pos; |
939 | 955 | ||
956 | if (0 != connection->destroy_later) | ||
957 | { | ||
958 | connection->destroy_later = -1; | ||
959 | return; | ||
960 | } | ||
940 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Shutting down connection (%p)\n", connection); | 961 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Shutting down connection (%p)\n", connection); |
941 | GNUNET_assert (NULL == connection->nth.notify_ready); | 962 | GNUNET_assert (NULL == connection->nth.notify_ready); |
942 | GNUNET_assert (NULL == connection->receiver); | 963 | GNUNET_assert (NULL == connection->receiver); |