From 61bf943d09cd43ca5fe9de1a8d329b808b0b194d Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Mon, 21 May 2018 18:10:38 +0200 Subject: [PATCH] fix crash on unexpected client disconnect on incoming message, remove bogus assertion --- src/cadet/cadet_api.c | 25 +++++++++++++----------- src/cadet/gnunet-service-cadet_channel.c | 8 ++++---- src/dht/plugin_block_dht.c | 15 +++++++++----- src/rps/test_rps.c | 2 +- src/rps/test_rps.conf | 4 ++-- 5 files changed, 31 insertions(+), 23 deletions(-) diff --git a/src/cadet/cadet_api.c b/src/cadet/cadet_api.c index 3c142a95c..59f0bfe85 100644 --- a/src/cadet/cadet_api.c +++ b/src/cadet/cadet_api.c @@ -464,6 +464,10 @@ cadet_mq_send_now (void *cls) } ch->allow_send--; ch->pending_env = NULL; + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Sending message on channel %s to CADET, new window size is %u\n", + GNUNET_i2s (&ch->peer), + ch->allow_send); GNUNET_MQ_send (ch->cadet->mq, env); GNUNET_MQ_impl_send_continue (ch->mq); @@ -781,6 +785,11 @@ handle_local_ack (void *cls, return; } ch->allow_send++; + LOG (GNUNET_ERROR_TYPE_DEBUG, + "Got an ACK on mq channel %X (peer %s); new window size is %u!\n", + ntohl (ch->ccn.channel_of_client), + GNUNET_i2s (&ch->peer), + ch->allow_send); if (NULL == ch->pending_env) { LOG (GNUNET_ERROR_TYPE_DEBUG, @@ -792,9 +801,6 @@ handle_local_ack (void *cls, } if (NULL != ch->mq_cont) return; /* already working on it! */ - LOG (GNUNET_ERROR_TYPE_DEBUG, - "Got an ACK on mq channel %X, sending pending message!\n", - ntohl (ch->ccn.channel_of_client)); ch->mq_cont = GNUNET_SCHEDULER_add_now (&cadet_mq_send_now, ch); @@ -992,6 +998,7 @@ check_get_tunnels (void *cls, { size_t esize; + (void) cls; esize = ntohs (message->size); if (sizeof (struct GNUNET_CADET_LocalInfoTunnel) == esize) return GNUNET_OK; @@ -1051,6 +1058,7 @@ check_get_tunnel (void *cls, size_t esize; size_t msize; + (void) cls; /* Verify message sanity */ msize = ntohs (msg->header.size); esize = sizeof (struct GNUNET_CADET_LocalInfoTunnel); @@ -1096,7 +1104,6 @@ handle_get_tunnel (void *cls, if (NULL == h->info_cb.tunnel_cb) return; - ch_n = ntohl (msg->channels); c_n = ntohl (msg->connections); @@ -1191,13 +1198,8 @@ destroy_channel_cb (void *cls, /* struct GNUNET_CADET_Handle *handle = cls; */ struct GNUNET_CADET_Channel *ch = value; - if (ntohl (ch->ccn.channel_of_client) >= GNUNET_CADET_LOCAL_CHANNEL_ID_CLI) - { - GNUNET_break (0); - LOG (GNUNET_ERROR_TYPE_DEBUG, - "channel %X not destroyed\n", - ntohl (ch->ccn.channel_of_client)); - } + (void) cls; + (void) cid; GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Destroying channel due to GNUNET_CADET_disconnect()\n"); destroy_channel (ch); @@ -1222,6 +1224,7 @@ destroy_port_cb (void *cls, /* struct GNUNET_CADET_Handle *handle = cls; */ struct GNUNET_CADET_Port *port = value; + (void) cls; /* This is a warning, the app should have cleanly closed all open ports */ GNUNET_break (0); GNUNET_CADET_close_port (port); diff --git a/src/cadet/gnunet-service-cadet_channel.c b/src/cadet/gnunet-service-cadet_channel.c index 7a7942dea..2d8d36c6c 100644 --- a/src/cadet/gnunet-service-cadet_channel.c +++ b/src/cadet/gnunet-service-cadet_channel.c @@ -1279,8 +1279,7 @@ GCCH_handle_channel_plaintext_data (struct CadetChannel *ch, uint32_t delta; GNUNET_assert (GNUNET_NO == ch->is_loopback); - if ( (GNUNET_YES == ch->destroy) && - (NULL == ch->owner) && + if ( (NULL == ch->owner) && (NULL == ch->dest) ) { /* This client is gone, but we still have messages to send to @@ -1290,8 +1289,9 @@ GCCH_handle_channel_plaintext_data (struct CadetChannel *ch, "Dropping incoming payload on %s as this end is already closed\n", GCCH_2s (ch)); /* send back DESTROY notification to stop further retransmissions! */ - GCT_send_channel_destroy (ch->t, - ch->ctn); + if (GNUNET_YES == ch->destroy) + GCT_send_channel_destroy (ch->t, + ch->ctn); return; } payload_size = ntohs (msg->header.size) - sizeof (*msg); diff --git a/src/dht/plugin_block_dht.c b/src/dht/plugin_block_dht.c index 24f8b21b2..9f2861b50 100644 --- a/src/dht/plugin_block_dht.c +++ b/src/dht/plugin_block_dht.c @@ -66,7 +66,8 @@ block_plugin_dht_create_group (void *cls, guard = va_arg (va, const char *); if (0 == strcmp (guard, "seen-set-size")) - bf_size = GNUNET_BLOCK_GROUP_compute_bloomfilter_size (va_arg (va, unsigned int), + bf_size = GNUNET_BLOCK_GROUP_compute_bloomfilter_size (va_arg (va, + unsigned int), BLOOMFILTER_K); else if (0 == strcmp (guard, "filter-size")) @@ -183,14 +184,17 @@ block_plugin_dht_get_key (void *cls, return GNUNET_SYSERR; if (block_size < sizeof (struct GNUNET_MessageHeader)) { - GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "block-dht", - _("Block not of type %u\n"), GNUNET_BLOCK_TYPE_DHT_HELLO); + GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, + "block-dht", + _("Block not of type %u\n"), + GNUNET_BLOCK_TYPE_DHT_HELLO); return GNUNET_NO; } msg = block; if (block_size != ntohs (msg->size)) { - GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "block-dht", + GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, + "block-dht", _("Size mismatch for block\n"), GNUNET_BLOCK_TYPE_DHT_HELLO); return GNUNET_NO; @@ -200,7 +204,8 @@ block_plugin_dht_get_key (void *cls, pid = (struct GNUNET_PeerIdentity *) key; if (GNUNET_OK != GNUNET_HELLO_get_id (hello, pid)) { - GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "block-dht", + GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, + "block-dht", _("Block of type %u is malformed\n"), GNUNET_BLOCK_TYPE_DHT_HELLO); return GNUNET_NO; diff --git a/src/rps/test_rps.c b/src/rps/test_rps.c index bae28428f..542919425 100644 --- a/src/rps/test_rps.c +++ b/src/rps/test_rps.c @@ -2782,7 +2782,7 @@ main (int argc, char *argv[]) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "This is the profiler\n"); cur_test_run.name = "test-rps-profiler"; - num_peers = 100; + num_peers = 10; mal_type = 3; cur_test_run.init_peer = profiler_init_peer; //cur_test_run.pre_test = mal_pre; diff --git a/src/rps/test_rps.conf b/src/rps/test_rps.conf index f171335d6..cf6b3150c 100644 --- a/src/rps/test_rps.conf +++ b/src/rps/test_rps.conf @@ -29,7 +29,7 @@ HOSTNAME = localhost # MAX_PARALLEL_TOPOLOGY_CONFIG_OPERATIONS = 100 OVERLAY_TOPOLOGY = CLIQUE #OVERLAY_TOPOLOGY = SMALL_WORLD -#SCALE_FREE_TOPOLOGY_CAP = +#SCALE_FREE_TOPOLOGY_CAP = # OVERLAY_RANDOM_LINKS = 25 @@ -74,6 +74,7 @@ DISABLE_TRY_CONNECT = YES [cadet] DISABLE_TRY_CONNECT = YES #OPTIONS=-l /tmp/rps_profiler_logs/cadet-[]-%Y-%m-%d.log +#PREFIX = valgrind #[arm] #GLOBAL_POSTFIX=-l /tmp/rps_profiler_logs/other-[]-%Y-%m-%d.log @@ -120,4 +121,3 @@ AUTOSTART = NO [fs] FORCESTART = NO AUTOSTART = NO - -- 2.25.1