aboutsummaryrefslogtreecommitdiff
path: root/src/set
diff options
context:
space:
mode:
Diffstat (limited to 'src/set')
-rw-r--r--src/set/gnunet-service-set.c31
-rw-r--r--src/set/gnunet-service-set.h9
-rw-r--r--src/set/gnunet-service-set_union.c23
3 files changed, 35 insertions, 28 deletions
diff --git a/src/set/gnunet-service-set.c b/src/set/gnunet-service-set.c
index 217b89d6d..75122395d 100644
--- a/src/set/gnunet-service-set.c
+++ b/src/set/gnunet-service-set.c
@@ -221,11 +221,7 @@ incoming_destroy (struct Operation *op)
221 GNUNET_SCHEDULER_cancel (op->timeout_task); 221 GNUNET_SCHEDULER_cancel (op->timeout_task);
222 op->timeout_task = NULL; 222 op->timeout_task = NULL;
223 } 223 }
224 if (NULL != (channel = op->channel)) 224 _GSS_operation_destroy2 (op);
225 {
226 op->channel = NULL;
227 GNUNET_CADET_channel_destroy (channel);
228 }
229} 225}
230 226
231 227
@@ -1199,9 +1195,30 @@ channel_end_cb (void *channel_ctx,
1199{ 1195{
1200 struct Operation *op = channel_ctx; 1196 struct Operation *op = channel_ctx;
1201 1197
1198 op->channel = NULL;
1199 _GSS_operation_destroy2 (op);
1200}
1201
1202
1203/**
1204 * This function probably should not exist
1205 * and be replaced by inlining more specific
1206 * logic in the various places where it is called.
1207 */
1208void
1209_GSS_operation_destroy2 (struct Operation *op)
1210{
1211 struct GNUNET_CADET_Channel *channel;
1212
1202 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1213 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1203 "channel_end_cb called\n"); 1214 "channel_end_cb called\n");
1204 op->channel = NULL; 1215 if (NULL != (channel = op->channel))
1216 {
1217 /* This will free op; called conditionally as this helper function
1218 is also called from within the channel disconnect handler. */
1219 op->channel = NULL;
1220 GNUNET_CADET_channel_destroy (channel);
1221 }
1205 if (NULL != op->listener) 1222 if (NULL != op->listener)
1206 incoming_destroy (op); 1223 incoming_destroy (op);
1207 else if (NULL != op->set) 1224 else if (NULL != op->set)
@@ -1376,7 +1393,7 @@ handle_client_reject (void *cls,
1376 "Peer request (op %u, app %s) rejected by client\n", 1393 "Peer request (op %u, app %s) rejected by client\n",
1377 op->listener->operation, 1394 op->listener->operation,
1378 GNUNET_h2s (&cs->listener->app_id)); 1395 GNUNET_h2s (&cs->listener->app_id));
1379 GNUNET_CADET_channel_destroy (op->channel); 1396 _GSS_operation_destroy2 (op);
1380 GNUNET_SERVICE_client_continue (cs->client); 1397 GNUNET_SERVICE_client_continue (cs->client);
1381} 1398}
1382 1399
diff --git a/src/set/gnunet-service-set.h b/src/set/gnunet-service-set.h
index f7c262eac..a58b22995 100644
--- a/src/set/gnunet-service-set.h
+++ b/src/set/gnunet-service-set.h
@@ -630,6 +630,15 @@ _GSS_operation_destroy (struct Operation *op,
630 630
631 631
632/** 632/**
633 * This function probably should not exist
634 * and be replaced by inlining more specific
635 * logic in the various places where it is called.
636 */
637void
638_GSS_operation_destroy2 (struct Operation *op);
639
640
641/**
633 * Get the table with implementing functions for set union. 642 * Get the table with implementing functions for set union.
634 * 643 *
635 * @return the operation specific VTable 644 * @return the operation specific VTable
diff --git a/src/set/gnunet-service-set_union.c b/src/set/gnunet-service-set_union.c
index c3c14f1ba..8c0c52d64 100644
--- a/src/set/gnunet-service-set_union.c
+++ b/src/set/gnunet-service-set_union.c
@@ -1367,25 +1367,6 @@ send_client_element (struct Operation *op,
1367 1367
1368 1368
1369/** 1369/**
1370 * Destroy remote channel.
1371 *
1372 * @param op operation
1373 */
1374void destroy_channel (struct Operation *op)
1375{
1376 struct GNUNET_CADET_Channel *channel;
1377
1378 if (NULL != (channel = op->channel))
1379 {
1380 /* This will free op; called conditionally as this helper function
1381 is also called from within the channel disconnect handler. */
1382 op->channel = NULL;
1383 GNUNET_CADET_channel_destroy (channel);
1384 }
1385}
1386
1387
1388/**
1389 * Signal to the client that the operation has finished and 1370 * Signal to the client that the operation has finished and
1390 * destroy the operation. 1371 * destroy the operation.
1391 * 1372 *
@@ -1467,7 +1448,7 @@ maybe_finish (struct Operation *op)
1467 { 1448 {
1468 op->state->phase = PHASE_DONE; 1449 op->state->phase = PHASE_DONE;
1469 send_client_done (op); 1450 send_client_done (op);
1470 destroy_channel (op); 1451 _GSS_operation_destroy2 (op);
1471 } 1452 }
1472 } 1453 }
1473} 1454}
@@ -1896,7 +1877,7 @@ handle_union_p2p_full_done (void *cls,
1896 op->state->phase = PHASE_DONE; 1877 op->state->phase = PHASE_DONE;
1897 GNUNET_CADET_receive_done (op->channel); 1878 GNUNET_CADET_receive_done (op->channel);
1898 send_client_done (op); 1879 send_client_done (op);
1899 destroy_channel (op); 1880 _GSS_operation_destroy2 (op);
1900 return; 1881 return;
1901 } 1882 }
1902 break; 1883 break;