From 319ff0fa21798013e1fbb6bdd0ce18b1be42fb07 Mon Sep 17 00:00:00 2001 From: Carlo von lynX Date: Sat, 30 Jul 2016 06:22:40 +0000 Subject: [PATCH] social: allow multiple calls to disconnect(), rest: handle warnings --- src/multicast/gnunet-service-multicast.c | 4 +++- src/multicast/multicast_api.c | 6 +++--- src/social/gnunet-social.c | 16 +++++++++++----- src/util/socks.c | 2 +- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/multicast/gnunet-service-multicast.c b/src/multicast/gnunet-service-multicast.c index 91cafb707..a14ecd04c 100644 --- a/src/multicast/gnunet-service-multicast.c +++ b/src/multicast/gnunet-service-multicast.c @@ -877,6 +877,7 @@ cadet_send_children (struct GNUNET_HashCode *pub_key_hash, } +#if 0 // unused as yet /** * Send message to all connected parents. */ @@ -890,6 +891,7 @@ cadet_send_parents (struct GNUNET_HashCode *pub_key_hash, cadet_send_cb, (void *) msg); return n; } +#endif /** @@ -1778,7 +1780,7 @@ cadet_recv_replay_response (void *cls, void **ctx, const struct GNUNET_MessageHeader *m) { - struct Channel *chn = *ctx; + //struct Channel *chn = *ctx; /* @todo FIXME: got replay error response, send request to other members */ diff --git a/src/multicast/multicast_api.c b/src/multicast/multicast_api.c index f5c8c3d34..e390a621c 100644 --- a/src/multicast/multicast_api.c +++ b/src/multicast/multicast_api.c @@ -400,9 +400,9 @@ member_recv_replay_response (void *cls, struct GNUNET_MULTICAST_Member * mem = GNUNET_CLIENT_MANAGER_get_user_context_ (client, sizeof (*grp)); grp = &mem->grp; - struct MulticastReplayResponseMessage * - res = (struct MulticastReplayResponseMessage *) msg; - + // FIXME: Something is missing here for the code to make sense + //struct MulticastReplayResponseMessage * + // res = (struct MulticastReplayResponseMessage *) msg; if (GNUNET_YES == grp->is_disconnecting) return; diff --git a/src/social/gnunet-social.c b/src/social/gnunet-social.c index 9841e83a6..5aa74c81a 100644 --- a/src/social/gnunet-social.c +++ b/src/social/gnunet-social.c @@ -131,6 +131,9 @@ static int opt_limit; /** exit code */ static int ret = 1; +/** are we waiting for service to close our connection */ +static char is_disconnecting = 0; + /** Task handle for timeout termination. */ struct GNUNET_SCHEDULER_Task *timeout_task; @@ -199,8 +202,11 @@ app_disconnected (void *cls) static void disconnect () { - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "disconnect()\n"); - GNUNET_SOCIAL_app_disconnect (app, app_disconnected, NULL); + // handle that we get called several times from several places, but should we? + if (!is_disconnecting++) { + GNUNET_SOCIAL_app_disconnect (app, app_disconnected, NULL); + } + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "disconnect() called for the #%d time\n", is_disconnecting); } @@ -218,21 +224,21 @@ static void timeout (void *cls) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "timeout()\n"); - //disconnect (); + disconnect (); } static void schedule_success (void *cls) { ret = 0; - //disconnect (); + disconnect (); } static void schedule_fail (void *cls) { - //disconnect (); + disconnect (); } diff --git a/src/util/socks.c b/src/util/socks.c index 387c2b698..ece79b3e4 100644 --- a/src/util/socks.c +++ b/src/util/socks.c @@ -599,7 +599,7 @@ GNUNET_SOCKS_do_connect (const char *service_name, if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg, service_name, "SOCKSHOST", &host0)) host0 = NULL; /* you don't want to feed a static string to free(), right? */ - socks5 = GNUNET_CONNECTION_create_from_connect (cfg, host0 || "127.0.0.1", port0); + socks5 = GNUNET_CONNECTION_create_from_connect (cfg, (char*)(host0 || "127.0.0.1"), port0); if (host0) GNUNET_free (host0); /* Sets to NULL if they do not exist */ -- 2.25.1