diff options
Diffstat (limited to 'src/fs')
-rw-r--r-- | src/fs/gnunet-service-fs.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/fs/gnunet-service-fs.c b/src/fs/gnunet-service-fs.c index 2e1c574c8..a0c09e946 100644 --- a/src/fs/gnunet-service-fs.c +++ b/src/fs/gnunet-service-fs.c | |||
@@ -217,6 +217,18 @@ struct ConnectedPeer | |||
217 | struct PendingMessage *pending_messages_tail; | 217 | struct PendingMessage *pending_messages_tail; |
218 | 218 | ||
219 | /** | 219 | /** |
220 | * How long does it typically take for us to transmit a message | ||
221 | * to this peer? (delay between the request being issued and | ||
222 | * the callback being invoked). | ||
223 | */ | ||
224 | struct GNUNET_LOAD_Value *transmission_delay; | ||
225 | |||
226 | /** | ||
227 | * Time when the last transmission request was issued. | ||
228 | */ | ||
229 | struct GNUNET_TIME_Absolute last_transmission_request_start; | ||
230 | |||
231 | /** | ||
220 | * Average priority of successful replies. Calculated | 232 | * Average priority of successful replies. Calculated |
221 | * as a moving average: new_avg = ((n-1)*last_avg+curr_prio) / n | 233 | * as a moving average: new_avg = ((n-1)*last_avg+curr_prio) / n |
222 | */ | 234 | */ |
@@ -1456,6 +1468,7 @@ peer_connect_handler (void *cls, | |||
1456 | uint32_t trust; | 1468 | uint32_t trust; |
1457 | 1469 | ||
1458 | cp = GNUNET_malloc (sizeof (struct ConnectedPeer)); | 1470 | cp = GNUNET_malloc (sizeof (struct ConnectedPeer)); |
1471 | cp->transmission_delay = GNUNET_LOAD_value_init (); | ||
1459 | cp->pid = GNUNET_PEER_intern (peer); | 1472 | cp->pid = GNUNET_PEER_intern (peer); |
1460 | 1473 | ||
1461 | fn = get_trust_filename (peer); | 1474 | fn = get_trust_filename (peer); |
@@ -1671,6 +1684,7 @@ peer_disconnect_handler (void *cls, | |||
1671 | GNUNET_CORE_notify_transmit_ready_cancel (cp->cth); | 1684 | GNUNET_CORE_notify_transmit_ready_cancel (cp->cth); |
1672 | while (NULL != (pm = cp->pending_messages_head)) | 1685 | while (NULL != (pm = cp->pending_messages_head)) |
1673 | destroy_pending_message (pm, 0 /* delivery failed */); | 1686 | destroy_pending_message (pm, 0 /* delivery failed */); |
1687 | GNUNET_LOAD_value_free (cp->transmission_delay); | ||
1674 | GNUNET_break (0 == cp->pending_requests); | 1688 | GNUNET_break (0 == cp->pending_requests); |
1675 | GNUNET_free (cp); | 1689 | GNUNET_free (cp); |
1676 | } | 1690 | } |
@@ -1905,6 +1919,8 @@ transmit_to_peer (void *cls, | |||
1905 | #endif | 1919 | #endif |
1906 | return 0; | 1920 | return 0; |
1907 | } | 1921 | } |
1922 | GNUNET_LOAD_update (cp->transmission_delay, | ||
1923 | GNUNET_TIME_absolute_get_duration (cp->last_transmission_request_start).value); | ||
1908 | msize = 0; | 1924 | msize = 0; |
1909 | while ( (NULL != (pm = cp->pending_messages_head) ) && | 1925 | while ( (NULL != (pm = cp->pending_messages_head) ) && |
1910 | (pm->msize <= size) ) | 1926 | (pm->msize <= size) ) |
@@ -1918,6 +1934,7 @@ transmit_to_peer (void *cls, | |||
1918 | { | 1934 | { |
1919 | GNUNET_PEER_resolve (cp->pid, | 1935 | GNUNET_PEER_resolve (cp->pid, |
1920 | &pid); | 1936 | &pid); |
1937 | cp->last_transmission_request_start = GNUNET_TIME_absolute_get (); | ||
1921 | cp->cth = GNUNET_CORE_notify_transmit_ready (core, | 1938 | cp->cth = GNUNET_CORE_notify_transmit_ready (core, |
1922 | pm->priority, | 1939 | pm->priority, |
1923 | GNUNET_CONSTANTS_SERVICE_TIMEOUT, | 1940 | GNUNET_CONSTANTS_SERVICE_TIMEOUT, |
@@ -2036,6 +2053,7 @@ add_to_pending_messages_for_peer (struct ConnectedPeer *cp, | |||
2036 | if (NULL != cp->cth) | 2053 | if (NULL != cp->cth) |
2037 | GNUNET_CORE_notify_transmit_ready_cancel (cp->cth); | 2054 | GNUNET_CORE_notify_transmit_ready_cancel (cp->cth); |
2038 | /* need to schedule transmission */ | 2055 | /* need to schedule transmission */ |
2056 | cp->last_transmission_request_start = GNUNET_TIME_absolute_get (); | ||
2039 | cp->cth = GNUNET_CORE_notify_transmit_ready (core, | 2057 | cp->cth = GNUNET_CORE_notify_transmit_ready (core, |
2040 | cp->pending_messages_head->priority, | 2058 | cp->pending_messages_head->priority, |
2041 | MAX_TRANSMIT_DELAY, | 2059 | MAX_TRANSMIT_DELAY, |