aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2017-06-20 19:32:29 +0200
committerFlorian Dold <florian.dold@gmail.com>2017-06-20 19:46:03 +0200
commitb8c0a4837377e4953b05a7df1b6ab6ec31c704a9 (patch)
tree9e6b0a6a9b5ee99afa08e80b7cfed1a87233b877
parent90302a3018c017b4a5b60d7c8f04f8924117c979 (diff)
downloadgnunet-b8c0a4837377e4953b05a7df1b6ab6ec31c704a9.tar.gz
gnunet-b8c0a4837377e4953b05a7df1b6ab6ec31c704a9.zip
set: disconnect, don't destroy yet
-rw-r--r--src/set/gnunet-service-set_union.c43
1 files changed, 32 insertions, 11 deletions
diff --git a/src/set/gnunet-service-set_union.c b/src/set/gnunet-service-set_union.c
index ca1049148..4ca10f0b4 100644
--- a/src/set/gnunet-service-set_union.c
+++ b/src/set/gnunet-service-set_union.c
@@ -1369,6 +1369,25 @@ send_client_element (struct Operation *op,
1369 1369
1370 1370
1371/** 1371/**
1372 * Destroy remote channel.
1373 *
1374 * @param op operation
1375 */
1376void destroy_channel (struct Operation *op)
1377{
1378 struct GNUNET_CADET_Channel *channel;
1379
1380 if (NULL != (channel = op->channel))
1381 {
1382 /* This will free op; called conditionally as this helper function
1383 is also called from within the channel disconnect handler. */
1384 op->channel = NULL;
1385 GNUNET_CADET_channel_destroy (channel);
1386 }
1387}
1388
1389
1390/**
1372 * Signal to the client that the operation has finished and 1391 * Signal to the client that the operation has finished and
1373 * destroy the operation. 1392 * destroy the operation.
1374 * 1393 *
@@ -1448,10 +1467,11 @@ maybe_finish (struct Operation *op)
1448 num_demanded); 1467 num_demanded);
1449 if (0 == num_demanded) 1468 if (0 == num_demanded)
1450 { 1469 {
1470 struct GNUNET_MQ_Envelope *ev;
1471
1451 op->state->phase = PHASE_DONE; 1472 op->state->phase = PHASE_DONE;
1452 send_client_done (op); 1473 send_client_done (op);
1453 _GSS_operation_destroy (op, 1474 destroy_channel (op);
1454 GNUNET_YES);
1455 } 1475 }
1456 } 1476 }
1457} 1477}
@@ -1869,18 +1889,21 @@ handle_union_p2p_full_done (void *cls,
1869 GNUNET_MQ_send (op->mq, 1889 GNUNET_MQ_send (op->mq,
1870 ev); 1890 ev);
1871 op->state->phase = PHASE_DONE; 1891 op->state->phase = PHASE_DONE;
1872 /* we now wait until the other peer disconnects */ 1892 /* we now wait until the other peer sends us the OVER message*/
1873 } 1893 }
1874 break; 1894 break;
1875 case PHASE_FULL_SENDING: 1895 case PHASE_FULL_SENDING:
1876 { 1896 {
1897 struct GNUNET_MQ_Envelope *ev;
1898
1877 LOG (GNUNET_ERROR_TYPE_DEBUG, 1899 LOG (GNUNET_ERROR_TYPE_DEBUG,
1878 "got FULL DONE, finishing\n"); 1900 "got FULL DONE, finishing\n");
1879 /* We sent the full set, and got the response for that. We're done. */ 1901 /* We sent the full set, and got the response for that. We're done. */
1880 op->state->phase = PHASE_DONE; 1902 op->state->phase = PHASE_DONE;
1903 GNUNET_CADET_receive_done (op->channel);
1881 send_client_done (op); 1904 send_client_done (op);
1882 _GSS_operation_destroy (op, 1905 destroy_channel (op);
1883 GNUNET_YES); 1906 return;
1884 } 1907 }
1885 break; 1908 break;
1886 default: 1909 default:
@@ -2117,7 +2140,6 @@ handle_union_p2p_done (void *cls,
2117 fail_union_operation (op); 2140 fail_union_operation (op);
2118 return; 2141 return;
2119 } 2142 }
2120
2121 switch (op->state->phase) 2143 switch (op->state->phase)
2122 { 2144 {
2123 case PHASE_INVENTORY_PASSIVE: 2145 case PHASE_INVENTORY_PASSIVE:
@@ -2135,8 +2157,9 @@ handle_union_p2p_done (void *cls,
2135 * all our demands are satisfied, so that the active 2157 * all our demands are satisfied, so that the active
2136 * peer can quit if we gave him everything. 2158 * peer can quit if we gave him everything.
2137 */ 2159 */
2160 GNUNET_CADET_receive_done (op->channel);
2138 maybe_finish (op); 2161 maybe_finish (op);
2139 break; 2162 return;
2140 case PHASE_INVENTORY_ACTIVE: 2163 case PHASE_INVENTORY_ACTIVE:
2141 LOG (GNUNET_ERROR_TYPE_DEBUG, 2164 LOG (GNUNET_ERROR_TYPE_DEBUG,
2142 "got DONE (as active partner), waiting to finish\n"); 2165 "got DONE (as active partner), waiting to finish\n");
@@ -2148,15 +2171,14 @@ handle_union_p2p_done (void *cls,
2148 * to the other peer once our demands are met. 2171 * to the other peer once our demands are met.
2149 */ 2172 */
2150 op->state->phase = PHASE_FINISH_CLOSING; 2173 op->state->phase = PHASE_FINISH_CLOSING;
2174 GNUNET_CADET_receive_done (op->channel);
2151 maybe_finish (op); 2175 maybe_finish (op);
2152 break; 2176 return;
2153 default: 2177 default:
2154 GNUNET_break_op (0); 2178 GNUNET_break_op (0);
2155 fail_union_operation (op); 2179 fail_union_operation (op);
2156 return; 2180 return;
2157 } 2181 }
2158 GNUNET_CADET_receive_done (op->channel);
2159
2160} 2182}
2161 2183
2162/** 2184/**
@@ -2400,7 +2422,6 @@ union_copy_state (struct SetState *state)
2400static void 2422static void
2401union_channel_death (struct Operation *op) 2423union_channel_death (struct Operation *op)
2402{ 2424{
2403 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "channel died, sending result to client\n");
2404 send_client_done (op); 2425 send_client_done (op);
2405 _GSS_operation_destroy (op, 2426 _GSS_operation_destroy (op,
2406 GNUNET_YES); 2427 GNUNET_YES);