diff options
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/nginx.c | 17 | ||||
| -rw-r--r-- | src/core/ngx_connection.h | 4 | ||||
| -rw-r--r-- | src/core/ngx_listen.h | 3 |
3 files changed, 20 insertions, 4 deletions
diff --git a/src/core/nginx.c b/src/core/nginx.c index b2f3f5fba..b33ce293e 100644 --- a/src/core/nginx.c +++ b/src/core/nginx.c @@ -18,6 +18,7 @@ /* */ +static void ngx_set_signals(ngx_log_t *log); static void ngx_open_listening_sockets(ngx_log_t *log); @@ -42,6 +43,8 @@ int main(int argc, char *const *argv) ngx_pool = ngx_create_pool(16 * 1024, &ngx_log); /* */ + ngx_set_signals(&ngx_log); + ngx_init_sockets(&ngx_log); /* TODO: read config */ @@ -70,6 +73,20 @@ int main(int argc, char *const *argv) return 0; } +static void ngx_set_signals(ngx_log_t *log) +{ + struct sigaction sa; + + ngx_memzero(&sa, sizeof(struct sigaction)); + sa.sa_handler = SIG_IGN; + sigemptyset(&sa.sa_mask); + if (sigaction(SIGPIPE, &sa, NULL) == -1) { + ngx_log_error(NGX_LOG_EMERG, log, ngx_errno, + "sigaction(SIGPIPE, SIG_IGN) failed"); + exit(1); + } +} + static void ngx_open_listening_sockets(ngx_log_t *log) { int times, failed, reuseaddr, i; diff --git a/src/core/ngx_connection.h b/src/core/ngx_connection.h index 2450ea3b8..b486f4be8 100644 --- a/src/core/ngx_connection.h +++ b/src/core/ngx_connection.h @@ -5,6 +5,7 @@ #include <ngx_log.h> #include <ngx_hunk.h> #include <ngx_alloc.h> +#include <ngx_string.h> #include <ngx_server.h> typedef struct ngx_connection_s ngx_connection_t; @@ -38,8 +39,7 @@ struct ngx_connection_s { struct sockaddr *sockaddr; socklen_t socklen; size_t addr; - char *addr_text; - size_t addr_textlen; + ngx_str_t addr_text; ngx_hunk_t *buffer; unsigned int post_accept_timeout; diff --git a/src/core/ngx_listen.h b/src/core/ngx_listen.h index 8108d837d..cf4a2ad0f 100644 --- a/src/core/ngx_listen.h +++ b/src/core/ngx_listen.h @@ -14,8 +14,7 @@ typedef struct { struct sockaddr *sockaddr; socklen_t socklen; size_t addr; - char *addr_text; - size_t addr_textlen; + ngx_str_t addr_text; int family; int type; |
