summaryrefslogtreecommitdiffstats
path: root/src/task.c
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2012-03-02 20:12:59 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2012-03-02 20:12:59 +0100
commitebd9d98fd7a2c08f57b1187a7b9efafbfbb63fe7 (patch)
tree707d1bfe6c1da4032f3859ee2b514ff5927a72c2 /src/task.c
parent3a4964f5e8c07943474036e594698b313a73d502 (diff)
downloadfastd-ebd9d98fd7a2c08f57b1187a7b9efafbfbb63fe7.tar
fastd-ebd9d98fd7a2c08f57b1187a7b9efafbfbb63fe7.zip
Delete pending tasks for deleted peers
Diffstat (limited to 'src/task.c')
-rw-r--r--src/task.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/task.c b/src/task.c
index 0d2dd6e..b565f1b 100644
--- a/src/task.c
+++ b/src/task.c
@@ -70,3 +70,32 @@ void fastd_task_schedule_handshake(fastd_context *ctx, fastd_peer *peer, int tim
fastd_queue_put(&ctx->task_queue, task, timeout);
}
+
+static bool delete_task(void *data, void *extra) {
+ fastd_task *task = data;
+ fastd_peer *peer = extra;
+
+ if (task->any.peer != peer)
+ return true;
+
+ switch (task->any.type) {
+ case TASK_SEND:
+ fastd_buffer_free(task->send.buffer);
+ break;
+
+ case TASK_HANDLE_RECV:
+ fastd_buffer_free(task->handle_recv.buffer);
+ break;
+
+ case TASK_HANDSHAKE:
+ break;
+ }
+
+ free(task);
+
+ return false;
+}
+
+void fastd_task_delete_peer(fastd_context *ctx, fastd_peer *peer) {
+ fastd_queue_filter(&ctx->task_queue, delete_task, peer);
+}