Win32 build compatible

This commit is contained in:
2018-06-05 09:18:30 +09:00
parent f5027e015c
commit 3e2b301715
+24 -24
View File
@@ -10,6 +10,9 @@
#include <ngx_event.h> #include <ngx_event.h>
static void ngx_close_accepted_udp_connection(ngx_connection_t *c);
#if !(NGX_WIN32) #if !(NGX_WIN32)
struct ngx_udp_connection_s { struct ngx_udp_connection_s {
@@ -19,7 +22,6 @@ struct ngx_udp_connection_s {
}; };
static void ngx_close_accepted_udp_connection(ngx_connection_t *c);
static ssize_t ngx_udp_shared_recv(ngx_connection_t *c, u_char *buf, static ssize_t ngx_udp_shared_recv(ngx_connection_t *c, u_char *buf,
size_t size); size_t size);
static ngx_int_t ngx_insert_udp_connection(ngx_connection_t *c); static ngx_int_t ngx_insert_udp_connection(ngx_connection_t *c);
@@ -417,23 +419,6 @@ ngx_event_recvmsg(ngx_event_t *ev)
} }
static void
ngx_close_accepted_udp_connection(ngx_connection_t *c)
{
ngx_free_connection(c);
c->fd = (ngx_socket_t) -1;
if (c->pool) {
ngx_destroy_pool(c->pool);
}
#if (NGX_STAT_STUB)
(void) ngx_atomic_fetch_add(ngx_stat_active, -1);
#endif
}
static ssize_t static ssize_t
ngx_udp_shared_recv(ngx_connection_t *c, u_char *buf, size_t size) ngx_udp_shared_recv(ngx_connection_t *c, u_char *buf, size_t size)
{ {
@@ -722,13 +707,13 @@ void ngx_event_recvmsg(ngx_event_t *ev)
c->pool = ngx_create_pool(ls->pool_size, ev->log); c->pool = ngx_create_pool(ls->pool_size, ev->log);
if (c->pool == NULL) { if (c->pool == NULL) {
ngx_close_accepted_connection(c); ngx_close_accepted_udp_connection(c);
return; return;
} }
c->sockaddr = ngx_palloc(c->pool, c->socklen); c->sockaddr = ngx_palloc(c->pool, c->socklen);
if (c->sockaddr == NULL) { if (c->sockaddr == NULL) {
ngx_close_accepted_connection(c); ngx_close_accepted_udp_connection(c);
return; return;
} }
@@ -736,7 +721,7 @@ void ngx_event_recvmsg(ngx_event_t *ev)
log = ngx_palloc(c->pool, sizeof(ngx_log_t)); log = ngx_palloc(c->pool, sizeof(ngx_log_t));
if (log == NULL) { if (log == NULL) {
ngx_close_accepted_connection(c); ngx_close_accepted_udp_connection(c);
return; return;
} }
@@ -754,7 +739,7 @@ void ngx_event_recvmsg(ngx_event_t *ev)
n = bytes; n = bytes;
c->buffer = ngx_create_temp_buf(c->pool, n); c->buffer = ngx_create_temp_buf(c->pool, n);
if (c->buffer == NULL) { if (c->buffer == NULL) {
ngx_close_accepted_connection(c); ngx_close_accepted_udp_connection(c);
return; return;
} }
@@ -786,7 +771,7 @@ void ngx_event_recvmsg(ngx_event_t *ev)
if (ls->addr_ntop) { if (ls->addr_ntop) {
c->addr_text.data = ngx_pnalloc(c->pool, ls->addr_text_max_len); c->addr_text.data = ngx_pnalloc(c->pool, ls->addr_text_max_len);
if (c->addr_text.data == NULL) { if (c->addr_text.data == NULL) {
ngx_close_accepted_connection(c); ngx_close_accepted_udp_connection(c);
return; return;
} }
@@ -794,7 +779,7 @@ void ngx_event_recvmsg(ngx_event_t *ev)
c->addr_text.data, c->addr_text.data,
ls->addr_text_max_len, 0); ls->addr_text_max_len, 0);
if (c->addr_text.len == 0) { if (c->addr_text.len == 0) {
ngx_close_accepted_connection(c); ngx_close_accepted_udp_connection(c);
return; return;
} }
} }
@@ -830,3 +815,18 @@ void ngx_event_recvmsg(ngx_event_t *ev)
#endif #endif
static void
ngx_close_accepted_udp_connection(ngx_connection_t *c)
{
ngx_free_connection(c);
c->fd = (ngx_socket_t) -1;
if (c->pool) {
ngx_destroy_pool(c->pool);
}
#if (NGX_STAT_STUB)
(void) ngx_atomic_fetch_add(ngx_stat_active, -1);
#endif
}