aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/set/gnunet-service-set.c17
-rw-r--r--src/set/gnunet-service-set.h8
-rw-r--r--src/set/gnunet-service-set_union.c5
-rw-r--r--src/set/test_set_union_result_full.c15
-rw-r--r--src/util/mq.c9
5 files changed, 44 insertions, 10 deletions
diff --git a/src/set/gnunet-service-set.c b/src/set/gnunet-service-set.c
index cf03b06aa..428a9d002 100644
--- a/src/set/gnunet-service-set.c
+++ b/src/set/gnunet-service-set.c
@@ -955,8 +955,8 @@ handle_client_evaluate (void *cls,
955 GNUNET_CONTAINER_DLL_insert (set->ops_head, set->ops_tail, op); 955 GNUNET_CONTAINER_DLL_insert (set->ops_head, set->ops_tail, op);
956 956
957 op->channel = GNUNET_MESH_channel_create (mesh, op, &msg->target_peer, 957 op->channel = GNUNET_MESH_channel_create (mesh, op, &msg->target_peer,
958 GNUNET_APPLICATION_TYPE_SET, 958 GNUNET_APPLICATION_TYPE_SET,
959 GNUNET_MESH_OPTION_RELIABLE); 959 GNUNET_MESH_OPTION_RELIABLE);
960 960
961 op->mq = GNUNET_MESH_mq_create (op->channel); 961 op->mq = GNUNET_MESH_mq_create (op->channel);
962 962
@@ -1261,17 +1261,28 @@ channel_new_cb (void *cls,
1261 */ 1261 */
1262static void 1262static void
1263channel_end_cb (void *cls, 1263channel_end_cb (void *cls,
1264 const struct GNUNET_MESH_Channel *channel, void *channel_ctx) 1264 const struct GNUNET_MESH_Channel *channel, void *channel_ctx)
1265{ 1265{
1266 struct Operation *op = channel_ctx; 1266 struct Operation *op = channel_ctx;
1267 1267
1268 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1268 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1269 "channel end cb called\n"); 1269 "channel end cb called\n");
1270 op->channel = NULL; 1270 op->channel = NULL;
1271 /* the vt can be null if a client already requested canceling op. */
1271 if (NULL != op->vt) 1272 if (NULL != op->vt)
1273 {
1274 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1275 "calling peer disconnect due to channel end\n");
1272 op->vt->peer_disconnect (op); 1276 op->vt->peer_disconnect (op);
1277 }
1278
1279 if (GNUNET_YES == op->keep)
1280 return;
1281
1273 /* mesh will never call us with the context again! */ 1282 /* mesh will never call us with the context again! */
1274 GNUNET_free (channel_ctx); 1283 GNUNET_free (channel_ctx);
1284 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1285 "channel end cb finished\n");
1275} 1286}
1276 1287
1277 1288
diff --git a/src/set/gnunet-service-set.h b/src/set/gnunet-service-set.h
index d82c72b16..95a24119b 100644
--- a/src/set/gnunet-service-set.h
+++ b/src/set/gnunet-service-set.h
@@ -311,8 +311,6 @@ struct Operation
311 /** 311 /**
312 * GNUNET_YES if this is not a "real" set operation yet, and we still 312 * GNUNET_YES if this is not a "real" set operation yet, and we still
313 * need to wait for the other peer to give us more details. 313 * need to wait for the other peer to give us more details.
314 *
315 * //TODO: replace with state-enum
316 */ 314 */
317 int is_incoming; 315 int is_incoming;
318 316
@@ -346,6 +344,12 @@ struct Operation
346 * a linked list. 344 * a linked list.
347 */ 345 */
348 struct Operation *prev; 346 struct Operation *prev;
347
348 /**
349 * Set to GNUNET_YES if the set service should not free
350 * the operation, as it is still needed (e.g. in some scheduled task).
351 */
352 int keep;
349}; 353};
350 354
351 355
diff --git a/src/set/gnunet-service-set_union.c b/src/set/gnunet-service-set_union.c
index be50ec8d6..6bb28471a 100644
--- a/src/set/gnunet-service-set_union.c
+++ b/src/set/gnunet-service-set_union.c
@@ -982,12 +982,15 @@ send_done_and_destroy (void *cls)
982 struct Operation *op = cls; 982 struct Operation *op = cls;
983 struct GNUNET_MQ_Envelope *ev; 983 struct GNUNET_MQ_Envelope *ev;
984 struct GNUNET_SET_ResultMessage *rm; 984 struct GNUNET_SET_ResultMessage *rm;
985 int keep = op->keep;
985 ev = GNUNET_MQ_msg (rm, GNUNET_MESSAGE_TYPE_SET_RESULT); 986 ev = GNUNET_MQ_msg (rm, GNUNET_MESSAGE_TYPE_SET_RESULT);
986 rm->request_id = htonl (op->spec->client_request_id); 987 rm->request_id = htonl (op->spec->client_request_id);
987 rm->result_status = htons (GNUNET_SET_STATUS_DONE); 988 rm->result_status = htons (GNUNET_SET_STATUS_DONE);
988 rm->element_type = htons (0); 989 rm->element_type = htons (0);
989 GNUNET_MQ_send (op->spec->set->client_mq, ev); 990 GNUNET_MQ_send (op->spec->set->client_mq, ev);
990 _GSS_operation_destroy (op); 991 _GSS_operation_destroy (op);
992 if (GNUNET_YES == keep)
993 GNUNET_free (op);
991} 994}
992 995
993 996
@@ -1060,6 +1063,8 @@ finish_and_destroy (struct Operation *op)
1060 1063
1061 if (GNUNET_SET_RESULT_FULL == op->spec->result_mode) 1064 if (GNUNET_SET_RESULT_FULL == op->spec->result_mode)
1062 { 1065 {
1066 /* prevent that the op is free'd by the tunnel end handler */
1067 op->keep = GNUNET_YES;
1063 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "sending full result set\n"); 1068 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "sending full result set\n");
1064 GNUNET_assert (NULL == op->state->full_result_iter); 1069 GNUNET_assert (NULL == op->state->full_result_iter);
1065 op->state->full_result_iter = 1070 op->state->full_result_iter =
diff --git a/src/set/test_set_union_result_full.c b/src/set/test_set_union_result_full.c
index e54332b8b..2ddd65c7c 100644
--- a/src/set/test_set_union_result_full.c
+++ b/src/set/test_set_union_result_full.c
@@ -28,6 +28,8 @@
28#include "gnunet_set_service.h" 28#include "gnunet_set_service.h"
29 29
30 30
31static int ret;
32
31static struct GNUNET_PeerIdentity local_id; 33static struct GNUNET_PeerIdentity local_id;
32 34
33static struct GNUNET_HashCode app_id; 35static struct GNUNET_HashCode app_id;
@@ -50,6 +52,7 @@ result_cb_set1 (void *cls, const struct GNUNET_SET_Element *element,
50 break; 52 break;
51 case GNUNET_SET_STATUS_FAILURE: 53 case GNUNET_SET_STATUS_FAILURE:
52 printf ("set 1: failure\n"); 54 printf ("set 1: failure\n");
55 ret = 1;
53 break; 56 break;
54 case GNUNET_SET_STATUS_DONE: 57 case GNUNET_SET_STATUS_DONE:
55 printf ("set 1: done\n"); 58 printf ("set 1: done\n");
@@ -72,6 +75,7 @@ result_cb_set2 (void *cls, const struct GNUNET_SET_Element *element,
72 break; 75 break;
73 case GNUNET_SET_STATUS_FAILURE: 76 case GNUNET_SET_STATUS_FAILURE:
74 printf ("set 2: failure\n"); 77 printf ("set 2: failure\n");
78 ret = 1;
75 break; 79 break;
76 case GNUNET_SET_STATUS_DONE: 80 case GNUNET_SET_STATUS_DONE:
77 printf ("set 2: done\n"); 81 printf ("set 2: done\n");
@@ -245,11 +249,12 @@ run (void *cls,
245int 249int
246main (int argc, char **argv) 250main (int argc, char **argv)
247{ 251{
248 int ret; 252 if (0 != GNUNET_TESTING_peer_run ("test_set_api",
249 253 "test_set.conf",
250 ret = GNUNET_TESTING_peer_run ("test_set_api", 254 &run, NULL))
251 "test_set.conf", 255 {
252 &run, NULL); 256 return 0;
257 }
253 return ret; 258 return ret;
254} 259}
255 260
diff --git a/src/util/mq.c b/src/util/mq.c
index bc13bbb36..a4691ff2c 100644
--- a/src/util/mq.c
+++ b/src/util/mq.c
@@ -268,6 +268,9 @@ impl_send_continue (void *cls,
268 struct GNUNET_MQ_Handle *mq = cls; 268 struct GNUNET_MQ_Handle *mq = cls;
269 struct GNUNET_MQ_Envelope *current_envelope; 269 struct GNUNET_MQ_Envelope *current_envelope;
270 270
271 if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0)
272 return;
273
271 mq->continue_task = GNUNET_SCHEDULER_NO_TASK; 274 mq->continue_task = GNUNET_SCHEDULER_NO_TASK;
272 /* call is only valid if we're actually currently sending 275 /* call is only valid if we're actually currently sending
273 * a message */ 276 * a message */
@@ -466,6 +469,12 @@ server_client_destroy_impl (struct GNUNET_MQ_Handle *mq,
466{ 469{
467 struct ServerClientSocketState *state = impl_state; 470 struct ServerClientSocketState *state = impl_state;
468 471
472 if (NULL != state->th)
473 {
474 GNUNET_SERVER_notify_transmit_ready_cancel (state->th);
475 state->th = NULL;
476 }
477
469 GNUNET_assert (NULL != mq); 478 GNUNET_assert (NULL != mq);
470 GNUNET_assert (NULL != state); 479 GNUNET_assert (NULL != state);
471 GNUNET_SERVER_client_drop (state->client); 480 GNUNET_SERVER_client_drop (state->client);