diff options
author | Bart Polot <bart@net.in.tum.de> | 2013-10-15 12:41:07 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2013-10-15 12:41:07 +0000 |
commit | 9d5e7ddec00e421f60cb0de94c0d8c63edb26d23 (patch) | |
tree | 820110682f4e79a942f6386f478c91bdce78468b /src/mesh | |
parent | d3e7733d52757d2a630741411dff0c832996c941 (diff) | |
download | gnunet-9d5e7ddec00e421f60cb0de94c0d8c63edb26d23.tar.gz gnunet-9d5e7ddec00e421f60cb0de94c0d8c63edb26d23.zip |
- always update client's rel info on ACK
Diffstat (limited to 'src/mesh')
-rw-r--r-- | src/mesh/gnunet-service-mesh_channel.c | 141 |
1 files changed, 82 insertions, 59 deletions
diff --git a/src/mesh/gnunet-service-mesh_channel.c b/src/mesh/gnunet-service-mesh_channel.c index 97c964f59..b7829aad7 100644 --- a/src/mesh/gnunet-service-mesh_channel.c +++ b/src/mesh/gnunet-service-mesh_channel.c | |||
@@ -389,6 +389,86 @@ send_client_data (struct MeshChannel *ch, | |||
389 | 389 | ||
390 | 390 | ||
391 | /** | 391 | /** |
392 | * Send a buffered message to the client, for in order delivery or | ||
393 | * as result of client ACK. | ||
394 | * | ||
395 | * @param ch Channel on which to empty the message buffer. | ||
396 | * @param c Client to send to. | ||
397 | * @param fwd Is this to send FWD data?. | ||
398 | */ | ||
399 | static void | ||
400 | send_client_buffered_data (struct MeshChannel *ch, | ||
401 | struct MeshClient *c, | ||
402 | int fwd) | ||
403 | { | ||
404 | struct MeshReliableMessage *copy; | ||
405 | struct MeshChannelReliability *rel; | ||
406 | |||
407 | LOG (GNUNET_ERROR_TYPE_DEBUG, "send_buffered_data\n"); | ||
408 | rel = fwd ? ch->dest_rel : ch->root_rel; | ||
409 | if (GNUNET_NO == rel->client_ready) | ||
410 | { | ||
411 | LOG (GNUNET_ERROR_TYPE_DEBUG, "client not ready\n"); | ||
412 | return; | ||
413 | } | ||
414 | |||
415 | copy = rel->head_recv; | ||
416 | /* We never buffer channel management messages */ | ||
417 | if (NULL != copy) | ||
418 | { | ||
419 | if (copy->mid == rel->mid_recv || GNUNET_NO == ch->reliable) | ||
420 | { | ||
421 | struct GNUNET_MESH_Data *msg = (struct GNUNET_MESH_Data *) ©[1]; | ||
422 | |||
423 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
424 | " have %u! now expecting %u\n", | ||
425 | copy->mid, rel->mid_recv + 1); | ||
426 | send_client_data (ch, msg, fwd); | ||
427 | rel->n_recv--; | ||
428 | rel->mid_recv++; | ||
429 | GNUNET_CONTAINER_DLL_remove (rel->head_recv, rel->tail_recv, copy); | ||
430 | GNUNET_free (copy); | ||
431 | } | ||
432 | else | ||
433 | { | ||
434 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
435 | " reliable && don't have %u, next is %u\n", | ||
436 | rel->mid_recv, | ||
437 | copy->mid); | ||
438 | return; | ||
439 | } | ||
440 | } | ||
441 | LOG (GNUNET_ERROR_TYPE_DEBUG, "send_buffered_data END\n"); | ||
442 | } | ||
443 | |||
444 | |||
445 | /** | ||
446 | * Allow a client to send more data. | ||
447 | * | ||
448 | * In case the client was already allowed to send data, do nothing. | ||
449 | * | ||
450 | * @param ch Channel. | ||
451 | * @param fwd Is this a FWD ACK? (FWD ACKs are sent to root) | ||
452 | */ | ||
453 | static void | ||
454 | send_client_ack (struct MeshChannel *ch, int fwd) | ||
455 | { | ||
456 | struct MeshChannelReliability *rel = fwd ? ch->root_rel : ch->dest_rel; | ||
457 | |||
458 | if (NULL == rel) | ||
459 | { | ||
460 | GNUNET_break (0); | ||
461 | return; | ||
462 | } | ||
463 | if (GNUNET_YES == rel->client_ready) | ||
464 | return; | ||
465 | |||
466 | GML_send_ack (fwd ? ch->root : ch->dest, fwd ? ch->lid_root : ch->lid_dest); | ||
467 | rel->client_ready = GNUNET_YES; | ||
468 | } | ||
469 | |||
470 | |||
471 | /** | ||
392 | * Destroy all reliable messages queued for a channel, | 472 | * Destroy all reliable messages queued for a channel, |
393 | * during a channel destruction. | 473 | * during a channel destruction. |
394 | * Frees the reliability structure itself. | 474 | * Frees the reliability structure itself. |
@@ -652,9 +732,9 @@ channel_confirm (struct MeshChannel *ch, int fwd) | |||
652 | /* TODO return? */ | 732 | /* TODO return? */ |
653 | } | 733 | } |
654 | } | 734 | } |
655 | GML_send_ack (fwd ? ch->root : ch->dest, fwd ? ch->lid_root : ch->lid_dest); | 735 | send_client_ack (ch, fwd); |
656 | 736 | ||
657 | /* In case of a FWD ACk (SYNACK) send a BCK ACK (ACK). */ | 737 | /* In case of a FWD ACK (SYNACK) send a BCK ACK (ACK). */ |
658 | if (fwd) | 738 | if (fwd) |
659 | channel_send_ack (ch, !fwd); | 739 | channel_send_ack (ch, !fwd); |
660 | } | 740 | } |
@@ -708,63 +788,6 @@ channel_save_copy (struct MeshChannel *ch, | |||
708 | } | 788 | } |
709 | 789 | ||
710 | 790 | ||
711 | |||
712 | /** | ||
713 | * Send a buffered message to the client, for in order delivery or | ||
714 | * as result of client ACK. | ||
715 | * | ||
716 | * @param ch Channel on which to empty the message buffer. | ||
717 | * @param c Client to send to. | ||
718 | * @param fwd Is this to send FWD data?. | ||
719 | */ | ||
720 | static void | ||
721 | send_client_buffered_data (struct MeshChannel *ch, | ||
722 | struct MeshClient *c, | ||
723 | int fwd) | ||
724 | { | ||
725 | struct MeshReliableMessage *copy; | ||
726 | struct MeshChannelReliability *rel; | ||
727 | |||
728 | LOG (GNUNET_ERROR_TYPE_DEBUG, "send_buffered_data\n"); | ||
729 | rel = fwd ? ch->dest_rel : ch->root_rel; | ||
730 | if (GNUNET_NO == rel->client_ready) | ||
731 | { | ||
732 | LOG (GNUNET_ERROR_TYPE_DEBUG, "client not ready\n"); | ||
733 | return; | ||
734 | } | ||
735 | |||
736 | copy = rel->head_recv; | ||
737 | /* We never buffer channel management messages */ | ||
738 | if (NULL != copy) | ||
739 | { | ||
740 | if (copy->mid == rel->mid_recv || GNUNET_NO == ch->reliable) | ||
741 | { | ||
742 | struct GNUNET_MESH_Data *msg = (struct GNUNET_MESH_Data *) ©[1]; | ||
743 | |||
744 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
745 | " have %u! now expecting %u\n", | ||
746 | copy->mid, rel->mid_recv + 1); | ||
747 | send_client_data (ch, msg, fwd); | ||
748 | rel->n_recv--; | ||
749 | rel->mid_recv++; | ||
750 | GNUNET_CONTAINER_DLL_remove (rel->head_recv, rel->tail_recv, copy); | ||
751 | GNUNET_free (copy); | ||
752 | } | ||
753 | else | ||
754 | { | ||
755 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
756 | " reliable && don't have %u, next is %u\n", | ||
757 | rel->mid_recv, | ||
758 | copy->mid); | ||
759 | return; | ||
760 | } | ||
761 | } | ||
762 | LOG (GNUNET_ERROR_TYPE_DEBUG, "send_buffered_data END\n"); | ||
763 | } | ||
764 | |||
765 | |||
766 | |||
767 | |||
768 | /** | 791 | /** |
769 | * Destroy a channel and free all resources. | 792 | * Destroy a channel and free all resources. |
770 | * | 793 | * |