summaryrefslogtreecommitdiff
path: root/src/transport/gnunet-service-transport_manipulation.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-08-12 13:54:33 +0000
committerChristian Grothoff <christian@grothoff.org>2013-08-12 13:54:33 +0000
commit48d15f62ec7ab68fc8602f2a8db219de3dc7d5d6 (patch)
treeb81629aa82e13b8c9dbc5c7ebd4002d93de04a02 /src/transport/gnunet-service-transport_manipulation.c
parente1b1446ff25ce0e5cb7871a16b24e88517d10803 (diff)
-more code migration to microseconds:
Diffstat (limited to 'src/transport/gnunet-service-transport_manipulation.c')
-rw-r--r--src/transport/gnunet-service-transport_manipulation.c145
1 files changed, 84 insertions, 61 deletions
diff --git a/src/transport/gnunet-service-transport_manipulation.c b/src/transport/gnunet-service-transport_manipulation.c
index 0ca732d62..eb75fbb01 100644
--- a/src/transport/gnunet-service-transport_manipulation.c
+++ b/src/transport/gnunet-service-transport_manipulation.c
@@ -578,42 +578,62 @@ GST_manipulation_recv (void *cls,
void
GST_manipulation_init (const struct GNUNET_CONFIGURATION_Handle *GST_cfg)
{
- unsigned long long tmp;
-
- if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (GST_cfg,
- "transport", "MANIPULATE_DISTANCE_IN", &tmp) && (tmp > 0))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Setting inbound distance_in to %u\n",
- (unsigned long long) tmp);
- set_metric (&man_handle.general, TM_RECEIVE, GNUNET_ATS_QUALITY_NET_DISTANCE, tmp);
- }
-
- if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (GST_cfg,
- "transport", "MANIPULATE_DISTANCE_OUT", &tmp) && (tmp > 0))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Setting outbound distance_in to %u\n",
- (unsigned long long) tmp);
- set_metric (&man_handle.general, TM_SEND, GNUNET_ATS_QUALITY_NET_DISTANCE, tmp);
- }
-
- if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (GST_cfg,
- "transport", "MANIPULATE_DELAY_IN", &tmp) && (tmp > 0))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Delaying inbound traffic for %llu ms\n",
- (unsigned long long) tmp);
- set_metric (&man_handle.general, TM_RECEIVE, GNUNET_ATS_QUALITY_NET_DELAY, tmp);
- }
-
-
- if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (GST_cfg,
- "transport", "MANIPULATE_DELAY_OUT", &tmp) && (tmp > 0))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Delaying outbound traffic for %llu ms\n",
- (unsigned long long) tmp);
- set_metric (&man_handle.general, TM_SEND, GNUNET_ATS_QUALITY_NET_DELAY, tmp);
- }
-
- man_handle.peers = GNUNET_CONTAINER_multihashmap_create (10, GNUNET_NO);
+ unsigned long long tmp;
+ struct GNUNET_TIME_Relative delay;
+
+ if ( (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (GST_cfg,
+ "transport",
+ "MANIPULATE_DISTANCE_IN",
+ &tmp)) &&
+ (tmp > 0) )
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Setting inbound distance_in to %llu\n",
+ (unsigned long long) tmp);
+ set_metric (&man_handle.general, TM_RECEIVE, GNUNET_ATS_QUALITY_NET_DISTANCE, tmp);
+ }
+
+ if ( (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (GST_cfg,
+ "transport",
+ "MANIPULATE_DISTANCE_OUT",
+ &tmp)) &&
+ (tmp > 0) )
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Setting outbound distance_in to %llu\n",
+ (unsigned long long) tmp);
+ set_metric (&man_handle.general, TM_SEND,
+ GNUNET_ATS_QUALITY_NET_DISTANCE, tmp);
+ }
+
+ if ( (GNUNET_OK == GNUNET_CONFIGURATION_get_value_time (GST_cfg,
+ "transport",
+ "MANIPULATE_DELAY_IN",
+ &delay)) &&
+ (delay.rel_value_us > 0) )
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Delaying inbound traffic for %s\n",
+ GNUNET_STRINGS_relative_time_to_string (delay, GNUNET_YES));
+ set_metric (&man_handle.general, TM_RECEIVE,
+ GNUNET_ATS_QUALITY_NET_DELAY,
+ delay.rel_value_us);
+ }
+ if ( (GNUNET_OK == GNUNET_CONFIGURATION_get_value_time (GST_cfg,
+ "transport",
+ "MANIPULATE_DELAY_OUT",
+ &delay)) &&
+ (delay.rel_value_us > 0) )
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Delaying outbound traffic for %s\n",
+ GNUNET_STRINGS_relative_time_to_string (delay, GNUNET_YES));
+ set_metric (&man_handle.general,
+ TM_SEND,
+ GNUNET_ATS_QUALITY_NET_DELAY,
+ delay.rel_value_us);
+ }
+ man_handle.peers = GNUNET_CONTAINER_multihashmap_create (10, GNUNET_NO);
}
@@ -622,33 +642,36 @@ free_tmps (void *cls,
const struct GNUNET_HashCode * key,
void *value)
{
- struct DelayQueueEntry *dqe;
- struct DelayQueueEntry *next;
- if (NULL != value)
- {
- struct TM_Peer *tmp = (struct TM_Peer *) value;
- if (GNUNET_YES != GNUNET_CONTAINER_multihashmap_remove (man_handle.peers, key, value))
- GNUNET_break (0);
- free_metric (tmp);
- next = tmp->send_head;
- while (NULL != (dqe = next))
- {
- next = dqe->next;
- GNUNET_CONTAINER_DLL_remove (tmp->send_head, tmp->send_tail, dqe);
- if (NULL != dqe->cont)
- dqe->cont (dqe->cont_cls, GNUNET_SYSERR, dqe->msg_size, 0);
- GNUNET_free (dqe);
- }
- if (GNUNET_SCHEDULER_NO_TASK != tmp->send_delay_task)
- {
- GNUNET_SCHEDULER_cancel (tmp->send_delay_task);
- tmp->send_delay_task = GNUNET_SCHEDULER_NO_TASK;
- }
- GNUNET_free (tmp);
- }
- return GNUNET_OK;
+ struct DelayQueueEntry *dqe;
+ struct DelayQueueEntry *next;
+
+ if (NULL != value)
+ {
+ struct TM_Peer *tmp = (struct TM_Peer *) value;
+
+ if (GNUNET_YES != GNUNET_CONTAINER_multihashmap_remove (man_handle.peers, key, value))
+ GNUNET_break (0);
+ free_metric (tmp);
+ next = tmp->send_head;
+ while (NULL != (dqe = next))
+ {
+ next = dqe->next;
+ GNUNET_CONTAINER_DLL_remove (tmp->send_head, tmp->send_tail, dqe);
+ if (NULL != dqe->cont)
+ dqe->cont (dqe->cont_cls, GNUNET_SYSERR, dqe->msg_size, 0);
+ GNUNET_free (dqe);
+ }
+ if (GNUNET_SCHEDULER_NO_TASK != tmp->send_delay_task)
+ {
+ GNUNET_SCHEDULER_cancel (tmp->send_delay_task);
+ tmp->send_delay_task = GNUNET_SCHEDULER_NO_TASK;
+ }
+ GNUNET_free (tmp);
+ }
+ return GNUNET_OK;
}
+
/**
* Notify manipulation about disconnect so it can discard queued messages
*