summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2013-05-07 15:51:54 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2013-05-07 15:51:54 +0000
commit7a3022c4bb8ea4f4d5d23263155d446d7dd4628f (patch)
tree6edc2b65bd5ac623f84a2a57896e7f26ae364469 /src
parent05aa8d8001e3977adb5d68d851db608c075dffee (diff)
fix for 0002881 + test
Diffstat (limited to 'src')
-rw-r--r--src/transport/Makefile.am13
-rw-r--r--src/transport/gnunet-service-transport_manipulation.c75
-rw-r--r--src/transport/test_transport_api_manipulation_cfg_peer1.conf31
-rw-r--r--src/transport/test_transport_api_manipulation_cfg_peer2.conf31
4 files changed, 137 insertions, 13 deletions
diff --git a/src/transport/Makefile.am b/src/transport/Makefile.am
index 14ab82e5d..258a7aae5 100644
--- a/src/transport/Makefile.am
+++ b/src/transport/Makefile.am
@@ -351,6 +351,7 @@ check_PROGRAMS = \
test_transport_blacklisting_multiple_plugins \
test_transport_api_manipulation_send_tcp \
test_transport_api_manipulation_recv_tcp \
+ test_transport_api_manipulation_cfg \
test_transport_api_reliability_tcp \
test_transport_api_reliability_tcp_nat \
test_transport_api_unreliability_udp \
@@ -406,6 +407,7 @@ TESTS = \
test_transport_blacklisting_multiple_plugins \
test_transport_api_manipulation_send_tcp \
test_transport_api_manipulation_recv_tcp \
+ test_transport_api_manipulation_cfg \
test_transport_api_reliability_tcp \
test_transport_api_reliability_tcp_nat \
test_transport_api_unreliability_udp \
@@ -677,6 +679,15 @@ test_transport_api_manipulation_recv_tcp_LDADD = \
$(top_builddir)/src/util/libgnunetutil.la \
$(top_builddir)/src/transport/libgnunettransporttesting.la
+test_transport_api_manipulation_cfg_SOURCES = \
+ test_transport_api_manipulation_cfg.c
+test_transport_api_manipulation_cfg_LDADD = \
+ $(top_builddir)/src/transport/libgnunettransport.la \
+ $(top_builddir)/src/hello/libgnunethello.la \
+ $(top_builddir)/src/util/libgnunetutil.la \
+ $(top_builddir)/src/transport/libgnunettransporttesting.la
+
+
test_transport_api_reliability_tcp_SOURCES = \
test_transport_api_reliability.c
@@ -1005,6 +1016,8 @@ test_transport_api_manipulation_send_tcp_peer1.conf\
test_transport_api_manipulation_send_tcp_peer2.conf\
test_transport_api_manipulation_recv_tcp_peer1.conf\
test_transport_api_manipulation_recv_tcp_peer2.conf\
+test_transport_api_manipulation_cfg_peer1.conf\
+test_transport_api_manipulation_cfg_peer2.conf\
test_transport_api_tcp_nat_peer1.conf\
test_transport_api_tcp_nat_peer2.conf\
test_transport_api_tcp_peer1.conf\
diff --git a/src/transport/gnunet-service-transport_manipulation.c b/src/transport/gnunet-service-transport_manipulation.c
index 76278aa4b..d537dd9b7 100644
--- a/src/transport/gnunet-service-transport_manipulation.c
+++ b/src/transport/gnunet-service-transport_manipulation.c
@@ -48,6 +48,7 @@ enum TRAFFIC_METRIC_DIRECTION
struct GST_ManipulationHandle man_handle;
+
/**
* Struct containing information about manipulations to a specific peer
*/
@@ -151,6 +152,11 @@ struct DelayQueueEntry
struct TM_Peer *tmp;
/**
+ * Peer ID
+ */
+ struct GNUNET_PeerIdentity id;
+
+ /**
* Absolute time when to send
*/
struct GNUNET_TIME_Absolute sent_at;
@@ -182,6 +188,14 @@ struct DelayQueueEntry
};
+struct DelayQueueEntry *generic_dqe_head;
+struct DelayQueueEntry *generic_dqe_tail;
+
+/**
+ * Task to schedule delayed sendding
+ */
+GNUNET_SCHEDULER_TaskIdentifier generic_send_delay_task;
+
static void
set_metric (struct TM_Peer *dest, int direction, uint32_t type, uint32_t value)
{
@@ -340,16 +354,34 @@ send_delayed (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
struct DelayQueueEntry *next;
struct TM_Peer *tmp = dqe->tmp;
struct GNUNET_TIME_Relative delay;
- tmp->send_delay_task = GNUNET_SCHEDULER_NO_TASK;
- GNUNET_CONTAINER_DLL_remove (tmp->send_head, tmp->send_tail, dqe);
- GST_neighbours_send (&tmp->peer, dqe->msg, dqe->msg_size, dqe->timeout, dqe->cont, dqe->cont_cls);
- next = tmp->send_head;
- if (NULL != next)
+ if (NULL != tmp)
+ {
+ tmp->send_delay_task = GNUNET_SCHEDULER_NO_TASK;
+ GNUNET_CONTAINER_DLL_remove (tmp->send_head, tmp->send_tail, dqe);
+ GST_neighbours_send (&dqe->id, dqe->msg, dqe->msg_size, dqe->timeout, dqe->cont, dqe->cont_cls);
+
+ next = tmp->send_head;
+ if (NULL != next)
+ {
+ /* More delayed messages */
+ delay = GNUNET_TIME_absolute_get_remaining (next->sent_at);
+ tmp->send_delay_task = GNUNET_SCHEDULER_add_delayed (delay, &send_delayed, dqe);
+ }
+ }
+ else
{
- /* More delayed messages */
- delay = GNUNET_TIME_absolute_get_remaining (next->sent_at);
- tmp->send_delay_task = GNUNET_SCHEDULER_add_delayed (delay, &send_delayed, dqe);
+ /* Remove from generic queue */
+ generic_send_delay_task = GNUNET_SCHEDULER_NO_TASK;
+ GNUNET_CONTAINER_DLL_remove (generic_dqe_head, generic_dqe_tail, dqe);
+ GST_neighbours_send (&dqe->id, dqe->msg, dqe->msg_size, dqe->timeout, dqe->cont, dqe->cont_cls);
+ next = generic_dqe_head;
+ if (NULL != next)
+ {
+ /* More delayed messages */
+ delay = GNUNET_TIME_absolute_get_remaining (next->sent_at);
+ generic_send_delay_task = GNUNET_SCHEDULER_add_delayed (delay, &send_delayed, dqe);
+ }
}
GNUNET_free (dqe);
@@ -384,6 +416,7 @@ GST_manipulation_send (const struct GNUNET_PeerIdentity *target, const void *msg
/* We have a delay */
delay.rel_value = find_metric(tmp, GNUNET_ATS_QUALITY_NET_DELAY, TM_SEND);
dqe = GNUNET_malloc (sizeof (struct DelayQueueEntry) + msg_size);
+ dqe->id = *target;
dqe->tmp = tmp;
dqe->sent_at = GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get(), delay);
dqe->cont = cont;
@@ -403,7 +436,8 @@ GST_manipulation_send (const struct GNUNET_PeerIdentity *target, const void *msg
/* We have a delay */
delay.rel_value = find_metric (&man_handle.general, GNUNET_ATS_QUALITY_NET_DELAY, TM_SEND);
dqe = GNUNET_malloc (sizeof (struct DelayQueueEntry) + msg_size);
- dqe->tmp = tmp;
+ dqe->id = *target;
+ dqe->tmp = NULL;
dqe->sent_at = GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get(), delay);
dqe->cont = cont;
dqe->cont_cls = cont_cls;
@@ -411,9 +445,9 @@ GST_manipulation_send (const struct GNUNET_PeerIdentity *target, const void *msg
dqe->msg_size = msg_size;
dqe->timeout = timeout;
memcpy (dqe->msg, msg, msg_size);
- GNUNET_CONTAINER_DLL_insert_tail (tmp->send_head, tmp->send_tail, dqe);
- if (GNUNET_SCHEDULER_NO_TASK == tmp->send_delay_task)
- tmp->send_delay_task =GNUNET_SCHEDULER_add_delayed (delay, &send_delayed, dqe);
+ GNUNET_CONTAINER_DLL_insert_tail (generic_dqe_head, generic_dqe_tail, dqe);
+ if (GNUNET_SCHEDULER_NO_TASK == generic_send_delay_task)
+ generic_send_delay_task = GNUNET_SCHEDULER_add_delayed (delay, &send_delayed, dqe);
return;
}
@@ -597,9 +631,24 @@ free_tmps (void *cls,
void
GST_manipulation_stop ()
{
+ struct DelayQueueEntry *cur;
+ struct DelayQueueEntry *next;
GNUNET_CONTAINER_multihashmap_iterate (man_handle.peers, &free_tmps,NULL);
-
GNUNET_CONTAINER_multihashmap_destroy (man_handle.peers);
+
+ next = generic_dqe_head;
+ while (NULL != (cur = next))
+ {
+ next = cur->next;
+ GNUNET_CONTAINER_DLL_remove (generic_dqe_head, generic_dqe_tail, cur);
+ GNUNET_free (cur);
+ }
+ if (GNUNET_SCHEDULER_NO_TASK != generic_send_delay_task)
+ {
+ GNUNET_SCHEDULER_cancel (generic_send_delay_task);
+ generic_send_delay_task = GNUNET_SCHEDULER_NO_TASK;
+ }
+
free_metric (&man_handle.general);
man_handle.peers = NULL;
}
diff --git a/src/transport/test_transport_api_manipulation_cfg_peer1.conf b/src/transport/test_transport_api_manipulation_cfg_peer1.conf
new file mode 100644
index 000000000..bfd01d5d8
--- /dev/null
+++ b/src/transport/test_transport_api_manipulation_cfg_peer1.conf
@@ -0,0 +1,31 @@
+@INLINE@ template_cfg_peer1.conf
+[PATHS]
+SERVICEHOME = /tmp/test-transport/api-tcp-p1/
+
+[transport-tcp]
+PORT = 12000
+TIMEOUT = 5 s
+
+[arm]
+PORT = 12005
+DEFAULTSERVICES = transport
+UNIXPATH = /tmp/gnunet-p1-service-arm.sock
+
+[statistics]
+PORT = 12004
+UNIXPATH = /tmp/gnunet-p1-service-statistics.sock
+
+[resolver]
+PORT = 12003
+UNIXPATH = /tmp/gnunet-p1-service-resolver.sock
+
+[peerinfo]
+PORT = 12002
+UNIXPATH = /tmp/gnunet-p1-service-peerinfo.sock
+
+[transport]
+PORT = 12001
+UNIXPATH = /tmp/gnunet-p1-service-transport.sock
+PLUGINS = tcp
+MANIPULATE_DELAY_IN = 100
+MANIPULATE_DELAY_OUT = 100 \ No newline at end of file
diff --git a/src/transport/test_transport_api_manipulation_cfg_peer2.conf b/src/transport/test_transport_api_manipulation_cfg_peer2.conf
new file mode 100644
index 000000000..6545e80e2
--- /dev/null
+++ b/src/transport/test_transport_api_manipulation_cfg_peer2.conf
@@ -0,0 +1,31 @@
+@INLINE@ template_cfg_peer2.conf
+[PATHS]
+SERVICEHOME = /tmp/test-transport/api-tcp-p2/
+
+[transport-tcp]
+PORT = 12015
+TIMEOUT = 5 s
+
+[arm]
+PORT = 12014
+DEFAULTSERVICES = transport
+UNIXPATH = /tmp/gnunet-p2-service-arm.sock
+
+[statistics]
+PORT = 12013
+UNIXPATH = /tmp/gnunet-p2-service-statistics.sock
+
+[resolver]
+PORT = 12012
+UNIXPATH = /tmp/gnunet-p2-service-resolver.sock
+
+[peerinfo]
+PORT = 12011
+UNIXPATH = /tmp/gnunet-p2-service-peerinfo.sock
+
+[transport]
+PORT = 12010
+PLUGINS = tcp
+UNIXPATH = /tmp/gnunet-p2-service-transport.sock
+MANIPULATE_DELAY_IN = 100
+MANIPULATE_DELAY_OUT = 100