diff options
author | Anton Kling <anton@kling.gg> | 2024-03-17 20:55:34 +0100 |
---|---|---|
committer | Anton Kling <anton@kling.gg> | 2024-03-17 20:55:34 +0100 |
commit | 0dccff86e50dfe1555b8bc29862dba2b972a3705 (patch) | |
tree | 8d0c354c65278afdc3427bb52e1e63900ccdbc05 /kernel/queue.c | |
parent | 2e8b474d4219e7faaac3823e73c8d528c2698a37 (diff) |
stuff
Diffstat (limited to 'kernel/queue.c')
-rw-r--r-- | kernel/queue.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/kernel/queue.c b/kernel/queue.c index 0f2f645..d77af85 100644 --- a/kernel/queue.c +++ b/kernel/queue.c @@ -1,11 +1,14 @@ +#include <assert.h> #include <kmalloc.h> #include <queue.h> #include <sched/scheduler.h> +#include <socket.h> #include <stdio.h> -int queue_create(u32 *id) { +int queue_create(u32 *id, process_t *p) { struct event_queue *q = kcalloc(1, sizeof(struct event_queue)); q->wait = 0; + q->p = p; list_init(&q->events); struct list *list = ¤t_task->event_queue; @@ -51,7 +54,7 @@ int queue_should_block(struct event_queue *q, int *is_empty) { *is_empty = 0; if (EVENT_TYPE_FD == ev->type) { kprintf("found fd: %d\n", ev->internal_id); - vfs_fd_t *fd = get_vfs_fd(ev->internal_id); + vfs_fd_t *fd = get_vfs_fd(ev->internal_id, q->p); kprintf("fd->inode->has_data: %x\n", fd->inode->has_data); if (!fd) { kprintf("queue: Invalid fd given\n"); @@ -62,8 +65,15 @@ int queue_should_block(struct event_queue *q, int *is_empty) { return 0; } } else if (EVENT_TYPE_TCP_SOCKET == ev->type) { - kprintf("tcp socket wait\n"); - return 0; + struct TcpConnection *con = tcp_get_connection(ev->internal_id, q->p); + assert(con); + assert(con->data_file); + if (con->data_file->has_data) { + kprintf("has data\n"); + return 0; + } else { + kprintf("blocking queue\n"); + } } } return 1; |