summaryrefslogtreecommitdiff
path: root/src/transport/gnunet-service-transport_manipulation.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2013-05-23 14:01:35 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2013-05-23 14:01:35 +0000
commit2c0bf156d17ea97298943fd28b3f5d4eb99de355 (patch)
tree6f8e13fb3e1e6a031758dc593c11429dbb16bd06 /src/transport/gnunet-service-transport_manipulation.c
parent9c818540f5e5254cc8c34976cfcd87993cd9387b (diff)
fix for 0002890
Diffstat (limited to 'src/transport/gnunet-service-transport_manipulation.c')
-rw-r--r--src/transport/gnunet-service-transport_manipulation.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/transport/gnunet-service-transport_manipulation.c b/src/transport/gnunet-service-transport_manipulation.c
index 786b95bed..eb520ec20 100644
--- a/src/transport/gnunet-service-transport_manipulation.c
+++ b/src/transport/gnunet-service-transport_manipulation.c
@@ -628,6 +628,8 @@ free_tmps (void *cls,
{
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)
@@ -640,6 +642,52 @@ free_tmps (void *cls,
return GNUNET_OK;
}
+/**
+ * Notify manipulation about disconnect so it can discard queued messages
+ *
+ * @param peer the disconnecting peer
+ */
+void
+GST_manipulation_peer_disconnect (const struct GNUNET_PeerIdentity *peer)
+{
+ struct TM_Peer *tmp;
+ struct DelayQueueEntry *dqe;
+ struct DelayQueueEntry *next;
+
+ if (NULL != (tmp = GNUNET_CONTAINER_multihashmap_get (man_handle.peers, &peer->hashPubKey)))
+ {
+ 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);
+ }
+ }
+ else if (UINT32_MAX != find_metric (&man_handle.general, GNUNET_ATS_QUALITY_NET_DELAY, TM_SEND))
+ {
+ next = generic_dqe_head;
+ while (NULL != (dqe = next))
+ {
+ if (0 == memcmp (&peer, &dqe->id, sizeof (dqe->id)))
+ {
+ GNUNET_CONTAINER_DLL_remove (generic_dqe_head, generic_dqe_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 != generic_send_delay_task)
+ {
+ GNUNET_SCHEDULER_cancel (generic_send_delay_task);
+ generic_send_delay_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining(generic_dqe_head->sent_at), &send_delayed, generic_dqe_head);
+ }
+ }
+}
+
/**
* Stop traffic manipulation
@@ -657,6 +705,8 @@ GST_manipulation_stop ()
{
next = cur->next;
GNUNET_CONTAINER_DLL_remove (generic_dqe_head, generic_dqe_tail, cur);
+ if (NULL != cur->cont)
+ cur->cont (cur->cont_cls, GNUNET_SYSERR, cur->msg_size, 0);
GNUNET_free (cur);
}
if (GNUNET_SCHEDULER_NO_TASK != generic_send_delay_task)