From 3a81c3e236a3679c0c0676d814c71d9ae5f38ec3 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 22 Oct 2011 20:16:14 +0000 Subject: [PATCH] eliminating GNUNET_TRANSPORT_set_quota code --- src/include/gnunet_transport_service.h | 16 --- src/transport/gnunet-service-transport.c | 7 +- .../gnunet-service-transport_clients.c | 30 ------ src/transport/transport.h | 2 +- src/transport/transport_api.c | 99 ------------------- 5 files changed, 6 insertions(+), 148 deletions(-) diff --git a/src/include/gnunet_transport_service.h b/src/include/gnunet_transport_service.h index 40e3fca5b..5f719f859 100644 --- a/src/include/gnunet_transport_service.h +++ b/src/include/gnunet_transport_service.h @@ -169,22 +169,6 @@ GNUNET_TRANSPORT_try_connect (struct GNUNET_TRANSPORT_Handle *handle, const struct GNUNET_PeerIdentity *target); -/** - * Set the share of incoming/outgoing bandwidth for the given - * peer to the specified amount. - * - * @param handle connection to transport service - * @param target who's bandwidth quota is being changed - * @param quota_in incoming bandwidth quota - * @param quota_out outgoing bandwidth quota - */ -void -GNUNET_TRANSPORT_set_quota (struct GNUNET_TRANSPORT_Handle *handle, - const struct GNUNET_PeerIdentity *target, - struct GNUNET_BANDWIDTH_Value32NBO quota_in, - struct GNUNET_BANDWIDTH_Value32NBO quota_out); - - /** * Opaque handle for a transmission-ready request. */ diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index 6273816c7..602a597e5 100644 --- a/src/transport/gnunet-service-transport.c +++ b/src/transport/gnunet-service-transport.c @@ -404,8 +404,11 @@ ats_request_address_change (void *cls, const struct GNUNET_PeerIdentity *peer, /* ATS tells me to disconnect from peer*/ if ((bw_in == 0) && (bw_out == 0)) { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "ATS tells me to disconnect from peer `%s'\n", - GNUNET_i2s (peer)); +#if DEBUG_TRANSPORT + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "ATS tells me to disconnect from peer `%s'\n", + GNUNET_i2s (peer)); +#endif GST_neighbours_force_disconnect(peer); return; } diff --git a/src/transport/gnunet-service-transport_clients.c b/src/transport/gnunet-service-transport_clients.c index 9252a5c10..6b07136e8 100644 --- a/src/transport/gnunet-service-transport_clients.c +++ b/src/transport/gnunet-service-transport_clients.c @@ -599,34 +599,6 @@ clients_handle_request_connect (void *cls, struct GNUNET_SERVER_Client *client, } -/** - * Client asked for a quota change for a particular peer. Process the request. - * - * @param cls unused - * @param client the client - * @param message the quota changing message - */ -static void -clients_handle_set_quota (void *cls, struct GNUNET_SERVER_Client *client, - const struct GNUNET_MessageHeader *message) -{ - const struct QuotaSetMessage *qsm; - - qsm = (const struct QuotaSetMessage *) message; - GNUNET_STATISTICS_update (GST_stats, - gettext_noop ("# SET QUOTA messages received"), 1, - GNUNET_NO); -#if DEBUG_TRANSPORT - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Received `%s' request (new quota %u) from client for peer `%4s'\n", - "SET_QUOTA", (unsigned int) ntohl (qsm->quota.value__), - GNUNET_i2s (&qsm->peer)); -#endif - GST_neighbours_set_incoming_quota (&qsm->peer, qsm->quota); - GNUNET_SERVER_receive_done (client, GNUNET_OK); -} - - /** * Take the given address and append it to the set of results sent back to * the client. @@ -883,8 +855,6 @@ GST_clients_start (struct GNUNET_SERVER_Handle *server) {&clients_handle_request_connect, NULL, GNUNET_MESSAGE_TYPE_TRANSPORT_REQUEST_CONNECT, sizeof (struct TransportRequestConnectMessage)}, - {&clients_handle_set_quota, NULL, - GNUNET_MESSAGE_TYPE_TRANSPORT_SET_QUOTA, sizeof (struct QuotaSetMessage)}, {&clients_handle_address_lookup, NULL, GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_LOOKUP, 0}, {&clients_handle_peer_address_lookup, NULL, diff --git a/src/transport/transport.h b/src/transport/transport.h index 8cc97e08f..f3c4329a9 100644 --- a/src/transport/transport.h +++ b/src/transport/transport.h @@ -176,7 +176,7 @@ struct QuotaSetMessage { /** - * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_NEIGHBOUR_INFO + * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_SET_QUOTA */ struct GNUNET_MessageHeader header; diff --git a/src/transport/transport_api.c b/src/transport/transport_api.c index 3d3d426e2..ab2993047 100644 --- a/src/transport/transport_api.c +++ b/src/transport/transport_api.c @@ -971,105 +971,6 @@ disconnect_and_schedule_reconnect (struct GNUNET_TRANSPORT_Handle *h) } -/** - * Closure for 'send_set_quota'. - */ -struct SetQuotaContext -{ - - /** - * Identity of the peer impacted by the quota change. - */ - struct GNUNET_PeerIdentity target; - - /** - * Quota to transmit. - */ - struct GNUNET_BANDWIDTH_Value32NBO quota_in; -}; - - -/** - * Send SET_QUOTA message to the service. - * - * @param cls the 'struct SetQuotaContext' - * @param size number of bytes available in buf - * @param buf where to copy the message - * @return number of bytes copied to buf - */ -static size_t -send_set_quota (void *cls, size_t size, void *buf) -{ - struct SetQuotaContext *sqc = cls; - struct QuotaSetMessage msg; - - if (buf == NULL) - { - GNUNET_free (sqc); - return 0; - } -#if DEBUG_TRANSPORT_API - LOG (GNUNET_ERROR_TYPE_DEBUG, - "Transmitting `%s' request with respect to `%4s'.\n", "SET_QUOTA", - GNUNET_i2s (&sqc->target)); -#endif - GNUNET_assert (size >= sizeof (struct QuotaSetMessage)); - msg.header.size = htons (sizeof (struct QuotaSetMessage)); - msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SET_QUOTA); - msg.quota = sqc->quota_in; - msg.peer = sqc->target; - memcpy (buf, &msg, sizeof (msg)); - GNUNET_free (sqc); - return sizeof (struct QuotaSetMessage); -} - - -/** - * Set the share of incoming bandwidth for the given - * peer to the specified amount. - * - * @param handle connection to transport service - * @param target who's bandwidth quota is being changed - * @param quota_in incoming bandwidth quota in bytes per ms - * @param quota_out outgoing bandwidth quota in bytes per ms - */ -void -GNUNET_TRANSPORT_set_quota (struct GNUNET_TRANSPORT_Handle *handle, - const struct GNUNET_PeerIdentity *target, - struct GNUNET_BANDWIDTH_Value32NBO quota_in, - struct GNUNET_BANDWIDTH_Value32NBO quota_out) -{ - struct Neighbour *n; - struct SetQuotaContext *sqc; - - n = neighbour_find (handle, target); - if (NULL == n) - { - LOG (GNUNET_ERROR_TYPE_ERROR, - "Quota changed to %u for peer `%s', but I have no such neighbour!\n", - (unsigned int) ntohl (quota_out.value__), GNUNET_i2s (target)); - return; - } - GNUNET_assert (NULL != handle->client); -#if DEBUG_TRANSPORT_API - if (ntohl (quota_out.value__) != n->out_tracker.available_bytes_per_s__) - LOG (GNUNET_ERROR_TYPE_DEBUG, "Quota changed from %u to %u for peer `%s'\n", - (unsigned int) n->out_tracker.available_bytes_per_s__, - (unsigned int) ntohl (quota_out.value__), GNUNET_i2s (target)); - else - LOG (GNUNET_ERROR_TYPE_DEBUG, "Quota remains at %u for peer `%s'\n", - (unsigned int) n->out_tracker.available_bytes_per_s__, - GNUNET_i2s (target)); -#endif - GNUNET_BANDWIDTH_tracker_update_quota (&n->out_tracker, quota_out); - sqc = GNUNET_malloc (sizeof (struct SetQuotaContext)); - sqc->target = *target; - sqc->quota_in = quota_in; - schedule_control_transmit (handle, sizeof (struct QuotaSetMessage), - &send_set_quota, sqc); -} - - /** * Send REQUEST_CONNECT message to the service. * -- 2.25.1