summaryrefslogtreecommitdiffstats
path: root/src/task.c
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2012-03-31 18:04:02 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2012-03-31 18:04:02 +0200
commit0c82651c30bf543903ca05df4e5b179201353ee1 (patch)
tree8c7d7eb1e2f41b500433b14213dc1532d4a79b0f /src/task.c
parent342d63a45a8918e45ddcf6a0b82b2f593f4bde12 (diff)
downloadfastd-0c82651c30bf543903ca05df4e5b179201353ee1.tar
fastd-0c82651c30bf543903ca05df4e5b179201353ee1.zip
Change how handshakes are triggered
Diffstat (limited to 'src/task.c')
-rw-r--r--src/task.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/task.c b/src/task.c
index 62afd4f..b4004ef 100644
--- a/src/task.c
+++ b/src/task.c
@@ -69,13 +69,22 @@ void fastd_task_schedule_handshake(fastd_context *ctx, fastd_peer *peer, int tim
fastd_queue_put(ctx, &ctx->task_queue, &task->entry, timeout);
}
+typedef struct _delete_task_extra {
+ fastd_peer *peer;
+ bool handshake_only;
+} delete_task_extra;
+
static bool delete_task(fastd_queue_entry *data, void *extra) {
+ delete_task_extra *e = extra;
fastd_task *task = container_of(data, fastd_task, entry);
- fastd_peer *peer = extra;
+ fastd_peer *peer = e->peer;
if (task->peer != peer)
return true;
+ if (e->handshake_only && task->type != TASK_HANDSHAKE)
+ return true;
+
switch (task->type) {
case TASK_SEND:
fastd_buffer_free(task->send.buffer);
@@ -95,5 +104,11 @@ static bool delete_task(fastd_queue_entry *data, void *extra) {
}
void fastd_task_delete_peer(fastd_context *ctx, fastd_peer *peer) {
- fastd_queue_filter(ctx, &ctx->task_queue, delete_task, peer);
+ delete_task_extra extra = {peer, false};
+ fastd_queue_filter(ctx, &ctx->task_queue, delete_task, &extra);
+}
+
+void fastd_task_delete_peer_handshakes(fastd_context *ctx, fastd_peer *peer) {
+ delete_task_extra extra = {peer, true};
+ fastd_queue_filter(ctx, &ctx->task_queue, delete_task, &extra);
}