aboutsummaryrefslogtreecommitdiff
path: root/src/stream
diff options
context:
space:
mode:
authorSree Harsha Totakura <totakura@in.tum.de>2012-11-26 13:00:28 +0000
committerSree Harsha Totakura <totakura@in.tum.de>2012-11-26 13:00:28 +0000
commiteb3c6390abc5885baf78e9c32a81682acee1019e (patch)
tree8465cf0391e7dd61bb95ac5da9a6f5cce684e5ef /src/stream
parent8f649931a3e853af3cd1b0efbb588ff4f929575f (diff)
downloadgnunet-eb3c6390abc5885baf78e9c32a81682acee1019e.tar.gz
gnunet-eb3c6390abc5885baf78e9c32a81682acee1019e.zip
seperate timeouts for MESH retries
Diffstat (limited to 'src/stream')
-rw-r--r--src/stream/stream_api.c52
1 files changed, 28 insertions, 24 deletions
diff --git a/src/stream/stream_api.c b/src/stream/stream_api.c
index 66c24dc86..562f2279c 100644
--- a/src/stream/stream_api.c
+++ b/src/stream/stream_api.c
@@ -36,7 +36,7 @@
36 36
37#include "platform.h" 37#include "platform.h"
38#include "gnunet_common.h" 38#include "gnunet_common.h"
39#include "gnunet_crypto_lib.h" 39#include "gnunet_util_lib.h"
40#include "gnunet_lockmanager_service.h" 40#include "gnunet_lockmanager_service.h"
41#include "gnunet_statistics_service.h" 41#include "gnunet_statistics_service.h"
42#include "gnunet_stream_lib.h" 42#include "gnunet_stream_lib.h"
@@ -281,6 +281,11 @@ struct GNUNET_STREAM_Socket
281 struct GNUNET_TIME_Relative ack_time_deadline; 281 struct GNUNET_TIME_Relative ack_time_deadline;
282 282
283 /** 283 /**
284 * Mesh transmit timeout
285 */
286 struct GNUNET_TIME_Relative mesh_retry_timeout;
287
288 /**
284 * The state of the protocol associated with this socket 289 * The state of the protocol associated with this socket
285 */ 290 */
286 enum State state; 291 enum State state;
@@ -576,7 +581,6 @@ static const unsigned int default_timeout = 10;
576 */ 581 */
577static const char *locking_domain = "GNUNET_STREAM_APPLOCK"; 582static const char *locking_domain = "GNUNET_STREAM_APPLOCK";
578 583
579
580/** 584/**
581 * Callback function for sending queued message 585 * Callback function for sending queued message
582 * 586 *
@@ -598,20 +602,21 @@ send_message_notify (void *cls, size_t size, void *buf)
598 return 0; /* just to be safe */ 602 return 0; /* just to be safe */
599 if (0 == size) /* request timed out */ 603 if (0 == size) /* request timed out */
600 { 604 {
601 socket->retries++; 605 socket->mesh_retry_timeout = GNUNET_TIME_STD_BACKOFF
606 (socket->mesh_retry_timeout);
602 LOG (GNUNET_ERROR_TYPE_DEBUG, 607 LOG (GNUNET_ERROR_TYPE_DEBUG,
603 "%s: Message sending timed out. Retry %d \n", 608 "%s: Message sending to MESH timed out. Retrying in %s \n",
604 GNUNET_i2s (&socket->other_peer), 609 GNUNET_i2s (&socket->other_peer),
605 socket->retries); 610 GNUNET_STRINGS_relative_time_to_string (socket->mesh_retry_timeout,
611 GNUNET_YES));
606 socket->transmit_handle = 612 socket->transmit_handle =
607 GNUNET_MESH_notify_transmit_ready (socket->tunnel, 613 GNUNET_MESH_notify_transmit_ready (socket->tunnel,
608 GNUNET_NO, /* Corking */ 614 GNUNET_NO, /* Corking */
609 /* FIXME: exponential backoff */ 615 socket->mesh_retry_timeout,
610 socket->retransmit_timeout, 616 &socket->other_peer,
611 &socket->other_peer, 617 ntohs (head->message->header.size),
612 ntohs (head->message->header.size), 618 &send_message_notify,
613 &send_message_notify, 619 socket);
614 socket);
615 return 0; 620 return 0;
616 } 621 }
617 ret = ntohs (head->message->header.size); 622 ret = ntohs (head->message->header.size);
@@ -631,16 +636,15 @@ send_message_notify (void *cls, size_t size, void *buf)
631 head = socket->queue_head; 636 head = socket->queue_head;
632 if (NULL != head) /* more pending messages to send */ 637 if (NULL != head) /* more pending messages to send */
633 { 638 {
634 socket->retries = 0; 639 socket->mesh_retry_timeout = GNUNET_TIME_relative_get_zero_ ();
635 socket->transmit_handle = 640 socket->transmit_handle =
636 GNUNET_MESH_notify_transmit_ready (socket->tunnel, 641 GNUNET_MESH_notify_transmit_ready (socket->tunnel,
637 GNUNET_NO, /* Corking */ 642 GNUNET_NO, /* Corking */
638 /* FIXME: exponential backoff */ 643 socket->mesh_retry_timeout,
639 socket->retransmit_timeout, 644 &socket->other_peer,
640 &socket->other_peer, 645 ntohs (head->message->header.size),
641 ntohs (head->message->header.size), 646 &send_message_notify,
642 &send_message_notify, 647 socket);
643 socket);
644 } 648 }
645 return ret; 649 return ret;
646} 650}
@@ -694,11 +698,11 @@ queue_message (struct GNUNET_STREAM_Socket *socket,
694 queue_entity); 698 queue_entity);
695 if (NULL == socket->transmit_handle) 699 if (NULL == socket->transmit_handle)
696 { 700 {
697 socket->retries = 0; 701 socket->mesh_retry_timeout = GNUNET_TIME_relative_get_zero_ ();
698 socket->transmit_handle = 702 socket->transmit_handle =
699 GNUNET_MESH_notify_transmit_ready (socket->tunnel, 703 GNUNET_MESH_notify_transmit_ready (socket->tunnel,
700 GNUNET_NO, /* Corking */ 704 GNUNET_NO, /* Corking */
701 socket->retransmit_timeout, 705 socket->mesh_retry_timeout,
702 &socket->other_peer, 706 &socket->other_peer,
703 ntohs (message->header.size), 707 ntohs (message->header.size),
704 &send_message_notify, 708 &send_message_notify,