aboutsummaryrefslogtreecommitdiff
path: root/src/ats/plugin_ats_proportional.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-02-05 12:52:20 +0000
committerChristian Grothoff <christian@grothoff.org>2015-02-05 12:52:20 +0000
commitc55971f17dc99f9833af48e078c8f681be771cb7 (patch)
tree544fd671b67903506419c98d463d086a696e25a1 /src/ats/plugin_ats_proportional.c
parent15dd8e6cc1199d611d804853e134882bf13b234a (diff)
downloadgnunet-c55971f17dc99f9833af48e078c8f681be771cb7.tar.gz
gnunet-c55971f17dc99f9833af48e078c8f681be771cb7.zip
big ATS refactoring, no serious semantic changes should stem from this
Diffstat (limited to 'src/ats/plugin_ats_proportional.c')
-rw-r--r--src/ats/plugin_ats_proportional.c154
1 files changed, 0 insertions, 154 deletions
diff --git a/src/ats/plugin_ats_proportional.c b/src/ats/plugin_ats_proportional.c
index 7bcc948b7..cc5a55ebb 100644
--- a/src/ats/plugin_ats_proportional.c
+++ b/src/ats/plugin_ats_proportional.c
@@ -713,7 +713,6 @@ find_best_address_it (void *cls,
713 struct FindBestAddressCtx *ctx = cls; 713 struct FindBestAddressCtx *ctx = cls;
714 struct ATS_Address *current = value; 714 struct ATS_Address *current = value;
715 struct ATS_Address *current_best = current; 715 struct ATS_Address *current_best = current;
716 struct GNUNET_TIME_Absolute now;
717 struct AddressSolverInformation *asi; 716 struct AddressSolverInformation *asi;
718 struct GNUNET_TIME_Relative active_time; 717 struct GNUNET_TIME_Relative active_time;
719 struct GNUNET_TIME_Relative min_active_time; 718 struct GNUNET_TIME_Relative min_active_time;
@@ -727,20 +726,6 @@ find_best_address_it (void *cls,
727 726
728 current_best = NULL; 727 current_best = NULL;
729 asi = current->solver_information; 728 asi = current->solver_information;
730 now = GNUNET_TIME_absolute_get ();
731
732 if ((current->active == GNUNET_NO)
733 && (current->blocked_until.abs_value_us
734 == GNUNET_TIME_absolute_max (now, current->blocked_until).abs_value_us))
735 {
736 /* This address is blocked for suggestion */
737 LOG (GNUNET_ERROR_TYPE_DEBUG,
738 "Address %p blocked for suggestion for %s \n",
739 current,
740 GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_difference (now, current->blocked_until),
741 GNUNET_YES));
742 return GNUNET_OK;
743 }
744 if (NULL == asi) 729 if (NULL == asi)
745 { 730 {
746 GNUNET_break (0); 731 GNUNET_break (0);
@@ -1695,143 +1680,6 @@ GAS_proportional_address_property_changed (void *solver,
1695 } 1680 }
1696} 1681}
1697 1682
1698/**
1699 * Transport session for this address has changed
1700 *
1701 * NOTE: values in addresses are already updated
1702 *
1703 * @param solver solver handle
1704 * @param address the address
1705 * @param cur_session the current session
1706 * @param new_session the new session
1707 */
1708static void
1709GAS_proportional_address_session_changed (void *solver,
1710 struct ATS_Address *address,
1711 uint32_t cur_session,
1712 uint32_t new_session)
1713{
1714 struct GAS_PROPORTIONAL_Handle *s = solver;
1715 struct ATS_Address *best_address;
1716 struct ATS_Address *active_address;
1717 struct AddressSolverInformation *asi;
1718
1719 if (cur_session != new_session)
1720 {
1721 LOG (GNUNET_ERROR_TYPE_DEBUG,
1722 "Session changed from %u to %u\n",
1723 cur_session,
1724 new_session);
1725 }
1726
1727 if (NULL == address->solver_information)
1728 {
1729 GNUNET_break (0);
1730 return;
1731 }
1732
1733 if (GNUNET_NO ==
1734 GNUNET_CONTAINER_multipeermap_contains (s->requests, &address->peer))
1735 return; /* Peer is not requested */
1736
1737 /* This peer is requested, find active and best address */
1738 active_address = get_active_address (s, s->addresses, &address->peer);
1739 best_address = update_active_address (s, &address->peer);
1740
1741 if ((NULL != best_address) && ((NULL != active_address) &&
1742 (GNUNET_YES == address_eq (active_address, best_address))))
1743 {
1744 asi = best_address->solver_information;
1745 GNUNET_assert (NULL != asi);
1746
1747 /* We sticked to the same address, therefore redistribute */
1748 distribute_bandwidth_in_network (s, asi->network);
1749 }
1750}
1751
1752
1753/**
1754 * Network scope for this address has changed
1755 *
1756 * NOTE: values in addresses are already updated
1757 *
1758 * @param solver solver handle
1759 * @param address the address
1760 * @param current_network the current network
1761 * @param new_network the new network
1762 */
1763static void
1764GAS_proportional_address_change_network (void *solver,
1765 struct ATS_Address *address,
1766 uint32_t current_network,
1767 uint32_t new_network)
1768{
1769 struct GAS_PROPORTIONAL_Handle *s = solver;
1770 struct AddressSolverInformation *asi;
1771 int save_active = GNUNET_NO;
1772
1773 if (current_network == new_network)
1774 {
1775 GNUNET_break(0);
1776 return;
1777 }
1778
1779 asi = address->solver_information;
1780 if (NULL == asi)
1781 {
1782 GNUNET_break(0);
1783 return;
1784 }
1785
1786 /* Network changed */
1787 LOG(GNUNET_ERROR_TYPE_DEBUG,
1788 "Network type changed, moving %s address from `%s' to `%s'\n",
1789 (GNUNET_YES == address->active) ? "active" : "inactive",
1790 GNUNET_ATS_print_network_type (current_network),
1791 GNUNET_ATS_print_network_type (new_network));
1792
1793
1794 /* Start bulk to prevent disconnect */
1795 GAS_proportional_bulk_start(s);
1796
1797 save_active = address->active;
1798
1799 /* Disable and assign no bandwidth */
1800 address->active = GNUNET_NO;
1801 address->assigned_bw_in = 0; /* no bandwidth assigned */
1802 address->assigned_bw_out = 0; /* no bandwidth assigned */
1803
1804 /* Remove from old network */
1805 GAS_proportional_address_delete (solver, address, GNUNET_NO);
1806
1807 /* Set new network type */
1808 if (NULL == get_network (solver, new_network))
1809 {
1810 /* Address changed to invalid network... */
1811 LOG(GNUNET_ERROR_TYPE_ERROR,
1812 _("Invalid network type `%u' `%s': Disconnect!\n"), new_network,
1813 GNUNET_ATS_print_network_type (new_network));
1814 s->bw_changed (s->bw_changed_cls, address);
1815 }
1816 else
1817 {
1818 /* Add to new network and update*/
1819 GAS_proportional_address_add (solver, address, new_network);
1820 }
1821 GAS_proportional_bulk_stop (s);
1822
1823 if (GNUNET_NO == GNUNET_CONTAINER_multipeermap_contains (s->requests, &address->peer))
1824 return; /* Peer is not requested */
1825
1826 /* Find new address to suggest */
1827 if (GNUNET_YES == save_active)
1828 {
1829 /* No address available, therefore disconnect */
1830 if (NULL == update_active_address (s, &address->peer))
1831 s->bw_changed (s->bw_changed_cls, address);
1832 }
1833
1834}
1835 1683
1836/** 1684/**
1837 * Add a new single address to a network 1685 * Add a new single address to a network
@@ -1914,8 +1762,6 @@ libgnunet_plugin_ats_proportional_init (void *cls)
1914 s->env = env; 1762 s->env = env;
1915 env->sf.s_add = &GAS_proportional_address_add; 1763 env->sf.s_add = &GAS_proportional_address_add;
1916 env->sf.s_address_update_property = &GAS_proportional_address_property_changed; 1764 env->sf.s_address_update_property = &GAS_proportional_address_property_changed;
1917 env->sf.s_address_update_session = &GAS_proportional_address_session_changed;
1918 env->sf.s_address_update_network = &GAS_proportional_address_change_network;
1919 env->sf.s_get = &GAS_proportional_get_preferred_address; 1765 env->sf.s_get = &GAS_proportional_get_preferred_address;
1920 env->sf.s_get_stop = &GAS_proportional_stop_get_preferred_address; 1766 env->sf.s_get_stop = &GAS_proportional_stop_get_preferred_address;
1921 env->sf.s_pref = &GAS_proportional_address_change_preference; 1767 env->sf.s_pref = &GAS_proportional_address_change_preference;