Actually using async
This commit is contained in:
@ -73,20 +73,15 @@ static int request_handler(client_ctx_t *ctx) {
|
|||||||
|
|
||||||
ctx->req_s = clock_micros();
|
ctx->req_s = clock_micros();
|
||||||
|
|
||||||
// FIXME async poll
|
|
||||||
ret = sock_poll_read(&client, NULL, NULL, 1, NULL, NULL, CLIENT_TIMEOUT * 1000);
|
|
||||||
|
|
||||||
http_add_header_field(&res->hdr, "Date", http_get_date(buf0, sizeof(buf0)));
|
http_add_header_field(&res->hdr, "Date", http_get_date(buf0, sizeof(buf0)));
|
||||||
http_add_header_field(&res->hdr, "Server", SERVER_STR);
|
http_add_header_field(&res->hdr, "Server", SERVER_STR);
|
||||||
if (ret <= 0) {
|
/*if (ret <= 0) {
|
||||||
if (errno != 0) return 0;
|
if (errno != 0) return 0;
|
||||||
|
|
||||||
ctx->c_keep_alive = 0;
|
ctx->c_keep_alive = 0;
|
||||||
res->status = http_get_status(408);
|
res->status = http_get_status(408);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
ctx->req_s = clock_micros();
|
|
||||||
|
|
||||||
http_req *req = &ctx->req;
|
http_req *req = &ctx->req;
|
||||||
ret = http_receive_request(client, req);
|
ret = http_receive_request(client, req);
|
||||||
|
@ -7,9 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "func.h"
|
#include "func.h"
|
||||||
#include "../async.h"
|
|
||||||
#include "../logger.h"
|
#include "../logger.h"
|
||||||
#include "../lib/mpmc.h"
|
|
||||||
#include "../lib/utils.h"
|
#include "../lib/utils.h"
|
||||||
#include "../lib/geoip.h"
|
#include "../lib/geoip.h"
|
||||||
#include "../workers.h"
|
#include "../workers.h"
|
||||||
@ -24,7 +22,7 @@ static int tcp_acceptor(client_ctx_t *ctx);
|
|||||||
|
|
||||||
void tcp_acceptor_func(client_ctx_t *ctx) {
|
void tcp_acceptor_func(client_ctx_t *ctx) {
|
||||||
if (tcp_acceptor(ctx) == 0) {
|
if (tcp_acceptor(ctx) == 0) {
|
||||||
async(ctx->socket.socket, POLLIN, 0, (void (*)(void *)) handle_request, ctx, (void (*)(void *)) tcp_close, ctx);
|
handle_request(ctx);
|
||||||
} else {
|
} else {
|
||||||
tcp_close(ctx);
|
tcp_close(ctx);
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include "lib/mpmc.h"
|
#include "lib/mpmc.h"
|
||||||
|
|
||||||
#include "worker/func.h"
|
#include "worker/func.h"
|
||||||
|
#include "async.h"
|
||||||
|
|
||||||
static mpmc_t tcp_acceptor_ctx, tcp_closer_ctx, request_handler_ctx,
|
static mpmc_t tcp_acceptor_ctx, tcp_closer_ctx, request_handler_ctx,
|
||||||
local_handler_ctx, fastcgi_handler_cxt, proxy_handler_ctx;
|
local_handler_ctx, fastcgi_handler_cxt, proxy_handler_ctx;
|
||||||
@ -50,10 +51,14 @@ int tcp_close(client_ctx_t *ctx) {
|
|||||||
return mpmc_queue(&tcp_closer_ctx, ctx);
|
return mpmc_queue(&tcp_closer_ctx, ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
int handle_request(client_ctx_t *ctx) {
|
static int handle_request_cb(client_ctx_t *ctx) {
|
||||||
return mpmc_queue(&request_handler_ctx, ctx);
|
return mpmc_queue(&request_handler_ctx, ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int handle_request(client_ctx_t *ctx) {
|
||||||
|
return async(ctx->socket.socket, POLLIN, 0, (void (*)(void *)) handle_request_cb, ctx, (void (*)(void *)) tcp_close, ctx);
|
||||||
|
}
|
||||||
|
|
||||||
int local_handle(client_ctx_t *ctx) {
|
int local_handle(client_ctx_t *ctx) {
|
||||||
return mpmc_queue(&local_handler_ctx, ctx);
|
return mpmc_queue(&local_handler_ctx, ctx);
|
||||||
}
|
}
|
||||||
@ -65,4 +70,3 @@ int fastcgi_handle(client_ctx_t *ctx) {
|
|||||||
int proxy_handle(client_ctx_t *ctx) {
|
int proxy_handle(client_ctx_t *ctx) {
|
||||||
return mpmc_queue(&proxy_handler_ctx, ctx);
|
return mpmc_queue(&proxy_handler_ctx, ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user