Add chunk_handler
This commit is contained in:
@@ -13,15 +13,16 @@
|
||||
#include "async.h"
|
||||
|
||||
static mpmc_t tcp_acceptor_ctx, request_handler_ctx, local_handler_ctx, fastcgi_handler_ctx, proxy_handler_ctx,
|
||||
ws_frame_handler_ctx;
|
||||
ws_frame_handler_ctx, chunk_handler_ctx;
|
||||
|
||||
int workers_init(void) {
|
||||
mpmc_init(&tcp_acceptor_ctx, 8, 64, (void (*)(void *)) tcp_acceptor_func, "tcp");
|
||||
mpmc_init(&request_handler_ctx, 16, 64, (void (*)(void *)) request_handler_func, "req");
|
||||
mpmc_init(&local_handler_ctx, 16, 64, (void (*)(void *)) local_handler_func, "local");
|
||||
mpmc_init(&fastcgi_handler_ctx, 16, 64, (void (*)(void *)) fastcgi_handler_func, "fcgi");
|
||||
mpmc_init(&proxy_handler_ctx, 16, 64, (void (*)(void *)) proxy_handler_func, "proxy");
|
||||
mpmc_init(&ws_frame_handler_ctx, 16, 64, (void (*)(void *)) ws_frame_handler_func, "ws");
|
||||
mpmc_init(&tcp_acceptor_ctx, 8, 64, (void (*)(void *)) tcp_acceptor_func, "tcp");
|
||||
mpmc_init(&request_handler_ctx, 8, 64, (void (*)(void *)) request_handler_func, "req");
|
||||
mpmc_init(&local_handler_ctx, 8, 64, (void (*)(void *)) local_handler_func, "local");
|
||||
mpmc_init(&fastcgi_handler_ctx, 8, 64, (void (*)(void *)) fastcgi_handler_func, "fcgi");
|
||||
mpmc_init(&proxy_handler_ctx, 8, 64, (void (*)(void *)) proxy_handler_func, "proxy");
|
||||
mpmc_init(&ws_frame_handler_ctx, 8, 64, (void (*)(void *)) ws_frame_handler_func, "ws");
|
||||
mpmc_init(&chunk_handler_ctx, 8, 64, (void (*)(void *)) chunk_handler_func, "chunk");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -32,6 +33,7 @@ void workers_stop(void) {
|
||||
mpmc_stop(&proxy_handler_ctx);
|
||||
mpmc_stop(&request_handler_ctx);
|
||||
mpmc_stop(&ws_frame_handler_ctx);
|
||||
mpmc_stop(&chunk_handler_ctx);
|
||||
}
|
||||
|
||||
void workers_destroy(void) {
|
||||
@@ -41,6 +43,7 @@ void workers_destroy(void) {
|
||||
mpmc_destroy(&proxy_handler_ctx);
|
||||
mpmc_destroy(&request_handler_ctx);
|
||||
mpmc_destroy(&ws_frame_handler_ctx);
|
||||
mpmc_destroy(&chunk_handler_ctx);
|
||||
}
|
||||
|
||||
int tcp_accept(client_ctx_t *ctx) {
|
||||
@@ -85,3 +88,14 @@ int ws_handle_frame(ws_ctx_t *ctx) {
|
||||
(void (*)(void *)) ws_close,
|
||||
(void (*)(void *)) ws_close);
|
||||
}
|
||||
|
||||
static int handle_chunk_cb(chunk_ctx_t *ctx) {
|
||||
return mpmc_queue(&chunk_handler_ctx, ctx);
|
||||
}
|
||||
|
||||
int handle_chunk(chunk_ctx_t *ctx) {
|
||||
return async(ctx->socket, ASYNC_WAIT_READ, 0, ctx,
|
||||
(void (*)(void *)) handle_chunk_cb,
|
||||
(void (*)(void *)) ctx->err_cb,
|
||||
(void (*)(void *)) ctx->err_cb);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user