summaryrefslogtreecommitdiffstats
path: root/src/task.c
diff options
context:
space:
mode:
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);
+}