From b80ca38067a55ae8588446ad47ecc7af65abefcc Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 7 Mar 2015 10:33:47 +0000 Subject: [PATCH] trying to fix #3702 by removing session from session map earlier -- and adding additional check for messages being enqueued for destroyed sessions --- .../gnunet-service-transport_neighbours.c | 20 ++++++---- src/transport/plugin_transport_udp.c | 37 +++++++++---------- 2 files changed, 29 insertions(+), 28 deletions(-) diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c index 9ce06d1b5..403eba3f6 100644 --- a/src/transport/gnunet-service-transport_neighbours.c +++ b/src/transport/gnunet-service-transport_neighbours.c @@ -1282,7 +1282,8 @@ transmit_send_continuation (void *cls, n->is_active = NULL; if (NULL != n->task) GNUNET_SCHEDULER_cancel (n->task); - n->task = GNUNET_SCHEDULER_add_now (&master_task, n); + n->task = GNUNET_SCHEDULER_add_now (&master_task, + n); } if (bytes_in_send_queue < mq->message_buf_size) { @@ -1299,14 +1300,14 @@ transmit_send_continuation (void *cls, GNUNET_break (size_payload == mq->message_buf_size); bytes_in_send_queue -= mq->message_buf_size; GNUNET_STATISTICS_set (GST_stats, - gettext_noop - ("# bytes in message queue for other peers"), - bytes_in_send_queue, GNUNET_NO); + gettext_noop ("# bytes in message queue for other peers"), + bytes_in_send_queue, + GNUNET_NO); if (GNUNET_OK == success) GNUNET_STATISTICS_update (GST_stats, - gettext_noop - ("# messages transmitted to other peers"), - 1, GNUNET_NO); + gettext_noop ("# messages transmitted to other peers"), + 1, + GNUNET_NO); else GNUNET_STATISTICS_update (GST_stats, gettext_noop @@ -1319,7 +1320,10 @@ transmit_send_continuation (void *cls, mq->message_buf_size, (success == GNUNET_OK) ? "success" : "FAILURE"); if (NULL != mq->cont) - mq->cont (mq->cont_cls, success, size_payload, physical); + mq->cont (mq->cont_cls, + success, + size_payload, + physical); GNUNET_free (mq); } diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c index c5542d200..9c9db06ae 100644 --- a/src/transport/plugin_transport_udp.c +++ b/src/transport/plugin_transport_udp.c @@ -1456,6 +1456,11 @@ enqueue (struct Plugin *plugin, { struct Session *session = udpw->session; + if (GNUNET_YES == session->in_destroy) + { + GNUNET_break (0); + return; + } if (plugin->bytes_in_buffer + udpw->msg_size > INT64_MAX) { GNUNET_break (0); @@ -2174,7 +2179,10 @@ udp_disconnect_session (void *cls, fragmented_message_done (s->frag_ctx, GNUNET_SYSERR); } - + GNUNET_assert (GNUNET_YES == + GNUNET_CONTAINER_multipeermap_remove (plugin->sessions, + &s->target, + s)); frc.rc = NULL; frc.udp_addr = s->address->address; frc.udp_addr_len = s->address->address_length; @@ -2193,6 +2201,7 @@ udp_disconnect_session (void *cls, GNUNET_free (d_ctx); } } + s->in_destroy = GNUNET_YES; next = plugin->ipv4_queue_head; while (NULL != (udpw = next)) { @@ -2221,13 +2230,6 @@ udp_disconnect_session (void *cls, GNUNET_free (udpw); } } - notify_session_monitor (s->plugin, - s, - GNUNET_TRANSPORT_SS_DONE); - plugin->env->session_end (plugin->env->cls, - s->address, - s); - if ( (NULL != s->frag_ctx) && (NULL != s->frag_ctx->cont) ) { @@ -2242,23 +2244,18 @@ udp_disconnect_session (void *cls, s->frag_ctx->payload_size, s->frag_ctx->on_wire_size); } - - GNUNET_assert (GNUNET_YES == - GNUNET_CONTAINER_multipeermap_remove (plugin->sessions, - &s->target, - s)); + notify_session_monitor (s->plugin, + s, + GNUNET_TRANSPORT_SS_DONE); + plugin->env->session_end (plugin->env->cls, + s->address, + s); GNUNET_STATISTICS_set (plugin->env->stats, "# UDP sessions active", GNUNET_CONTAINER_multipeermap_size (plugin->sessions), GNUNET_NO); - if (s->rc > 0) - { - s->in_destroy = GNUNET_YES; - } - else - { + if (0 == s->rc) free_session (s); - } return GNUNET_OK; } -- 2.25.1