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(-) (limited to 'src/psyc') 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 08d1fb4ad8581fca79dcc35e18c5d086fd11821f Mon Sep 17 00:00:00 2001 From: lurchi Date: Sat, 18 Nov 2017 11:10:27 +0100 Subject: Introduce PART/PART_ACK messages (tests will fail until multicast module is adapted, too) --- src/include/gnunet_protocols.h | 10 ++++-- src/psyc/gnunet-service-psyc.c | 72 +++++++++++++++++++++++++++++-------- src/psyc/psyc_api.c | 82 +++++++++++++++++++++++++++--------------- 3 files changed, 118 insertions(+), 46 deletions(-) (limited to 'src/psyc') diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h index 2daf5eb46..02097603e 100644 --- a/src/include/gnunet_protocols.h +++ b/src/include/gnunet_protocols.h @@ -2067,7 +2067,11 @@ extern "C" /** S->C: slave join acknowledgement */ #define GNUNET_MESSAGE_TYPE_PSYC_SLAVE_JOIN_ACK 684 -/* 685-686 */ +/** C->S: request to part from a channel */ +#define GNUNET_MESSAGE_TYPE_PSYC_PART_REQUEST 685 + +/** S->C: acknowledgement that a slave of master parted from a channel */ +#define GNUNET_MESSAGE_TYPE_PSYC_PART_ACK 686 /** M->S->C: incoming join request from multicast */ #define GNUNET_MESSAGE_TYPE_PSYC_JOIN_REQUEST 687 @@ -2244,12 +2248,12 @@ extern "C" * * Unicast message from a group member to the peer wanting to join. */ -#define GNUNET_MESSAGE_TYPE_MULTICAST_JOIN_DECISION 753 +//#define GNUNET_MESSAGE_TYPE_MULTICAST_JOIN_DECISION 753 /** * A peer wants to part the group. */ -#define GNUNET_MESSAGE_TYPE_MULTICAST_PART_REQUEST 754 +//#define GNUNET_MESSAGE_TYPE_MULTICAST_PART_REQUEST 754 /** * Acknowledgement sent in response to a part request. diff --git a/src/psyc/gnunet-service-psyc.c b/src/psyc/gnunet-service-psyc.c index 73a3ae4ee..8af3264fd 100644 --- a/src/psyc/gnunet-service-psyc.c +++ b/src/psyc/gnunet-service-psyc.c @@ -508,8 +508,8 @@ cleanup_master (struct Master *mst) { struct Channel *chn = &mst->channel; - if (NULL != mst->origin) - GNUNET_MULTICAST_origin_stop (mst->origin, NULL, NULL); // FIXME + //if (NULL != mst->origin) + // GNUNET_MULTICAST_origin_stop (mst->origin, cleanup_cb, cleanup_cls); GNUNET_CONTAINER_multihashmap_destroy (mst->join_reqs); GNUNET_CONTAINER_multihashmap_remove (masters, &chn->pub_key_hash, mst); } @@ -546,11 +546,11 @@ cleanup_slave (struct Slave *slv) GNUNET_free (slv->relays); slv->relays = NULL; } - if (NULL != slv->member) - { - GNUNET_MULTICAST_member_part (slv->member, NULL, NULL); // FIXME - slv->member = NULL; - } + //if (NULL != slv->member) + //{ + // GNUNET_MULTICAST_member_part (slv->member, cleanup_cb, cleanup_cls); + // slv->member = NULL; + //} GNUNET_CONTAINER_multihashmap_remove (slaves, &chn->pub_key_hash, slv); } @@ -646,14 +646,15 @@ client_notify_disconnect (void *cls, (GNUNET_YES == chn->is_master) ? "master" : "slave", GNUNET_h2s (&chn->pub_key_hash)); chn->is_disconnected = GNUNET_YES; - if (NULL != chn->tmit_head) - { /* Send pending messages to multicast before cleanup. */ - transmit_message (chn); - } - else - { - cleanup_channel (chn); - } + cleanup_channel (chn); + //if (NULL != chn->tmit_head) + //{ /* Send pending messages to multicast before cleanup. */ + // transmit_message (chn); + //} + //else + //{ + // cleanup_channel (chn); + //} } } @@ -2037,6 +2038,43 @@ handle_client_join_decision (void *cls, } +static void +channel_part_cb (void *cls) +{ + struct GNUNET_SERVICE_Client *client = cls; + struct GNUNET_MQ_Envelope *env; + + env = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_PSYC_PART_ACK); + GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), + env); +} + + +static void +handle_client_part_request (void *cls, + const struct GNUNET_MessageHeader *msg) +{ + struct Client *c = cls; + + if (GNUNET_YES == c->channel->is_master) + { + struct Master *mst = (struct Master *) c->channel; + + GNUNET_assert (NULL != mst->origin); + GNUNET_MULTICAST_origin_stop (mst->origin, channel_part_cb, c->client); + mst->origin = NULL; + } + else + { + struct Slave *slv = (struct Slave *) c->channel; + + GNUNET_assert (NULL != slv->member); + GNUNET_MULTICAST_member_part (slv->member, channel_part_cb, c->client); + slv->member = NULL; + } +} + + /** * Send acknowledgement to a client. * @@ -2805,6 +2843,10 @@ GNUNET_SERVICE_MAIN GNUNET_MESSAGE_TYPE_PSYC_JOIN_DECISION, struct GNUNET_PSYC_JoinDecisionMessage, NULL), + GNUNET_MQ_hd_fixed_size (client_part_request, + GNUNET_MESSAGE_TYPE_PSYC_PART_REQUEST, + struct GNUNET_MessageHeader, + NULL), GNUNET_MQ_hd_var_size (client_psyc_message, GNUNET_MESSAGE_TYPE_PSYC_MESSAGE, struct GNUNET_MessageHeader, diff --git a/src/psyc/psyc_api.c b/src/psyc/psyc_api.c index e7790d201..cdb9ce881 100644 --- a/src/psyc/psyc_api.c +++ b/src/psyc/psyc_api.c @@ -555,6 +555,10 @@ handle_slave_join_decision (void *cls, static void channel_cleanup (struct GNUNET_PSYC_Channel *chn) { + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "cleaning up channel %p\n", + chn); + GNUNET_assert (0); if (NULL != chn->tmit) { GNUNET_PSYC_transmit_destroy (chn->tmit); @@ -585,33 +589,43 @@ channel_cleanup (struct GNUNET_PSYC_Channel *chn) static void -channel_disconnect (struct GNUNET_PSYC_Channel *chn, - GNUNET_ContinuationCallback cb, - void *cls) +handle_channel_part_ack (void *cls, + const struct GNUNET_MessageHeader *msg) { - chn->is_disconnecting = GNUNET_YES; - chn->disconnect_cb = cb; - chn->disconnect_cls = cls; + struct GNUNET_PSYC_Channel *chn = cls; - if (NULL != chn->mq) - { - struct GNUNET_MQ_Envelope *env = GNUNET_MQ_get_last_envelope (chn->mq); - if (NULL != env) - { - GNUNET_MQ_notify_sent (env, (GNUNET_SCHEDULER_TaskCallback) channel_cleanup, chn); - } - else - { - channel_cleanup (chn); - } - } - else - { - channel_cleanup (chn); - } + channel_cleanup (chn); } +//static void +//channel_disconnect (struct GNUNET_PSYC_Channel *chn, +// GNUNET_ContinuationCallback cb, +// void *cls) +//{ +// chn->is_disconnecting = GNUNET_YES; +// chn->disconnect_cb = cb; +// chn->disconnect_cls = cls; +// +// if (NULL != chn->mq) +// { +// struct GNUNET_MQ_Envelope *env = GNUNET_MQ_get_last_envelope (chn->mq); +// if (NULL != env) +// { +// GNUNET_MQ_notify_sent (env, (GNUNET_SCHEDULER_TaskCallback) channel_cleanup, chn); +// } +// else +// { +// channel_cleanup (chn); +// } +// } +// else +// { +// channel_cleanup (chn); +// } +//} + + /*** MASTER ***/ @@ -671,6 +685,10 @@ master_connect (struct GNUNET_PSYC_Master *mst) GNUNET_MESSAGE_TYPE_PSYC_JOIN_REQUEST, struct GNUNET_PSYC_JoinRequestMessage, mst), + GNUNET_MQ_hd_fixed_size (channel_part_ack, + GNUNET_MESSAGE_TYPE_PSYC_PART_ACK, + struct GNUNET_MessageHeader, + chn), GNUNET_MQ_hd_var_size (channel_message, GNUNET_MESSAGE_TYPE_PSYC_MESSAGE, struct GNUNET_PSYC_MessageHeader, @@ -780,10 +798,12 @@ GNUNET_PSYC_master_stop (struct GNUNET_PSYC_Master *mst, void *stop_cls) { struct GNUNET_PSYC_Channel *chn = &mst->chn; + struct GNUNET_MQ_Envelope *env; - /* FIXME: send msg to service */ - - channel_disconnect (chn, stop_cb, stop_cls); + chn->disconnect_cb = stop_cb; + chn->disconnect_cls = stop_cls; + env = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_PSYC_PART_REQUEST); + GNUNET_MQ_send (chn->mq, env); } @@ -971,6 +991,10 @@ slave_connect (struct GNUNET_PSYC_Slave *slv) GNUNET_MESSAGE_TYPE_PSYC_JOIN_DECISION, struct GNUNET_PSYC_JoinDecisionMessage, slv), + GNUNET_MQ_hd_fixed_size (channel_part_ack, + GNUNET_MESSAGE_TYPE_PSYC_PART_ACK, + struct GNUNET_MessageHeader, + chn), GNUNET_MQ_hd_var_size (channel_message, GNUNET_MESSAGE_TYPE_PSYC_MESSAGE, struct GNUNET_PSYC_MessageHeader, @@ -1118,10 +1142,12 @@ GNUNET_PSYC_slave_part (struct GNUNET_PSYC_Slave *slv, void *part_cls) { struct GNUNET_PSYC_Channel *chn = &slv->chn; + struct GNUNET_MQ_Envelope *env; - /* FIXME: send msg to service */ - - channel_disconnect (chn, part_cb, part_cls); + chn->disconnect_cb = part_cb; + chn->disconnect_cls = part_cls; + env = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_PSYC_PART_REQUEST); + GNUNET_MQ_send (chn->mq, env); } -- cgit v1.2.3 From fc1b64c4cab95a5b39d64b06707ecf20e615af7f Mon Sep 17 00:00:00 2001 From: lurchi Date: Fri, 24 Nov 2017 21:56:14 +0100 Subject: added FIXME --- src/psyc/gnunet-service-psyc.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/psyc') diff --git a/src/psyc/gnunet-service-psyc.c b/src/psyc/gnunet-service-psyc.c index 8af3264fd..5397793c3 100644 --- a/src/psyc/gnunet-service-psyc.c +++ b/src/psyc/gnunet-service-psyc.c @@ -615,6 +615,8 @@ client_notify_disconnect (void *cls, (GNUNET_YES == chn->is_master) ? "master" : "slave", GNUNET_h2s (&chn->pub_key_hash)); + // FIXME (due to protocol change): here we must not remove all clients, + // only the one we were notified about! struct ClientList *cli = chn->clients_head; while (NULL != cli) { -- cgit v1.2.3 From 130d7e66aea9c9b6ec3955dc9446530057dcb10c Mon Sep 17 00:00:00 2001 From: lurchi Date: Fri, 24 Nov 2017 21:58:12 +0100 Subject: mark channel as disconnectin when a part request is sent; cleanup --- src/psyc/psyc_api.c | 30 ++---------------------------- 1 file changed, 2 insertions(+), 28 deletions(-) (limited to 'src/psyc') diff --git a/src/psyc/psyc_api.c b/src/psyc/psyc_api.c index cdb9ce881..a045f9eb2 100644 --- a/src/psyc/psyc_api.c +++ b/src/psyc/psyc_api.c @@ -598,34 +598,6 @@ handle_channel_part_ack (void *cls, } -//static void -//channel_disconnect (struct GNUNET_PSYC_Channel *chn, -// GNUNET_ContinuationCallback cb, -// void *cls) -//{ -// chn->is_disconnecting = GNUNET_YES; -// chn->disconnect_cb = cb; -// chn->disconnect_cls = cls; -// -// if (NULL != chn->mq) -// { -// struct GNUNET_MQ_Envelope *env = GNUNET_MQ_get_last_envelope (chn->mq); -// if (NULL != env) -// { -// GNUNET_MQ_notify_sent (env, (GNUNET_SCHEDULER_TaskCallback) channel_cleanup, chn); -// } -// else -// { -// channel_cleanup (chn); -// } -// } -// else -// { -// channel_cleanup (chn); -// } -//} - - /*** MASTER ***/ @@ -800,6 +772,7 @@ GNUNET_PSYC_master_stop (struct GNUNET_PSYC_Master *mst, struct GNUNET_PSYC_Channel *chn = &mst->chn; struct GNUNET_MQ_Envelope *env; + chn->is_disconnecting = GNUNET_YES; chn->disconnect_cb = stop_cb; chn->disconnect_cls = stop_cls; env = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_PSYC_PART_REQUEST); @@ -1144,6 +1117,7 @@ GNUNET_PSYC_slave_part (struct GNUNET_PSYC_Slave *slv, struct GNUNET_PSYC_Channel *chn = &slv->chn; struct GNUNET_MQ_Envelope *env; + chn->is_disconnecting = GNUNET_YES; chn->disconnect_cb = part_cb; chn->disconnect_cls = part_cls; env = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_PSYC_PART_REQUEST); -- cgit v1.2.3 From 28c941178588fbf349e24a9ebf2dfe36aec2eded Mon Sep 17 00:00:00 2001 From: lurchi Date: Sun, 24 Dec 2017 13:08:05 +0100 Subject: forgot to call GNUNET_SERVICE_client_continue --- src/psyc/gnunet-service-psyc.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'src/psyc') diff --git a/src/psyc/gnunet-service-psyc.c b/src/psyc/gnunet-service-psyc.c index 5397793c3..35cc5551d 100644 --- a/src/psyc/gnunet-service-psyc.c +++ b/src/psyc/gnunet-service-psyc.c @@ -603,20 +603,19 @@ client_notify_disconnect (void *cls, if (NULL == chn) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "%p User context is NULL in client_disconnect()\n", + "%p User context is NULL in client_notify_disconnect ()\n", chn); GNUNET_break (0); return; } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "%p Client (%s) disconnected from channel %s\n", + "%p Client %p (%s) disconnected from channel %s\n", chn, + client, (GNUNET_YES == chn->is_master) ? "master" : "slave", GNUNET_h2s (&chn->pub_key_hash)); - // FIXME (due to protocol change): here we must not remove all clients, - // only the one we were notified about! struct ClientList *cli = chn->clients_head; while (NULL != cli) { @@ -649,14 +648,6 @@ client_notify_disconnect (void *cls, GNUNET_h2s (&chn->pub_key_hash)); chn->is_disconnected = GNUNET_YES; cleanup_channel (chn); - //if (NULL != chn->tmit_head) - //{ /* Send pending messages to multicast before cleanup. */ - // transmit_message (chn); - //} - //else - //{ - // cleanup_channel (chn); - //} } } @@ -691,7 +682,7 @@ client_send_msg (const struct Channel *chn, const struct GNUNET_MessageHeader *msg) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "%p Sending message to clients.\n", + "Sending message to clients of channel %p.\n", chn); struct ClientList *cli = chn->clients_head; @@ -702,7 +693,6 @@ client_send_msg (const struct Channel *chn, GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (cli->client), env); - cli = cli->next; } } @@ -737,7 +727,7 @@ client_send_result (struct GNUNET_SERVICE_Client *client, uint64_t op_id, GNUNET_memcpy (&res[1], data, data_size); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "%p Sending result to client for operation #%" PRIu64 ": %" PRId64 " (size: %u)\n", + "%p Sending result to client for OP ID %" PRIu64 ": %" PRId64 " (size: %u)\n", client, GNUNET_ntohll (op_id), result_code, @@ -1834,6 +1824,9 @@ handle_client_slave_join (void *cls, struct GNUNET_CRYPTO_EcdsaPublicKey slv_pub_key; struct GNUNET_HashCode pub_key_hash, slv_pub_hash; + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "got join request from client %p\n", + client); GNUNET_CRYPTO_ecdsa_key_get_public (&req->slave_key, &slv_pub_key); GNUNET_CRYPTO_hash (&slv_pub_key, sizeof (slv_pub_key), &slv_pub_hash); GNUNET_CRYPTO_hash (&req->channel_pub_key, sizeof (req->channel_pub_key), &pub_key_hash); @@ -2061,7 +2054,10 @@ handle_client_part_request (void *cls, if (GNUNET_YES == c->channel->is_master) { struct Master *mst = (struct Master *) c->channel; - + + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Got part request from master %p\n", + mst); GNUNET_assert (NULL != mst->origin); GNUNET_MULTICAST_origin_stop (mst->origin, channel_part_cb, c->client); mst->origin = NULL; @@ -2070,10 +2066,14 @@ handle_client_part_request (void *cls, { struct Slave *slv = (struct Slave *) c->channel; + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Got part request from slave %p\n", + slv); GNUNET_assert (NULL != slv->member); GNUNET_MULTICAST_member_part (slv->member, channel_part_cb, c->client); slv->member = NULL; } + GNUNET_SERVICE_client_continue (c->client); } @@ -2829,9 +2829,9 @@ run (void *cls, GNUNET_SERVICE_MAIN ("psyc", GNUNET_SERVICE_OPTION_NONE, - run, - client_notify_connect, - client_notify_disconnect, + &run, + &client_notify_connect, + &client_notify_disconnect, NULL, GNUNET_MQ_hd_fixed_size (client_master_start, GNUNET_MESSAGE_TYPE_PSYC_MASTER_START, -- cgit v1.2.3 From 804c401123f78873678a8553503e14ab434e9983 Mon Sep 17 00:00:00 2001 From: lurchi Date: Sun, 24 Dec 2017 13:15:07 +0100 Subject: remove debug assertion; add debug output --- src/psyc/psyc_api.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'src/psyc') diff --git a/src/psyc/psyc_api.c b/src/psyc/psyc_api.c index a045f9eb2..d8f4c98bc 100644 --- a/src/psyc/psyc_api.c +++ b/src/psyc/psyc_api.c @@ -260,6 +260,10 @@ handle_channel_result (void *cls, GNUNET_OP_result (chn->op, GNUNET_ntohll (res->op_id), GNUNET_ntohll (res->result_code), data, data_size, NULL); + + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "handle_channel_result: Received result message with OP ID %" PRIu64 "\n", + GNUNET_ntohll (res->op_id)); } @@ -558,7 +562,6 @@ channel_cleanup (struct GNUNET_PSYC_Channel *chn) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "cleaning up channel %p\n", chn); - GNUNET_assert (0); if (NULL != chn->tmit) { GNUNET_PSYC_transmit_destroy (chn->tmit); @@ -566,6 +569,7 @@ channel_cleanup (struct GNUNET_PSYC_Channel *chn) } if (NULL != chn->recv) { + GNUNET_PSYC_receive_destroy (chn->recv); chn->recv = NULL; } @@ -684,8 +688,11 @@ master_connect (struct GNUNET_PSYC_Master *mst) GNUNET_MQ_handler_end () }; - chn->mq = GNUNET_CLIENT_connect (chn->cfg, "psyc", - handlers, master_disconnected, mst); + chn->mq = GNUNET_CLIENT_connect (chn->cfg, + "psyc", + handlers, + &master_disconnected, + mst); GNUNET_assert (NULL != chn->mq); chn->tmit = GNUNET_PSYC_transmit_create (chn->mq); @@ -1244,6 +1251,9 @@ GNUNET_PSYC_channel_slave_add (struct GNUNET_PSYC_Channel *chn, req->did_join = GNUNET_YES; req->op_id = GNUNET_htonll (GNUNET_OP_add (chn->op, result_cb, cls, NULL)); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "GNUNET_PSYC_channel_slave_add, OP ID: %" PRIu64 "\n", + GNUNET_ntohll (req->op_id)); GNUNET_MQ_send (chn->mq, env); } @@ -1294,6 +1304,9 @@ GNUNET_PSYC_channel_slave_remove (struct GNUNET_PSYC_Channel *chn, req->did_join = GNUNET_NO; req->op_id = GNUNET_htonll (GNUNET_OP_add (chn->op, result_cb, cls, NULL)); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "GNUNET_PSYC_channel_slave_remove, OP ID: %" PRIu64 "\n", + GNUNET_ntohll (req->op_id)); GNUNET_MQ_send (chn->mq, env); } @@ -1332,6 +1345,10 @@ channel_history_replay (struct GNUNET_PSYC_Channel *chn, req->message_limit = GNUNET_htonll (message_limit); req->flags = htonl (flags); req->op_id = GNUNET_htonll (hist->op_id); + + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "channel_history_replay, OP ID: %" PRIu64 "\n", + GNUNET_ntohll (req->op_id)); GNUNET_memcpy (&req[1], method_prefix, method_size); GNUNET_MQ_send (chn->mq, env); @@ -1470,6 +1487,11 @@ channel_state_get (struct GNUNET_PSYC_Channel *chn, struct GNUNET_MQ_Envelope * env = GNUNET_MQ_msg_extra (req, name_size, type); req->op_id = GNUNET_htonll (sr->op_id); + + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "channel_state_get, OP ID: %" PRIu64 "\n", + GNUNET_ntohll (req->op_id)); + GNUNET_memcpy (&req[1], name, name_size); GNUNET_MQ_send (chn->mq, env); -- cgit v1.2.3 From 1e0f7ee75e5c6123916b70a870c81e4f56671437 Mon Sep 17 00:00:00 2001 From: lurchi Date: Sun, 24 Dec 2017 13:25:41 +0100 Subject: be more clear about test procedure (use self-explanatory function names) --- src/psyc/test_psyc.c | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) (limited to 'src/psyc') diff --git a/src/psyc/test_psyc.c b/src/psyc/test_psyc.c index 03a1890b1..370befb9d 100644 --- a/src/psyc/test_psyc.c +++ b/src/psyc/test_psyc.c @@ -754,16 +754,23 @@ slave_add () } +static void +schedule_second_slave_join (void *cls) +{ + slave_join (TEST_SLAVE_JOIN_ACCEPT); +} + + static void first_slave_parted (void *cls) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "First slave parted.\n"); - slave_join (TEST_SLAVE_JOIN_ACCEPT); + GNUNET_SCHEDULER_add_now (&schedule_second_slave_join, NULL); } static void -schedule_slave_part (void *cls) +schedule_first_slave_part (void *cls) { GNUNET_PSYC_slave_part (slv, GNUNET_NO, &first_slave_parted, NULL); } @@ -783,7 +790,7 @@ join_decision_cb (void *cls, case TEST_SLAVE_JOIN_REJECT: GNUNET_assert (0 == is_admitted); GNUNET_assert (1 == join_req_count); - GNUNET_SCHEDULER_add_now (&schedule_slave_part, NULL); + GNUNET_SCHEDULER_add_now (&schedule_first_slave_part, NULL); break; case TEST_SLAVE_JOIN_ACCEPT: @@ -844,11 +851,18 @@ slave_join (int t) struct GNUNET_PSYC_Message * join_msg = GNUNET_PSYC_message_create ("_request_join", env, "some data", 9); - slv = GNUNET_PSYC_slave_join (cfg, &channel_pub_key, slave_key, + slv = GNUNET_PSYC_slave_join (cfg, + &channel_pub_key, + slave_key, GNUNET_PSYC_SLAVE_JOIN_NONE, - &origin, 0, NULL, - &slave_message_cb, &slave_message_part_cb, - &slave_connect_cb, &join_decision_cb, NULL, + &origin, + 0, + NULL, + &slave_message_cb, + &slave_message_part_cb, + &slave_connect_cb, + &join_decision_cb, + NULL, join_msg); GNUNET_free (join_msg); slv_chn = GNUNET_PSYC_slave_get_channel (slv); -- cgit v1.2.3 From d5698902c09f47a7fcb544e8fbb5da9984ee1384 Mon Sep 17 00:00:00 2001 From: lurchi Date: Tue, 26 Dec 2017 18:05:40 +0100 Subject: test_psyc: less services and less noise in the output --- src/psyc/test_psyc.conf | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/psyc') diff --git a/src/psyc/test_psyc.conf b/src/psyc/test_psyc.conf index e69de29bb..e00a614d2 100644 --- a/src/psyc/test_psyc.conf +++ b/src/psyc/test_psyc.conf @@ -0,0 +1,16 @@ +@INLINE@ ../../contrib/no_forcestart.conf + +[PATHS] +GNUNET_TEST_HOME = /tmp/gnunet-test-psyc/ + +[transport] +PLUGINS = tcp + +[nat] +DISABLEV6 = YES +ENABLE_UPNP = NO +BEHIND_NAT = NO +ALLOW_NAT = NO +INTERNAL_ADDRESS = 127.0.0.1 +EXTERNAL_ADDRESS = 127.0.0.1 + -- cgit v1.2.3 From aef12de46c7a1f7a00cad0c66efb750cfe59d708 Mon Sep 17 00:00:00 2001 From: lurchi Date: Tue, 26 Dec 2017 18:16:26 +0100 Subject: result is a boolean; stylistic changes --- src/psyc/gnunet-service-psyc.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/psyc') diff --git a/src/psyc/gnunet-service-psyc.c b/src/psyc/gnunet-service-psyc.c index 35cc5551d..8b5c69a65 100644 --- a/src/psyc/gnunet-service-psyc.c +++ b/src/psyc/gnunet-service-psyc.c @@ -1696,7 +1696,7 @@ store_recv_slave_counters (void *cls, int result, uint64_t max_fragment_id, res.result_code = htonl (result); res.max_message_id = GNUNET_htonll (max_message_id); - if (GNUNET_OK == result || GNUNET_NO == result) + if (GNUNET_YES == result || GNUNET_NO == result) { chn->max_message_id = max_message_id; chn->max_state_message_id = max_state_message_id; @@ -1901,7 +1901,7 @@ handle_client_slave_join (void *cls, GNUNET_CONTAINER_multihashmap_put (slaves, &chn->pub_key_hash, chn, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); chn->store_op = GNUNET_PSYCSTORE_counters_get (store, &chn->pub_key, - &store_recv_slave_counters, slv); + &store_recv_slave_counters, slv); } else { @@ -1948,8 +1948,9 @@ handle_client_slave_join (void *cls, } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "%p Client connected as slave to channel %s.\n", - slv, GNUNET_h2s (&chn->pub_key_hash)); + "Client %p connected as slave to channel %s.\n", + client, + GNUNET_h2s (&chn->pub_key_hash)); struct ClientList *cli = GNUNET_malloc (sizeof (*cli)); cli->client = client; @@ -2399,7 +2400,9 @@ handle_client_psyc_message (void *cls, if (GNUNET_YES != chn->is_ready) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "%p Channel is not ready yet, disconnecting client.\n", chn); + "%p Channel is not ready yet, disconnecting client %p.\n", + chn, + client); GNUNET_break (0); GNUNET_SERVICE_client_drop (client); return; -- cgit v1.2.3 From af9ae1f37cbd418abd14f1fab0bb10210f68fefa Mon Sep 17 00:00:00 2001 From: lurchi Date: Sat, 30 Dec 2017 18:44:03 +0100 Subject: master/slave pointers must not be NULL immediatly after sending leave request --- src/psyc/gnunet-service-psyc.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) (limited to 'src/psyc') diff --git a/src/psyc/gnunet-service-psyc.c b/src/psyc/gnunet-service-psyc.c index 8b5c69a65..740886423 100644 --- a/src/psyc/gnunet-service-psyc.c +++ b/src/psyc/gnunet-service-psyc.c @@ -279,7 +279,7 @@ struct Channel * Is the client disconnected? * #GNUNET_YES or #GNUNET_NO */ - uint8_t is_disconnected; + uint8_t is_disconnecting; /** * Is this a channel master (#GNUNET_YES), or slave (#GNUNET_NO)? @@ -508,8 +508,6 @@ cleanup_master (struct Master *mst) { struct Channel *chn = &mst->channel; - //if (NULL != mst->origin) - // GNUNET_MULTICAST_origin_stop (mst->origin, cleanup_cb, cleanup_cls); GNUNET_CONTAINER_multihashmap_destroy (mst->join_reqs); GNUNET_CONTAINER_multihashmap_remove (masters, &chn->pub_key_hash, mst); } @@ -546,11 +544,6 @@ cleanup_slave (struct Slave *slv) GNUNET_free (slv->relays); slv->relays = NULL; } - //if (NULL != slv->member) - //{ - // GNUNET_MULTICAST_member_part (slv->member, cleanup_cb, cleanup_cls); - // slv->member = NULL; - //} GNUNET_CONTAINER_multihashmap_remove (slaves, &chn->pub_key_hash, slv); } @@ -646,7 +639,7 @@ client_notify_disconnect (void *cls, chn, (GNUNET_YES == chn->is_master) ? "master" : "slave", GNUNET_h2s (&chn->pub_key_hash)); - chn->is_disconnected = GNUNET_YES; + chn->is_disconnecting = GNUNET_YES; cleanup_channel (chn); } } @@ -2052,6 +2045,7 @@ handle_client_part_request (void *cls, { struct Client *c = cls; + c->channel->is_disconnecting = GNUNET_YES; if (GNUNET_YES == c->channel->is_master) { struct Master *mst = (struct Master *) c->channel; @@ -2061,7 +2055,6 @@ handle_client_part_request (void *cls, mst); GNUNET_assert (NULL != mst->origin); GNUNET_MULTICAST_origin_stop (mst->origin, channel_part_cb, c->client); - mst->origin = NULL; } else { @@ -2072,7 +2065,6 @@ handle_client_part_request (void *cls, slv); GNUNET_assert (NULL != slv->member); GNUNET_MULTICAST_member_part (slv->member, channel_part_cb, c->client); - slv->member = NULL; } GNUNET_SERVICE_client_continue (c->client); } @@ -2137,7 +2129,7 @@ transmit_notify (void *cls, size_t *data_size, void *data) { GNUNET_SCHEDULER_add_now (&schedule_transmit_message, chn); } - else if (GNUNET_YES == chn->is_disconnected + else if (GNUNET_YES == chn->is_disconnecting && tmit_msg->last_ptype < GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_END) { /* FIXME: handle partial message (when still in_transmit) */ -- cgit v1.2.3 From 1d6a686ccc73ce02fd6e22decb82425012a82a04 Mon Sep 17 00:00:00 2001 From: lurchi Date: Sat, 30 Dec 2017 20:37:01 +0100 Subject: cleanup --- src/psyc/gnunet-service-psyc.c | 30 +++++++++++++----------------- src/social/social_api.c | 16 ++++------------ src/social/test_social.c | 2 +- 3 files changed, 18 insertions(+), 30 deletions(-) (limited to 'src/psyc') diff --git a/src/psyc/gnunet-service-psyc.c b/src/psyc/gnunet-service-psyc.c index 740886423..cf161435a 100644 --- a/src/psyc/gnunet-service-psyc.c +++ b/src/psyc/gnunet-service-psyc.c @@ -1188,12 +1188,12 @@ fragment_queue_insert (struct Channel *chn, else if (GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_METHOD == first_ptype || frag_offset == fragq->header_size) { /* header is now complete */ - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%p Header of message %" PRIu64 " is complete.\n", chn, GNUNET_ntohll (mmsg->message_id)); - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%p Adding message %" PRIu64 " to queue.\n", chn, GNUNET_ntohll (mmsg->message_id)); @@ -1201,7 +1201,7 @@ fragment_queue_insert (struct Channel *chn, } else { - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%p Header of message %" PRIu64 " is NOT complete yet: %" PRIu64 " != %" PRIu64 "\n", chn, GNUNET_ntohll (mmsg->message_id), @@ -1216,7 +1216,7 @@ fragment_queue_insert (struct Channel *chn, if (frag_offset == fragq->size) fragq->state = MSG_FRAG_STATE_END; else - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%p Message %" PRIu64 " is NOT complete yet: %" PRIu64 " != %" PRIu64 "\n", chn, GNUNET_ntohll (mmsg->message_id), @@ -1271,7 +1271,7 @@ static void fragment_queue_run (struct Channel *chn, uint64_t msg_id, struct FragmentQueue *fragq, uint8_t drop) { - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%p Running message fragment queue for message %" PRIu64 " (state: %u).\n", chn, msg_id, @@ -1399,7 +1399,7 @@ store_recv_state_modify_result (void *cls, int64_t result, static uint64_t message_queue_run (struct Channel *chn) { - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%p Running message queue.\n", chn); uint64_t n = 0; uint64_t msg_id; @@ -1407,7 +1407,7 @@ message_queue_run (struct Channel *chn) while (GNUNET_YES == GNUNET_CONTAINER_heap_peek2 (chn->recv_msgs, NULL, &msg_id)) { - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%p Processing message %" PRIu64 " in queue.\n", chn, msg_id); struct GNUNET_HashCode msg_id_hash; hash_key_from_hll (&msg_id_hash, msg_id); @@ -1417,7 +1417,7 @@ message_queue_run (struct Channel *chn) if (NULL == fragq || fragq->state <= MSG_FRAG_STATE_HEADER) { - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%p No fragq (%p) or header not complete.\n", chn, fragq); break; @@ -1439,7 +1439,7 @@ message_queue_run (struct Channel *chn) && (chn->max_message_id != msg_id - 1 && chn->max_message_id != msg_id)) { - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%p Out of order message. " "(%" PRIu64 " != %" PRIu64 " - 1)\n", chn, chn->max_message_id, msg_id); @@ -1455,7 +1455,7 @@ message_queue_run (struct Channel *chn) { if (msg_id - fragq->state_delta != chn->max_state_message_id) { - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%p Out of order stateful message. " "(%" PRIu64 " - %" PRIu64 " != %" PRIu64 ")\n", chn, msg_id, fragq->state_delta, chn->max_state_message_id); @@ -1501,8 +1501,6 @@ message_queue_run (struct Channel *chn) static uint64_t message_queue_drop (struct Channel *chn) { - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "%p Dropping message queue.\n", chn); uint64_t n = 0; uint64_t msg_id; while (GNUNET_YES == GNUNET_CONTAINER_heap_peek2 (chn->recv_msgs, NULL, @@ -2241,12 +2239,10 @@ transmit_message (struct Channel *chn) static void master_queue_message (struct Master *mst, struct TransmitMessage *tmit_msg) { - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "%p master_queue_message()\n", mst); - if (GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_METHOD == tmit_msg->first_ptype) { tmit_msg->id = ++mst->max_message_id; - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%p master_queue_message: message_id=%" PRIu64 "\n", mst, tmit_msg->id); struct GNUNET_PSYC_MessageMethod *pmeth @@ -2258,7 +2254,7 @@ master_queue_message (struct Master *mst, struct TransmitMessage *tmit_msg) } else if (pmeth->flags & GNUNET_PSYC_MASTER_TRANSMIT_STATE_MODIFY) { - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%p master_queue_message: state_delta=%" PRIu64 "\n", mst, tmit_msg->id - mst->max_state_message_id); pmeth->state_delta = GNUNET_htonll (tmit_msg->id @@ -2267,7 +2263,7 @@ master_queue_message (struct Master *mst, struct TransmitMessage *tmit_msg) } else { - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%p master_queue_message: state not modified\n", mst); pmeth->state_delta = GNUNET_htonll (GNUNET_PSYC_STATE_NOT_MODIFIED); } diff --git a/src/social/social_api.c b/src/social/social_api.c index 48e376404..96ddfe912 100644 --- a/src/social/social_api.c +++ b/src/social/social_api.c @@ -397,12 +397,9 @@ guest_cleanup (struct GNUNET_SOCIAL_Guest *gst) static void place_cleanup (struct GNUNET_SOCIAL_Place *plc) { - struct GNUNET_HashCode place_pub_hash; - - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "place_cleanup\n"); - - GNUNET_CRYPTO_hash (&plc->pub_key, sizeof (plc->pub_key), &place_pub_hash); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "cleaning up place %p\n", + plc); if (NULL != plc->tmit) { GNUNET_PSYC_transmit_destroy (plc->tmit); @@ -433,11 +430,6 @@ place_cleanup (struct GNUNET_SOCIAL_Place *plc) static void place_disconnect (struct GNUNET_SOCIAL_Place *plc) { - struct GNUNET_HashCode place_pub_hash; - - GNUNET_CRYPTO_hash (&plc->pub_key, - sizeof (plc->pub_key), - &place_pub_hash); place_cleanup (plc); } @@ -1515,7 +1507,7 @@ GNUNET_SOCIAL_host_announce (struct GNUNET_SOCIAL_Host *hst, void *notify_data_cls, enum GNUNET_SOCIAL_AnnounceFlags flags) { - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "PSYC_transmit_message for host, method: %s\n", method_name); if (GNUNET_OK == diff --git a/src/social/test_social.c b/src/social/test_social.c index 61dbd121c..4d95cf005 100644 --- a/src/social/test_social.c +++ b/src/social/test_social.c @@ -359,7 +359,7 @@ host_farewell2 (void *cls, const struct GNUNET_SOCIAL_Nym *nym, struct GNUNET_PSYC_Environment *env) { - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, "Nym left the place again.\n"); GNUNET_SCHEDULER_add_now (&schedule_host_leave, NULL); } -- cgit v1.2.3