aboutsummaryrefslogtreecommitdiff
path: root/src/transport/gnunet-service-transport.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport/gnunet-service-transport.c')
-rw-r--r--src/transport/gnunet-service-transport.c64
1 files changed, 56 insertions, 8 deletions
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c
index 12db541ac..0d33ac5ca 100644
--- a/src/transport/gnunet-service-transport.c
+++ b/src/transport/gnunet-service-transport.c
@@ -43,8 +43,6 @@
43 43
44#define DEBUG_PING_PONG GNUNET_NO 44#define DEBUG_PING_PONG GNUNET_NO
45 45
46#define SIGN_USELESS GNUNET_NO
47
48#define DEBUG_TRANSPORT_HELLO GNUNET_YES 46#define DEBUG_TRANSPORT_HELLO GNUNET_YES
49 47
50/** 48/**
@@ -2011,6 +2009,48 @@ remove_session_validations (void *cls,
2011 2009
2012 2010
2013/** 2011/**
2012 * We've been disconnected from the other peer (for some
2013 * connection-oriented transport). Either quickly
2014 * re-establish the connection or signal the disconnect
2015 * to the CORE.
2016 *
2017 * @param p overall plugin context
2018 * @param nl neighbour that was disconnected
2019 */
2020static void
2021try_fast_reconnect (struct TransportPlugin *p,
2022 struct NeighbourList *nl)
2023{
2024 /* FIXME-MW: fast reconnect / transport switching not implemented... */
2025 /* Note: the idea here is to hide problems with transports (or
2026 switching between plugins) from the core to eliminate the need to
2027 re-negotiate session keys and the like; OTOH, we should tell core
2028 quickly (much faster than timeout) `if a connection was lost and
2029 could not be re-established (i.e. other peer went down or is
2030 unable / refuses to communicate);
2031
2032 So we should consider:
2033 1) ideally: our own willingness / need to connect
2034 2) prior failures to connect to this peer (by plugin)
2035 3) ideally: reaons why other peer terminated (as far as knowable)
2036
2037 Most importantly, it must be POSSIBLE for another peer to terminate
2038 a connection for a while (without us instantly re-establishing it).
2039 Similarly, if another peer is gone we should quickly notify CORE.
2040 OTOH, if there was a minor glitch (i.e. crash of gnunet-service-transport
2041 on the other end), we should reconnect in such a way that BOTH CORE
2042 services never even notice.
2043 Furthermore, the same mechanism (or small variation) could be used
2044 to switch to a better-performing plugin (ATS).
2045
2046 Finally, this needs to be tested throughly... */
2047
2048 /* No reconnect, signal disconnect instead! */
2049 disconnect_neighbour (nl, GNUNET_NO);
2050}
2051
2052
2053/**
2014 * Function that will be called whenever the plugin internally 2054 * Function that will be called whenever the plugin internally
2015 * cleans up a session pointer and hence the service needs to 2055 * cleans up a session pointer and hence the service needs to
2016 * discard all of those sessions as well. Plugins that do not 2056 * discard all of those sessions as well. Plugins that do not
@@ -2037,7 +2077,7 @@ plugin_env_session_end (void *cls,
2037 session); 2077 session);
2038 nl = find_neighbour (peer); 2078 nl = find_neighbour (peer);
2039 if (nl == NULL) 2079 if (nl == NULL)
2040 return; 2080 return; /* was never marked as connected */
2041 rl = nl->plugins; 2081 rl = nl->plugins;
2042 while (rl != NULL) 2082 while (rl != NULL)
2043 { 2083 {
@@ -2046,7 +2086,7 @@ plugin_env_session_end (void *cls,
2046 rl = rl->next; 2086 rl = rl->next;
2047 } 2087 }
2048 if (rl == NULL) 2088 if (rl == NULL)
2049 return; 2089 return; /* was never marked as connected */
2050 prev = NULL; 2090 prev = NULL;
2051 pos = rl->addresses; 2091 pos = rl->addresses;
2052 while ( (pos != NULL) && 2092 while ( (pos != NULL) &&
@@ -2056,10 +2096,15 @@ plugin_env_session_end (void *cls,
2056 pos = pos->next; 2096 pos = pos->next;
2057 } 2097 }
2058 if (pos == NULL) 2098 if (pos == NULL)
2059 return; 2099 return; /* was never marked as connected */
2060 pos->session = NULL; 2100 pos->session = NULL;
2061 if (pos->addrlen != 0) 2101 if (pos->addrlen != 0)
2062 return; 2102 {
2103 if (nl->received_pong != GNUNET_NO)
2104 try_fast_reconnect (p, nl);
2105 return;
2106 }
2107 /* was inbound connection, free 'pos' */
2063 if (prev == NULL) 2108 if (prev == NULL)
2064 rl->addresses = pos->next; 2109 rl->addresses = pos->next;
2065 else 2110 else
@@ -2072,13 +2117,16 @@ plugin_env_session_end (void *cls,
2072 } 2117 }
2073 GNUNET_free (pos); 2118 GNUNET_free (pos);
2074 if (nl->received_pong == GNUNET_NO) 2119 if (nl->received_pong == GNUNET_NO)
2075 return; /* nothing to do */ 2120 return; /* nothing to do, never connected... */
2076 /* check if we have any validated addresses left */ 2121 /* check if we have any validated addresses left */
2077 pos = rl->addresses; 2122 pos = rl->addresses;
2078 while (pos != NULL) 2123 while (pos != NULL)
2079 { 2124 {
2080 if (pos->validated) 2125 if (pos->validated)
2081 return; 2126 {
2127 try_fast_reconnect (p, nl);
2128 return;
2129 }
2082 pos = pos->next; 2130 pos = pos->next;
2083 } 2131 }
2084 /* no valid addresses left, signal disconnect! */ 2132 /* no valid addresses left, signal disconnect! */