diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2011-03-18 16:41:57 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2011-03-18 16:41:57 +0000 |
commit | 1d436d8516c2968ce4f36e2f15859075be58f779 (patch) | |
tree | 5395d42f77d8b61de6161ca02cbcadd5a8d1ddb8 /src | |
parent | 9239434df21c273fecff72b921e457589fa62c95 (diff) | |
download | gnunet-1d436d8516c2968ce4f36e2f15859075be58f779.tar.gz gnunet-1d436d8516c2968ce4f36e2f15859075be58f779.zip |
unix domains sockets are now preferred
Diffstat (limited to 'src')
-rw-r--r-- | src/transport/gnunet-service-transport.c | 70 | ||||
-rw-r--r-- | src/transport/test_transport_api_multi_peer1.conf | 5 | ||||
-rw-r--r-- | src/transport/test_transport_api_multi_peer2.conf | 4 | ||||
-rw-r--r-- | src/transport/test_transport_ats.c | 1 | ||||
-rw-r--r-- | src/transport/test_transport_ats_peer1.conf | 5 | ||||
-rw-r--r-- | src/transport/test_transport_ats_peer2.conf | 5 | ||||
-rw-r--r-- | src/transport/transport.h | 21 |
7 files changed, 91 insertions, 20 deletions
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index e55fc41ac..1a5d0af4b 100644 --- a/src/transport/gnunet-service-transport.c +++ b/src/transport/gnunet-service-transport.c | |||
@@ -929,7 +929,7 @@ static void disconnect_neighbour (struct NeighbourList *n, int check); | |||
929 | * | 929 | * |
930 | * @param neighbour target peer for which to transmit | 930 | * @param neighbour target peer for which to transmit |
931 | */ | 931 | */ |
932 | static void try_transmission_to_peer (struct NeighbourList *neighbour); | 932 | static void try_transmission_to_peer (struct NeighbourList *n); |
933 | 933 | ||
934 | 934 | ||
935 | struct ATS_info * ats_init (); | 935 | struct ATS_info * ats_init (); |
@@ -947,6 +947,9 @@ void ats_notify_ats_data (struct ATS_info * ats, | |||
947 | const struct GNUNET_PeerIdentity *peer, | 947 | const struct GNUNET_PeerIdentity *peer, |
948 | const struct GNUNET_TRANSPORT_ATS_Information *ats_data); | 948 | const struct GNUNET_TRANSPORT_ATS_Information *ats_data); |
949 | 949 | ||
950 | struct ForeignAddressList * ats_get_preferred_address (struct ATS_info * ats, | ||
951 | struct NeighbourList *n); | ||
952 | |||
950 | /** | 953 | /** |
951 | * Find an entry in the neighbour list for a particular peer. | 954 | * Find an entry in the neighbour list for a particular peer. |
952 | * | 955 | * |
@@ -1525,6 +1528,9 @@ find_ready_address(struct NeighbourList *neighbour) | |||
1525 | struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get (); | 1528 | struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get (); |
1526 | struct ForeignAddressList *best_address; | 1529 | struct ForeignAddressList *best_address; |
1527 | 1530 | ||
1531 | /* Hack to prefer unix domain sockets */ | ||
1532 | struct ForeignAddressList *unix_address = NULL; | ||
1533 | |||
1528 | best_address = NULL; | 1534 | best_address = NULL; |
1529 | while (head != NULL) | 1535 | while (head != NULL) |
1530 | { | 1536 | { |
@@ -1566,6 +1572,12 @@ find_ready_address(struct NeighbourList *neighbour) | |||
1566 | (unsigned long long) addresses->timeout.abs_value, | 1572 | (unsigned long long) addresses->timeout.abs_value, |
1567 | (unsigned int) addresses->distance); | 1573 | (unsigned int) addresses->distance); |
1568 | #endif | 1574 | #endif |
1575 | if (0==strcmp(head->plugin->short_name,"unix")) | ||
1576 | { | ||
1577 | if ((unix_address == NULL) || ((unix_address != NULL) && | ||
1578 | (addresses->latency.rel_value < unix_address->latency.rel_value))) | ||
1579 | unix_address = addresses; | ||
1580 | } | ||
1569 | if ( ( (best_address == NULL) || | 1581 | if ( ( (best_address == NULL) || |
1570 | (addresses->connected == GNUNET_YES) || | 1582 | (addresses->connected == GNUNET_YES) || |
1571 | (best_address->connected == GNUNET_NO) ) && | 1583 | (best_address->connected == GNUNET_NO) ) && |
@@ -1577,12 +1589,22 @@ find_ready_address(struct NeighbourList *neighbour) | |||
1577 | connected a chance some times... */ | 1589 | connected a chance some times... */ |
1578 | addresses = addresses->next; | 1590 | addresses = addresses->next; |
1579 | } | 1591 | } |
1592 | if (unix_address != NULL) | ||
1593 | break; | ||
1580 | head = head->next; | 1594 | head = head->next; |
1581 | } | 1595 | } |
1596 | if (unix_address != NULL) | ||
1597 | { | ||
1598 | best_address = unix_address; | ||
1599 | #if DEBUG_TRANSPORT | ||
1600 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Found unix address, forced this address\n"); | ||
1601 | #endif | ||
1602 | } | ||
1582 | if (best_address != NULL) | 1603 | if (best_address != NULL) |
1583 | { | 1604 | { |
1584 | #if DEBUG_TRANSPORT | 1605 | #if DEBUG_TRANSPORT |
1585 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1606 | |
1607 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1586 | "Best address found (`%s') has latency of %llu ms.\n", | 1608 | "Best address found (`%s') has latency of %llu ms.\n", |
1587 | (best_address->addrlen > 0) | 1609 | (best_address->addrlen > 0) |
1588 | ? a2s (best_address->ready_list->plugin->short_name, | 1610 | ? a2s (best_address->ready_list->plugin->short_name, |
@@ -1599,6 +1621,7 @@ find_ready_address(struct NeighbourList *neighbour) | |||
1599 | 1, | 1621 | 1, |
1600 | GNUNET_NO); | 1622 | GNUNET_NO); |
1601 | } | 1623 | } |
1624 | |||
1602 | return best_address; | 1625 | return best_address; |
1603 | 1626 | ||
1604 | } | 1627 | } |
@@ -1626,7 +1649,7 @@ retry_transmission_task (void *cls, | |||
1626 | * @param neighbour target peer for which to transmit | 1649 | * @param neighbour target peer for which to transmit |
1627 | */ | 1650 | */ |
1628 | static void | 1651 | static void |
1629 | try_transmission_to_peer (struct NeighbourList *neighbour) | 1652 | try_transmission_to_peer (struct NeighbourList *n) |
1630 | { | 1653 | { |
1631 | struct ReadyList *rl; | 1654 | struct ReadyList *rl; |
1632 | struct MessageQueue *mq; | 1655 | struct MessageQueue *mq; |
@@ -1634,7 +1657,7 @@ try_transmission_to_peer (struct NeighbourList *neighbour) | |||
1634 | ssize_t ret; | 1657 | ssize_t ret; |
1635 | int force_address; | 1658 | int force_address; |
1636 | 1659 | ||
1637 | if (neighbour->messages_head == NULL) | 1660 | if (n->messages_head == NULL) |
1638 | { | 1661 | { |
1639 | #if DEBUG_TRANSPORT | 1662 | #if DEBUG_TRANSPORT |
1640 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1663 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -1644,12 +1667,12 @@ try_transmission_to_peer (struct NeighbourList *neighbour) | |||
1644 | return; /* nothing to do */ | 1667 | return; /* nothing to do */ |
1645 | } | 1668 | } |
1646 | rl = NULL; | 1669 | rl = NULL; |
1647 | mq = neighbour->messages_head; | 1670 | mq = n->messages_head; |
1648 | force_address = GNUNET_YES; | 1671 | force_address = GNUNET_YES; |
1649 | if (mq->specific_address == NULL) | 1672 | if (mq->specific_address == NULL) |
1650 | { | 1673 | { |
1651 | /* TODO: ADD ATS */ | 1674 | /* TODO: ADD ATS */ |
1652 | mq->specific_address = find_ready_address(neighbour); | 1675 | mq->specific_address = ats_get_preferred_address(ats, n); |
1653 | GNUNET_STATISTICS_update (stats, | 1676 | GNUNET_STATISTICS_update (stats, |
1654 | gettext_noop ("# transport selected peer address freely"), | 1677 | gettext_noop ("# transport selected peer address freely"), |
1655 | 1, | 1678 | 1, |
@@ -1680,9 +1703,9 @@ try_transmission_to_peer (struct NeighbourList *neighbour) | |||
1680 | mq->message_buf_size, | 1703 | mq->message_buf_size, |
1681 | GNUNET_NO); | 1704 | GNUNET_NO); |
1682 | if (mq->client != NULL) | 1705 | if (mq->client != NULL) |
1683 | transmit_send_ok (mq->client, neighbour, &neighbour->id, GNUNET_NO); | 1706 | transmit_send_ok (mq->client, n, &n->id, GNUNET_NO); |
1684 | GNUNET_CONTAINER_DLL_remove (neighbour->messages_head, | 1707 | GNUNET_CONTAINER_DLL_remove (n->messages_head, |
1685 | neighbour->messages_tail, | 1708 | n->messages_tail, |
1686 | mq); | 1709 | mq); |
1687 | GNUNET_free (mq); | 1710 | GNUNET_free (mq); |
1688 | return; /* nobody ready */ | 1711 | return; /* nobody ready */ |
@@ -1691,11 +1714,11 @@ try_transmission_to_peer (struct NeighbourList *neighbour) | |||
1691 | gettext_noop ("# message delivery deferred (no address)"), | 1714 | gettext_noop ("# message delivery deferred (no address)"), |
1692 | 1, | 1715 | 1, |
1693 | GNUNET_NO); | 1716 | GNUNET_NO); |
1694 | if (neighbour->retry_task != GNUNET_SCHEDULER_NO_TASK) | 1717 | if (n->retry_task != GNUNET_SCHEDULER_NO_TASK) |
1695 | GNUNET_SCHEDULER_cancel (neighbour->retry_task); | 1718 | GNUNET_SCHEDULER_cancel (n->retry_task); |
1696 | neighbour->retry_task = GNUNET_SCHEDULER_add_delayed (timeout, | 1719 | n->retry_task = GNUNET_SCHEDULER_add_delayed (timeout, |
1697 | &retry_transmission_task, | 1720 | &retry_transmission_task, |
1698 | neighbour); | 1721 | n); |
1699 | #if DEBUG_TRANSPORT | 1722 | #if DEBUG_TRANSPORT |
1700 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1723 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1701 | "No validated destination address available to transmit message of size %u to peer `%4s', will wait %llums to find an address.\n", | 1724 | "No validated destination address available to transmit message of size %u to peer `%4s', will wait %llums to find an address.\n", |
@@ -1707,8 +1730,8 @@ try_transmission_to_peer (struct NeighbourList *neighbour) | |||
1707 | (unless that's already pending...) */ | 1730 | (unless that's already pending...) */ |
1708 | return; | 1731 | return; |
1709 | } | 1732 | } |
1710 | GNUNET_CONTAINER_DLL_remove (neighbour->messages_head, | 1733 | GNUNET_CONTAINER_DLL_remove (n->messages_head, |
1711 | neighbour->messages_tail, | 1734 | n->messages_tail, |
1712 | mq); | 1735 | mq); |
1713 | if (mq->specific_address->connected == GNUNET_NO) | 1736 | if (mq->specific_address->connected == GNUNET_NO) |
1714 | mq->specific_address->connect_attempts++; | 1737 | mq->specific_address->connect_attempts++; |
@@ -5675,6 +5698,23 @@ void ats_notify_ats_data (struct ATS_info * ats, | |||
5675 | ats_calculate_bandwidth_distribution(ats); | 5698 | ats_calculate_bandwidth_distribution(ats); |
5676 | } | 5699 | } |
5677 | 5700 | ||
5701 | struct ForeignAddressList * ats_get_preferred_address (struct ATS_info * ats, | ||
5702 | struct NeighbourList *n) | ||
5703 | { | ||
5704 | #if DEBUG_ATS | ||
5705 | GNUNET_log (GNUNET_ERROR_TYPE_BULK, "ats_get_prefered_transport for peer: %s\n",GNUNET_i2s(&n->id)); | ||
5706 | #endif | ||
5707 | struct ReadyList *next = n->plugins; | ||
5708 | while (next != NULL) | ||
5709 | { | ||
5710 | #if DEBUG_ATS | ||
5711 | GNUNET_log (GNUNET_ERROR_TYPE_BULK, "plugin: %s %i\n",next->plugin->short_name,strcmp(next->plugin->short_name,"unix")); | ||
5712 | #endif | ||
5713 | next = next->next; | ||
5714 | } | ||
5715 | return find_ready_address(n); | ||
5716 | } | ||
5717 | |||
5678 | /** | 5718 | /** |
5679 | * Initiate transport service. | 5719 | * Initiate transport service. |
5680 | * | 5720 | * |
diff --git a/src/transport/test_transport_api_multi_peer1.conf b/src/transport/test_transport_api_multi_peer1.conf index 0f0977277..2e95a5bd8 100644 --- a/src/transport/test_transport_api_multi_peer1.conf +++ b/src/transport/test_transport_api_multi_peer1.conf | |||
@@ -27,6 +27,9 @@ USE_IPv4 = YES | |||
27 | #BINDTO4 = 127.0.0.1 | 27 | #BINDTO4 = 127.0.0.1 |
28 | #BINDTO6 = ::1 | 28 | #BINDTO6 = ::1 |
29 | 29 | ||
30 | [transport-unix] | ||
31 | PORT = 30004 | ||
32 | |||
30 | [fs] | 33 | [fs] |
31 | AUTOSTART = NO | 34 | AUTOSTART = NO |
32 | 35 | ||
@@ -56,7 +59,7 @@ FRIENDS-ONLY = NO | |||
56 | MINIMUM-FRIENDS = 0 | 59 | MINIMUM-FRIENDS = 0 |
57 | 60 | ||
58 | [transport] | 61 | [transport] |
59 | PLUGINS = tcp udp http | 62 | PLUGINS = tcp udp http unix |
60 | #DEBUG = YES | 63 | #DEBUG = YES |
61 | #PREFIX = xterm -T transport2 -e gdb --command=cmd --args | 64 | #PREFIX = xterm -T transport2 -e gdb --command=cmd --args |
62 | #PREFIX = valgrind --tool=memcheck --leak-check=full --log-file=transport%p | 65 | #PREFIX = valgrind --tool=memcheck --leak-check=full --log-file=transport%p |
diff --git a/src/transport/test_transport_api_multi_peer2.conf b/src/transport/test_transport_api_multi_peer2.conf index 9f6ffb239..c1f1eadb9 100644 --- a/src/transport/test_transport_api_multi_peer2.conf +++ b/src/transport/test_transport_api_multi_peer2.conf | |||
@@ -27,6 +27,8 @@ USE_IPv4 = YES | |||
27 | #BINDTO4 = 127.0.0.1 | 27 | #BINDTO4 = 127.0.0.1 |
28 | #BINDTO6 = ::1 | 28 | #BINDTO6 = ::1 |
29 | 29 | ||
30 | [transport-unix] | ||
31 | PORT = 40005 | ||
30 | 32 | ||
31 | [core] | 33 | [core] |
32 | AUTOSTART = NO | 34 | AUTOSTART = NO |
@@ -57,7 +59,7 @@ FRIENDS-ONLY = NO | |||
57 | MINIMUM-FRIENDS = 0 | 59 | MINIMUM-FRIENDS = 0 |
58 | 60 | ||
59 | [transport] | 61 | [transport] |
60 | PLUGINS = tcp udp http | 62 | PLUGINS = tcp udp http unix |
61 | #DEBUG = YES | 63 | #DEBUG = YES |
62 | ACCEPT_FROM6 = ::1; | 64 | ACCEPT_FROM6 = ::1; |
63 | ACCEPT_FROM = 127.0.0.1; | 65 | ACCEPT_FROM = 127.0.0.1; |
diff --git a/src/transport/test_transport_ats.c b/src/transport/test_transport_ats.c index 4c636cab6..739975951 100644 --- a/src/transport/test_transport_ats.c +++ b/src/transport/test_transport_ats.c | |||
@@ -336,7 +336,6 @@ static void | |||
336 | exchange_hello (void *cls, | 336 | exchange_hello (void *cls, |
337 | const struct GNUNET_MessageHeader *message) | 337 | const struct GNUNET_MessageHeader *message) |
338 | { | 338 | { |
339 | return; | ||
340 | struct PeerContext *me = cls; | 339 | struct PeerContext *me = cls; |
341 | 340 | ||
342 | GNUNET_TRANSPORT_get_hello_cancel (p1.th, &exchange_hello, me); | 341 | GNUNET_TRANSPORT_get_hello_cancel (p1.th, &exchange_hello, me); |
diff --git a/src/transport/test_transport_ats_peer1.conf b/src/transport/test_transport_ats_peer1.conf index e750ee011..0347d293f 100644 --- a/src/transport/test_transport_ats_peer1.conf +++ b/src/transport/test_transport_ats_peer1.conf | |||
@@ -8,6 +8,9 @@ ENABLE_UPNP = NO | |||
8 | INTERNAL_ADDRESS = 127.0.0.1 | 8 | INTERNAL_ADDRESS = 127.0.0.1 |
9 | EXTERNAL_ADDRESS = 127.0.0.1 | 9 | EXTERNAL_ADDRESS = 127.0.0.1 |
10 | 10 | ||
11 | [transport-unix] | ||
12 | PORT = 4368 | ||
13 | |||
11 | [fs] | 14 | [fs] |
12 | AUTOSTART = NO | 15 | AUTOSTART = NO |
13 | 16 | ||
@@ -37,7 +40,7 @@ FRIENDS-ONLY = NO | |||
37 | MINIMUM-FRIENDS = 0 | 40 | MINIMUM-FRIENDS = 0 |
38 | 41 | ||
39 | [transport] | 42 | [transport] |
40 | PLUGINS = tcp | 43 | PLUGINS = tcp unix |
41 | #DEBUG = YES | 44 | #DEBUG = YES |
42 | #PREFIX = xterm -T transport2 -e gdb --command=cmd --args | 45 | #PREFIX = xterm -T transport2 -e gdb --command=cmd --args |
43 | #PREFIX = valgrind --tool=memcheck --leak-check=full --log-file=transport%p | 46 | #PREFIX = valgrind --tool=memcheck --leak-check=full --log-file=transport%p |
diff --git a/src/transport/test_transport_ats_peer2.conf b/src/transport/test_transport_ats_peer2.conf index 40f0b0732..065ed56a5 100644 --- a/src/transport/test_transport_ats_peer2.conf +++ b/src/transport/test_transport_ats_peer2.conf | |||
@@ -8,6 +8,9 @@ ENABLE_UPNP = NO | |||
8 | EXTERNAL_ADDRESS = 127.0.0.1 | 8 | EXTERNAL_ADDRESS = 127.0.0.1 |
9 | INTERNAL_ADDRESS = 127.0.0.1 | 9 | INTERNAL_ADDRESS = 127.0.0.1 |
10 | 10 | ||
11 | [transport-unix] | ||
12 | PORT = 5368 | ||
13 | |||
11 | [core] | 14 | [core] |
12 | AUTOSTART = NO | 15 | AUTOSTART = NO |
13 | 16 | ||
@@ -37,7 +40,7 @@ FRIENDS-ONLY = NO | |||
37 | MINIMUM-FRIENDS = 0 | 40 | MINIMUM-FRIENDS = 0 |
38 | 41 | ||
39 | [transport] | 42 | [transport] |
40 | PLUGINS = tcp | 43 | PLUGINS = tcp unix |
41 | #DEBUG = YES | 44 | #DEBUG = YES |
42 | ACCEPT_FROM6 = ::1; | 45 | ACCEPT_FROM6 = ::1; |
43 | ACCEPT_FROM = 127.0.0.1; | 46 | ACCEPT_FROM = 127.0.0.1; |
diff --git a/src/transport/transport.h b/src/transport/transport.h index 00af17cab..dc9e7ce58 100644 --- a/src/transport/transport.h +++ b/src/transport/transport.h | |||
@@ -30,6 +30,27 @@ | |||
30 | #include "gnunet_time_lib.h" | 30 | #include "gnunet_time_lib.h" |
31 | #include "gnunet_transport_service.h" | 31 | #include "gnunet_transport_service.h" |
32 | 32 | ||
33 | /* Minimum time between to calculations*/ | ||
34 | #define ATS_MIN_INTERVAL GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS,250) | ||
35 | #define ATS_EXEC_INTERVAL GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS,1) | ||
36 | |||
37 | #define DEBUG_ATS GNUNET_NO | ||
38 | |||
39 | struct ATS_info | ||
40 | { | ||
41 | struct GNUNET_CONTAINER_MultiHashMap * peers; | ||
42 | struct GNUNET_TIME_Absolute last; | ||
43 | struct GNUNET_TIME_Relative min_delta; | ||
44 | struct GNUNET_TIME_Relative reg_delta; | ||
45 | |||
46 | GNUNET_SCHEDULER_TaskIdentifier ats_task; | ||
47 | }; | ||
48 | |||
49 | struct ATS_peer | ||
50 | { | ||
51 | struct GNUNET_PeerIdentity peer; | ||
52 | }; | ||
53 | |||
33 | #define DEBUG_TRANSPORT GNUNET_NO | 54 | #define DEBUG_TRANSPORT GNUNET_NO |
34 | #define DEBUG_TRANSPORT_TIMEOUT GNUNET_NO | 55 | #define DEBUG_TRANSPORT_TIMEOUT GNUNET_NO |
35 | #define DEBUG_TRANSPORT_DISCONNECT GNUNET_NO | 56 | #define DEBUG_TRANSPORT_DISCONNECT GNUNET_NO |