aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2014-12-15 07:17:55 +0000
committerBart Polot <bart@net.in.tum.de>2014-12-15 07:17:55 +0000
commit4253dace949ef4d4480b26d091046ff08fa1b6bc (patch)
tree853143cbedb77fb9eb3d053fb5d00ac07b045dae
parent99d028e9fe6e4ee9ab8c0b61002652d455358665 (diff)
downloadgnunet-4253dace949ef4d4480b26d091046ff08fa1b6bc.tar.gz
gnunet-4253dace949ef4d4480b26d091046ff08fa1b6bc.zip
Fix connection count to count only ESTABLISHED connections, use DEFINE instead of hardcoded number
-rw-r--r--src/cadet/gnunet-service-cadet_connection.c4
-rw-r--r--src/cadet/gnunet-service-cadet_peer.c15
-rw-r--r--src/cadet/gnunet-service-cadet_tunnel.c23
-rw-r--r--src/cadet/gnunet-service-cadet_tunnel.h2
4 files changed, 25 insertions, 19 deletions
diff --git a/src/cadet/gnunet-service-cadet_connection.c b/src/cadet/gnunet-service-cadet_connection.c
index ee96dddf8..fe4a22747 100644
--- a/src/cadet/gnunet-service-cadet_connection.c
+++ b/src/cadet/gnunet-service-cadet_connection.c
@@ -1833,6 +1833,7 @@ GCC_handle_broken (void* cls,
1833 } 1833 }
1834 1834
1835 t = c->t; 1835 t = c->t;
1836
1836 fwd = is_fwd (c, id); 1837 fwd = is_fwd (c, id);
1837 c->destroy = GNUNET_YES; 1838 c->destroy = GNUNET_YES;
1838 if (GCC_is_terminal (c, fwd)) 1839 if (GCC_is_terminal (c, fwd))
@@ -2699,7 +2700,8 @@ GCC_get_allowed (struct CadetConnection *c, int fwd)
2699 struct CadetFlowControl *fc; 2700 struct CadetFlowControl *fc;
2700 2701
2701 fc = fwd ? &c->fwd_fc : &c->bck_fc; 2702 fc = fwd ? &c->fwd_fc : &c->bck_fc;
2702 if (GC_is_pid_bigger (fc->last_pid_recv, fc->last_ack_sent)) 2703 if (CADET_CONNECTION_READY != c->state
2704 || GC_is_pid_bigger (fc->last_pid_recv, fc->last_ack_sent))
2703 { 2705 {
2704 return 0; 2706 return 0;
2705 } 2707 }
diff --git a/src/cadet/gnunet-service-cadet_peer.c b/src/cadet/gnunet-service-cadet_peer.c
index b57c77e11..838a2d3de 100644
--- a/src/cadet/gnunet-service-cadet_peer.c
+++ b/src/cadet/gnunet-service-cadet_peer.c
@@ -941,8 +941,8 @@ search_handler (void *cls, const struct CadetPeerPath *path)
941 /* Count connections */ 941 /* Count connections */
942 connection_count = GCT_count_connections (peer->tunnel); 942 connection_count = GCT_count_connections (peer->tunnel);
943 943
944 /* If we already have 3 (or more (?!)) connections, it's enough */ 944 /* If we already have our minimum (or more) connections, it's enough */
945 if (3 <= connection_count) 945 if (CONNECTIONS_PER_TUNNEL <= connection_count)
946 return; 946 return;
947 947
948 if (CADET_TUNNEL_SEARCHING == GCT_get_cstate (peer->tunnel)) 948 if (CADET_TUNNEL_SEARCHING == GCT_get_cstate (peer->tunnel))
@@ -1914,11 +1914,7 @@ GCP_add_path (struct CadetPeer *peer, struct CadetPeerPath *path,
1914 LOG (GNUNET_ERROR_TYPE_DEBUG, " added\n"); 1914 LOG (GNUNET_ERROR_TYPE_DEBUG, " added\n");
1915 GNUNET_CONTAINER_DLL_insert_before (peer->path_head, 1915 GNUNET_CONTAINER_DLL_insert_before (peer->path_head,
1916 peer->path_tail, aux, path); 1916 peer->path_tail, aux, path);
1917 if (NULL != peer->tunnel && 3 < GCT_count_connections (peer->tunnel)) 1917 goto finish;
1918 {
1919 GCP_connect (peer);
1920 }
1921 return path;
1922 } 1918 }
1923 else 1919 else
1924 { 1920 {
@@ -1933,7 +1929,10 @@ GCP_add_path (struct CadetPeer *peer, struct CadetPeerPath *path,
1933 GNUNET_CONTAINER_DLL_insert_tail (peer->path_head, peer->path_tail, 1929 GNUNET_CONTAINER_DLL_insert_tail (peer->path_head, peer->path_tail,
1934 path); 1930 path);
1935 LOG (GNUNET_ERROR_TYPE_DEBUG, " added last\n"); 1931 LOG (GNUNET_ERROR_TYPE_DEBUG, " added last\n");
1936 if (NULL != peer->tunnel && 3 < GCT_count_connections (peer->tunnel)) 1932
1933finish:
1934 if (NULL != peer->tunnel
1935 && CONNECTIONS_PER_TUNNEL < GCT_count_connections (peer->tunnel))
1937 { 1936 {
1938 GCP_connect (peer); 1937 GCP_connect (peer);
1939 } 1938 }
diff --git a/src/cadet/gnunet-service-cadet_tunnel.c b/src/cadet/gnunet-service-cadet_tunnel.c
index 44b9f3153..cab5809a3 100644
--- a/src/cadet/gnunet-service-cadet_tunnel.c
+++ b/src/cadet/gnunet-service-cadet_tunnel.c
@@ -37,8 +37,6 @@
37 37
38#define REKEY_WAIT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5) 38#define REKEY_WAIT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5)
39 39
40#define CONNECTIONS_PER_TUNNEL 3
41
42#if !defined(GNUNET_CULL_LOGGING) 40#if !defined(GNUNET_CULL_LOGGING)
43#define DUMP_KEYS_TO_STDERR GNUNET_YES 41#define DUMP_KEYS_TO_STDERR GNUNET_YES
44#else 42#else
@@ -2332,7 +2330,7 @@ trim_connections (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
2332 2330
2333 for (c = iter = t->connection_head; NULL != iter; iter = iter->next) 2331 for (c = iter = t->connection_head; NULL != iter; iter = iter->next)
2334 { 2332 {
2335 if ((NULL == c || iter->created.abs_value_us > c->created.abs_value_us) 2333 if ((iter->created.abs_value_us > c->created.abs_value_us)
2336 && GNUNET_NO == GCC_is_direct (iter->c)) 2334 && GNUNET_NO == GCC_is_direct (iter->c))
2337 { 2335 {
2338 c = iter; 2336 c = iter;
@@ -2788,7 +2786,7 @@ GCT_count_connections (struct CadetTunnel *t)
2788 return 0; 2786 return 0;
2789 2787
2790 for (count = 0, iter = t->connection_head; NULL != iter; iter = iter->next) 2788 for (count = 0, iter = t->connection_head; NULL != iter; iter = iter->next)
2791 if (CADET_CONNECTION_DESTROYED != GCC_get_state (iter->c)) 2789 if (CADET_CONNECTION_READY == GCC_get_state (iter->c))
2792 count++; 2790 count++;
2793 2791
2794 return count; 2792 return count;
@@ -3065,24 +3063,29 @@ GCT_send_connection_acks (struct CadetTunnel *t)
3065 } 3063 }
3066 3064
3067 /* Authorize connections to send more data */ 3065 /* Authorize connections to send more data */
3068 to_allow = buffer; /* - allowed; */ 3066 to_allow = buffer; /* FIXME (- allowed;) */
3069 3067
3070 for (iter = t->connection_head; 3068 for (iter = t->connection_head;
3071 NULL != iter && to_allow > 0; 3069 NULL != iter && to_allow > 0;
3072 iter = iter->next) 3070 iter = iter->next)
3073 { 3071 {
3074 allow_per_connection = to_allow/cs; 3072 if (CADET_CONNECTION_READY != GCC_get_state (iter->c)
3075 to_allow -= allow_per_connection; 3073 || get_connection_allowed (iter) > 64 / 3)
3076 cs--;
3077 if (get_connection_allowed (iter) > 64 / 3)
3078 { 3074 {
3079 continue; 3075 continue;
3080 } 3076 }
3077 allow_per_connection = to_allow/cs;
3078 to_allow -= allow_per_connection;
3079 cs--;
3081 GCC_allow (iter->c, allow_per_connection, 3080 GCC_allow (iter->c, allow_per_connection,
3082 GCC_is_origin (iter->c, GNUNET_NO)); 3081 GCC_is_origin (iter->c, GNUNET_NO));
3083 } 3082 }
3084 3083
3085 GNUNET_break (to_allow == 0); //FIXME tripped 3084 if (0 != to_allow)
3085 {
3086 GNUNET_break (0);
3087 LOG (GNUNET_ERROR_TYPE_WARNING, " reminding to_allow: %u\n", to_allow);
3088 }
3086} 3089}
3087 3090
3088 3091
diff --git a/src/cadet/gnunet-service-cadet_tunnel.h b/src/cadet/gnunet-service-cadet_tunnel.h
index 3c57896d5..12be8a032 100644
--- a/src/cadet/gnunet-service-cadet_tunnel.h
+++ b/src/cadet/gnunet-service-cadet_tunnel.h
@@ -40,6 +40,8 @@ extern "C"
40#include "platform.h" 40#include "platform.h"
41#include "gnunet_util_lib.h" 41#include "gnunet_util_lib.h"
42 42
43#define CONNECTIONS_PER_TUNNEL 3
44
43/** 45/**
44 * All the connectivity states a tunnel can be in. 46 * All the connectivity states a tunnel can be in.
45 */ 47 */