Mercurial > hg > nginx-vendor-0-5
comparison src/event/ngx_event_accept.c @ 10:46833bd150cb NGINX_0_1_5
nginx 0.1.5
*) Bugfix: on Solaris and Linux there may be too many "recvmsg()
returned not enough data" alerts.
*) Bugfix: there were the "writev() failed (22: Invalid argument)"
errors on Solaris in proxy mode without sendfile. On other platforms
that do not support sendfile at all the process got caught in an
endless loop.
*) Bugfix: segmentation fault on Solaris in proxy mode and using
sendfile.
*) Bugfix: segmentation fault on Solaris.
*) Bugfix: on-line upgrade did not work on Linux.
*) Bugfix: the ngx_http_autoindex_module module did not escape the
spaces, the quotes, and the percent signs in the directory listing.
*) Change: the decrease of the copy operations.
*) Feature: the userid_p3p directive.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Thu, 11 Nov 2004 00:00:00 +0300 |
parents | 4b2dafa26fe2 |
children | 45fe5b98a9de |
comparison
equal
deleted
inserted
replaced
9:77eee314ddbd | 10:46833bd150cb |
---|---|
9 #include <ngx_event.h> | 9 #include <ngx_event.h> |
10 #include <nginx.h> | 10 #include <nginx.h> |
11 | 11 |
12 | 12 |
13 typedef struct { | 13 typedef struct { |
14 int flag; | 14 int flag; |
15 u_char *name; | 15 ngx_str_t *name; |
16 } ngx_accept_log_ctx_t; | 16 } ngx_accept_log_ctx_t; |
17 | 17 |
18 | 18 |
19 static void ngx_close_accepted_socket(ngx_socket_t s, ngx_log_t *log); | 19 static void ngx_close_accepted_socket(ngx_socket_t s, ngx_log_t *log); |
20 static size_t ngx_accept_log_error(void *data, char *buf, size_t len); | 20 static u_char *ngx_accept_log_error(void *data, u_char *buf, size_t len); |
21 | 21 |
22 | 22 |
23 void ngx_event_accept(ngx_event_t *ev) | 23 void ngx_event_accept(ngx_event_t *ev) |
24 { | 24 { |
25 ngx_uint_t instance, accepted; | 25 ngx_uint_t instance, accepted; |
44 } | 44 } |
45 | 45 |
46 ls = ev->data; | 46 ls = ev->data; |
47 | 47 |
48 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, ev->log, 0, | 48 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, ev->log, 0, |
49 "accept on %s, ready: %d", | 49 "accept on %V, ready: %d", |
50 ls->listening->addr_text.data, ev->available); | 50 &ls->listening->addr_text, ev->available); |
51 | 51 |
52 ev->ready = 0; | 52 ev->ready = 0; |
53 accepted = 0; | 53 accepted = 0; |
54 pool = NULL; | 54 pool = NULL; |
55 | 55 |
86 return; | 86 return; |
87 } | 87 } |
88 | 88 |
89 /* -1 disables the connection number logging */ | 89 /* -1 disables the connection number logging */ |
90 ctx->flag = -1; | 90 ctx->flag = -1; |
91 ctx->name = ls->listening->addr_text.data; | 91 ctx->name = &ls->listening->addr_text; |
92 | 92 |
93 log->data = ctx; | 93 log->data = ctx; |
94 log->handler = ngx_accept_log_error; | 94 log->handler = ngx_accept_log_error; |
95 | 95 |
96 len = ls->listening->socklen; | 96 len = ls->listening->socklen; |
112 ngx_destroy_pool(pool); | 112 ngx_destroy_pool(pool); |
113 return; | 113 return; |
114 } | 114 } |
115 | 115 |
116 ngx_log_error(NGX_LOG_ALERT, ev->log, err, | 116 ngx_log_error(NGX_LOG_ALERT, ev->log, err, |
117 "accept() on %s failed", | 117 "accept() on %V failed", &ls->listening->addr_text); |
118 ls->listening->addr_text.data); | |
119 | 118 |
120 if (err == NGX_ECONNABORTED) { | 119 if (err == NGX_ECONNABORTED) { |
121 if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) { | 120 if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) { |
122 ev->available--; | 121 ev->available--; |
123 } | 122 } |
142 /* disable warning: Win32 SOCKET is u_int while UNIX socket is int */ | 141 /* disable warning: Win32 SOCKET is u_int while UNIX socket is int */ |
143 | 142 |
144 if ((ngx_uint_t) s >= ecf->connections) { | 143 if ((ngx_uint_t) s >= ecf->connections) { |
145 | 144 |
146 ngx_log_error(NGX_LOG_ALERT, ev->log, 0, | 145 ngx_log_error(NGX_LOG_ALERT, ev->log, 0, |
147 "accept() on %s returned socket #%d while " | 146 "accept() on %V returned socket #%d while " |
148 "only %d connections was configured, " | 147 "only %d connections was configured, " |
149 "closing the connection", | 148 "closing the connection", |
150 ls->listening->addr_text.data, s, ecf->connections); | 149 &ls->listening->addr_text, s, ecf->connections); |
151 | 150 |
152 ngx_close_accepted_socket(s, log); | 151 ngx_close_accepted_socket(s, log); |
153 ngx_destroy_pool(pool); | 152 ngx_destroy_pool(pool); |
154 return; | 153 return; |
155 } | 154 } |
183 return; | 182 return; |
184 } | 183 } |
185 } | 184 } |
186 } | 185 } |
187 | 186 |
188 #if (WIN32) | 187 #if (NGX_WIN32) |
189 /* | 188 /* |
190 * Winsock assignes a socket number divisible by 4 | 189 * Winsock assignes a socket number divisible by 4 |
191 * so to find a connection we divide a socket number by 4. | 190 * so to find a connection we divide a socket number by 4. |
192 */ | 191 */ |
193 | 192 |
194 if (s % 4) { | 193 if (s % 4) { |
195 ngx_log_error(NGX_LOG_EMERG, ev->log, 0, | 194 ngx_log_error(NGX_LOG_EMERG, ev->log, 0, |
196 "accept() on %s returned socket #%d, " | 195 "accept() on %V returned socket #%d, " |
197 "not divisible by 4", | 196 "not divisible by 4", |
198 ls->listening->addr_text.data, s); | 197 &ls->listening->addr_text, s); |
199 exit(1); | 198 exit(1); |
200 } | 199 } |
201 | 200 |
202 c = &ngx_cycle->connections[s / 4]; | 201 c = &ngx_cycle->connections[s / 4]; |
203 rev = &ngx_cycle->read_events[s / 4]; | 202 rev = &ngx_cycle->read_events[s / 4]; |
465 ngx_close_socket_n " failed"); | 464 ngx_close_socket_n " failed"); |
466 } | 465 } |
467 } | 466 } |
468 | 467 |
469 | 468 |
470 static size_t ngx_accept_log_error(void *data, char *buf, size_t len) | 469 static u_char *ngx_accept_log_error(void *data, u_char *buf, size_t len) |
471 { | 470 { |
472 ngx_accept_log_ctx_t *ctx = data; | 471 ngx_accept_log_ctx_t *ctx = data; |
473 | 472 |
474 return ngx_snprintf(buf, len, " while accept() on %s", ctx->name); | 473 return ngx_snprintf(buf, len, " while accept() on %V", ctx->name); |
475 } | 474 } |