From b9054051b9bf232968dc52b4732a65381c6a0e5f Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sat, 14 Apr 2012 16:59:54 +0200 Subject: Reduce task queue usage --- src/task.c | 45 --------------------------------------------- 1 file changed, 45 deletions(-) (limited to 'src/task.c') diff --git a/src/task.c b/src/task.c index fb75766..3483853 100644 --- a/src/task.c +++ b/src/task.c @@ -31,35 +31,6 @@ fastd_task* fastd_task_get(fastd_context *ctx) { return container_of(fastd_queue_get(ctx, &ctx->task_queue), fastd_task, entry); } -static void fastd_task_put_send_type(fastd_context *ctx, fastd_peer *peer, uint8_t packet_type, fastd_buffer buffer) { - fastd_task *task = malloc(sizeof(fastd_task)); - - task->type = TASK_SEND; - task->peer = peer; - task->send.packet_type = packet_type; - task->send.buffer = buffer; - - fastd_queue_put(ctx, &ctx->task_queue, &task->entry, 0); -} - -void fastd_task_put_send_handshake(fastd_context *ctx, fastd_peer *peer, fastd_buffer buffer) { - fastd_task_put_send_type(ctx, peer, PACKET_HANDSHAKE, buffer); -} - -void fastd_task_put_send(fastd_context *ctx, fastd_peer *peer, fastd_buffer buffer) { - fastd_task_put_send_type(ctx, peer, PACKET_DATA, buffer); -} - -void fastd_task_put_handle_recv(fastd_context *ctx, fastd_peer *peer, fastd_buffer buffer) { - fastd_task *task = malloc(sizeof(fastd_task)); - - task->type = TASK_HANDLE_RECV; - task->peer = peer; - task->handle_recv.buffer = buffer; - - fastd_queue_put(ctx, &ctx->task_queue, &task->entry, 0); -} - static bool is_handshake(fastd_queue_entry *data, void *extra) { fastd_task *task = container_of(data, fastd_task, entry); fastd_peer *peer = extra; @@ -153,22 +124,6 @@ static bool delete_task(fastd_queue_entry *data, void *extra) { if (e->keepalive_only && task->type != TASK_KEEPALIVE) return true; - switch (task->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; - - case TASK_KEEPALIVE: - break; - } - free(task); return false; -- cgit v1.2.3