From 9372cb529f88dd9e31bb51752601c91421651860 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 6 Nov 2015 23:39:48 +0000 Subject: removing definitively dead try_connect-related logic (#3675) --- src/include/gnunet_protocols.h | 6 - src/include/gnunet_transport_service.h | 49 ------- src/transport/gnunet-service-transport_clients.c | 40 ------ src/transport/transport_api.c | 161 +---------------------- 4 files changed, 1 insertion(+), 255 deletions(-) diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h index 9ac749637..7ec3ceb70 100644 --- a/src/include/gnunet_protocols.h +++ b/src/include/gnunet_protocols.h @@ -1265,12 +1265,6 @@ extern "C" */ #define GNUNET_MESSAGE_TYPE_TRANSPORT_PONG 373 -/** - * Message for transport service from a client asking that a - * connection be initiated with another peer. - */ -#define GNUNET_MESSAGE_TYPE_TRANSPORT_REQUEST_CONNECT 374 - /** * Transport SYN message exchanged between transport services to * indicate that a session should be marked as 'connected'. diff --git a/src/include/gnunet_transport_service.h b/src/include/gnunet_transport_service.h index c2f5798ad..8a20c52a7 100644 --- a/src/include/gnunet_transport_service.h +++ b/src/include/gnunet_transport_service.h @@ -160,55 +160,6 @@ void GNUNET_TRANSPORT_disconnect (struct GNUNET_TRANSPORT_Handle *handle); -/* ************************* Connections *********************** */ - -/** - * Opaque handle for a transmission-ready request. - */ -struct GNUNET_TRANSPORT_TryConnectHandle; - -/** - * Function to call with result of the try connect request. - * - * @param cls closure - * @param result #GNUNET_OK if message was transmitted to transport service - * #GNUNET_SYSERR if message was not transmitted to transport service - */ -typedef void -(*GNUNET_TRANSPORT_TryConnectCallback) (void *cls, - int result); - - -/** - * Ask the transport service to establish a connection to - * the given peer. - * - * @param handle connection to transport service - * @param target who we should try to connect to - * @param cb callback to be called when request was transmitted to transport - * service - * @param cb_cls closure for the callback @a cb - * @return a `struct GNUNET_TRANSPORT_TryConnectHandle` handle or - * NULL on failure (@a cb will not be called) - * @deprecated - */ -struct GNUNET_TRANSPORT_TryConnectHandle * -GNUNET_TRANSPORT_try_connect (struct GNUNET_TRANSPORT_Handle *handle, - const struct GNUNET_PeerIdentity *target, - GNUNET_TRANSPORT_TryConnectCallback cb, - void *cb_cls); - - -/** - * Cancel the request to transport to try a connect - * Callback will not be called - * - * @param tch handle to cancel - */ -void -GNUNET_TRANSPORT_try_connect_cancel (struct GNUNET_TRANSPORT_TryConnectHandle *tch); - - /* ************************* Sending *************************** */ /** diff --git a/src/transport/gnunet-service-transport_clients.c b/src/transport/gnunet-service-transport_clients.c index 86c833c5b..84de4853b 100644 --- a/src/transport/gnunet-service-transport_clients.c +++ b/src/transport/gnunet-service-transport_clients.c @@ -875,43 +875,6 @@ clients_handle_send (void *cls, } -/** - * Handle request connect message - * - * @param cls closure (always NULL) - * @param client identification of the client - * @param message the actual message - */ -static void -clients_handle_request_connect (void *cls, - struct GNUNET_SERVER_Client *client, - const struct GNUNET_MessageHeader *message) -{ - const struct TransportRequestConnectMessage *trcm; - - trcm = (const struct TransportRequestConnectMessage *) message; - GNUNET_break (0 == ntohl (trcm->reserved)); - GNUNET_STATISTICS_update (GST_stats, - gettext_noop - ("# REQUEST CONNECT messages received"), 1, - GNUNET_NO); - if (0 == memcmp (&trcm->peer, - &GST_my_identity, - sizeof (struct GNUNET_PeerIdentity))) - { - GNUNET_break (0); - GNUNET_SERVER_receive_done (client, - GNUNET_OK); - return; - } - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Received a request connect message for peer `%s'\n", - GNUNET_i2s (&trcm->peer)); - GST_neighbours_try_connect (&trcm->peer); - GNUNET_SERVER_receive_done (client, GNUNET_OK); -} - - /** * Take the given address and append it to the set of results sent back to * the client. This function may be called serveral times for a single @@ -1546,9 +1509,6 @@ GST_clients_start (struct GNUNET_SERVER_Handle *server) GNUNET_MESSAGE_TYPE_HELLO, 0}, {&clients_handle_send, NULL, GNUNET_MESSAGE_TYPE_TRANSPORT_SEND, 0}, - {&clients_handle_request_connect, NULL, - GNUNET_MESSAGE_TYPE_TRANSPORT_REQUEST_CONNECT, - sizeof (struct TransportRequestConnectMessage)}, {&clients_handle_address_to_string, NULL, GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING, 0}, {&clients_handle_monitor_peers, NULL, 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 @@ -202,49 +202,6 @@ struct GNUNET_TRANSPORT_GetHelloHandle }; -/** - * Entry in linked list for a try-connect request. - */ -struct GNUNET_TRANSPORT_TryConnectHandle -{ - /** - * For the DLL. - */ - struct GNUNET_TRANSPORT_TryConnectHandle *prev; - - /** - * For the DLL. - */ - struct GNUNET_TRANSPORT_TryConnectHandle *next; - - /** - * Peer we should try to connect to. - */ - struct GNUNET_PeerIdentity pid; - - /** - * Transport service handle this request is part of. - */ - struct GNUNET_TRANSPORT_Handle *th; - - /** - * Message transmission request to communicate to service. - */ - struct GNUNET_TRANSPORT_TransmitHandle *tth; - - /** - * Function to call upon completion (of request transmission). - */ - GNUNET_TRANSPORT_TryConnectCallback cb; - - /** - * Closure for @e cb. - */ - void *cb_cls; - -}; - - /** * Entry in linked list for all offer-HELLO requests. */ @@ -355,16 +312,6 @@ struct GNUNET_TRANSPORT_Handle */ struct GNUNET_TRANSPORT_GetHelloHandle *hwl_tail; - /** - * Linked list of pending try connect requests head - */ - struct GNUNET_TRANSPORT_TryConnectHandle *tc_head; - - /** - * Linked list of pending try connect requests tail - */ - struct GNUNET_TRANSPORT_TryConnectHandle *tc_tail; - /** * Linked list of pending offer HELLO requests head */ @@ -1352,110 +1299,6 @@ cancel_control_transmit (struct GNUNET_TRANSPORT_Handle *th, } -/** - * Send #GNUNET_MESSAGE_TYPE_TRANSPORT_REQUEST_CONNECT message to the - * service. - * - * @param cls the `struct GNUNET_TRANSPORT_TryConnectHandle` - * @param size number of bytes available in @a buf - * @param buf where to copy the message - * @return number of bytes copied to @a buf - */ -static size_t -send_try_connect (void *cls, - size_t size, - void *buf) -{ - struct GNUNET_TRANSPORT_TryConnectHandle *tch = cls; - struct TransportRequestConnectMessage msg; - - tch->tth = NULL; - if (NULL == buf) - { - LOG (GNUNET_ERROR_TYPE_DEBUG, - "Discarding REQUEST_CONNECT request to `%s' due to error in transport service connection.\n", - GNUNET_i2s (&tch->pid)); - if (NULL != tch->cb) - tch->cb (tch->cb_cls, - GNUNET_SYSERR); - GNUNET_TRANSPORT_try_connect_cancel (tch); - return 0; - } - LOG (GNUNET_ERROR_TYPE_DEBUG, - "Transmitting `%s' request with respect to `%s'.\n", - "REQUEST_CONNECT", - GNUNET_i2s (&tch->pid)); - GNUNET_assert (size >= sizeof (struct TransportRequestConnectMessage)); - msg.header.size = htons (sizeof (struct TransportRequestConnectMessage)); - msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_REQUEST_CONNECT); - msg.reserved = htonl (0); - msg.peer = tch->pid; - memcpy (buf, &msg, sizeof (msg)); - if (NULL != tch->cb) - tch->cb (tch->cb_cls, GNUNET_OK); - GNUNET_TRANSPORT_try_connect_cancel (tch); - return sizeof (struct TransportRequestConnectMessage); -} - - -/** - * Ask the transport service to establish a connection to - * the given peer. - * - * @param handle connection to transport service - * @param target who we should try to connect to - * @param cb callback to be called when request was transmitted to transport - * service - * @param cb_cls closure for the callback - * @return a `struct GNUNET_TRANSPORT_TryConnectHandle` handle or - * NULL on failure (cb will not be called) - */ -struct GNUNET_TRANSPORT_TryConnectHandle * -GNUNET_TRANSPORT_try_connect (struct GNUNET_TRANSPORT_Handle *handle, - const struct GNUNET_PeerIdentity *target, - GNUNET_TRANSPORT_TryConnectCallback cb, - void *cb_cls) -{ - struct GNUNET_TRANSPORT_TryConnectHandle *tch; - - if (NULL == handle->client) - return NULL; - tch = GNUNET_new (struct GNUNET_TRANSPORT_TryConnectHandle); - tch->th = handle; - tch->pid = *target; - tch->cb = cb; - tch->cb_cls = cb_cls; - tch->tth = schedule_control_transmit (handle, - sizeof (struct TransportRequestConnectMessage), - &send_try_connect, tch); - GNUNET_CONTAINER_DLL_insert (handle->tc_head, - handle->tc_tail, - tch); - return tch; -} - - -/** - * Cancel the request to transport to try a connect - * Callback will not be called - * - * @param tch the handle to cancel - */ -void -GNUNET_TRANSPORT_try_connect_cancel (struct GNUNET_TRANSPORT_TryConnectHandle *tch) -{ - struct GNUNET_TRANSPORT_Handle *th; - - th = tch->th; - if (NULL != tch->tth) - cancel_control_transmit (th, tch->tth); - GNUNET_CONTAINER_DLL_remove (th->tc_head, - th->tc_tail, - tch); - GNUNET_free (tch); -} - - /** * Send HELLO message to the service. * @@ -1873,8 +1716,6 @@ GNUNET_TRANSPORT_disconnect (struct GNUNET_TRANSPORT_Handle *handle) } GNUNET_free_non_null (handle->my_hello); handle->my_hello = NULL; - GNUNET_assert (NULL == handle->tc_head); - GNUNET_assert (NULL == handle->tc_tail); GNUNET_assert (NULL == handle->hwl_head); GNUNET_assert (NULL == handle->hwl_tail); GNUNET_CONTAINER_heap_destroy (handle->ready_heap); @@ -1916,7 +1757,7 @@ GNUNET_TRANSPORT_notify_transmit_ready (struct GNUNET_TRANSPORT_Handle *handle, n = neighbour_find (handle, target); if (NULL == n) { - /* use GNUNET_TRANSPORT_try_connect first, only use this function + /* only use this function * once a connection has been established */ GNUNET_assert (0); return NULL; -- cgit v1.2.3