aboutsummaryrefslogtreecommitdiff
path: root/src/set/gnunet-service-set_union.c
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2017-06-11 06:08:39 +0200
committerFlorian Dold <florian.dold@gmail.com>2017-06-11 06:09:00 +0200
commitf69bdc6985991ed4062ffa0bd3dc21dab5689613 (patch)
tree3e646214a2e12971cd63ffd5b29c2a1eb9f89523 /src/set/gnunet-service-set_union.c
parent9e1e0255ccf57f2ee0a2be9f4d49ee6308bdd738 (diff)
downloadgnunet-f69bdc6985991ed4062ffa0bd3dc21dab5689613.tar.gz
gnunet-f69bdc6985991ed4062ffa0bd3dc21dab5689613.zip
set: add 'over' message, since cadet does not reliably detect channel termination
Diffstat (limited to 'src/set/gnunet-service-set_union.c')
-rw-r--r--src/set/gnunet-service-set_union.c43
1 files changed, 38 insertions, 5 deletions
diff --git a/src/set/gnunet-service-set_union.c b/src/set/gnunet-service-set_union.c
index fc7e578e6..bb2acbf59 100644
--- a/src/set/gnunet-service-set_union.c
+++ b/src/set/gnunet-service-set_union.c
@@ -1375,7 +1375,7 @@ send_client_element (struct Operation *op,
1375 * @param cls operation to destroy 1375 * @param cls operation to destroy
1376 */ 1376 */
1377static void 1377static void
1378send_done_and_destroy (void *cls) 1378send_client_done (void *cls)
1379{ 1379{
1380 struct Operation *op = cls; 1380 struct Operation *op = cls;
1381 struct GNUNET_MQ_Envelope *ev; 1381 struct GNUNET_MQ_Envelope *ev;
@@ -1391,6 +1391,19 @@ send_done_and_destroy (void *cls)
1391 rm->current_size = GNUNET_htonll (GNUNET_CONTAINER_multihashmap32_size (op->state->key_to_element)); 1391 rm->current_size = GNUNET_htonll (GNUNET_CONTAINER_multihashmap32_size (op->state->key_to_element));
1392 GNUNET_MQ_send (op->set->cs->mq, 1392 GNUNET_MQ_send (op->set->cs->mq,
1393 ev); 1393 ev);
1394}
1395
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);
1394 /* Will also call the union-specific cancel function. */ 1407 /* Will also call the union-specific cancel function. */
1395 _GSS_operation_destroy (op, 1408 _GSS_operation_destroy (op,
1396 GNUNET_YES); 1409 GNUNET_YES);
@@ -1422,7 +1435,7 @@ maybe_finish (struct Operation *op)
1422 ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_SET_UNION_P2P_DONE); 1435 ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_SET_UNION_P2P_DONE);
1423 GNUNET_MQ_send (op->mq, 1436 GNUNET_MQ_send (op->mq,
1424 ev); 1437 ev);
1425 /* We now wait until the other peer closes the channel 1438 /* We now wait until the other peer sends P2P_OVER
1426 * after it got all elements from us. */ 1439 * after it got all elements from us. */
1427 } 1440 }
1428 } 1441 }
@@ -1433,8 +1446,15 @@ maybe_finish (struct Operation *op)
1433 num_demanded); 1446 num_demanded);
1434 if (0 == num_demanded) 1447 if (0 == num_demanded)
1435 { 1448 {
1449 struct GNUNET_MQ_Envelope *ev;
1450
1436 op->state->phase = PHASE_DONE; 1451 op->state->phase = PHASE_DONE;
1437 send_done_and_destroy (op); 1452 ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_SET_UNION_P2P_OVER);
1453 GNUNET_MQ_notify_sent (ev,
1454 &send_client_done,
1455 op);
1456 GNUNET_MQ_send (op->mq,
1457 ev);
1438 } 1458 }
1439 } 1459 }
1440} 1460}
@@ -1850,7 +1870,7 @@ handle_union_p2p_full_done (void *cls,
1850 1870
1851 ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_SET_UNION_P2P_FULL_DONE); 1871 ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_SET_UNION_P2P_FULL_DONE);
1852 GNUNET_MQ_notify_sent (ev, 1872 GNUNET_MQ_notify_sent (ev,
1853 &send_done_and_destroy, 1873 &send_client_done,
1854 op); 1874 op);
1855 GNUNET_MQ_send (op->mq, 1875 GNUNET_MQ_send (op->mq,
1856 ev); 1876 ev);
@@ -1865,7 +1885,7 @@ handle_union_p2p_full_done (void *cls,
1865 /* We sent the full set, and got the response for that. We're done. */ 1885 /* We sent the full set, and got the response for that. We're done. */
1866 op->state->phase = PHASE_DONE; 1886 op->state->phase = PHASE_DONE;
1867 GNUNET_CADET_receive_done (op->channel); 1887 GNUNET_CADET_receive_done (op->channel);
1868 send_done_and_destroy (op); 1888 send_client_done_and_destroy (op);
1869 return; 1889 return;
1870 } 1890 }
1871 break; 1891 break;
@@ -2144,6 +2164,19 @@ handle_union_p2p_done (void *cls,
2144 } 2164 }
2145} 2165}
2146 2166
2167/**
2168 * Handle a over message from a remote peer
2169 *
2170 * @param cls the union operation
2171 * @param mh the message
2172 */
2173void
2174handle_union_p2p_over (void *cls,
2175 const struct GNUNET_MessageHeader *mh)
2176{
2177 send_client_done (cls);
2178}
2179
2147 2180
2148/** 2181/**
2149 * Initiate operation to evaluate a set union with a remote peer. 2182 * Initiate operation to evaluate a set union with a remote peer.