diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/consensus/gnunet-service-consensus.c | 15 | ||||
-rw-r--r-- | src/set/gnunet-service-set_union.c | 49 |
2 files changed, 46 insertions, 18 deletions
diff --git a/src/consensus/gnunet-service-consensus.c b/src/consensus/gnunet-service-consensus.c index 4af7199aa..6b76efb18 100644 --- a/src/consensus/gnunet-service-consensus.c +++ b/src/consensus/gnunet-service-consensus.c | |||
@@ -1133,8 +1133,11 @@ set_result_cb (void *cls, | |||
1133 | // XXX: check first if any changes to the underlying | 1133 | // XXX: check first if any changes to the underlying |
1134 | // set are still pending | 1134 | // set are still pending |
1135 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1135 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1136 | "Finishing setop in Task {%s}\n", | 1136 | "P%u: Finishing setop in Task {%s} (%u/%u)\n", |
1137 | debug_str_task_key (&task->key)); | 1137 | session->local_peer_idx, |
1138 | debug_str_task_key (&task->key), | ||
1139 | (unsigned int) task->step->finished_tasks, | ||
1140 | (unsigned int) task->step->tasks_len); | ||
1138 | if (NULL != output_rfn) | 1141 | if (NULL != output_rfn) |
1139 | { | 1142 | { |
1140 | rfn_commit (output_rfn, task_other_peer (task)); | 1143 | rfn_commit (output_rfn, task_other_peer (task)); |
@@ -1470,6 +1473,7 @@ commit_set (struct ConsensusSession *session, | |||
1470 | peers to wait. */ | 1473 | peers to wait. */ |
1471 | GNUNET_SET_operation_cancel (setop->op); | 1474 | GNUNET_SET_operation_cancel (setop->op); |
1472 | setop->op = NULL; | 1475 | setop->op = NULL; |
1476 | finish_task (task); | ||
1473 | } | 1477 | } |
1474 | #endif | 1478 | #endif |
1475 | } | 1479 | } |
@@ -2378,6 +2382,13 @@ finish_task (struct TaskEntry *task) | |||
2378 | 2382 | ||
2379 | task->step->finished_tasks++; | 2383 | task->step->finished_tasks++; |
2380 | 2384 | ||
2385 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2386 | "P%u: Finishing setop in Task {%s} (now %u/%u tasks finished in step)\n", | ||
2387 | task->step->session->local_peer_idx, | ||
2388 | debug_str_task_key (&task->key), | ||
2389 | (unsigned int) task->step->finished_tasks, | ||
2390 | (unsigned int) task->step->tasks_len); | ||
2391 | |||
2381 | if (task->step->finished_tasks == task->step->tasks_len) | 2392 | if (task->step->finished_tasks == task->step->tasks_len) |
2382 | finish_step (task->step); | 2393 | finish_step (task->step); |
2383 | } | 2394 | } |
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 | */ | ||
1402 | static void | ||
1403 | send_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) | |||
2409 | static void | 2425 | static void |
2410 | union_channel_death (struct Operation *op) | 2426 | union_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 | } |