Compare commits
2 Commits
0b1b0bcb56
...
d461ba6f29
Author | SHA1 | Date | |
---|---|---|---|
d461ba6f29
|
|||
5b98fd0dab
|
11
src/server.c
11
src/server.c
@@ -185,7 +185,7 @@ static void terminate_forcefully(int sig) {
|
||||
}
|
||||
|
||||
static void terminate_gracefully(int sig) {
|
||||
fprintf(stderr, "\n");
|
||||
if (sig != 0) fprintf(stderr, "\n");
|
||||
notice("Terminating gracefully...");
|
||||
|
||||
struct sigaction act = {0};
|
||||
@@ -410,7 +410,13 @@ int main(int argc, char *const argv[]) {
|
||||
|
||||
notice("Ready to accept connections");
|
||||
|
||||
int error = 0;
|
||||
async_thread();
|
||||
if (errno != 0) {
|
||||
errno = 0;
|
||||
error = 2;
|
||||
terminate_gracefully(0);
|
||||
}
|
||||
|
||||
notice("Goodbye!");
|
||||
|
||||
@@ -424,5 +430,6 @@ int main(int argc, char *const argv[]) {
|
||||
async_free();
|
||||
logger_stop();
|
||||
logger_join();
|
||||
return 0;
|
||||
|
||||
return error;
|
||||
}
|
||||
|
@@ -12,14 +12,14 @@
|
||||
#include "worker/func.h"
|
||||
#include "async.h"
|
||||
|
||||
static mpmc_t tcp_acceptor_ctx, request_handler_ctx, local_handler_ctx, fastcgi_handler_cxt, proxy_handler_ctx,
|
||||
static mpmc_t tcp_acceptor_ctx, request_handler_ctx, local_handler_ctx, fastcgi_handler_ctx, proxy_handler_ctx,
|
||||
ws_frame_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_cxt, 16, 64, (void (*)(void *)) fastcgi_handler_func, "fcgi");
|
||||
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");
|
||||
return -1;
|
||||
@@ -28,7 +28,7 @@ int workers_init(void) {
|
||||
void workers_stop(void) {
|
||||
mpmc_stop(&tcp_acceptor_ctx);
|
||||
mpmc_stop(&local_handler_ctx);
|
||||
mpmc_stop(&fastcgi_handler_cxt);
|
||||
mpmc_stop(&fastcgi_handler_ctx);
|
||||
mpmc_stop(&proxy_handler_ctx);
|
||||
mpmc_stop(&request_handler_ctx);
|
||||
mpmc_stop(&ws_frame_handler_ctx);
|
||||
@@ -37,7 +37,7 @@ void workers_stop(void) {
|
||||
void workers_destroy(void) {
|
||||
mpmc_destroy(&tcp_acceptor_ctx);
|
||||
mpmc_destroy(&local_handler_ctx);
|
||||
mpmc_destroy(&fastcgi_handler_cxt);
|
||||
mpmc_destroy(&fastcgi_handler_ctx);
|
||||
mpmc_destroy(&proxy_handler_ctx);
|
||||
mpmc_destroy(&request_handler_ctx);
|
||||
mpmc_destroy(&ws_frame_handler_ctx);
|
||||
@@ -68,7 +68,7 @@ int local_handle(client_ctx_t *ctx) {
|
||||
}
|
||||
|
||||
int fastcgi_handle(client_ctx_t *ctx) {
|
||||
return mpmc_queue(&fastcgi_handler_cxt, ctx);
|
||||
return mpmc_queue(&fastcgi_handler_ctx, ctx);
|
||||
}
|
||||
|
||||
int proxy_handle(client_ctx_t *ctx) {
|
||||
|
Reference in New Issue
Block a user