aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2013-10-09 15:52:55 +0000
committerBart Polot <bart@net.in.tum.de>2013-10-09 15:52:55 +0000
commit0c568b2d745a90d30ffdc10a88be8e46929218c3 (patch)
tree34cf233c1dbe1b4d9c98053c54f4f7dfec6641b7
parent84acdaf73e35f0851ec0fb6dc2c4d6afb840bd6e (diff)
downloadgnunet-0c568b2d745a90d30ffdc10a88be8e46929218c3.tar.gz
gnunet-0c568b2d745a90d30ffdc10a88be8e46929218c3.zip
- local channel id better accounted for per-client
-rw-r--r--src/mesh/gnunet-service-mesh_channel.c30
-rw-r--r--src/mesh/gnunet-service-mesh_connection.c2
-rw-r--r--src/mesh/gnunet-service-mesh_local.c36
-rw-r--r--src/mesh/gnunet-service-mesh_local.h10
-rw-r--r--src/mesh/gnunet-service-mesh_tunnel.c11
5 files changed, 57 insertions, 32 deletions
diff --git a/src/mesh/gnunet-service-mesh_channel.c b/src/mesh/gnunet-service-mesh_channel.c
index d280e336f..ba0ed6d61 100644
--- a/src/mesh/gnunet-service-mesh_channel.c
+++ b/src/mesh/gnunet-service-mesh_channel.c
@@ -33,8 +33,10 @@
33 33
34#define LOG(level, ...) GNUNET_log_from(level,"mesh-chn",__VA_ARGS__) 34#define LOG(level, ...) GNUNET_log_from(level,"mesh-chn",__VA_ARGS__)
35 35
36#define MESH_RETRANSMIT_TIME GNUNET_TIME_UNIT_SECONDS
36#define MESH_RETRANSMIT_MARGIN 4 37#define MESH_RETRANSMIT_MARGIN 4
37 38
39
38/** 40/**
39 * All the states a connection can be in. 41 * All the states a connection can be in.
40 */ 42 */
@@ -356,8 +358,8 @@ send_client_data (struct MeshChannel *ch,
356 * @param ch Channel to which add the client. 358 * @param ch Channel to which add the client.
357 * @param c Client which to add to the channel. 359 * @param c Client which to add to the channel.
358 */ 360 */
359static void 361void
360channel_add_client (struct MeshChannel *ch, struct MeshClient *c) 362GMCH_add_client (struct MeshChannel *ch, struct MeshClient *c)
361{ 363{
362 struct MeshTunnel3 *t = ch->t; 364 struct MeshTunnel3 *t = ch->t;
363 365
@@ -368,20 +370,10 @@ channel_add_client (struct MeshChannel *ch, struct MeshClient *c)
368 } 370 }
369 371
370 /* Assign local id as destination */ 372 /* Assign local id as destination */
371 while (NULL != GML_channel_get (c, t->next_local_chid)) 373 ch->lid_dest = GML_get_next_chid (c);
372 t->next_local_chid = (t->next_local_chid + 1) | GNUNET_MESH_LOCAL_CHANNEL_ID_SERV;
373 ch->lid_dest = t->next_local_chid++;
374 t->next_local_chid = t->next_local_chid | GNUNET_MESH_LOCAL_CHANNEL_ID_SERV;
375 374
376 /* Store in client's hashmap */ 375 /* Store in client's hashmap */
377 if (GNUNET_OK != 376 GML_channel_add (c, ch->lid_dest, ch);
378 GNUNET_CONTAINER_multihashmap32_put (c->incoming_channels,
379 ch->lid_dest, ch,
380 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST))
381 {
382 GNUNET_break (0);
383 return;
384 }
385 377
386 GNUNET_break (NULL == ch->dest_rel); 378 GNUNET_break (NULL == ch->dest_rel);
387 ch->dest_rel = GNUNET_new (struct MeshChannelReliability); 379 ch->dest_rel = GNUNET_new (struct MeshChannelReliability);
@@ -540,7 +532,7 @@ channel_retransmit_message (void *cls,
540 */ 532 */
541 payload = (struct GNUNET_MESH_Data *) &copy[1]; 533 payload = (struct GNUNET_MESH_Data *) &copy[1];
542 fwd = (rel == ch->root_rel); 534 fwd = (rel == ch->root_rel);
543 c = tunnel_get_connection (ch->t, fwd); 535 c = GMT_get_connection (ch->t, fwd);
544 hop = connection_get_hop (c, fwd); 536 hop = connection_get_hop (c, fwd);
545 for (q = hop->queue_head; NULL != q; q = q->next) 537 for (q = hop->queue_head; NULL != q; q = q->next)
546 { 538 {
@@ -558,7 +550,7 @@ channel_retransmit_message (void *cls,
558 { 550 {
559 LOG (GNUNET_ERROR_TYPE_DEBUG, "!!! RETRANSMIT %u\n", copy->mid); 551 LOG (GNUNET_ERROR_TYPE_DEBUG, "!!! RETRANSMIT %u\n", copy->mid);
560 552
561 send_prebuilt_message_channel (&payload->header, ch, fwd); 553 GMCH_send_prebuilt_message (&payload->header, ch, fwd);
562 GNUNET_STATISTICS_update (stats, "# data retransmitted", 1, GNUNET_NO); 554 GNUNET_STATISTICS_update (stats, "# data retransmitted", 1, GNUNET_NO);
563 } 555 }
564 else 556 else
@@ -588,7 +580,6 @@ channel_send_connections_ack (struct MeshChannel *ch,
588{ 580{
589 struct MeshTunnel3 *t = ch->t; 581 struct MeshTunnel3 *t = ch->t;
590 struct MeshConnection *c; 582 struct MeshConnection *c;
591 struct MeshFlowControl *fc;
592 uint32_t allowed; 583 uint32_t allowed;
593 uint32_t to_allow; 584 uint32_t to_allow;
594 uint32_t allow_per_connection; 585 uint32_t allow_per_connection;
@@ -599,10 +590,11 @@ channel_send_connections_ack (struct MeshChannel *ch,
599 fwd ? "FWD" : "BCK", peer2s (ch->t->peer), ch->gid); 590 fwd ? "FWD" : "BCK", peer2s (ch->t->peer), ch->gid);
600 591
601 /* Count connections, how many messages are already allowed */ 592 /* Count connections, how many messages are already allowed */
593 cs = GMT_count_connections (t);
602 for (cs = 0, allowed = 0, c = t->connection_head; NULL != c; c = c->next) 594 for (cs = 0, allowed = 0, c = t->connection_head; NULL != c; c = c->next)
603 { 595 {
604 fc = fwd ? &c->fwd_fc : &c->bck_fc; 596 fc = fwd ? &c->fwd_fc : &c->bck_fc;
605 if (GMC_is_pid_bigger(fc->last_pid_recv, fc->last_ack_sent)) 597 if (GMC_is_pid_bigger (fc->last_pid_recv, fc->last_ack_sent))
606 { 598 {
607 GNUNET_break (0); 599 GNUNET_break (0);
608 continue; 600 continue;
@@ -631,7 +623,7 @@ channel_send_connections_ack (struct MeshChannel *ch,
631 { 623 {
632 continue; 624 continue;
633 } 625 }
634 connection_send_ack (c, allow_per_connection, fwd); 626 GMC_send_ack (c, allow_per_connection, fwd);
635 } 627 }
636 628
637 LOG (GNUNET_ERROR_TYPE_DEBUG, 629 LOG (GNUNET_ERROR_TYPE_DEBUG,
diff --git a/src/mesh/gnunet-service-mesh_connection.c b/src/mesh/gnunet-service-mesh_connection.c
index 776690a76..20f122ded 100644
--- a/src/mesh/gnunet-service-mesh_connection.c
+++ b/src/mesh/gnunet-service-mesh_connection.c
@@ -40,8 +40,6 @@
40#define MESH_MAX_POLL_TIME GNUNET_TIME_relative_multiply (\ 40#define MESH_MAX_POLL_TIME GNUNET_TIME_relative_multiply (\
41 GNUNET_TIME_UNIT_MINUTES,\ 41 GNUNET_TIME_UNIT_MINUTES,\
42 10) 42 10)
43#define MESH_RETRANSMIT_TIME GNUNET_TIME_UNIT_SECONDS
44
45#define LOG(level, ...) GNUNET_log_from (level,"mesh-con",__VA_ARGS__) 43#define LOG(level, ...) GNUNET_log_from (level,"mesh-con",__VA_ARGS__)
46 44
47 45
diff --git a/src/mesh/gnunet-service-mesh_local.c b/src/mesh/gnunet-service-mesh_local.c
index 3fea3a714..1e3bf1669 100644
--- a/src/mesh/gnunet-service-mesh_local.c
+++ b/src/mesh/gnunet-service-mesh_local.c
@@ -58,12 +58,17 @@ struct MeshClient
58 */ 58 */
59 struct GNUNET_CONTAINER_MultiHashMap32 *own_channels; 59 struct GNUNET_CONTAINER_MultiHashMap32 *own_channels;
60 60
61 /** 61 /**
62 * Tunnels this client has accepted, indexed by incoming local id 62 * Tunnels this client has accepted, indexed by incoming local id
63 */ 63 */
64 struct GNUNET_CONTAINER_MultiHashMap32 *incoming_channels; 64 struct GNUNET_CONTAINER_MultiHashMap32 *incoming_channels;
65 65
66 /** 66 /**
67 * Channel ID for the next incoming channel.
68 */
69 MESH_ChannelNumber next_chid;
70
71 /**
67 * Handle to communicate with the client 72 * Handle to communicate with the client
68 */ 73 */
69 struct GNUNET_SERVER_Client *handle; 74 struct GNUNET_SERVER_Client *handle;
@@ -177,9 +182,10 @@ handle_client_connect (void *cls, struct GNUNET_SERVER_Client *client)
177 182
178 if (NULL == client) 183 if (NULL == client)
179 return; 184 return;
180 c = GNUNET_malloc (sizeof (struct MeshClient)); 185 c = GNUNET_new (struct MeshClient);
181 c->handle = client; 186 c->handle = client;
182 c->id = next_client_id++; /* overflow not important: just for debug */ 187 c->id = next_client_id++; /* overflow not important: just for debug */
188 c->next_chid = GNUNET_MESH_LOCAL_CHANNEL_ID_SERV;
183 GNUNET_SERVER_client_keep (client); 189 GNUNET_SERVER_client_keep (client);
184 GNUNET_SERVER_client_set_user_context (client, c); 190 GNUNET_SERVER_client_set_user_context (client, c);
185 GNUNET_CONTAINER_DLL_insert (clients_head, clients_tail, c); 191 GNUNET_CONTAINER_DLL_insert (clients_head, clients_tail, c);
@@ -894,6 +900,7 @@ GML_channel_add (struct MeshClient *client,
894 GNUNET_break (0); 900 GNUNET_break (0);
895} 901}
896 902
903
897/** 904/**
898 * Remove a channel from a client 905 * Remove a channel from a client
899 * 906 *
@@ -914,6 +921,31 @@ GML_channel_remove (struct MeshClient *client,
914 GNUNET_break (0); 921 GNUNET_break (0);
915} 922}
916 923
924
925/**
926 * Get the tunnel's next free local channel ID.
927 *
928 * @param c Client.
929 *
930 * @return LID of a channel free to use.
931 */
932MESH_ChannelNumber
933GML_get_next_chid (struct MeshClient *c)
934{
935 MESH_ChannelNumber chid;
936
937 while (NULL != GML_channel_get (c, c->next_chid))
938 {
939 LOG (GNUNET_ERROR_TYPE_DEBUG, "Channel %u exists...\n", c->next_chid);
940 c->next_chid = (c->next_chid + 1) | GNUNET_MESH_LOCAL_CHANNEL_ID_SERV;
941 }
942 chid = c->next_chid;
943 c->next_chid = (c->next_chid + 1) | GNUNET_MESH_LOCAL_CHANNEL_ID_SERV;
944
945 return chid;
946}
947
948
917/** 949/**
918 * Check if client has registered with the service and has not disconnected 950 * Check if client has registered with the service and has not disconnected
919 * 951 *
diff --git a/src/mesh/gnunet-service-mesh_local.h b/src/mesh/gnunet-service-mesh_local.h
index 637a87aeb..4befb24ac 100644
--- a/src/mesh/gnunet-service-mesh_local.h
+++ b/src/mesh/gnunet-service-mesh_local.h
@@ -107,6 +107,16 @@ GML_channel_remove (struct MeshClient *client,
107 struct MeshChannel *ch); 107 struct MeshChannel *ch);
108 108
109/** 109/**
110 * Get the tunnel's next free local channel ID.
111 *
112 * @param c Client.
113 *
114 * @return LID of a channel free to use.
115 */
116MESH_ChannelNumber
117GML_get_next_chid (struct MeshClient *c);
118
119/**
110 * Check if client has registered with the service and has not disconnected 120 * Check if client has registered with the service and has not disconnected
111 * 121 *
112 * @param client the client to check 122 * @param client the client to check
diff --git a/src/mesh/gnunet-service-mesh_tunnel.c b/src/mesh/gnunet-service-mesh_tunnel.c
index 362ce7e74..1ceb500ba 100644
--- a/src/mesh/gnunet-service-mesh_tunnel.c
+++ b/src/mesh/gnunet-service-mesh_tunnel.c
@@ -115,11 +115,6 @@ struct MeshTunnel3
115 MESH_ChannelNumber next_chid; 115 MESH_ChannelNumber next_chid;
116 116
117 /** 117 /**
118 * Channel ID for the next incoming channel.
119 */
120 MESH_ChannelNumber next_local_chid;
121
122 /**
123 * Pending message count. 118 * Pending message count.
124 */ 119 */
125 int pending_messages; 120 int pending_messages;
@@ -589,7 +584,6 @@ GMT_new (void)
589 584
590 t = GNUNET_new (struct MeshTunnel3); 585 t = GNUNET_new (struct MeshTunnel3);
591 t->next_chid = 0; 586 t->next_chid = 0;
592 t->next_local_chid = GNUNET_MESH_LOCAL_CHANNEL_ID_SERV;
593// if (GNUNET_OK != 587// if (GNUNET_OK !=
594// GNUNET_CONTAINER_multihashmap_put (tunnels, tid, t, 588// GNUNET_CONTAINER_multihashmap_put (tunnels, tid, t,
595// GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST)) 589// GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST))
@@ -1074,13 +1068,12 @@ GMT_get_destination (struct MeshTunnel3 *t)
1074} 1068}
1075 1069
1076 1070
1077
1078/** 1071/**
1079 * Get the tunnel's next free Channel ID. 1072 * Get the tunnel's next free global channel ID.
1080 * 1073 *
1081 * @param t Tunnel. 1074 * @param t Tunnel.
1082 * 1075 *
1083 * @return ID of a channel free to use. 1076 * @return GID of a channel free to use.
1084 */ 1077 */
1085MESH_ChannelNumber 1078MESH_ChannelNumber
1086GMT_get_next_chid (struct MeshTunnel3 *t) 1079GMT_get_next_chid (struct MeshTunnel3 *t)