aboutsummaryrefslogtreecommitdiff
path: root/src/core/gnunet-service-core.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-10-10 11:09:42 +0000
committerChristian Grothoff <christian@grothoff.org>2011-10-10 11:09:42 +0000
commit376b5f749c03e1ff149c2e8248eed9bec928872a (patch)
tree7c44864219de6d7d77bdaec34c9e4b7aaf199647 /src/core/gnunet-service-core.c
parent9767d2478ccb8dcc3152cb617d84cd4cec2097c3 (diff)
downloadgnunet-376b5f749c03e1ff149c2e8248eed9bec928872a.tar.gz
gnunet-376b5f749c03e1ff149c2e8248eed9bec928872a.zip
dead code elimination
Diffstat (limited to 'src/core/gnunet-service-core.c')
-rw-r--r--src/core/gnunet-service-core.c159
1 files changed, 0 insertions, 159 deletions
diff --git a/src/core/gnunet-service-core.c b/src/core/gnunet-service-core.c
index ae424edad..5d262fdc6 100644
--- a/src/core/gnunet-service-core.c
+++ b/src/core/gnunet-service-core.c
@@ -567,11 +567,6 @@ struct Neighbour
567 struct GNUNET_BANDWIDTH_Tracker available_send_window; 567 struct GNUNET_BANDWIDTH_Tracker available_send_window;
568 568
569 /** 569 /**
570 * Tracking bandwidth for receiving from this peer.
571 */
572 struct GNUNET_BANDWIDTH_Tracker available_recv_window;
573
574 /**
575 * How valueable were the messages of this peer recently? 570 * How valueable were the messages of this peer recently?
576 */ 571 */
577 unsigned long long current_preference; 572 unsigned long long current_preference;
@@ -884,45 +879,6 @@ get_neighbour_timeout (struct Neighbour *n)
884 879
885 880
886/** 881/**
887 * Helper function for update_preference_sum.
888 */
889static int
890update_preference (void *cls, const GNUNET_HashCode * key, void *value)
891{
892 unsigned long long *ps = cls;
893 struct Neighbour *n = value;
894
895 n->current_preference /= 2;
896 *ps += n->current_preference;
897 return GNUNET_OK;
898}
899
900
901/**
902 * A preference value for a neighbour was update. Update
903 * the preference sum accordingly.
904 *
905 * @param inc how much was a preference value increased?
906 */
907static void
908update_preference_sum (unsigned long long inc)
909{
910 unsigned long long os;
911
912 os = preference_sum;
913 preference_sum += inc;
914 if (preference_sum >= os)
915 return; /* done! */
916 /* overflow! compensate by cutting all values in half! */
917 preference_sum = 0;
918 GNUNET_CONTAINER_multihashmap_iterate (neighbours, &update_preference,
919 &preference_sum);
920 GNUNET_STATISTICS_set (stats, gettext_noop ("# total peer preference"),
921 preference_sum, GNUNET_NO);
922}
923
924
925/**
926 * Find the entry for the given neighbour. 882 * Find the entry for the given neighbour.
927 * 883 *
928 * @param peer identity of the neighbour 884 * @param peer identity of the neighbour
@@ -1605,112 +1561,6 @@ handle_client_have_peer (void *cls, struct GNUNET_SERVER_Client *client,
1605 1561
1606 1562
1607/** 1563/**
1608 * Handle REQUEST_INFO request.
1609 *
1610 * @param cls unused
1611 * @param client client sending the request
1612 * @param message iteration request message
1613 */
1614static void
1615handle_client_request_info (void *cls, struct GNUNET_SERVER_Client *client,
1616 const struct GNUNET_MessageHeader *message)
1617{
1618 const struct RequestInfoMessage *rcm;
1619 struct Client *pos;
1620 struct Neighbour *n;
1621 struct ConfigurationInfoMessage cim;
1622 int32_t want_reserv;
1623 int32_t got_reserv;
1624 unsigned long long old_preference;
1625 struct GNUNET_TIME_Relative rdelay;
1626
1627 rdelay = GNUNET_TIME_relative_get_zero ();
1628#if DEBUG_CORE_CLIENT
1629 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Core service receives `%s' request.\n",
1630 "REQUEST_INFO");
1631#endif
1632 pos = clients;
1633 while (pos != NULL)
1634 {
1635 if (client == pos->client_handle)
1636 break;
1637 pos = pos->next;
1638 }
1639 if (pos == NULL)
1640 {
1641 GNUNET_break (0);
1642 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
1643 return;
1644 }
1645
1646 rcm = (const struct RequestInfoMessage *) message;
1647 n = find_neighbour (&rcm->peer);
1648 memset (&cim, 0, sizeof (cim));
1649 if ((n != NULL) && (GNUNET_YES == n->is_connected))
1650 {
1651 want_reserv = ntohl (rcm->reserve_inbound);
1652 if (want_reserv < 0)
1653 {
1654 got_reserv = want_reserv;
1655 }
1656 else if (want_reserv > 0)
1657 {
1658 rdelay =
1659 GNUNET_BANDWIDTH_tracker_get_delay (&n->available_recv_window,
1660 want_reserv);
1661 if (rdelay.rel_value == 0)
1662 got_reserv = want_reserv;
1663 else
1664 got_reserv = 0; /* all or nothing */
1665 }
1666 else
1667 got_reserv = 0;
1668 GNUNET_BANDWIDTH_tracker_consume (&n->available_recv_window, got_reserv);
1669 old_preference = n->current_preference;
1670 n->current_preference += GNUNET_ntohll (rcm->preference_change);
1671 if (old_preference > n->current_preference)
1672 {
1673 /* overflow; cap at maximum value */
1674 n->current_preference = ULLONG_MAX;
1675 }
1676 update_preference_sum (n->current_preference - old_preference);
1677#if DEBUG_CORE_QUOTA
1678 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1679 "Received reservation request for %d bytes for peer `%4s', reserved %d bytes, suggesting delay of %llu ms\n",
1680 (int) want_reserv, GNUNET_i2s (&rcm->peer), (int) got_reserv,
1681 (unsigned long long) rdelay.rel_value);
1682#endif
1683 cim.reserved_amount = htonl (got_reserv);
1684 cim.reserve_delay = GNUNET_TIME_relative_hton (rdelay);
1685 cim.bw_out = n->bw_out;
1686 cim.preference = n->current_preference;
1687 }
1688 else
1689 {
1690 /* Technically, this COULD happen (due to asynchronous behavior),
1691 * but it should be rare, so we should generate an info event
1692 * to help diagnosis of serious errors that might be masked by this */
1693 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1694 _
1695 ("Client asked for preference change with peer `%s', which is not connected!\n"),
1696 GNUNET_i2s (&rcm->peer));
1697 GNUNET_SERVER_receive_done (client, GNUNET_OK);
1698 return;
1699 }
1700 cim.header.size = htons (sizeof (struct ConfigurationInfoMessage));
1701 cim.header.type = htons (GNUNET_MESSAGE_TYPE_CORE_CONFIGURATION_INFO);
1702 cim.peer = rcm->peer;
1703 cim.rim_id = rcm->rim_id;
1704#if DEBUG_CORE_CLIENT
1705 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message to client.\n",
1706 "CONFIGURATION_INFO");
1707#endif
1708 send_to_client (pos, &cim.header, GNUNET_NO);
1709 GNUNET_SERVER_receive_done (client, GNUNET_OK);
1710}
1711
1712
1713/**
1714 * Free the given entry for the neighbour (it has 1564 * Free the given entry for the neighbour (it has
1715 * already been removed from the list at this point). 1565 * already been removed from the list at this point).
1716 * 1566 *
@@ -4298,11 +4148,7 @@ neighbour_quota_update (void *cls,
4298 (n->bw_out.value__ != q_out_min.value__)) 4148 (n->bw_out.value__ != q_out_min.value__))
4299 { 4149 {
4300 if (n->bw_in.value__ != q_in.value__) 4150 if (n->bw_in.value__ != q_in.value__)
4301 {
4302 n->bw_in = q_in; 4151 n->bw_in = q_in;
4303 GNUNET_BANDWIDTH_tracker_update_quota (&n->available_recv_window,
4304 n->bw_in);
4305 }
4306 if (n->bw_out.value__ != q_out_min.value__) 4152 if (n->bw_out.value__ != q_out_min.value__)
4307 n->bw_out = q_out_min; 4153 n->bw_out = q_out_min;
4308 if (GNUNET_YES == n->is_connected) 4154 if (GNUNET_YES == n->is_connected)
@@ -4356,8 +4202,6 @@ handle_transport_notify_connect (void *cls,
4356 update_neighbour_performance (n, ats, ats_count); 4202 update_neighbour_performance (n, ats, ats_count);
4357 GNUNET_BANDWIDTH_tracker_init (&n->available_send_window, n->bw_out, 4203 GNUNET_BANDWIDTH_tracker_init (&n->available_send_window, n->bw_out,
4358 MAX_WINDOW_TIME_S); 4204 MAX_WINDOW_TIME_S);
4359 GNUNET_BANDWIDTH_tracker_init (&n->available_recv_window, n->bw_in,
4360 MAX_WINDOW_TIME_S);
4361#if DEBUG_CORE 4205#if DEBUG_CORE
4362 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received connection from `%4s'.\n", 4206 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received connection from `%4s'.\n",
4363 GNUNET_i2s (&n->peer)); 4207 GNUNET_i2s (&n->peer));
@@ -4520,9 +4364,6 @@ run (void *cls, struct GNUNET_SERVER_Handle *server,
4520 GNUNET_MESSAGE_TYPE_CORE_PEER_CONNECTED, 4364 GNUNET_MESSAGE_TYPE_CORE_PEER_CONNECTED,
4521 sizeof (struct GNUNET_MessageHeader) + 4365 sizeof (struct GNUNET_MessageHeader) +
4522 sizeof (struct GNUNET_PeerIdentity)}, 4366 sizeof (struct GNUNET_PeerIdentity)},
4523 {&handle_client_request_info, NULL,
4524 GNUNET_MESSAGE_TYPE_CORE_REQUEST_INFO,
4525 sizeof (struct RequestInfoMessage)},
4526 {&handle_client_send_request, NULL, 4367 {&handle_client_send_request, NULL,
4527 GNUNET_MESSAGE_TYPE_CORE_SEND_REQUEST, 4368 GNUNET_MESSAGE_TYPE_CORE_SEND_REQUEST,
4528 sizeof (struct SendMessageRequest)}, 4369 sizeof (struct SendMessageRequest)},