From ab092a5f61921b89ce71f36cd4a1dd57fe73433a Mon Sep 17 00:00:00 2001 From: Ava Affine Date: Mon, 4 May 2026 20:29:35 +0000 Subject: [PATCH] WIP: request and connection machine Signed-off-by: Ava Affine --- .gitignore | 1 + muninn.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/.gitignore b/.gitignore index 46febc8..fae2bb2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ libmuninn.so libmuninn.dylib nginx/.cache +.cache diff --git a/muninn.c b/muninn.c index 5e5d6ab..e57af14 100644 --- a/muninn.c +++ b/muninn.c @@ -1,6 +1,13 @@ #include #include +typedef struct { + ngx_uint_t read_state; + ngx_log_t *log; + ngx_pool_t *pool; + ngx_chain_t *output; +} mun_dns_request; + static ngx_command_t ngx_muninn_commands[] = {}; static ngx_core_module_t ngx_muninn_module_ctx = { @@ -24,4 +31,39 @@ ngx_module_t ngx_muninn_core_module = { NGX_MODULE_V1_PADDING }; +static void (*mun_read_handler_list[])(ngx_event_t *) = { + // list of function pointers +}; +static ngx_uint_t mun_read_handler_adjacency[][7] = { + /* Entries: + * { NGX_OK next handler + * NGX_ERROR next handler + * NGX_AGAIN next handler + * NGX_BUSY next handler + * NGX_DONE next handler + * NGX_DECLINED next handler + * NGX_ABORT next handler } + * + * next handler = index into mun_read_handler_list + * ALL INDEXES BETWEEN THIS AND mun_read_handler_list MUST Match + */ +}; + + +// configuration directives to make a configuration interface + +// postconfiguration hook that actually does the work of setting up an event loop +// - calls ngx_create_listening based on sockaddr and socklen +// - sets listening->handler (see ngx_http_init_connection) +// - sets listening->pool_size +// - sets all this shit (see ngx_http_add_listening) + +// listening-> init connection handler +// close connection function for error handling +// set up read event handler for conn->read->handler +// set up write event handler for conn->write->handler +// make a new request obj and set c->data + +// figure out how a read is actually done +// figure out how a write is actually done