diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-11-06 23:39:48 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-11-06 23:39:48 +0000 |
commit | 9372cb529f88dd9e31bb51752601c91421651860 (patch) | |
tree | cea61fb70509c5acfc1d31c52fc2297279710582 /src/transport/transport_api.c | |
parent | 17bca33cca3c06668aa07c2750000a40a229c4a3 (diff) | |
download | gnunet-9372cb529f88dd9e31bb51752601c91421651860.tar.gz gnunet-9372cb529f88dd9e31bb51752601c91421651860.zip |
removing definitively dead try_connect-related logic (#3675)
Diffstat (limited to 'src/transport/transport_api.c')
-rw-r--r-- | src/transport/transport_api.c | 161 |
1 files changed, 1 insertions, 160 deletions
diff --git a/src/transport/transport_api.c b/src/transport/transport_api.c index 29416b03d..9663d4ecd 100644 --- a/src/transport/transport_api.c +++ b/src/transport/transport_api.c | |||
@@ -203,49 +203,6 @@ struct GNUNET_TRANSPORT_GetHelloHandle | |||
203 | 203 | ||
204 | 204 | ||
205 | /** | 205 | /** |
206 | * Entry in linked list for a try-connect request. | ||
207 | */ | ||
208 | struct GNUNET_TRANSPORT_TryConnectHandle | ||
209 | { | ||
210 | /** | ||
211 | * For the DLL. | ||
212 | */ | ||
213 | struct GNUNET_TRANSPORT_TryConnectHandle *prev; | ||
214 | |||
215 | /** | ||
216 | * For the DLL. | ||
217 | */ | ||
218 | struct GNUNET_TRANSPORT_TryConnectHandle *next; | ||
219 | |||
220 | /** | ||
221 | * Peer we should try to connect to. | ||
222 | */ | ||
223 | struct GNUNET_PeerIdentity pid; | ||
224 | |||
225 | /** | ||
226 | * Transport service handle this request is part of. | ||
227 | */ | ||
228 | struct GNUNET_TRANSPORT_Handle *th; | ||
229 | |||
230 | /** | ||
231 | * Message transmission request to communicate to service. | ||
232 | */ | ||
233 | struct GNUNET_TRANSPORT_TransmitHandle *tth; | ||
234 | |||
235 | /** | ||
236 | * Function to call upon completion (of request transmission). | ||
237 | */ | ||
238 | GNUNET_TRANSPORT_TryConnectCallback cb; | ||
239 | |||
240 | /** | ||
241 | * Closure for @e cb. | ||
242 | */ | ||
243 | void *cb_cls; | ||
244 | |||
245 | }; | ||
246 | |||
247 | |||
248 | /** | ||
249 | * Entry in linked list for all offer-HELLO requests. | 206 | * Entry in linked list for all offer-HELLO requests. |
250 | */ | 207 | */ |
251 | struct GNUNET_TRANSPORT_OfferHelloHandle | 208 | struct GNUNET_TRANSPORT_OfferHelloHandle |
@@ -356,16 +313,6 @@ struct GNUNET_TRANSPORT_Handle | |||
356 | struct GNUNET_TRANSPORT_GetHelloHandle *hwl_tail; | 313 | struct GNUNET_TRANSPORT_GetHelloHandle *hwl_tail; |
357 | 314 | ||
358 | /** | 315 | /** |
359 | * Linked list of pending try connect requests head | ||
360 | */ | ||
361 | struct GNUNET_TRANSPORT_TryConnectHandle *tc_head; | ||
362 | |||
363 | /** | ||
364 | * Linked list of pending try connect requests tail | ||
365 | */ | ||
366 | struct GNUNET_TRANSPORT_TryConnectHandle *tc_tail; | ||
367 | |||
368 | /** | ||
369 | * Linked list of pending offer HELLO requests head | 316 | * Linked list of pending offer HELLO requests head |
370 | */ | 317 | */ |
371 | struct GNUNET_TRANSPORT_OfferHelloHandle *oh_head; | 318 | struct GNUNET_TRANSPORT_OfferHelloHandle *oh_head; |
@@ -1353,110 +1300,6 @@ cancel_control_transmit (struct GNUNET_TRANSPORT_Handle *th, | |||
1353 | 1300 | ||
1354 | 1301 | ||
1355 | /** | 1302 | /** |
1356 | * Send #GNUNET_MESSAGE_TYPE_TRANSPORT_REQUEST_CONNECT message to the | ||
1357 | * service. | ||
1358 | * | ||
1359 | * @param cls the `struct GNUNET_TRANSPORT_TryConnectHandle` | ||
1360 | * @param size number of bytes available in @a buf | ||
1361 | * @param buf where to copy the message | ||
1362 | * @return number of bytes copied to @a buf | ||
1363 | */ | ||
1364 | static size_t | ||
1365 | send_try_connect (void *cls, | ||
1366 | size_t size, | ||
1367 | void *buf) | ||
1368 | { | ||
1369 | struct GNUNET_TRANSPORT_TryConnectHandle *tch = cls; | ||
1370 | struct TransportRequestConnectMessage msg; | ||
1371 | |||
1372 | tch->tth = NULL; | ||
1373 | if (NULL == buf) | ||
1374 | { | ||
1375 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
1376 | "Discarding REQUEST_CONNECT request to `%s' due to error in transport service connection.\n", | ||
1377 | GNUNET_i2s (&tch->pid)); | ||
1378 | if (NULL != tch->cb) | ||
1379 | tch->cb (tch->cb_cls, | ||
1380 | GNUNET_SYSERR); | ||
1381 | GNUNET_TRANSPORT_try_connect_cancel (tch); | ||
1382 | return 0; | ||
1383 | } | ||
1384 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
1385 | "Transmitting `%s' request with respect to `%s'.\n", | ||
1386 | "REQUEST_CONNECT", | ||
1387 | GNUNET_i2s (&tch->pid)); | ||
1388 | GNUNET_assert (size >= sizeof (struct TransportRequestConnectMessage)); | ||
1389 | msg.header.size = htons (sizeof (struct TransportRequestConnectMessage)); | ||
1390 | msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_REQUEST_CONNECT); | ||
1391 | msg.reserved = htonl (0); | ||
1392 | msg.peer = tch->pid; | ||
1393 | memcpy (buf, &msg, sizeof (msg)); | ||
1394 | if (NULL != tch->cb) | ||
1395 | tch->cb (tch->cb_cls, GNUNET_OK); | ||
1396 | GNUNET_TRANSPORT_try_connect_cancel (tch); | ||
1397 | return sizeof (struct TransportRequestConnectMessage); | ||
1398 | } | ||
1399 | |||
1400 | |||
1401 | /** | ||
1402 | * Ask the transport service to establish a connection to | ||
1403 | * the given peer. | ||
1404 | * | ||
1405 | * @param handle connection to transport service | ||
1406 | * @param target who we should try to connect to | ||
1407 | * @param cb callback to be called when request was transmitted to transport | ||
1408 | * service | ||
1409 | * @param cb_cls closure for the callback | ||
1410 | * @return a `struct GNUNET_TRANSPORT_TryConnectHandle` handle or | ||
1411 | * NULL on failure (cb will not be called) | ||
1412 | */ | ||
1413 | struct GNUNET_TRANSPORT_TryConnectHandle * | ||
1414 | GNUNET_TRANSPORT_try_connect (struct GNUNET_TRANSPORT_Handle *handle, | ||
1415 | const struct GNUNET_PeerIdentity *target, | ||
1416 | GNUNET_TRANSPORT_TryConnectCallback cb, | ||
1417 | void *cb_cls) | ||
1418 | { | ||
1419 | struct GNUNET_TRANSPORT_TryConnectHandle *tch; | ||
1420 | |||
1421 | if (NULL == handle->client) | ||
1422 | return NULL; | ||
1423 | tch = GNUNET_new (struct GNUNET_TRANSPORT_TryConnectHandle); | ||
1424 | tch->th = handle; | ||
1425 | tch->pid = *target; | ||
1426 | tch->cb = cb; | ||
1427 | tch->cb_cls = cb_cls; | ||
1428 | tch->tth = schedule_control_transmit (handle, | ||
1429 | sizeof (struct TransportRequestConnectMessage), | ||
1430 | &send_try_connect, tch); | ||
1431 | GNUNET_CONTAINER_DLL_insert (handle->tc_head, | ||
1432 | handle->tc_tail, | ||
1433 | tch); | ||
1434 | return tch; | ||
1435 | } | ||
1436 | |||
1437 | |||
1438 | /** | ||
1439 | * Cancel the request to transport to try a connect | ||
1440 | * Callback will not be called | ||
1441 | * | ||
1442 | * @param tch the handle to cancel | ||
1443 | */ | ||
1444 | void | ||
1445 | GNUNET_TRANSPORT_try_connect_cancel (struct GNUNET_TRANSPORT_TryConnectHandle *tch) | ||
1446 | { | ||
1447 | struct GNUNET_TRANSPORT_Handle *th; | ||
1448 | |||
1449 | th = tch->th; | ||
1450 | if (NULL != tch->tth) | ||
1451 | cancel_control_transmit (th, tch->tth); | ||
1452 | GNUNET_CONTAINER_DLL_remove (th->tc_head, | ||
1453 | th->tc_tail, | ||
1454 | tch); | ||
1455 | GNUNET_free (tch); | ||
1456 | } | ||
1457 | |||
1458 | |||
1459 | /** | ||
1460 | * Send HELLO message to the service. | 1303 | * Send HELLO message to the service. |
1461 | * | 1304 | * |
1462 | * @param cls the HELLO message to send | 1305 | * @param cls the HELLO message to send |
@@ -1873,8 +1716,6 @@ GNUNET_TRANSPORT_disconnect (struct GNUNET_TRANSPORT_Handle *handle) | |||
1873 | } | 1716 | } |
1874 | GNUNET_free_non_null (handle->my_hello); | 1717 | GNUNET_free_non_null (handle->my_hello); |
1875 | handle->my_hello = NULL; | 1718 | handle->my_hello = NULL; |
1876 | GNUNET_assert (NULL == handle->tc_head); | ||
1877 | GNUNET_assert (NULL == handle->tc_tail); | ||
1878 | GNUNET_assert (NULL == handle->hwl_head); | 1719 | GNUNET_assert (NULL == handle->hwl_head); |
1879 | GNUNET_assert (NULL == handle->hwl_tail); | 1720 | GNUNET_assert (NULL == handle->hwl_tail); |
1880 | GNUNET_CONTAINER_heap_destroy (handle->ready_heap); | 1721 | GNUNET_CONTAINER_heap_destroy (handle->ready_heap); |
@@ -1916,7 +1757,7 @@ GNUNET_TRANSPORT_notify_transmit_ready (struct GNUNET_TRANSPORT_Handle *handle, | |||
1916 | n = neighbour_find (handle, target); | 1757 | n = neighbour_find (handle, target); |
1917 | if (NULL == n) | 1758 | if (NULL == n) |
1918 | { | 1759 | { |
1919 | /* use GNUNET_TRANSPORT_try_connect first, only use this function | 1760 | /* only use this function |
1920 | * once a connection has been established */ | 1761 | * once a connection has been established */ |
1921 | GNUNET_assert (0); | 1762 | GNUNET_assert (0); |
1922 | return NULL; | 1763 | return NULL; |