From 4fe6ffb8fbffbcc728118f20326fc699295aa1fc Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Wed, 4 Oct 2017 13:59:39 +0200 Subject: delay cancelling listen operations to avoid rejecting operations before they had a chance to start, fixes misc. test case failures related to set --- src/include/gnunet_set_service.h | 2 ++ src/scalarproduct/gnunet-service-scalarproduct-ecc_alice.c | 8 -------- src/scalarproduct/gnunet-service-scalarproduct_alice.c | 8 +------- src/set/gnunet-service-set.c | 6 ++++++ src/set/test_set_intersection_result_full.c | 2 -- src/set/test_set_union_result_symmetric.c | 2 -- 6 files changed, 9 insertions(+), 19 deletions(-) diff --git a/src/include/gnunet_set_service.h b/src/include/gnunet_set_service.h index 6e822d82e..dfe9b8954 100644 --- a/src/include/gnunet_set_service.h +++ b/src/include/gnunet_set_service.h @@ -452,6 +452,8 @@ GNUNET_SET_listen (const struct GNUNET_CONFIGURATION_Handle *cfg, /** * Cancel the given listen operation. After calling cancel, the * listen callback for this listen handle will not be called again. + * Note that cancelling a listen operation will automatically reject + * all operations that have not yet been accepted. * * @param lh handle for the listen operation */ diff --git a/src/scalarproduct/gnunet-service-scalarproduct-ecc_alice.c b/src/scalarproduct/gnunet-service-scalarproduct-ecc_alice.c index c0b33f8ef..57f275c81 100644 --- a/src/scalarproduct/gnunet-service-scalarproduct-ecc_alice.c +++ b/src/scalarproduct/gnunet-service-scalarproduct-ecc_alice.c @@ -260,8 +260,6 @@ destroy_service_session (struct AliceServiceSession *s) } if (NULL != s->intersection_listen) { - LOG (GNUNET_ERROR_TYPE_DEBUG, - "Set intersection, listen still up!\n"); GNUNET_SET_listen_cancel (s->intersection_listen); s->intersection_listen = NULL; } @@ -274,8 +272,6 @@ destroy_service_session (struct AliceServiceSession *s) } if (NULL != s->intersection_set) { - LOG (GNUNET_ERROR_TYPE_DEBUG, - "Set intersection, set still there!\n"); GNUNET_SET_destroy (s->intersection_set); s->intersection_set = NULL; } @@ -809,10 +805,6 @@ cb_intersection_request_alice (void *cls, prepare_client_end_notification (s); return; } - GNUNET_SET_destroy (s->intersection_set); - s->intersection_set = NULL; - GNUNET_SET_listen_cancel (s->intersection_listen); - s->intersection_listen = NULL; } diff --git a/src/scalarproduct/gnunet-service-scalarproduct_alice.c b/src/scalarproduct/gnunet-service-scalarproduct_alice.c index a55d03900..fcb1ce032 100644 --- a/src/scalarproduct/gnunet-service-scalarproduct_alice.c +++ b/src/scalarproduct/gnunet-service-scalarproduct_alice.c @@ -243,8 +243,6 @@ free_element_cb (void *cls, static void destroy_service_session (struct AliceServiceSession *s) { - unsigned int i; - if (GNUNET_YES == s->in_destroy) return; s->in_destroy = GNUNET_YES; @@ -285,7 +283,7 @@ destroy_service_session (struct AliceServiceSession *s) } if (NULL != s->sorted_elements) { - for (i=0;iused_element_count;i++) + for (unsigned int i=0;iused_element_count;i++) gcry_mpi_release (s->sorted_elements[i].value); GNUNET_free (s->sorted_elements); s->sorted_elements = NULL; @@ -1043,10 +1041,6 @@ cb_intersection_request_alice (void *cls, prepare_client_end_notification (s); return; } - GNUNET_SET_destroy (s->intersection_set); - s->intersection_set = NULL; - GNUNET_SET_listen_cancel (s->intersection_listen); - s->intersection_listen = NULL; } diff --git a/src/set/gnunet-service-set.c b/src/set/gnunet-service-set.c index 617a33661..42d06b275 100644 --- a/src/set/gnunet-service-set.c +++ b/src/set/gnunet-service-set.c @@ -628,7 +628,13 @@ client_disconnect_cb (void *cls, GNUNET_CADET_close_port (listener->open_port); listener->open_port = NULL; while (NULL != (op = listener->op_head)) + { + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Destroying incoming operation `%u' from peer `%s'\n", + (unsigned int) op->client_request_id, + GNUNET_i2s (&op->peer)); incoming_destroy (op); + } GNUNET_CONTAINER_DLL_remove (listener_head, listener_tail, listener); diff --git a/src/set/test_set_intersection_result_full.c b/src/set/test_set_intersection_result_full.c index a36aae4d5..16de983cf 100644 --- a/src/set/test_set_intersection_result_full.c +++ b/src/set/test_set_intersection_result_full.c @@ -131,8 +131,6 @@ listen_cb (void *cls, "starting intersection by accepting and committing\n"); GNUNET_assert (NULL != context_msg); GNUNET_assert (ntohs (context_msg->type) == GNUNET_MESSAGE_TYPE_DUMMY); - GNUNET_SET_listen_cancel (listen_handle); - listen_handle = NULL; oh2 = GNUNET_SET_accept (request, GNUNET_SET_RESULT_FULL, (struct GNUNET_SET_Option[]) { 0 }, diff --git a/src/set/test_set_union_result_symmetric.c b/src/set/test_set_union_result_symmetric.c index f81c7b8f7..3008e5aac 100644 --- a/src/set/test_set_union_result_symmetric.c +++ b/src/set/test_set_union_result_symmetric.c @@ -182,8 +182,6 @@ listen_cb (void *cls, GNUNET_assert (ntohs (context_msg->type) == GNUNET_MESSAGE_TYPE_DUMMY); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "listen cb called\n"); - GNUNET_SET_listen_cancel (listen_handle); - listen_handle = NULL; oh2 = GNUNET_SET_accept (request, GNUNET_SET_RESULT_SYMMETRIC, (struct GNUNET_SET_Option[]) { 0 }, -- cgit v1.2.3