aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2009-07-16 22:27:01 +0000
committerChristian Grothoff <christian@grothoff.org>2009-07-16 22:27:01 +0000
commit700336146abfc054ce2a380b2511a9bbe77f4ec1 (patch)
treefa63722c9afa2653f1d62db94748e7dfa2ee1e2a /src
parent0ce7c7880daac2269711a99f56bcc29afca5acc8 (diff)
downloadgnunet-700336146abfc054ce2a380b2511a9bbe77f4ec1.tar.gz
gnunet-700336146abfc054ce2a380b2511a9bbe77f4ec1.zip
fixes
Diffstat (limited to 'src')
-rw-r--r--src/core/core.h4
-rw-r--r--src/core/test_core_api.c2
-rw-r--r--src/core/test_core_api_peer1.conf4
-rw-r--r--src/core/test_core_api_peer2.conf4
-rw-r--r--src/transport/gnunet-service-transport.c65
-rw-r--r--src/transport/plugin_transport_tcp.c26
-rw-r--r--src/transport/test_transport_api.c2
-rw-r--r--src/transport/transport.h2
8 files changed, 79 insertions, 30 deletions
diff --git a/src/core/core.h b/src/core/core.h
index 19a090ea0..647d18698 100644
--- a/src/core/core.h
+++ b/src/core/core.h
@@ -29,12 +29,12 @@
29/** 29/**
30 * General core debugging. 30 * General core debugging.
31 */ 31 */
32#define DEBUG_CORE GNUNET_YES 32#define DEBUG_CORE GNUNET_NO
33 33
34/** 34/**
35 * Debugging interaction core-clients. 35 * Debugging interaction core-clients.
36 */ 36 */
37#define DEBUG_CORE_CLIENT GNUNET_YES 37#define DEBUG_CORE_CLIENT GNUNET_NO
38 38
39/** 39/**
40 * Definition of bits in the InitMessage's options field that specify 40 * Definition of bits in the InitMessage's options field that specify
diff --git a/src/core/test_core_api.c b/src/core/test_core_api.c
index ff565ad02..df354a856 100644
--- a/src/core/test_core_api.c
+++ b/src/core/test_core_api.c
@@ -34,7 +34,7 @@
34#include "gnunet_scheduler_lib.h" 34#include "gnunet_scheduler_lib.h"
35#include "gnunet_transport_service.h" 35#include "gnunet_transport_service.h"
36 36
37#define VERBOSE GNUNET_YES 37#define VERBOSE GNUNET_NO
38 38
39#define START_ARM GNUNET_YES 39#define START_ARM GNUNET_YES
40 40
diff --git a/src/core/test_core_api_peer1.conf b/src/core/test_core_api_peer1.conf
index 749bbbeab..0cea16038 100644
--- a/src/core/test_core_api_peer1.conf
+++ b/src/core/test_core_api_peer1.conf
@@ -12,7 +12,7 @@ PLUGINS = tcp
12#PREFIX = xterm -T transport1 -e 12#PREFIX = xterm -T transport1 -e
13#PREFIX = xterm -T transport1 -e gdb -x cmd --args 13#PREFIX = xterm -T transport1 -e gdb -x cmd --args
14#PREFIX = xterm -T transport1 -e valgrind --tool=memcheck 14#PREFIX = xterm -T transport1 -e valgrind --tool=memcheck
15DEBUG = YES 15#DEBUG = YES
16 16
17[arm] 17[arm]
18PORT = 12466 18PORT = 12466
@@ -36,7 +36,7 @@ PORT = 12470
36#OPTIONS = -l log-core-1 36#OPTIONS = -l log-core-1
37#PREFIX = xterm -T core1 -e gdb -x cmd --args 37#PREFIX = xterm -T core1 -e gdb -x cmd --args
38#PREFIX = xterm -T core1 -e 38#PREFIX = xterm -T core1 -e
39DEBUG = YES 39#DEBUG = YES
40 40
41[testing] 41[testing]
42WEAKRANDOM = YES 42WEAKRANDOM = YES
diff --git a/src/core/test_core_api_peer2.conf b/src/core/test_core_api_peer2.conf
index e61537fab..6e311e1e1 100644
--- a/src/core/test_core_api_peer2.conf
+++ b/src/core/test_core_api_peer2.conf
@@ -11,7 +11,7 @@ PORT = 22465
11PLUGINS = tcp 11PLUGINS = tcp
12#PREFIX = xterm -T transport2 -e 12#PREFIX = xterm -T transport2 -e
13#PREFIX = xterm -T transport2 -e valgrind --tool=memcheck 13#PREFIX = xterm -T transport2 -e valgrind --tool=memcheck
14DEBUG = YES 14#DEBUG = YES
15 15
16[arm] 16[arm]
17PORT = 22466 17PORT = 22466
@@ -33,7 +33,7 @@ PORT = 22469
33PORT = 22470 33PORT = 22470
34#PREFIX = xterm -T core2 -e 34#PREFIX = xterm -T core2 -e
35#PREFIX = xterm -T core2 -e valgrind --tool=memcheck 35#PREFIX = xterm -T core2 -e valgrind --tool=memcheck
36DEBUG = YES 36#DEBUG = YES
37 37
38[testing] 38[testing]
39WEAKRANDOM = YES 39WEAKRANDOM = YES
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c
index 83f54c0b9..445fb4315 100644
--- a/src/transport/gnunet-service-transport.c
+++ b/src/transport/gnunet-service-transport.c
@@ -798,24 +798,32 @@ try_alternative_plugins (struct NeighbourList *neighbour)
798 798
799 799
800/** 800/**
801 * Check the ready list for the given neighbour and 801 * The peer specified by the given neighbour has timed-out or a plugin
802 * if a plugin is ready for transmission (and if we 802 * has disconnected. We may either need to do nothing (other plugins
803 * have a message), do so! 803 * still up), or trigger a full disconnect and clean up. This
804 * function updates our state and do the necessary notifications.
805 * Also notifies our clients that the neighbour is now officially
806 * gone.
804 * 807 *
805 * @param neighbour target peer for which to check the plugins 808 * @param n the neighbour list entry for the peer
809 * @param check should we just check if all plugins
810 * disconnected or must we ask all plugins to
811 * disconnect?
806 */ 812 */
807static void try_transmission_to_peer (struct NeighbourList *neighbour); 813static void
814disconnect_neighbour (struct NeighbourList *n,
815 int check);
808 816
809 817
810/** 818/**
811 * The peer specified by the given neighbour has timed-out. Update 819 * Check the ready list for the given neighbour and
812 * our state and do the necessary notifications. Also notifies 820 * if a plugin is ready for transmission (and if we
813 * our clients that the neighbour is now officially gone. 821 * have a message), do so!
814 * 822 *
815 * @param n the neighbour list entry for the peer 823 * @param neighbour target peer for which to check the plugins
816 */ 824 */
817static void 825static void
818disconnect_neighbour (struct NeighbourList *n); 826try_transmission_to_peer (struct NeighbourList *neighbour);
819 827
820 828
821/** 829/**
@@ -868,6 +876,7 @@ transmit_send_continuation (void *cls,
868 "Transmission to peer `%s' failed, marking connection as down.\n", 876 "Transmission to peer `%s' failed, marking connection as down.\n",
869 GNUNET_i2s(target)); 877 GNUNET_i2s(target));
870 rl->connected = GNUNET_NO; 878 rl->connected = GNUNET_NO;
879 rl->plugin_handle = NULL;
871 } 880 }
872 if (!mq->internal_msg) 881 if (!mq->internal_msg)
873 rl->transmit_ready = GNUNET_YES; 882 rl->transmit_ready = GNUNET_YES;
@@ -889,8 +898,8 @@ transmit_send_continuation (void *cls,
889 another message (if available) */ 898 another message (if available) */
890 if (result == GNUNET_OK) 899 if (result == GNUNET_OK)
891 try_transmission_to_peer (n); 900 try_transmission_to_peer (n);
892 else 901 else
893 disconnect_neighbour (n); 902 disconnect_neighbour (n, GNUNET_YES);
894} 903}
895 904
896 905
@@ -1837,19 +1846,37 @@ process_hello (struct TransportPlugin *plugin,
1837 1846
1838 1847
1839/** 1848/**
1840 * The peer specified by the given neighbour has timed-out. Update 1849 * The peer specified by the given neighbour has timed-out or a plugin
1841 * our state and do the necessary notifications. Also notifies 1850 * has disconnected. We may either need to do nothing (other plugins
1842 * our clients that the neighbour is now officially gone. 1851 * still up), or trigger a full disconnect and clean up. This
1852 * function updates our state and do the necessary notifications.
1853 * Also notifies our clients that the neighbour is now officially
1854 * gone.
1843 * 1855 *
1844 * @param n the neighbour list entry for the peer 1856 * @param n the neighbour list entry for the peer
1857 * @param check should we just check if all plugins
1858 * disconnected or must we ask all plugins to
1859 * disconnect?
1845 */ 1860 */
1846static void 1861static void
1847disconnect_neighbour (struct NeighbourList *n) 1862disconnect_neighbour (struct NeighbourList *n,
1863 int check)
1848{ 1864{
1849 struct ReadyList *rpos; 1865 struct ReadyList *rpos;
1850 struct NeighbourList *npos; 1866 struct NeighbourList *npos;
1851 struct NeighbourList *nprev; 1867 struct NeighbourList *nprev;
1852 struct MessageQueue *mq; 1868 struct MessageQueue *mq;
1869
1870 if (GNUNET_YES == check)
1871 {
1872 rpos = n->plugins;
1873 while (NULL != rpos)
1874 {
1875 if (GNUNET_YES == rpos->connected)
1876 return; /* still connected */
1877 rpos = rpos->next;
1878 }
1879 }
1853 1880
1854#if DEBUG_TRANSPORT 1881#if DEBUG_TRANSPORT
1855 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, 1882 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
@@ -1945,7 +1972,7 @@ neighbour_timeout_task (void *cls,
1945 GNUNET_i2s(&n->id)); 1972 GNUNET_i2s(&n->id));
1946#endif 1973#endif
1947 n->timeout_task = GNUNET_SCHEDULER_NO_PREREQUISITE_TASK; 1974 n->timeout_task = GNUNET_SCHEDULER_NO_PREREQUISITE_TASK;
1948 disconnect_neighbour (n); 1975 disconnect_neighbour (n, GNUNET_NO);
1949} 1976}
1950 1977
1951 1978
@@ -2063,7 +2090,7 @@ plugin_env_receive (void *cls,
2063 service_context->connected = GNUNET_NO; 2090 service_context->connected = GNUNET_NO;
2064 service_context->plugin_handle = NULL; 2091 service_context->plugin_handle = NULL;
2065 } 2092 }
2066 disconnect_neighbour (n); 2093 disconnect_neighbour (n, GNUNET_YES);
2067 return NULL; 2094 return NULL;
2068 } 2095 }
2069#if DEBUG_TRANSPORT 2096#if DEBUG_TRANSPORT
diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c
index 11b9f0709..3ed20d4fa 100644
--- a/src/transport/plugin_transport_tcp.c
+++ b/src/transport/plugin_transport_tcp.c
@@ -1600,6 +1600,9 @@ handle_tcp_pong (void *cls,
1600 struct GNUNET_PeerIdentity peer; 1600 struct GNUNET_PeerIdentity peer;
1601 char *sender_addr; 1601 char *sender_addr;
1602 size_t addrlen; 1602 size_t addrlen;
1603 const struct sockaddr *addr;
1604 struct sockaddr_in v4;
1605 struct sockaddr_in6 v6;
1603 1606
1604#if DEBUG_TRANSPORT 1607#if DEBUG_TRANSPORT
1605 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, 1608 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
@@ -1637,8 +1640,27 @@ handle_tcp_pong (void *cls,
1637 GNUNET_CRYPTO_hash (&vcr->signer, 1640 GNUNET_CRYPTO_hash (&vcr->signer,
1638 sizeof( struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), 1641 sizeof( struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
1639 &peer.hashPubKey); 1642 &peer.hashPubKey);
1640 sender_addr = GNUNET_strdup (GNUNET_a2s((const struct sockaddr*) &vcr[1], 1643 addr = (const struct sockaddr*) &vcr[1];
1641 addrlen)); 1644 if (addrlen == sizeof (struct sockaddr_in))
1645 {
1646 memcpy (&v4, addr, sizeof (struct sockaddr_in));
1647 v4.sin_port = htons(check_port (plugin, ntohs (v4.sin_port)));
1648 sender_addr = GNUNET_strdup (GNUNET_a2s((const struct sockaddr*) &v4,
1649 addrlen));
1650 }
1651 else if (addrlen == sizeof (struct sockaddr_in6))
1652 {
1653 memcpy (&v6, addr, sizeof (struct sockaddr_in6));
1654 v6.sin6_port = htons(check_port (plugin, ntohs (v6.sin6_port)));
1655 sender_addr = GNUNET_strdup (GNUNET_a2s((const struct sockaddr*) &v6,
1656 addrlen));
1657 }
1658 else
1659 {
1660 GNUNET_break_op (0);
1661 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
1662 return;
1663 }
1642 plugin->env->notify_validation (plugin->env->cls, 1664 plugin->env->notify_validation (plugin->env->cls,
1643 "tcp", 1665 "tcp",
1644 &peer, 1666 &peer,
diff --git a/src/transport/test_transport_api.c b/src/transport/test_transport_api.c
index 80c1c04d8..fb8cfe302 100644
--- a/src/transport/test_transport_api.c
+++ b/src/transport/test_transport_api.c
@@ -31,7 +31,7 @@
31#include "gnunet_transport_service.h" 31#include "gnunet_transport_service.h"
32#include "transport.h" 32#include "transport.h"
33 33
34#define VERBOSE GNUNET_YES 34#define VERBOSE GNUNET_NO
35 35
36#define START_ARM GNUNET_YES 36#define START_ARM GNUNET_YES
37 37
diff --git a/src/transport/transport.h b/src/transport/transport.h
index 35e48da2e..13dcbb6b8 100644
--- a/src/transport/transport.h
+++ b/src/transport/transport.h
@@ -27,7 +27,7 @@
27#include "gnunet_time_lib.h" 27#include "gnunet_time_lib.h"
28#include "gnunet_transport_service.h" 28#include "gnunet_transport_service.h"
29 29
30#define DEBUG_TRANSPORT GNUNET_YES 30#define DEBUG_TRANSPORT GNUNET_NO
31 31
32/** 32/**
33 * For how long do we allow unused bandwidth 33 * For how long do we allow unused bandwidth