aboutsummaryrefslogtreecommitdiff
path: root/src/set
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2014-11-30 16:53:11 +0000
committerChristian Grothoff <christian@grothoff.org>2014-11-30 16:53:11 +0000
commit6e92863ee3b53577d31f4a0e3bf5bad8e47f4437 (patch)
tree1f47c5b50299fc4ddddc474cb091b8dc196480b1 /src/set
parent3ff74fa1dac7f7b839930959962f4f1c843708bd (diff)
downloadgnunet-6e92863ee3b53577d31f4a0e3bf5bad8e47f4437.tar.gz
gnunet-6e92863ee3b53577d31f4a0e3bf5bad8e47f4437.zip
-use keep as RC to address #3561
Diffstat (limited to 'src/set')
-rw-r--r--src/set/gnunet-service-set.c4
-rw-r--r--src/set/gnunet-service-set.h7
-rw-r--r--src/set/gnunet-service-set_intersection.c4
-rw-r--r--src/set/gnunet-service-set_union.c6
4 files changed, 12 insertions, 9 deletions
diff --git a/src/set/gnunet-service-set.c b/src/set/gnunet-service-set.c
index c40ac9c53..746a9da02 100644
--- a/src/set/gnunet-service-set.c
+++ b/src/set/gnunet-service-set.c
@@ -1388,6 +1388,7 @@ channel_end_cb (void *cls,
1388 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1388 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1389 "channel_end_cb called\n"); 1389 "channel_end_cb called\n");
1390 op->channel = NULL; 1390 op->channel = NULL;
1391 op->keep++;
1391 /* the vt can be null if a client already requested canceling op. */ 1392 /* the vt can be null if a client already requested canceling op. */
1392 if (NULL != op->vt) 1393 if (NULL != op->vt)
1393 { 1394 {
@@ -1395,7 +1396,8 @@ channel_end_cb (void *cls,
1395 "calling peer disconnect due to channel end\n"); 1396 "calling peer disconnect due to channel end\n");
1396 op->vt->peer_disconnect (op); 1397 op->vt->peer_disconnect (op);
1397 } 1398 }
1398 if (GNUNET_YES != op->keep) 1399 op->keep--;
1400 if (0 == op->keep)
1399 { 1401 {
1400 /* cadet will never call us with the context again! */ 1402 /* cadet will never call us with the context again! */
1401 GNUNET_free (op); 1403 GNUNET_free (op);
diff --git a/src/set/gnunet-service-set.h b/src/set/gnunet-service-set.h
index ab8155883..b2904dc06 100644
--- a/src/set/gnunet-service-set.h
+++ b/src/set/gnunet-service-set.h
@@ -388,10 +388,11 @@ struct Operation
388 unsigned int generation_created; 388 unsigned int generation_created;
389 389
390 /** 390 /**
391 * Set to #GNUNET_YES if the set service should not free the 391 * Incremented whenever (during shutdown) some component still
392 * operation, as it is still needed (e.g. in some scheduled task). 392 * needs to do something with this before the operation is freed.
393 * (Used as a reference counter, but only during termination.)
393 */ 394 */
394 int keep; 395 unsigned int keep;
395}; 396};
396 397
397 398
diff --git a/src/set/gnunet-service-set_intersection.c b/src/set/gnunet-service-set_intersection.c
index ceb6a3ccb..ed21cd1bb 100644
--- a/src/set/gnunet-service-set_intersection.c
+++ b/src/set/gnunet-service-set_intersection.c
@@ -549,7 +549,7 @@ send_remaining_elements (void *cls)
549 { 549 {
550 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 550 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
551 "Sending done and destroy because iterator ran out\n"); 551 "Sending done and destroy because iterator ran out\n");
552 op->keep = GNUNET_NO; 552 op->keep--;
553 send_client_done_and_destroy (op); 553 send_client_done_and_destroy (op);
554 return; 554 return;
555 } 555 }
@@ -907,7 +907,7 @@ finish_and_destroy (struct Operation *op)
907 GNUNET_CONTAINER_multihashmap_size (op->state->my_elements)); 907 GNUNET_CONTAINER_multihashmap_size (op->state->my_elements));
908 op->state->full_result_iter 908 op->state->full_result_iter
909 = GNUNET_CONTAINER_multihashmap_iterator_create (op->state->my_elements); 909 = GNUNET_CONTAINER_multihashmap_iterator_create (op->state->my_elements);
910 op->keep = GNUNET_YES; 910 op->keep++;
911 send_remaining_elements (op); 911 send_remaining_elements (op);
912 return; 912 return;
913 } 913 }
diff --git a/src/set/gnunet-service-set_union.c b/src/set/gnunet-service-set_union.c
index 459996eca..53c5ef43c 100644
--- a/src/set/gnunet-service-set_union.c
+++ b/src/set/gnunet-service-set_union.c
@@ -994,7 +994,6 @@ send_done_and_destroy (void *cls)
994 struct Operation *op = cls; 994 struct Operation *op = cls;
995 struct GNUNET_MQ_Envelope *ev; 995 struct GNUNET_MQ_Envelope *ev;
996 struct GNUNET_SET_ResultMessage *rm; 996 struct GNUNET_SET_ResultMessage *rm;
997 int keep = op->keep;
998 997
999 ev = GNUNET_MQ_msg (rm, GNUNET_MESSAGE_TYPE_SET_RESULT); 998 ev = GNUNET_MQ_msg (rm, GNUNET_MESSAGE_TYPE_SET_RESULT);
1000 rm->request_id = htonl (op->spec->client_request_id); 999 rm->request_id = htonl (op->spec->client_request_id);
@@ -1002,7 +1001,8 @@ send_done_and_destroy (void *cls)
1002 rm->element_type = htons (0); 1001 rm->element_type = htons (0);
1003 GNUNET_MQ_send (op->spec->set->client_mq, ev); 1002 GNUNET_MQ_send (op->spec->set->client_mq, ev);
1004 _GSS_operation_destroy (op, GNUNET_YES); 1003 _GSS_operation_destroy (op, GNUNET_YES);
1005 if (GNUNET_YES == keep) 1004 op->keep--;
1005 if (0 == op->keep)
1006 GNUNET_free (op); 1006 GNUNET_free (op);
1007} 1007}
1008 1008
@@ -1081,7 +1081,7 @@ finish_and_destroy (struct Operation *op)
1081 if (GNUNET_SET_RESULT_FULL == op->spec->result_mode) 1081 if (GNUNET_SET_RESULT_FULL == op->spec->result_mode)
1082 { 1082 {
1083 /* prevent that the op is free'd by the tunnel end handler */ 1083 /* prevent that the op is free'd by the tunnel end handler */
1084 op->keep = GNUNET_YES; 1084 op->keep++;
1085 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1085 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1086 "sending full result set\n"); 1086 "sending full result set\n");
1087 GNUNET_assert (NULL == op->state->full_result_iter); 1087 GNUNET_assert (NULL == op->state->full_result_iter);