aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2013-08-13 13:42:56 +0000
committerBart Polot <bart@net.in.tum.de>2013-08-13 13:42:56 +0000
commitf0912f4f9366cbb833f3c77291306aa95b54cd10 (patch)
treee6518922ccb82d82f96b2814511fc0ac73d9a117
parent6c0f027643f9a6fef37ecf6737899e55985153af (diff)
downloadgnunet-f0912f4f9366cbb833f3c77291306aa95b54cd10.tar.gz
gnunet-f0912f4f9366cbb833f3c77291306aa95b54cd10.zip
- fixes, removed dead code
-rw-r--r--src/mesh/gnunet-service-mesh-enc.c134
1 files changed, 24 insertions, 110 deletions
diff --git a/src/mesh/gnunet-service-mesh-enc.c b/src/mesh/gnunet-service-mesh-enc.c
index 48b673488..aef1a36d4 100644
--- a/src/mesh/gnunet-service-mesh-enc.c
+++ b/src/mesh/gnunet-service-mesh-enc.c
@@ -142,7 +142,7 @@ enum MeshConnectionState
142 MESH_CONNECTION_NEW, 142 MESH_CONNECTION_NEW,
143 143
144 /** 144 /**
145 * Connection created, waiting for ACK. 145 * Connection create message sent, waiting for ACK.
146 */ 146 */
147 MESH_CONNECTION_SENT, 147 MESH_CONNECTION_SENT,
148 148
@@ -823,8 +823,8 @@ static unsigned long long dht_replication_level;
823static unsigned long long max_connections; 823static unsigned long long max_connections;
824 824
825/** 825/**
826 * How many messages *in total* are we willing to queue, divided by number of 826 * How many messages *in total* are we willing to queue, divide by number of
827 * connections to get tunnel queue size. 827 * connections to get connection queue size.
828 */ 828 */
829static unsigned long long max_msgs_queue; 829static unsigned long long max_msgs_queue;
830 830
@@ -1802,6 +1802,10 @@ send_ack (struct MeshConnection *c, uint32_t ack, int fwd)
1802 msg.tid = c->t->id; 1802 msg.tid = c->t->id;
1803 msg.cid = htonl (c->id); 1803 msg.cid = htonl (c->id);
1804 1804
1805 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1806 "connection send %s ack %u on %s[%X]\n",
1807 fwd ? "FWD" : "BCK", ack, GNUNET_h2s (&c->t->id), c->id);
1808
1805 send_prebuilt_message_connection (&msg.header, c, NULL, fwd); 1809 send_prebuilt_message_connection (&msg.header, c, NULL, fwd);
1806} 1810}
1807 1811
@@ -2825,7 +2829,11 @@ tunnel_send_queued_data (struct MeshTunnel2 *t, int fwd)
2825 struct MeshTunnelQueue *next; 2829 struct MeshTunnelQueue *next;
2826 unsigned int room; 2830 unsigned int room;
2827 2831
2832 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2833 "tunnel_send_queued_data on %s\n",
2834 GNUNET_h2s (&t->id));
2828 room = tunnel_get_buffer (t, fwd); 2835 room = tunnel_get_buffer (t, fwd);
2836 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " buffer space: %u\n", room);
2829 for (tq = t->tq_head; NULL != tq && room > 0; tq = next) 2837 for (tq = t->tq_head; NULL != tq && room > 0; tq = next)
2830 { 2838 {
2831 next = tq->next; 2839 next = tq->next;
@@ -3036,6 +3044,10 @@ connection_send_ack (struct MeshConnection *c, int fwd)
3036 next_fc = fwd ? &c->fwd_fc : &c->bck_fc; 3044 next_fc = fwd ? &c->fwd_fc : &c->bck_fc;
3037 prev_fc = fwd ? &c->bck_fc : &c->fwd_fc; 3045 prev_fc = fwd ? &c->bck_fc : &c->fwd_fc;
3038 3046
3047 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3048 "connection send %s ack on %s[%X]\n",
3049 fwd ? "FWD" : "BCK", GNUNET_h2s (&c->t->id), c->id);
3050
3039 /* Check if we need to transmit the ACK */ 3051 /* Check if we need to transmit the ACK */
3040 if (prev_fc->last_ack_sent - prev_fc->last_pid_recv > 3) 3052 if (prev_fc->last_ack_sent - prev_fc->last_pid_recv > 3)
3041 { 3053 {
@@ -3066,110 +3078,6 @@ connection_send_ack (struct MeshConnection *c, int fwd)
3066 3078
3067 3079
3068/** 3080/**
3069 * Send an ACK informing the client about available buffer space.
3070 *
3071 * Note that although the name is fwd_ack, the FWD mean forward *traffic*,
3072 * the ACK itself goes "back" (towards root).
3073 *
3074 * @param ch Channel on which to send the ACK, NULL if unknown.
3075 * @param fwd Is this FWD ACK? (Going dest->owner)
3076 */
3077// static void
3078// channel_send_ack (struct MeshChannel *ch, uint16_t type, int fwd)
3079// {
3080// struct MeshChannelReliability *rel;
3081// struct MeshFlowControl *next_fc;
3082// struct MeshFlowControl *prev_fc;
3083// struct MeshClient *c;
3084// struct MeshClient *o;
3085// GNUNET_PEER_Id hop;
3086// uint32_t delta_mid;
3087// uint32_t ack;
3088// int delta;
3089//
3090// rel = fwd ? ch->fwd_rel : ch->bck_rel;
3091// c = fwd ? ch->client : ch->owner;
3092// o = fwd ? ch->owner : ch->client;
3093// hop = fwd ? connection_get_prev_hop (cn) : connection_get_next_hop (cn);
3094// next_fc = fwd ? &t->next_fc : &t->prev_fc;
3095// prev_fc = fwd ? &t->prev_fc : &t->next_fc;
3096//
3097// switch (type)
3098// {
3099// case GNUNET_MESSAGE_TYPE_MESH_UNICAST:
3100// case GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN:
3101// GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3102// "ACK due to %s\n",
3103// GNUNET_MESH_DEBUG_M2S (type));
3104// if (GNUNET_YES == t->nobuffer && (GNUNET_NO == t->reliable || NULL == c))
3105// {
3106// GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Not sending ACK, nobuffer\n");
3107// return;
3108// }
3109// if (GNUNET_YES == t->reliable && NULL != c)
3110// tunnel_send_data_ack (t, fwd);
3111// break;
3112// case GNUNET_MESSAGE_TYPE_MESH_UNICAST_ACK:
3113// case GNUNET_MESSAGE_TYPE_MESH_TO_ORIG_ACK:
3114// case GNUNET_MESSAGE_TYPE_MESH_ACK:
3115// case GNUNET_MESSAGE_TYPE_MESH_LOCAL_ACK:
3116// break;
3117// case GNUNET_MESSAGE_TYPE_MESH_POLL:
3118// case GNUNET_MESSAGE_TYPE_MESH_CONNECTION_ACK:
3119// t->force_ack = GNUNET_YES;
3120// break;
3121// default:
3122// GNUNET_break (0);
3123// }
3124//
3125// /* Check if we need to transmit the ACK */
3126// if (NULL == o &&
3127// prev_fc->last_ack_sent - prev_fc->last_pid_recv > 3 &&
3128// GNUNET_NO == t->force_ack)
3129// {
3130// GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Not sending ACK, buffer free\n");
3131// GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3132// " last pid recv: %u, last ack sent: %u\n",
3133// prev_fc->last_pid_recv, prev_fc->last_ack_sent);
3134// return;
3135// }
3136//
3137// /* Ok, ACK might be necessary, what PID to ACK? */
3138// delta = t->queue_max - next_fc->queue_n;
3139// if (NULL != o && GNUNET_YES == t->reliable && NULL != rel->head_sent)
3140// delta_mid = rel->mid_sent - rel->head_sent->mid;
3141// else
3142// delta_mid = 0;
3143// if (0 > delta || (GNUNET_YES == t->reliable &&
3144// NULL != o &&
3145// (10 < rel->n_sent || 64 <= delta_mid)))
3146// delta = 0;
3147// if (NULL != o && delta > 1)
3148// delta = 1;
3149// ack = prev_fc->last_pid_recv + delta;
3150// GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " ACK %u\n", ack);
3151// GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3152// " last pid %u, last ack %u, qmax %u, q %u\n",
3153// prev_fc->last_pid_recv, prev_fc->last_ack_sent,
3154// t->queue_max, next_fc->queue_n);
3155// if (ack == prev_fc->last_ack_sent && GNUNET_NO == t->force_ack)
3156// {
3157// GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Not sending FWD ACK, not needed\n");
3158// return;
3159// }
3160//
3161// prev_fc->last_ack_sent = ack;
3162// if (NULL != o)
3163// send_local_ack (t, o, fwd);
3164// else if (0 != hop)
3165// send_ack (t, hop, ack);
3166// else
3167// GNUNET_break (GNUNET_YES == t->destroy);
3168// t->force_ack = GNUNET_NO;
3169// }
3170
3171
3172/**
3173 * Modify the mesh message TID from global to local and send to client. 3081 * Modify the mesh message TID from global to local and send to client.
3174 * 3082 *
3175 * @param ch Channel on which to send the message. 3083 * @param ch Channel on which to send the message.
@@ -3553,6 +3461,10 @@ channel_send_ack (struct MeshChannel *ch, uint32_t buffer, int fwd)
3553 uint32_t to_allow; 3461 uint32_t to_allow;
3554 unsigned int cs; 3462 unsigned int cs;
3555 3463
3464 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3465 "Channel send %s ack on %s:%X\n",
3466 fwd ? "FWD" : "BCK", GNUNET_h2s (&ch->t->id), ch->gid);
3467
3556 /* Count connections, how many messages are already allowed */ 3468 /* Count connections, how many messages are already allowed */
3557 for (cs = 0, allowed = 0, c = t->connection_head; NULL != c; c = c->next) 3469 for (cs = 0, allowed = 0, c = t->connection_head; NULL != c; c = c->next)
3558 { 3470 {
@@ -3790,7 +3702,7 @@ tunnel_new (const struct GNUNET_HashCode *tid)
3790 3702
3791 t = GNUNET_new (struct MeshTunnel2); 3703 t = GNUNET_new (struct MeshTunnel2);
3792 t->id = *tid; 3704 t->id = *tid;
3793 t->next_chid = GNUNET_MESH_LOCAL_CHANNEL_ID_SERV; 3705 t->next_chid = 0;
3794 if (GNUNET_OK != 3706 if (GNUNET_OK !=
3795 GNUNET_CONTAINER_multihashmap_put (tunnels, tid, t, 3707 GNUNET_CONTAINER_multihashmap_put (tunnels, tid, t,
3796 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST)) 3708 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST))
@@ -3870,6 +3782,8 @@ connection_new (struct GNUNET_HashCode *tid, uint32_t cid)
3870 c->id = cid; 3782 c->id = cid;
3871 fc_init (&c->fwd_fc); 3783 fc_init (&c->fwd_fc);
3872 fc_init (&c->bck_fc); 3784 fc_init (&c->bck_fc);
3785 c->fwd_fc.c = c;
3786 c->bck_fc.c = c;
3873 tunnel_add_connection (t, c); 3787 tunnel_add_connection (t, c);
3874 3788
3875 return c; 3789 return c;
@@ -4063,7 +3977,7 @@ channel_new (struct MeshTunnel2 *t,
4063 3977
4064 if (NULL != owner) 3978 if (NULL != owner)
4065 { 3979 {
4066 while (NULL != channel_get_by_local_id (owner, t->next_chid)) 3980 while (NULL != channel_get (t, t->next_chid))
4067 t->next_chid = (t->next_chid + 1) & ~GNUNET_MESH_LOCAL_CHANNEL_ID_CLI; 3981 t->next_chid = (t->next_chid + 1) & ~GNUNET_MESH_LOCAL_CHANNEL_ID_CLI;
4068 ch->gid = t->next_chid; 3982 ch->gid = t->next_chid;
4069 t->next_chid = (t->next_chid + 1) & ~GNUNET_MESH_LOCAL_CHANNEL_ID_CLI; 3983 t->next_chid = (t->next_chid + 1) & ~GNUNET_MESH_LOCAL_CHANNEL_ID_CLI;
@@ -4599,7 +4513,7 @@ queue_add (void *cls, uint16_t type, size_t size,
4599 return; /* Drop this message */ 4513 return; /* Drop this message */
4600 } 4514 }
4601 4515
4602 if (GMC_is_pid_bigger(fc->last_pid_sent + 1, fc->last_ack_recv) && 4516 if (GMC_is_pid_bigger (fc->last_pid_sent + 1, fc->last_ack_recv) &&
4603 GNUNET_SCHEDULER_NO_TASK == fc->poll_task) 4517 GNUNET_SCHEDULER_NO_TASK == fc->poll_task)
4604 fc->poll_task = GNUNET_SCHEDULER_add_delayed (fc->poll_time, 4518 fc->poll_task = GNUNET_SCHEDULER_add_delayed (fc->poll_time,
4605 &connection_poll, 4519 &connection_poll,