aboutsummaryrefslogtreecommitdiff
path: root/src/mesh
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2013-10-15 12:28:57 +0000
committerBart Polot <bart@net.in.tum.de>2013-10-15 12:28:57 +0000
commitd3e7733d52757d2a630741411dff0c832996c941 (patch)
tree1f53a8e10824337a7f409345b5e4904fe75bd716 /src/mesh
parentd08487cfb5cd5854cd44c6d79dcfbb312fb83504 (diff)
downloadgnunet-d3e7733d52757d2a630741411dff0c832996c941.tar.gz
gnunet-d3e7733d52757d2a630741411dff0c832996c941.zip
- avoid double ACK'ing to clients on loopback create
- fix ACK id being sent - debug
Diffstat (limited to 'src/mesh')
-rw-r--r--src/mesh/gnunet-service-mesh_channel.c83
1 files changed, 45 insertions, 38 deletions
diff --git a/src/mesh/gnunet-service-mesh_channel.c b/src/mesh/gnunet-service-mesh_channel.c
index b142ea054..97c964f59 100644
--- a/src/mesh/gnunet-service-mesh_channel.c
+++ b/src/mesh/gnunet-service-mesh_channel.c
@@ -325,6 +325,36 @@ add_buffered_data (const struct GNUNET_MESH_Data *msg,
325 LOG (GNUNET_ERROR_TYPE_DEBUG, "add_buffered_data END\n"); 325 LOG (GNUNET_ERROR_TYPE_DEBUG, "add_buffered_data END\n");
326} 326}
327 327
328/**
329 * Add a destination client to a channel, initializing all data structures
330 * in the channel and the client.
331 *
332 * @param ch Channel to which add the destination.
333 * @param c Client which to add to the channel.
334 */
335static void
336add_destination (struct MeshChannel *ch, struct MeshClient *c)
337{
338 if (NULL != ch->dest)
339 {
340 GNUNET_break (0);
341 return;
342 }
343
344 /* Assign local id as destination */
345 ch->lid_dest = GML_get_next_chid (c);
346
347 /* Store in client's hashmap */
348 GML_channel_add (c, ch->lid_dest, ch);
349
350 GNUNET_break (NULL == ch->dest_rel);
351 ch->dest_rel = GNUNET_new (struct MeshChannelReliability);
352 ch->dest_rel->ch = ch;
353 ch->dest_rel->expected_delay = MESH_RETRANSMIT_TIME;
354
355 ch->dest = c;
356}
357
328 358
329/** 359/**
330 * Send data to a client. 360 * Send data to a client.
@@ -359,36 +389,6 @@ send_client_data (struct MeshChannel *ch,
359 389
360 390
361/** 391/**
362 * Add a client to a channel, initializing all needed data structures.
363 *
364 * @param ch Channel to which add the client.
365 * @param c Client which to add to the channel.
366 */
367void
368GMCH_add_client (struct MeshChannel *ch, struct MeshClient *c)
369{
370 if (NULL != ch->dest)
371 {
372 GNUNET_break (0);
373 return;
374 }
375
376 /* Assign local id as destination */
377 ch->lid_dest = GML_get_next_chid (c);
378
379 /* Store in client's hashmap */
380 GML_channel_add (c, ch->lid_dest, ch);
381
382 GNUNET_break (NULL == ch->dest_rel);
383 ch->dest_rel = GNUNET_new (struct MeshChannelReliability);
384 ch->dest_rel->ch = ch;
385 ch->dest_rel->expected_delay = MESH_RETRANSMIT_TIME;
386
387 ch->dest = c;
388}
389
390
391/**
392 * Destroy all reliable messages queued for a channel, 392 * Destroy all reliable messages queued for a channel,
393 * during a channel destruction. 393 * during a channel destruction.
394 * Frees the reliability structure itself. 394 * Frees the reliability structure itself.
@@ -916,6 +916,7 @@ handle_loopback (struct MeshChannel *ch,
916/******************************** API ***********************************/ 916/******************************** API ***********************************/
917/******************************************************************************/ 917/******************************************************************************/
918 918
919
919/** 920/**
920 * Get channel ID. 921 * Get channel ID.
921 * 922 *
@@ -1235,7 +1236,13 @@ GMCH_handle_local_data (struct MeshChannel *ch,
1235 if (GNUNET_YES == ch->reliable) 1236 if (GNUNET_YES == ch->reliable)
1236 channel_save_copy (ch, &payload->header, fwd); 1237 channel_save_copy (ch, &payload->header, fwd);
1237 if (GMT_get_buffer (ch->t, fwd) > 0) 1238 if (GMT_get_buffer (ch->t, fwd) > 0)
1238 GML_send_ack (c, fwd ? ch->lid_root : ch->lid_dest); 1239 {
1240 MESH_ChannelNumber ackid;
1241 ackid = fwd ? ch->lid_root : ch->lid_dest;
1242 LOG (GNUNET_ERROR_TYPE_DEBUG,
1243 " sending ack to client (%X)\n", ackid);
1244 GML_send_ack (c, ackid);
1245 }
1239 1246
1240 return GNUNET_OK; 1247 return GNUNET_OK;
1241} 1248}
@@ -1545,20 +1552,20 @@ GMCH_handle_create (struct MeshTunnel3 *t,
1545 channel_destroy (ch); 1552 channel_destroy (ch);
1546 return NULL; 1553 return NULL;
1547 } 1554 }
1555 else
1556 {
1557 LOG (GNUNET_ERROR_TYPE_DEBUG, " client %p has port registered\n", c);
1558 }
1548 1559
1549 GMCH_add_client (ch, c); 1560 add_destination (ch, c);
1550 if (GNUNET_YES == ch->reliable) 1561 if (GNUNET_YES == ch->reliable)
1551 LOG (GNUNET_ERROR_TYPE_DEBUG, "!!! Reliable\n"); 1562 LOG (GNUNET_ERROR_TYPE_DEBUG, "!!! Reliable\n");
1563 else
1564 LOG (GNUNET_ERROR_TYPE_DEBUG, "!!! Not Reliable\n");
1552 1565
1553 GMCH_send_create (ch); 1566 GMCH_send_create (ch);
1554 channel_send_ack (ch, fwd); 1567 channel_send_ack (ch, fwd);
1555 1568
1556 if (GNUNET_NO == ch->dest_rel->client_ready)
1557 {
1558 GML_send_ack (ch->dest, ch->lid_dest);
1559 ch->dest_rel->client_ready = GNUNET_YES;
1560 }
1561
1562 return ch; 1569 return ch;
1563} 1570}
1564 1571