diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2012-03-02 20:12:59 +0100 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2012-03-02 20:12:59 +0100 |
commit | ebd9d98fd7a2c08f57b1187a7b9efafbfbb63fe7 (patch) | |
tree | 707d1bfe6c1da4032f3859ee2b514ff5927a72c2 /src/task.c | |
parent | 3a4964f5e8c07943474036e594698b313a73d502 (diff) | |
download | fastd-ebd9d98fd7a2c08f57b1187a7b9efafbfbb63fe7.tar fastd-ebd9d98fd7a2c08f57b1187a7b9efafbfbb63fe7.zip |
Delete pending tasks for deleted peers
Diffstat (limited to 'src/task.c')
-rw-r--r-- | src/task.c | 29 |
1 files changed, 29 insertions, 0 deletions
@@ -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); +} |