Mercurial > hg > nginx
comparison src/event/ngx_event_acceptex.c @ 100:7ebc8b7fb816
nginx-0.0.1-2003-06-03-19:42:58 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Tue, 03 Jun 2003 15:42:58 +0000 |
parents | 738fe44c70d5 |
children | 7e86d028d8f0 |
comparison
equal
deleted
inserted
replaced
99:a059e1aa65d4 | 100:7ebc8b7fb816 |
---|---|
1 | 1 |
2 #include <ngx_config.h> | 2 #include <ngx_config.h> |
3 #include <ngx_core.h> | |
3 | 4 |
4 #include <ngx_core.h> | |
5 #include <ngx_types.h> | |
6 #include <ngx_log.h> | |
7 #include <ngx_listen.h> | 5 #include <ngx_listen.h> |
8 #include <ngx_connection.h> | 6 |
9 #include <ngx_event.h> | 7 #include <ngx_event.h> |
10 #include <ngx_event_close.h> | 8 #include <ngx_event_close.h> |
11 #include <ngx_iocp_module.h> | 9 #include <ngx_iocp_module.h> |
12 | 10 |
13 #include <ngx_event_acceptex.h> | 11 #include <ngx_event_acceptex.h> |
14 | 12 |
15 | 13 |
16 | 14 |
17 /* This function should always return NGX_OK even there are some failures | 15 void ngx_event_acceptex(ngx_event_t *ev) |
18 because if we return NGX_ERROR then listening socket would be closed */ | |
19 | |
20 int ngx_event_acceptex(ngx_event_t *ev) | |
21 { | 16 { |
22 ngx_connection_t *c; | 17 ngx_connection_t *c; |
23 | 18 |
24 c = (ngx_connection_t *) ev->data; | 19 c = (ngx_connection_t *) ev->data; |
25 | 20 |
26 if (ev->ovlp.error) { | 21 if (ev->ovlp.error) { |
27 ngx_log_error(NGX_LOG_CRIT, ev->log, ev->ovlp.error, | 22 ngx_log_error(NGX_LOG_CRIT, ev->log, ev->ovlp.error, |
28 "AcceptEx(%s) falied", c->addr_text.data); | 23 "AcceptEx() falied for %s", c->addr_text.data); |
29 return NGX_OK; | 24 return; |
30 } | 25 } |
31 | 26 |
32 #if 0 | 27 /* TODO: can we do SO_UPDATE_ACCEPT_CONTEXT just before shutdown() ??? |
33 | |
34 /* can we do SO_UPDATE_ACCEPT_CONTEXT just before shutdown() ??? | |
35 or AcceptEx's context will be lost ??? */ | 28 or AcceptEx's context will be lost ??? */ |
36 | 29 |
37 /* SO_UPDATE_ACCEPT_CONTEXT is required for shutdown() to work */ | 30 /* SO_UPDATE_ACCEPT_CONTEXT is required for shutdown() to work */ |
38 if (setsockopt(context->accept_socket, SOL_SOCKET, | 31 if (setsockopt(c->fd, SOL_SOCKET, SO_UPDATE_ACCEPT_CONTEXT, |
39 SO_UPDATE_ACCEPT_CONTEXT, (char *)&nsd, | 32 (char *)&c->listening->fd, sizeof(ngx_socket_t)) == -1) |
40 sizeof(nsd))) { | 33 { |
41 ap_log_error(APLOG_MARK, APLOG_ERR, WSAGetLastError(), server_conf, | 34 ngx_log_error(NGX_LOG_CRIT, ev->log, ngx_socket_errno, |
42 "setsockopt(SO_UPDATE_ACCEPT_CONTEXT) failed."); | 35 "setsockopt(SO_UPDATE_ACCEPT_CONTEXT) failed for %s", |
36 c->addr_text.data); | |
43 | 37 |
44 /* non fatal - we can not only do lingering close */ | 38 /* non fatal - we can not only do lingering close */ |
45 | 39 } |
46 #endif | |
47 | 40 |
48 getacceptexsockaddrs(c->data, 0, | 41 getacceptexsockaddrs(c->data, 0, |
49 c->socklen + 16, c->socklen + 16, | 42 c->socklen + 16, c->socklen + 16, |
50 &c->local_sockaddr, &c->local_socklen, | 43 &c->local_sockaddr, &c->local_socklen, |
51 &c->sockaddr, &c->socklen); | 44 &c->sockaddr, &c->socklen); |
55 /* STUB: InterlockedInc() */ | 48 /* STUB: InterlockedInc() */ |
56 c->number = ngx_connection_counter++; | 49 c->number = ngx_connection_counter++; |
57 | 50 |
58 c->handler(c); | 51 c->handler(c); |
59 | 52 |
60 return NGX_OK; | 53 return; |
61 | 54 |
62 } | 55 } |
63 | 56 |
64 | 57 |
65 int ngx_event_post_acceptex(ngx_listen_t *ls, int n) | 58 int ngx_event_post_acceptex(ngx_listen_t *ls, int n) |