diff options
author | Bart Polot <bart@net.in.tum.de> | 2013-05-14 10:19:05 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2013-05-14 10:19:05 +0000 |
commit | 0cb74a6ea36eecc4cc2885aee9e53ba78e3a9ee4 (patch) | |
tree | 4571a95ecd6b42f16d9883b4da19f9082ba90235 /src | |
parent | f6ab8147a173a9dce1802ae7cbcdda4c1f35d375 (diff) | |
download | gnunet-0cb74a6ea36eecc4cc2885aee9e53ba78e3a9ee4.tar.gz gnunet-0cb74a6ea36eecc4cc2885aee9e53ba78e3a9ee4.zip |
- refactor fc init
Diffstat (limited to 'src')
-rw-r--r-- | src/mesh/gnunet-service-mesh-new.c | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/src/mesh/gnunet-service-mesh-new.c b/src/mesh/gnunet-service-mesh-new.c index b24bbfefe..7f904e1dd 100644 --- a/src/mesh/gnunet-service-mesh-new.c +++ b/src/mesh/gnunet-service-mesh-new.c | |||
@@ -1798,13 +1798,6 @@ tunnel_add_client (struct MeshTunnel *t, struct MeshClient *c) | |||
1798 | return; | 1798 | return; |
1799 | } | 1799 | } |
1800 | t->client = c; | 1800 | t->client = c; |
1801 | t->next_fc.last_ack_sent = t->prev_fc.last_pid_recv + 1; | ||
1802 | t->next_fc.last_pid_sent = t->prev_fc.last_pid_recv; | ||
1803 | t->next_fc.last_ack_recv = t->nobuffer ? 1 : INITIAL_WINDOW_SIZE - 1; | ||
1804 | t->next_fc.last_pid_recv = (uint32_t) -1; /* Expected next: 0 */ | ||
1805 | t->next_fc.poll_task = GNUNET_SCHEDULER_NO_TASK; | ||
1806 | t->next_fc.poll_time = GNUNET_TIME_UNIT_SECONDS; | ||
1807 | t->next_fc.queue_n = 0; | ||
1808 | } | 1801 | } |
1809 | 1802 | ||
1810 | 1803 | ||
@@ -2291,6 +2284,20 @@ tunnel_destroy_empty (struct MeshTunnel *t) | |||
2291 | t->destroy = GNUNET_YES; | 2284 | t->destroy = GNUNET_YES; |
2292 | } | 2285 | } |
2293 | 2286 | ||
2287 | /** | ||
2288 | * Initialize a Flow Control structure | ||
2289 | */ | ||
2290 | static void | ||
2291 | fc_init (struct MeshFlowControl *fc) | ||
2292 | { | ||
2293 | fc->last_pid_sent = (uint32_t) -1; /* Next (expected) = 0 */ | ||
2294 | fc->last_pid_recv = (uint32_t) -1; | ||
2295 | fc->last_ack_sent = INITIAL_WINDOW_SIZE - 1; | ||
2296 | fc->last_ack_recv = INITIAL_WINDOW_SIZE - 1; | ||
2297 | fc->poll_task = GNUNET_SCHEDULER_NO_TASK; | ||
2298 | fc->poll_time = GNUNET_TIME_UNIT_SECONDS; | ||
2299 | fc->queue_n = 0; | ||
2300 | } | ||
2294 | 2301 | ||
2295 | /** | 2302 | /** |
2296 | * Create a new tunnel | 2303 | * Create a new tunnel |
@@ -2319,14 +2326,8 @@ tunnel_new (GNUNET_PEER_Id owner, | |||
2319 | t->id.tid = tid; | 2326 | t->id.tid = tid; |
2320 | t->queue_max = (max_msgs_queue / max_tunnels) + 1; | 2327 | t->queue_max = (max_msgs_queue / max_tunnels) + 1; |
2321 | t->owner = client; | 2328 | t->owner = client; |
2322 | t->next_fc.last_pid_sent = (uint32_t) -1; /* Next (expected) = 0 */ | 2329 | fc_init (&t->next_fc); |
2323 | t->next_fc.last_pid_recv = (uint32_t) -1; | 2330 | fc_init (&t->prev_fc); |
2324 | t->prev_fc.last_pid_sent = (uint32_t) -1; | ||
2325 | t->prev_fc.last_pid_recv = (uint32_t) -1; | ||
2326 | t->next_fc.last_ack_sent = INITIAL_WINDOW_SIZE - 1; | ||
2327 | t->next_fc.last_ack_recv = INITIAL_WINDOW_SIZE - 1; | ||
2328 | t->prev_fc.last_ack_sent = INITIAL_WINDOW_SIZE - 1; | ||
2329 | t->prev_fc.last_ack_recv = INITIAL_WINDOW_SIZE - 1; | ||
2330 | t->local_tid = local; | 2331 | t->local_tid = local; |
2331 | n_tunnels++; | 2332 | n_tunnels++; |
2332 | GNUNET_STATISTICS_update (stats, "# tunnels", 1, GNUNET_NO); | 2333 | GNUNET_STATISTICS_update (stats, "# tunnels", 1, GNUNET_NO); |