From 42dc7e7b6cf4519e772a3d0a8a35fbf6cec97a4f Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 29 Oct 2017 11:23:15 +0100 Subject: fix wrong condition, do only drop if it has not been dropped, instead of causing double-drop --- src/util/service.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/util/service.c b/src/util/service.c index 10dc93faf..782adf5c5 100644 --- a/src/util/service.c +++ b/src/util/service.c @@ -2402,7 +2402,7 @@ resume_client_receive (void *cls) GNUNET_YES); if (GNUNET_SYSERR == ret) { - if (NULL != c->drop_task) + if (NULL == c->drop_task) GNUNET_SERVICE_client_drop (c); return; } @@ -2514,6 +2514,10 @@ GNUNET_SERVICE_client_drop (struct GNUNET_SERVICE_Client *c) { struct GNUNET_SERVICE_Handle *sh = c->sh; + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Client dropped: %p (MQ: %p)\n", + c, + c->mq); if (NULL != c->drop_task) { /* asked to drop twice! */ -- cgit v1.2.3 From 059e364e55a1a3dda010762e0f029753abcbb1c6 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 29 Oct 2017 11:23:34 +0100 Subject: clarify use of client_drop --- src/include/gnunet_service_lib.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/include/gnunet_service_lib.h b/src/include/gnunet_service_lib.h index aacafe956..dda827c95 100644 --- a/src/include/gnunet_service_lib.h +++ b/src/include/gnunet_service_lib.h @@ -366,11 +366,16 @@ GNUNET_SERVICE_client_disable_continue_warning (struct GNUNET_SERVICE_Client *c) /** * Ask the server to disconnect from the given client. This is the * same as returning #GNUNET_SYSERR within the check procedure when - * handling a message, wexcept that it allows dropping of a client even + * handling a message, except that it allows dropping of a client even * when not handling a message from that client. The `disconnect_cb` * will be called on @a c even if the application closes the connection * using this function. * + * This function should be called (outside of util's internal logic) + * if (and usually only if) the client has violated the + * protocol. Otherwise, we should leave it to the client to disconnect + * from the service. + * * @param c client to disconnect now */ void -- cgit v1.2.3 From da376896f525195c469cee2d1a4a5cb57ad6b6f8 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 29 Oct 2017 11:24:22 +0100 Subject: handle service disconnect without crashing if reconnect fails --- src/psyc/psyc_api.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/psyc/psyc_api.c b/src/psyc/psyc_api.c index c93d8b383..e7790d201 100644 --- a/src/psyc/psyc_api.c +++ b/src/psyc/psyc_api.c @@ -931,7 +931,8 @@ slave_reconnect (void *cls) * Reconnect after backoff period. */ static void -slave_disconnected (void *cls, enum GNUNET_MQ_Error error) +slave_disconnected (void *cls, + enum GNUNET_MQ_Error error) { struct GNUNET_PSYC_Slave *slv = cls; struct GNUNET_PSYC_Channel *chn = &slv->chn; @@ -950,7 +951,7 @@ slave_disconnected (void *cls, enum GNUNET_MQ_Error error) chn->mq = NULL; } chn->reconnect_task = GNUNET_SCHEDULER_add_delayed (chn->reconnect_delay, - slave_reconnect, + &slave_reconnect, slv); chn->reconnect_delay = GNUNET_TIME_STD_BACKOFF (chn->reconnect_delay); } @@ -993,9 +994,19 @@ slave_connect (struct GNUNET_PSYC_Slave *slv) GNUNET_MQ_handler_end () }; - chn->mq = GNUNET_CLIENT_connect (chn->cfg, "psyc", - handlers, slave_disconnected, slv); - GNUNET_assert (NULL != chn->mq); + chn->mq = GNUNET_CLIENT_connect (chn->cfg, + "psyc", + handlers, + &slave_disconnected, + slv); + if (NULL == chn->mq) + { + chn->reconnect_task = GNUNET_SCHEDULER_add_delayed (chn->reconnect_delay, + &slave_reconnect, + slv); + chn->reconnect_delay = GNUNET_TIME_STD_BACKOFF (chn->reconnect_delay); + return; + } chn->tmit = GNUNET_PSYC_transmit_create (chn->mq); GNUNET_MQ_send_copy (chn->mq, chn->connect_env); -- cgit v1.2.3 From e1e838cdb804ed54aedccf5fce030ecc066028cd Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 29 Oct 2017 11:24:52 +0100 Subject: better logging of message processing errors in mq handling --- src/util/mq.c | 15 ++++++++++++--- src/util/mst.c | 18 +++++++++++++++--- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/util/mq.c b/src/util/mq.c index c7ed5330e..6ad6b82eb 100644 --- a/src/util/mq.c +++ b/src/util/mq.c @@ -221,8 +221,10 @@ GNUNET_MQ_inject_message (struct GNUNET_MQ_Handle *mq, uint16_t mtype = ntohs (mh->type); LOG (GNUNET_ERROR_TYPE_DEBUG, - "Received message of type %u and size %u\n", - mtype, msize); + "Queue %p received message of type %u and size %u\n", + mq, + mtype, + msize); if (NULL == mq->handlers) goto done; @@ -359,7 +361,8 @@ GNUNET_MQ_send (struct GNUNET_MQ_Handle *mq, mq->current_envelope = ev; GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "mq: sending message of type %u, queue empty\n", ntohs(ev->mh->type)); + "mq: sending message of type %u, queue empty\n", + ntohs(ev->mh->type)); mq->send_impl (mq, ev->mh, @@ -848,6 +851,9 @@ GNUNET_MQ_destroy (struct GNUNET_MQ_Handle *mq) ev); GNUNET_assert (0 < mq->queue_length); mq->queue_length--; + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "MQ destroy drops message of type %u\n", + ntohs (ev->mh->type)); GNUNET_MQ_discard (ev); } if (NULL != mq->current_envelope) @@ -855,6 +861,9 @@ GNUNET_MQ_destroy (struct GNUNET_MQ_Handle *mq) /* we can only discard envelopes that * are not queued! */ mq->current_envelope->parent_queue = NULL; + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "MQ destroy drops message of type %u\n", + ntohs (mq->current_envelope->mh->type)); GNUNET_MQ_discard (mq->current_envelope); mq->current_envelope = NULL; GNUNET_assert (0 < mq->queue_length); diff --git a/src/util/mst.c b/src/util/mst.c index 0d90c5d10..4c2a74212 100644 --- a/src/util/mst.c +++ b/src/util/mst.c @@ -1,6 +1,6 @@ /* This file is part of GNUnet. - Copyright (C) 2010, 2016 GNUnet e.V. + Copyright (C) 2010, 2016, 2017 GNUnet e.V. GNUnet is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published @@ -229,9 +229,15 @@ do_align: if (one_shot == GNUNET_YES) one_shot = GNUNET_SYSERR; mst->off += want; - if (GNUNET_SYSERR == mst->cb (mst->cb_cls, - hdr)) + if (GNUNET_SYSERR == mst->cb (mst->cb_cls, + hdr)) + { + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + "Failure processing message of type %u and size %u\n", + ntohs (hdr->type), + ntohs (hdr->size)); return GNUNET_SYSERR; + } if (mst->off == mst->pos) { /* reset to beginning of buffer, it's free right now! */ @@ -273,7 +279,13 @@ do_align: one_shot = GNUNET_SYSERR; if (GNUNET_SYSERR == mst->cb (mst->cb_cls, hdr)) + { + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + "Failure processing message of type %u and size %u\n", + ntohs (hdr->type), + ntohs (hdr->size)); return GNUNET_SYSERR; + } buf += want; size -= want; } -- cgit v1.2.3 From cfd5e9d749ae8d9d07ef77943a9b560b491468fc Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 29 Oct 2017 11:25:20 +0100 Subject: do handle CTRL-C properly in test_social --- src/social/test_social.c | 91 +++++++++++++++++++++++++++++++----------------- 1 file changed, 59 insertions(+), 32 deletions(-) diff --git a/src/social/test_social.c b/src/social/test_social.c index 8d49e7413..de2299320 100644 --- a/src/social/test_social.c +++ b/src/social/test_social.c @@ -180,10 +180,28 @@ host_announce2 (); /** - * Clean up all resources used. + * Terminate the test case (failure). + * + * @param cls NULL */ static void -cleanup () +end_badly (void *cls) +{ + end_badly_task = NULL; + GNUNET_SCHEDULER_shutdown (); + res = 2; + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Test FAILED.\n"); +} + + +/** + * Terminate the test case (failure). + * + * @param cls NULL + */ +static void +end_shutdown (void *cls) { if (NULL != id) { @@ -202,7 +220,11 @@ cleanup () GNUNET_PSYC_slicer_destroy (host_slicer); host_slicer = NULL; } - + if (NULL != end_badly_task) + { + GNUNET_SCHEDULER_cancel (end_badly_task); + end_badly_task = NULL; + } if (NULL != gst) { GNUNET_SOCIAL_guest_leave (gst, NULL, NULL, NULL); @@ -216,21 +238,6 @@ cleanup () hst_plc = NULL; } GNUNET_SOCIAL_app_disconnect (app, NULL, NULL); - GNUNET_SCHEDULER_shutdown (); -} - - -/** - * Terminate the test case (failure). - * - * @param cls NULL - */ -static void -end_badly (void *cls) -{ - res = 1; - cleanup (); - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Test FAILED.\n"); } @@ -242,8 +249,8 @@ end_badly (void *cls) static void end_normally (void *cls) { + GNUNET_SCHEDULER_shutdown (); res = 0; - cleanup (); GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, "Test PASSED.\n"); } @@ -372,6 +379,7 @@ host_reconnected (void *cls, int result, is_host_reconnected = GNUNET_YES; if (GNUNET_YES == is_guest_reconnected) { + GNUNET_assert (NULL != gst); GNUNET_SCHEDULER_add_now (&schedule_guest_leave, NULL); } } @@ -390,6 +398,7 @@ guest_reconnected (void *cls, int result, is_guest_reconnected = GNUNET_YES; if (GNUNET_YES == is_host_reconnected) { + GNUNET_assert (NULL != gst); GNUNET_SCHEDULER_add_now (&schedule_guest_leave, NULL); } } @@ -411,11 +420,15 @@ app_recv_host (void *cls, enum GNUNET_SOCIAL_AppPlaceState place_state) { struct GNUNET_HashCode host_pub_hash; - GNUNET_CRYPTO_hash (host_pub_key, sizeof (*host_pub_key), &host_pub_hash); + + GNUNET_CRYPTO_hash (host_pub_key, + sizeof (*host_pub_key), + &host_pub_hash); GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, "Test #%u: Got app host place notification: %s\n", - test, GNUNET_h2s (&host_pub_hash)); + test, + GNUNET_h2s (&host_pub_hash)); if (test == TEST_RECONNECT) { @@ -424,8 +437,11 @@ app_recv_host (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, "Test #%u: Reconnecting to host place: %s\n", test, GNUNET_h2s (&host_pub_hash)); - hst = GNUNET_SOCIAL_host_enter_reconnect (hconn, host_slicer, host_reconnected, - host_answer_door, host_farewell2, NULL); + hst = GNUNET_SOCIAL_host_enter_reconnect (hconn, host_slicer, + &host_reconnected, + &host_answer_door, + &host_farewell2, + NULL); } } } @@ -439,7 +455,10 @@ app_recv_guest (void *cls, enum GNUNET_SOCIAL_AppPlaceState place_state) { struct GNUNET_HashCode guest_pub_hash; - GNUNET_CRYPTO_hash (guest_pub_key, sizeof (*guest_pub_key), &guest_pub_hash); + + GNUNET_CRYPTO_hash (guest_pub_key, + sizeof (*guest_pub_key), + &guest_pub_hash); GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, "Test #%u: Got app guest place notification: %s\n", @@ -447,13 +466,19 @@ app_recv_guest (void *cls, if (test == TEST_RECONNECT) { - if (0 == memcmp (&place_pub_key, guest_pub_key, sizeof (*guest_pub_key))) + if (0 == memcmp (&place_pub_key, + guest_pub_key, + sizeof (*guest_pub_key))) { GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, "Test #%u: Reconnecting to guest place: %s\n", test, GNUNET_h2s (&guest_pub_hash)); - gst = GNUNET_SOCIAL_guest_enter_reconnect (gconn, GNUNET_PSYC_SLAVE_JOIN_NONE, - guest_slicer, guest_reconnected, NULL); + gst = GNUNET_SOCIAL_guest_enter_reconnect (gconn, + GNUNET_PSYC_SLAVE_JOIN_NONE, + guest_slicer, + &guest_reconnected, + NULL); + GNUNET_assert (NULL != gst); } } } @@ -527,10 +552,10 @@ schedule_reconnect (void *cls) GNUNET_SOCIAL_app_disconnect (app, NULL, NULL); app = GNUNET_SOCIAL_app_connect (cfg, app_id, - app_recv_ego, - app_recv_host, - app_recv_guest, - app_connected, + &app_recv_ego, + &app_recv_host, + &app_recv_guest, + &app_connected, NULL); } @@ -1387,9 +1412,11 @@ run (void *cls, #endif { cfg = c; + res = 1; end_badly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); - + GNUNET_SCHEDULER_add_shutdown (&end_shutdown, + NULL); GNUNET_CRYPTO_get_peer_identity (cfg, &this_peer); id = GNUNET_IDENTITY_connect (cfg, &identity_ego_cb, NULL); -- cgit v1.2.3 From ca78392674d82d97832798f933b9c75f4e0af367 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 29 Oct 2017 11:27:32 +0100 Subject: logging, cosmetic fixes --- src/social/gnunet-service-social.c | 34 +++++++++++++++++----------------- src/social/social_api.c | 3 +++ src/social/test_social.conf | 3 +++ 3 files changed, 23 insertions(+), 17 deletions(-) diff --git a/src/social/gnunet-service-social.c b/src/social/gnunet-service-social.c index f9e70a25d..04bbba192 100644 --- a/src/social/gnunet-service-social.c +++ b/src/social/gnunet-service-social.c @@ -570,7 +570,6 @@ client_notify_disconnect (void *cls, if (NULL != c->app_id) GNUNET_free (c->app_id); - GNUNET_free (c); if (NULL == plc) @@ -586,7 +585,9 @@ client_notify_disconnect (void *cls, { if (cli->client == client) { - GNUNET_CONTAINER_DLL_remove (plc->clients_head, plc->clients_tail, cli); + GNUNET_CONTAINER_DLL_remove (plc->clients_head, + plc->clients_tail, + cli); GNUNET_free (cli); break; } @@ -608,11 +609,13 @@ client_notify_connect (void *cls, struct GNUNET_SERVICE_Client *client, struct GNUNET_MQ_Handle *mq) { - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client connected: %p\n", client); + struct Client *c = GNUNET_new (struct Client); - struct Client *c = GNUNET_malloc (sizeof (*c)); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Client %p connected with queue %p\n", + client, + mq); c->client = client; - return c; } @@ -2204,7 +2207,7 @@ handle_client_app_detach (void *cls, } -int +static int app_places_entry_remove (void *cls, const struct GNUNET_HashCode *key, void *value) { struct Place *plc = cls; @@ -2247,15 +2250,14 @@ handle_client_place_leave (void *cls, /* FIXME: disconnect from the network, but keep local connection for history access */ /* Disconnect all clients connected to the place */ - struct ClientListItem *cli = plc->clients_head, *next; - while (NULL != cli) + + for (struct ClientListItem *cli = plc->clients_head; + NULL != cli; + cli = cli->next) { - GNUNET_CONTAINER_DLL_remove (plc->clients_head, plc->clients_tail, cli); // protocol design failure: should *tell* clients that room is gone! - GNUNET_SERVICE_client_drop (cli->client); - next = cli->next; - GNUNET_free (cli); - cli = next; + if (client != cli->client) + GNUNET_SERVICE_client_drop (cli->client); } if (GNUNET_YES != plc->is_disconnected) @@ -2268,10 +2270,11 @@ handle_client_place_leave (void *cls, else { cleanup_place (plc); + c->place = NULL; } } // FIXME: can't continue+drop above, but should not drop above! - // GNUNET_SERVICE_client_continue (client); + GNUNET_SERVICE_client_continue (client); } @@ -2989,7 +2992,6 @@ handle_client_psyc_message (void *cls, "%p Received message with invalid payload size (%u) from client.\n", plc, psize); GNUNET_break (0); - psyc_transmit_cancel (plc, client); GNUNET_SERVICE_client_drop (client); return; } @@ -3003,7 +3005,6 @@ handle_client_psyc_message (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%p Received invalid message part from client.\n", plc); GNUNET_break (0); - psyc_transmit_cancel (plc, client); GNUNET_SERVICE_client_drop (client); return; } @@ -3029,7 +3030,6 @@ handle_client_psyc_message (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%p Received invalid message part from client.\n", plc); GNUNET_break (0); - psyc_transmit_cancel (plc, client); ret = GNUNET_SYSERR; } diff --git a/src/social/social_api.c b/src/social/social_api.c index fc649fcde..1db8e501a 100644 --- a/src/social/social_api.c +++ b/src/social/social_api.c @@ -1044,6 +1044,7 @@ static void place_cleanup (struct GNUNET_SOCIAL_Place *plc) { struct GNUNET_HashCode place_pub_hash; + GNUNET_CRYPTO_hash (&plc->pub_key, sizeof (plc->pub_key), &place_pub_hash); GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "%s place cleanup: %s\n", @@ -2092,6 +2093,8 @@ leave_done_cont (void *cls) { struct LeaveContext *lc = cls; + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + "social_api: guest's place_leave message sent!\n"); GNUNET_SOCIAL_guest_disconnect (lc->gst, lc->disconnect_cb, lc->disconnect_cb_cls); diff --git a/src/social/test_social.conf b/src/social/test_social.conf index 52ed20c6b..a11144b60 100644 --- a/src/social/test_social.conf +++ b/src/social/test_social.conf @@ -3,3 +3,6 @@ [social] AUTOSTART = YES FORCESTART = YES + +[transport] +PLUGINS = udp -- cgit v1.2.3 From d10108c802b56535b03597e9fbb7603b0eeef9c0 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 29 Oct 2017 12:16:51 +0100 Subject: minor style fix --- src/util/scheduler.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/util/scheduler.c b/src/util/scheduler.c index a7b1d8e2a..b07c51811 100644 --- a/src/util/scheduler.c +++ b/src/util/scheduler.c @@ -73,7 +73,7 @@ * Argument to be passed from the driver to * #GNUNET_SCHEDULER_run_from_driver(). Contains the * scheduler's internal state. - */ + */ struct GNUNET_SCHEDULER_Handle { /** @@ -94,7 +94,7 @@ struct GNUNET_SCHEDULER_Handle * Driver we used for the event loop. */ const struct GNUNET_SCHEDULER_Driver *driver; - + }; @@ -127,7 +127,7 @@ struct GNUNET_SCHEDULER_Task * Handle to the scheduler's state. */ const struct GNUNET_SCHEDULER_Handle *sh; - + /** * Set of file descriptors this task is waiting * for for reading. Once ready, this is updated @@ -172,7 +172,7 @@ struct GNUNET_SCHEDULER_Task * Size of the @e fds array. */ unsigned int fds_len; - + /** * Why is the task ready? Set after task is added to ready queue. * Initially set to zero. All reasons that have already been @@ -589,9 +589,7 @@ static void dump_backtrace (struct GNUNET_SCHEDULER_Task *t) { #if EXECINFO - unsigned int i; - - for (i = 0; i < t->num_backtrace_strings; i++) + for (unsigned int i = 0; i < t->num_backtrace_strings; i++) LOG (GNUNET_ERROR_TYPE_DEBUG, "Task %p trace %u: %s\n", t, @@ -1849,7 +1847,7 @@ GNUNET_SCHEDULER_task_ready (struct GNUNET_SCHEDULER_Task *task, * * @param sh scheduler handle that was given to the `loop` * @return #GNUNET_OK if there are more tasks that are ready, - * and thus we would like to run more (yield to avoid + * and thus we would like to run more (yield to avoid * blocking other activities for too long) * #GNUNET_NO if we are done running tasks (yield to block) * #GNUNET_SYSERR on error @@ -1876,11 +1874,11 @@ GNUNET_SCHEDULER_run_from_driver (struct GNUNET_SCHEDULER_Handle *sh) pending_timeout_last = NULL; queue_ready_task (pos); } - + if (0 == ready_count) return GNUNET_NO; - /* find out which task priority level we are going to + /* find out which task priority level we are going to process this time */ max_priority_added = GNUNET_SCHEDULER_PRIORITY_KEEP; GNUNET_assert (NULL == ready_head[GNUNET_SCHEDULER_PRIORITY_KEEP]); -- cgit v1.2.3 From 17f5db6f7c8d60930367738b3d872fbf891486ee Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 29 Oct 2017 12:32:57 +0100 Subject: allow MST callback to distinguish between disconnect and parse error situations, and only log for the hard errors --- src/cadet/gnunet-service-cadet_tunnels.c | 4 ++- .../gnunet-helper-audio-playback-gst.c | 5 ++++ src/conversation/gnunet-helper-audio-playback.c | 5 ++++ src/conversation/gnunet_gst.c | 5 ++++ src/conversation/microphone.c | 4 ++- src/core/gnunet-service-core.c | 3 +++ src/core/gnunet-service-core_kx.c | 3 +++ src/fs/fs_dirmetascan.c | 3 +++ src/include/gnunet_mst_lib.h | 4 ++- src/statistics/gnunet-service-statistics.c | 4 ++- src/testbed/gnunet-helper-testbed.c | 7 +++--- src/transport/gnunet-helper-transport-wlan-dummy.c | 6 +++++ src/transport/plugin_transport_http_server.c | 2 +- src/util/client.c | 8 +++--- src/util/mst.c | 29 +++++++++++++--------- src/vpn/gnunet-service-vpn.c | 3 +++ 16 files changed, 72 insertions(+), 23 deletions(-) diff --git a/src/cadet/gnunet-service-cadet_tunnels.c b/src/cadet/gnunet-service-cadet_tunnels.c index 22e19ef70..fb91a4a6a 100644 --- a/src/cadet/gnunet-service-cadet_tunnels.c +++ b/src/cadet/gnunet-service-cadet_tunnels.c @@ -2856,7 +2856,9 @@ handle_plaintext_channel_destroy (void *cls, * * @param cls the `struct CadetTunnel` that got the message * @param msg the message - * @return #GNUNET_OK (continue to process) + * @return #GNUNET_OK on success (always) + * #GNUNET_NO to stop further processing (no error) + * #GNUNET_SYSERR to stop further processing with error */ static int handle_decrypted (void *cls, diff --git a/src/conversation/gnunet-helper-audio-playback-gst.c b/src/conversation/gnunet-helper-audio-playback-gst.c index 264b14e76..002fed6c7 100644 --- a/src/conversation/gnunet-helper-audio-playback-gst.c +++ b/src/conversation/gnunet-helper-audio-playback-gst.c @@ -221,6 +221,11 @@ feed_buffer_to_gst (const char *audio, size_t b_len) /** * Message callback + * + * @param msg message we received. + * @return #GNUNET_OK on success, + * #GNUNET_NO to stop further processing due to disconnect (no error) + * #GNUNET_SYSERR to stop further processing due to error */ static int stdin_receiver (void *cls, diff --git a/src/conversation/gnunet-helper-audio-playback.c b/src/conversation/gnunet-helper-audio-playback.c index 4344e1d41..18f63ad18 100644 --- a/src/conversation/gnunet-helper-audio-playback.c +++ b/src/conversation/gnunet-helper-audio-playback.c @@ -546,6 +546,11 @@ ogg_demux_and_decode () /** * Message callback + * + * @param msg message we received. + * @return #GNUNET_OK on success, + * #GNUNET_NO to stop further processing due to disconnect (no error) + * #GNUNET_SYSERR to stop further processing due to error */ static int stdin_receiver (void *cls, diff --git a/src/conversation/gnunet_gst.c b/src/conversation/gnunet_gst.c index 52cb2ccbc..828b35077 100644 --- a/src/conversation/gnunet_gst.c +++ b/src/conversation/gnunet_gst.c @@ -649,6 +649,11 @@ gnunet_read (GNUNET_gstData * d) /** * Message callback + * + * @param msg message we received. + * @return #GNUNET_OK on success, + * #GNUNET_NO to stop further processing due to disconnect (no error) + * #GNUNET_SYSERR to stop further processing due to error */ static int stdin_receiver (void *cls, diff --git a/src/conversation/microphone.c b/src/conversation/microphone.c index 7871433a3..11468fc59 100644 --- a/src/conversation/microphone.c +++ b/src/conversation/microphone.c @@ -65,7 +65,9 @@ struct Microphone * * @param cls clsoure with our `struct Microphone` * @param msg the message from the helper - * @return #GNUNET_OK on success, #GNUNET_SYSERR on error + * @return #GNUNET_OK on success, + * #GNUNET_NO to stop further processing (no error) + * #GNUNET_SYSERR to stop further processing with error */ static int process_record_messages (void *cls, diff --git a/src/core/gnunet-service-core.c b/src/core/gnunet-service-core.c index 625bf9655..214f72904 100644 --- a/src/core/gnunet-service-core.c +++ b/src/core/gnunet-service-core.c @@ -426,6 +426,9 @@ struct TokenizerContext * * @param cls reservation request (`struct TokenizerContext`) * @param message the actual message + * @return #GNUNET_OK on success, + * #GNUNET_NO to stop further processing (no error) + * #GNUNET_SYSERR to stop further processing with error */ static int tokenized_cb (void *cls, diff --git a/src/core/gnunet-service-core_kx.c b/src/core/gnunet-service-core_kx.c index 8a7cada5c..ae0ae508f 100644 --- a/src/core/gnunet-service-core_kx.c +++ b/src/core/gnunet-service-core_kx.c @@ -708,6 +708,9 @@ setup_fresh_ping (struct GSC_KeyExchangeInfo *kx) * * @param cls the `struct GSC_KeyExchangeInfo` * @param m the message + * @return #GNUNET_OK on success, + * #GNUNET_NO to stop further processing (no error) + * #GNUNET_SYSERR to stop further processing with error */ static int deliver_message (void *cls, diff --git a/src/fs/fs_dirmetascan.c b/src/fs/fs_dirmetascan.c index 7b9f178fd..8a3e37b49 100644 --- a/src/fs/fs_dirmetascan.c +++ b/src/fs/fs_dirmetascan.c @@ -246,6 +246,9 @@ finish_scan (void *cls) * * @param cls the closure (directory scanner object) * @param msg message from the helper process + * @return #GNUNET_OK on success, + * #GNUNET_NO to stop further processing (no error) + * #GNUNET_SYSERR to stop further processing with error */ static int process_helper_msgs (void *cls, diff --git a/src/include/gnunet_mst_lib.h b/src/include/gnunet_mst_lib.h index 7a1ca7a55..fe6524eb3 100644 --- a/src/include/gnunet_mst_lib.h +++ b/src/include/gnunet_mst_lib.h @@ -61,7 +61,9 @@ struct GNUNET_MessageStreamTokenizer; * * @param cls closure * @param message the actual message - * @return #GNUNET_OK on success, #GNUNET_SYSERR to stop further processing + * @return #GNUNET_OK on success, + * #GNUNET_NO to stop further processing due to disconnect (no error) + * #GNUNET_SYSERR to stop further processing due to error */ typedef int (*GNUNET_MessageTokenizerCallback) (void *cls, diff --git a/src/statistics/gnunet-service-statistics.c b/src/statistics/gnunet-service-statistics.c index 0cb136b99..87e966a01 100644 --- a/src/statistics/gnunet-service-statistics.c +++ b/src/statistics/gnunet-service-statistics.c @@ -998,7 +998,9 @@ client_disconnect_cb (void *cls, * * @param cls NULL * @param message the message found on disk - * @return #GNUNET_OK on success, #GNUNET_SYSERR to stop further processing + * @return #GNUNET_OK on success, + * #GNUNET_NO to stop further processing (no error) + * #GNUNET_SYSERR to stop further processing with error */ static int inject_message (void *cls, diff --git a/src/testbed/gnunet-helper-testbed.c b/src/testbed/gnunet-helper-testbed.c index 392f257dd..9601e7567 100644 --- a/src/testbed/gnunet-helper-testbed.c +++ b/src/testbed/gnunet-helper-testbed.c @@ -292,8 +292,9 @@ child_death_task (void *cls) * * @param cls identification of the client * @param message the actual message - * - * @return #GNUNET_OK on success, #GNUNET_SYSERR to stop further processing + * @return #GNUNET_OK on success, + * #GNUNET_NO to stop further processing (no error) + * #GNUNET_SYSERR to stop further processing with error */ static int tokenizer_cb (void *cls, @@ -359,7 +360,7 @@ tokenizer_cb (void *cls, cfg = GNUNET_CONFIGURATION_create (); if (GNUNET_OK != GNUNET_CONFIGURATION_deserialize (cfg, - config, + config, ul_config_size, NULL)) { diff --git a/src/transport/gnunet-helper-transport-wlan-dummy.c b/src/transport/gnunet-helper-transport-wlan-dummy.c index 63ed9c4b7..f02d8bdd7 100644 --- a/src/transport/gnunet-helper-transport-wlan-dummy.c +++ b/src/transport/gnunet-helper-transport-wlan-dummy.c @@ -121,6 +121,9 @@ send_mac_to_plugin (char *buffer, struct GNUNET_TRANSPORT_WLAN_MacAddress *mac) * * @param cls the 'struct SendBuffer' to copy the converted message to * @param hdr inbound message from the FIFO + * @return #GNUNET_OK on success, + * #GNUNET_NO to stop further processing (no error) + * #GNUNET_SYSERR to stop further processing with error */ static int stdin_send (void *cls, @@ -167,6 +170,9 @@ stdin_send (void *cls, * * @param cls the 'struct SendBuffer' to copy to * @param hdr the message we received to copy to the buffer + * @return #GNUNET_OK on success, + * #GNUNET_NO to stop further processing (no error) + * #GNUNET_SYSERR to stop further processing with error */ static int file_in_send (void *cls, diff --git a/src/transport/plugin_transport_http_server.c b/src/transport/plugin_transport_http_server.c index d9fade44f..6a9c1b0ba 100644 --- a/src/transport/plugin_transport_http_server.c +++ b/src/transport/plugin_transport_http_server.c @@ -1651,7 +1651,7 @@ server_send_callback (void *cls, * * @param cls current session as closure * @param message the message to be forwarded to transport service - * @return #GNUNET_OK + * @return #GNUNET_OK (all OK) */ static int server_receive_mst_cb (void *cls, diff --git a/src/util/client.c b/src/util/client.c index 90bc837d7..138b1cfdd 100644 --- a/src/util/client.c +++ b/src/util/client.c @@ -306,7 +306,9 @@ transmit_ready (void *cls) * * @param cls the `struct ClientState` * @param msg message we received. - * @return #GNUNET_OK on success, #GNUNET_SYSERR to stop further processing + * @return #GNUNET_OK on success, + * #GNUNET_NO to stop further processing due to disconnect (no error) + * #GNUNET_SYSERR to stop further processing due to error */ static int recv_message (void *cls, @@ -315,7 +317,7 @@ recv_message (void *cls, struct ClientState *cstate = cls; if (GNUNET_YES == cstate->in_destroy) - return GNUNET_SYSERR; + return GNUNET_NO; LOG (GNUNET_ERROR_TYPE_DEBUG, "Received message of type %u and size %u from %s\n", ntohs (msg->type), @@ -324,7 +326,7 @@ recv_message (void *cls, GNUNET_MQ_inject_message (cstate->mq, msg); if (GNUNET_YES == cstate->in_destroy) - return GNUNET_SYSERR; + return GNUNET_NO; return GNUNET_OK; } diff --git a/src/util/mst.c b/src/util/mst.c index 4c2a74212..5e472965f 100644 --- a/src/util/mst.c +++ b/src/util/mst.c @@ -126,6 +126,7 @@ GNUNET_MST_from_buffer (struct GNUNET_MessageStreamTokenizer *mst, int need_align; unsigned long offset; int ret; + int cbret; GNUNET_assert (mst->off <= mst->pos); GNUNET_assert (mst->pos <= mst->curr_buf); @@ -229,13 +230,15 @@ do_align: if (one_shot == GNUNET_YES) one_shot = GNUNET_SYSERR; mst->off += want; - if (GNUNET_SYSERR == mst->cb (mst->cb_cls, - hdr)) + if (GNUNET_OK != + (cbret = mst->cb (mst->cb_cls, + hdr))) { - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Failure processing message of type %u and size %u\n", - ntohs (hdr->type), - ntohs (hdr->size)); + if (GNUNET_SYSERR == cbret) + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + "Failure processing message of type %u and size %u\n", + ntohs (hdr->type), + ntohs (hdr->size)); return GNUNET_SYSERR; } if (mst->off == mst->pos) @@ -277,13 +280,15 @@ do_align: } if (one_shot == GNUNET_YES) one_shot = GNUNET_SYSERR; - if (GNUNET_SYSERR == mst->cb (mst->cb_cls, - hdr)) + if (GNUNET_OK != + (cbret = mst->cb (mst->cb_cls, + hdr))) { - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Failure processing message of type %u and size %u\n", - ntohs (hdr->type), - ntohs (hdr->size)); + if (GNUNET_SYSERR == cbret) + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + "Failure processing message of type %u and size %u\n", + ntohs (hdr->type), + ntohs (hdr->size)); return GNUNET_SYSERR; } buf += want; diff --git a/src/vpn/gnunet-service-vpn.c b/src/vpn/gnunet-service-vpn.c index d9daaa7e2..bdc638176 100644 --- a/src/vpn/gnunet-service-vpn.c +++ b/src/vpn/gnunet-service-vpn.c @@ -2218,6 +2218,9 @@ route_packet (struct DestinationEntry *destination, * * @param cls closure, NULL * @param message message we got from the client (VPN channel interface) + * @return #GNUNET_OK on success, + * #GNUNET_NO to stop further processing (no error) + * #GNUNET_SYSERR to stop further processing with error */ static int message_token (void *cls, -- cgit v1.2.3 From 7c1ce9a71e362727509f013900a50ba5879ca8b2 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 29 Oct 2017 12:39:48 +0100 Subject: Fix tcp on exit crash -- could have sworn I fixed this one before --- src/transport/tcp_server_legacy.c | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/src/transport/tcp_server_legacy.c b/src/transport/tcp_server_legacy.c index 6b4daa525..d0ce790fc 100644 --- a/src/transport/tcp_server_legacy.c +++ b/src/transport/tcp_server_legacy.c @@ -1476,23 +1476,6 @@ GNUNET_SERVER_connect_notify_cancel (struct GNUNET_SERVER_Handle *server, } -/** - * Destroy the connection that is passed in via @a cls. Used - * as calling #GNUNET_CONNECTION_destroy from within a function - * that was itself called from within process_notify() of - * 'connection.c' is not allowed (see #2329). - * - * @param cls connection to destroy - */ -static void -destroy_connection (void *cls) -{ - struct GNUNET_CONNECTION_Handle *connection = cls; - - GNUNET_CONNECTION_destroy (connection); -} - - /** * Ask the server to disconnect from the given client. * This is the same as returning #GNUNET_SYSERR from a message @@ -1565,8 +1548,7 @@ GNUNET_SERVER_client_disconnect (struct GNUNET_SERVER_Client *client) GNUNET_CONNECTION_persist_ (client->connection); if (NULL != client->th.cth) GNUNET_SERVER_notify_transmit_ready_cancel (&client->th); - (void) GNUNET_SCHEDULER_add_now (&destroy_connection, - client->connection); + GNUNET_CONNECTION_destroy (client->connection); /* need to cancel again, as it might have been re-added in the meantime (i.e. during callbacks) */ if (NULL != client->warn_task) -- cgit v1.2.3