aboutsummaryrefslogtreecommitdiff
path: root/src/set
diff options
context:
space:
mode:
Diffstat (limited to 'src/set')
-rw-r--r--src/set/gnunet-service-set_union.c49
1 files changed, 33 insertions, 16 deletions
diff --git a/src/set/gnunet-service-set_union.c b/src/set/gnunet-service-set_union.c
index 94910dd02..3e18bf08e 100644
--- a/src/set/gnunet-service-set_union.c
+++ b/src/set/gnunet-service-set_union.c
@@ -1381,6 +1381,24 @@ send_client_done (void *cls)
1381 struct GNUNET_MQ_Envelope *ev; 1381 struct GNUNET_MQ_Envelope *ev;
1382 struct GNUNET_SET_ResultMessage *rm; 1382 struct GNUNET_SET_ResultMessage *rm;
1383 1383
1384 if (GNUNET_YES == op->state->client_done_sent) {
1385 return;
1386 }
1387
1388 if (PHASE_DONE != op->state->phase) {
1389 LOG (GNUNET_ERROR_TYPE_ERROR,
1390 "union operation failed\n");
1391 ev = GNUNET_MQ_msg (rm, GNUNET_MESSAGE_TYPE_SET_RESULT);
1392 rm->result_status = htons (GNUNET_SET_STATUS_FAILURE);
1393 rm->request_id = htonl (op->client_request_id);
1394 rm->element_type = htons (0);
1395 GNUNET_MQ_send (op->set->cs->mq,
1396 ev);
1397 return;
1398 }
1399
1400 op->state->client_done_sent = GNUNET_YES;
1401
1384 LOG (GNUNET_ERROR_TYPE_INFO, 1402 LOG (GNUNET_ERROR_TYPE_INFO,
1385 "Signalling client that union operation is done\n"); 1403 "Signalling client that union operation is done\n");
1386 ev = GNUNET_MQ_msg (rm, 1404 ev = GNUNET_MQ_msg (rm,
@@ -1393,22 +1411,6 @@ send_client_done (void *cls)
1393 ev); 1411 ev);
1394} 1412}
1395 1413
1396/**
1397 * Signal to the client that the operation has finished and
1398 * destroy the operation.
1399 *
1400 * @param cls operation to destroy
1401 */
1402static void
1403send_client_done_and_destroy (void *cls)
1404{
1405 struct Operation *op = cls;
1406 send_client_done (cls);
1407 /* Will also call the union-specific cancel function. */
1408 _GSS_operation_destroy (op,
1409 GNUNET_YES);
1410}
1411
1412 1414
1413/** 1415/**
1414 * Tests if the operation is finished, and if so notify. 1416 * Tests if the operation is finished, and if so notify.
@@ -1449,6 +1451,13 @@ maybe_finish (struct Operation *op)
1449 struct GNUNET_MQ_Envelope *ev; 1451 struct GNUNET_MQ_Envelope *ev;
1450 1452
1451 op->state->phase = PHASE_DONE; 1453 op->state->phase = PHASE_DONE;
1454 /* FIXME: temporary hack, send message twice and add notification to second message,
1455 * so we can be pretty sure that the other party gets at least one of these
1456 * (since tunnel end handler is currently broken).
1457 */
1458 ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_SET_UNION_P2P_OVER);
1459 GNUNET_MQ_send (op->mq,
1460 ev);
1452 ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_SET_UNION_P2P_OVER); 1461 ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_SET_UNION_P2P_OVER);
1453 GNUNET_MQ_notify_sent (ev, 1462 GNUNET_MQ_notify_sent (ev,
1454 &send_client_done, 1463 &send_client_done,
@@ -1884,6 +1893,13 @@ handle_union_p2p_full_done (void *cls,
1884 /* We sent the full set, and got the response for that. We're done. */ 1893 /* We sent the full set, and got the response for that. We're done. */
1885 op->state->phase = PHASE_DONE; 1894 op->state->phase = PHASE_DONE;
1886 GNUNET_CADET_receive_done (op->channel); 1895 GNUNET_CADET_receive_done (op->channel);
1896 /* FIXME: temporary hack, send message twice and add notification to second message,
1897 * so we can be pretty sure that the other party gets at least one of these
1898 * (since tunnel end handler is currently broken).
1899 */
1900 ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_SET_UNION_P2P_OVER);
1901 GNUNET_MQ_send (op->mq,
1902 ev);
1887 ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_SET_UNION_P2P_OVER); 1903 ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_SET_UNION_P2P_OVER);
1888 GNUNET_MQ_notify_sent (ev, 1904 GNUNET_MQ_notify_sent (ev,
1889 &send_client_done, 1905 &send_client_done,
@@ -2409,6 +2425,7 @@ union_copy_state (struct SetState *state)
2409static void 2425static void
2410union_channel_death (struct Operation *op) 2426union_channel_death (struct Operation *op)
2411{ 2427{
2428 send_client_done (op);
2412 _GSS_operation_destroy (op, 2429 _GSS_operation_destroy (op,
2413 GNUNET_YES); 2430 GNUNET_YES);
2414} 2431}