Mercurial > hg > nginx
annotate src/event/ngx_event_connect.c @ 6536:f7849bfb6d21
Improved EPOLLRDHUP handling.
When it's known that the kernel supports EPOLLRDHUP, there is no need in
additional recv() call to get EOF or error when the flag is absent in the
event generated by the kernel. A special runtime test is done at startup
to detect if EPOLLRDHUP is actually supported by the kernel because
epoll_ctl() silently ignores unknown flags.
With this knowledge it's now possible to drop the "ready" flag for partial
read. Previously, the "ready" flag was kept until the recv() returned EOF
or error. In particular, this change allows the lingering close heuristics
(which relies on the "ready" flag state) to actually work on Linux, and not
wait for more data in most cases.
The "available" flag is now used in the read event with the semantics similar
to the corresponding counter in kqueue.
author | Valentin Bartenev <vbart@nginx.com> |
---|---|
date | Fri, 13 May 2016 17:19:23 +0300 |
parents | 1d0e03db9f8e |
children | 2c7b488a61fb |
rev | line source |
---|---|
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
417
diff
changeset
|
1 |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
417
diff
changeset
|
2 /* |
444
42d11f017717
nginx-0.1.0-2004-09-29-20:00:49 import; remove years from copyright
Igor Sysoev <igor@sysoev.ru>
parents:
441
diff
changeset
|
3 * Copyright (C) Igor Sysoev |
4412 | 4 * Copyright (C) Nginx, Inc. |
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
417
diff
changeset
|
5 */ |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
417
diff
changeset
|
6 |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
7 |
136
da00cde00e8a
nginx-0.0.1-2003-10-02-09:39:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
8 #include <ngx_config.h> |
da00cde00e8a
nginx-0.0.1-2003-10-02-09:39:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
9 #include <ngx_core.h> |
da00cde00e8a
nginx-0.0.1-2003-10-02-09:39:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
10 #include <ngx_event.h> |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
11 #include <ngx_event_connect.h> |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
12 |
131
049e78b1f852
nginx-0.0.1-2003-08-14-10:00:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
124
diff
changeset
|
13 |
6530
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
14 #if (NGX_HAVE_TRANSPARENT_PROXY) |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
15 static ngx_int_t ngx_event_connect_set_transparent(ngx_peer_connection_t *pc, |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
16 ngx_socket_t s); |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
17 #endif |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
18 |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
19 |
487 | 20 ngx_int_t |
21 ngx_event_connect_peer(ngx_peer_connection_t *pc) | |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
22 { |
6436 | 23 int rc, type; |
1470 | 24 ngx_int_t event; |
543 | 25 ngx_err_t err; |
884 | 26 ngx_uint_t level; |
543 | 27 ngx_socket_t s; |
28 ngx_event_t *rev, *wev; | |
29 ngx_connection_t *c; | |
122
cd91e4a1ad0d
nginx-0.0.1-2003-07-23-17:10:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
121
diff
changeset
|
30 |
884 | 31 rc = pc->get(pc, pc->data); |
32 if (rc != NGX_OK) { | |
33 return rc; | |
121
b3655b21375a
nginx-0.0.1-2003-07-22-23:53:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
120
diff
changeset
|
34 } |
b3655b21375a
nginx-0.0.1-2003-07-22-23:53:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
120
diff
changeset
|
35 |
6436 | 36 type = (pc->type ? pc->type : SOCK_STREAM); |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
37 |
6436 | 38 s = ngx_socket(pc->sockaddr->sa_family, type, 0); |
39 | |
40 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, pc->log, 0, "%s socket %d", | |
41 (type == SOCK_STREAM) ? "stream" : "dgram", s); | |
509 | 42 |
5360
3d2d3e1cf427
Win32: MinGW GCC compatibility.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5141
diff
changeset
|
43 if (s == (ngx_socket_t) -1) { |
121
b3655b21375a
nginx-0.0.1-2003-07-22-23:53:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
120
diff
changeset
|
44 ngx_log_error(NGX_LOG_ALERT, pc->log, ngx_socket_errno, |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
45 ngx_socket_n " failed"); |
119
cd54bcbaf3b5
nginx-0.0.1-2003-07-21-01:15:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
46 return NGX_ERROR; |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
47 } |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
48 |
323
ba876b26b76d
nginx-0.0.3-2004-04-21-22:54:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
309
diff
changeset
|
49 |
543 | 50 c = ngx_get_connection(s, pc->log); |
323
ba876b26b76d
nginx-0.0.3-2004-04-21-22:54:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
309
diff
changeset
|
51 |
543 | 52 if (c == NULL) { |
323
ba876b26b76d
nginx-0.0.3-2004-04-21-22:54:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
309
diff
changeset
|
53 if (ngx_close_socket(s) == -1) { |
ba876b26b76d
nginx-0.0.3-2004-04-21-22:54:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
309
diff
changeset
|
54 ngx_log_error(NGX_LOG_ALERT, pc->log, ngx_socket_errno, |
ba876b26b76d
nginx-0.0.3-2004-04-21-22:54:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
309
diff
changeset
|
55 ngx_close_socket_n "failed"); |
ba876b26b76d
nginx-0.0.3-2004-04-21-22:54:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
309
diff
changeset
|
56 } |
ba876b26b76d
nginx-0.0.3-2004-04-21-22:54:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
309
diff
changeset
|
57 |
ba876b26b76d
nginx-0.0.3-2004-04-21-22:54:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
309
diff
changeset
|
58 return NGX_ERROR; |
ba876b26b76d
nginx-0.0.3-2004-04-21-22:54:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
309
diff
changeset
|
59 } |
ba876b26b76d
nginx-0.0.3-2004-04-21-22:54:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
309
diff
changeset
|
60 |
6436 | 61 c->type = type; |
62 | |
121
b3655b21375a
nginx-0.0.1-2003-07-22-23:53:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
120
diff
changeset
|
63 if (pc->rcvbuf) { |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
64 if (setsockopt(s, SOL_SOCKET, SO_RCVBUF, |
563 | 65 (const void *) &pc->rcvbuf, sizeof(int)) == -1) |
66 { | |
121
b3655b21375a
nginx-0.0.1-2003-07-22-23:53:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
120
diff
changeset
|
67 ngx_log_error(NGX_LOG_ALERT, pc->log, ngx_socket_errno, |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
68 "setsockopt(SO_RCVBUF) failed"); |
3271
fcd98af88df3
proxy_bind, fastcgi_bind, and memcached_bind
Igor Sysoev <igor@sysoev.ru>
parents:
2540
diff
changeset
|
69 goto failed; |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
70 } |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
71 } |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
72 |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
73 if (ngx_nonblocking(s) == -1) { |
121
b3655b21375a
nginx-0.0.1-2003-07-22-23:53:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
120
diff
changeset
|
74 ngx_log_error(NGX_LOG_ALERT, pc->log, ngx_socket_errno, |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
75 ngx_nonblocking_n " failed"); |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
76 |
3271
fcd98af88df3
proxy_bind, fastcgi_bind, and memcached_bind
Igor Sysoev <igor@sysoev.ru>
parents:
2540
diff
changeset
|
77 goto failed; |
fcd98af88df3
proxy_bind, fastcgi_bind, and memcached_bind
Igor Sysoev <igor@sysoev.ru>
parents:
2540
diff
changeset
|
78 } |
543 | 79 |
3271
fcd98af88df3
proxy_bind, fastcgi_bind, and memcached_bind
Igor Sysoev <igor@sysoev.ru>
parents:
2540
diff
changeset
|
80 if (pc->local) { |
6530
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
81 |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
82 #if (NGX_HAVE_TRANSPARENT_PROXY) |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
83 if (pc->transparent) { |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
84 if (ngx_event_connect_set_transparent(pc, s) != NGX_OK) { |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
85 goto failed; |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
86 } |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
87 } |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
88 #endif |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
89 |
3271
fcd98af88df3
proxy_bind, fastcgi_bind, and memcached_bind
Igor Sysoev <igor@sysoev.ru>
parents:
2540
diff
changeset
|
90 if (bind(s, pc->local->sockaddr, pc->local->socklen) == -1) { |
fcd98af88df3
proxy_bind, fastcgi_bind, and memcached_bind
Igor Sysoev <igor@sysoev.ru>
parents:
2540
diff
changeset
|
91 ngx_log_error(NGX_LOG_CRIT, pc->log, ngx_socket_errno, |
fcd98af88df3
proxy_bind, fastcgi_bind, and memcached_bind
Igor Sysoev <igor@sysoev.ru>
parents:
2540
diff
changeset
|
92 "bind(%V) failed", &pc->local->name); |
fcd98af88df3
proxy_bind, fastcgi_bind, and memcached_bind
Igor Sysoev <igor@sysoev.ru>
parents:
2540
diff
changeset
|
93 |
fcd98af88df3
proxy_bind, fastcgi_bind, and memcached_bind
Igor Sysoev <igor@sysoev.ru>
parents:
2540
diff
changeset
|
94 goto failed; |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
95 } |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
96 } |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
97 |
6436 | 98 if (type == SOCK_STREAM) { |
99 c->recv = ngx_recv; | |
100 c->send = ngx_send; | |
101 c->recv_chain = ngx_recv_chain; | |
102 c->send_chain = ngx_send_chain; | |
103 | |
104 c->sendfile = 1; | |
483 | 105 |
6436 | 106 if (pc->sockaddr->sa_family == AF_UNIX) { |
107 c->tcp_nopush = NGX_TCP_NOPUSH_DISABLED; | |
108 c->tcp_nodelay = NGX_TCP_NODELAY_DISABLED; | |
109 | |
110 #if (NGX_SOLARIS) | |
111 /* Solaris's sendfilev() supports AF_NCA, AF_INET, and AF_INET6 */ | |
112 c->sendfile = 0; | |
113 #endif | |
114 } | |
115 | |
116 } else { /* type == SOCK_DGRAM */ | |
117 c->recv = ngx_udp_recv; | |
118 c->send = ngx_send; | |
119 } | |
1397
6c25a49e548a
upstream sendfile bit was overridden by r->connection->sendfile
Igor Sysoev <igor@sysoev.ru>
parents:
884
diff
changeset
|
120 |
543 | 121 c->log_error = pc->log_error; |
119
cd54bcbaf3b5
nginx-0.0.1-2003-07-21-01:15:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
122 |
561 | 123 rev = c->read; |
124 wev = c->write; | |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
125 |
191
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
189
diff
changeset
|
126 rev->log = pc->log; |
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
189
diff
changeset
|
127 wev->log = pc->log; |
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
189
diff
changeset
|
128 |
121
b3655b21375a
nginx-0.0.1-2003-07-22-23:53:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
120
diff
changeset
|
129 pc->connection = c; |
119
cd54bcbaf3b5
nginx-0.0.1-2003-07-21-01:15:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
130 |
561 | 131 c->number = ngx_atomic_fetch_add(ngx_connection_counter, 1); |
257
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
132 |
121
b3655b21375a
nginx-0.0.1-2003-07-22-23:53:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
120
diff
changeset
|
133 if (ngx_add_conn) { |
b3655b21375a
nginx-0.0.1-2003-07-22-23:53:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
120
diff
changeset
|
134 if (ngx_add_conn(c) == NGX_ERROR) { |
3271
fcd98af88df3
proxy_bind, fastcgi_bind, and memcached_bind
Igor Sysoev <igor@sysoev.ru>
parents:
2540
diff
changeset
|
135 goto failed; |
121
b3655b21375a
nginx-0.0.1-2003-07-22-23:53:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
120
diff
changeset
|
136 } |
577 | 137 } |
121
b3655b21375a
nginx-0.0.1-2003-07-22-23:53:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
120
diff
changeset
|
138 |
543 | 139 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, pc->log, 0, |
5600
957d734362ed
Fixed format specifier in logging of "c->number".
Sergey Kandaurov <pluknet@nginx.com>
parents:
5360
diff
changeset
|
140 "connect to %V, fd:%d #%uA", pc->name, s, c->number); |
137
2a615b036870
nginx-0.0.1-2003-10-03-19:50:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
136
diff
changeset
|
141 |
884 | 142 rc = connect(s, pc->sockaddr, pc->socklen); |
122
cd91e4a1ad0d
nginx-0.0.1-2003-07-23-17:10:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
121
diff
changeset
|
143 |
cd91e4a1ad0d
nginx-0.0.1-2003-07-23-17:10:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
121
diff
changeset
|
144 if (rc == -1) { |
cd91e4a1ad0d
nginx-0.0.1-2003-07-23-17:10:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
121
diff
changeset
|
145 err = ngx_socket_errno; |
186
c1f3a3c7c5db
nginx-0.0.1-2003-11-17-00:49:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
169
diff
changeset
|
146 |
c1f3a3c7c5db
nginx-0.0.1-2003-11-17-00:49:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
169
diff
changeset
|
147 |
2117
9d62abd76ea5
handle connect()'s EAGAIN on Linux
Igor Sysoev <igor@sysoev.ru>
parents:
1869
diff
changeset
|
148 if (err != NGX_EINPROGRESS |
9d62abd76ea5
handle connect()'s EAGAIN on Linux
Igor Sysoev <igor@sysoev.ru>
parents:
1869
diff
changeset
|
149 #if (NGX_WIN32) |
9d62abd76ea5
handle connect()'s EAGAIN on Linux
Igor Sysoev <igor@sysoev.ru>
parents:
1869
diff
changeset
|
150 /* Winsock returns WSAEWOULDBLOCK (NGX_EAGAIN) */ |
9d62abd76ea5
handle connect()'s EAGAIN on Linux
Igor Sysoev <igor@sysoev.ru>
parents:
1869
diff
changeset
|
151 && err != NGX_EAGAIN |
9d62abd76ea5
handle connect()'s EAGAIN on Linux
Igor Sysoev <igor@sysoev.ru>
parents:
1869
diff
changeset
|
152 #endif |
9d62abd76ea5
handle connect()'s EAGAIN on Linux
Igor Sysoev <igor@sysoev.ru>
parents:
1869
diff
changeset
|
153 ) |
9d62abd76ea5
handle connect()'s EAGAIN on Linux
Igor Sysoev <igor@sysoev.ru>
parents:
1869
diff
changeset
|
154 { |
1869
192443881e51
add NGX_ENETDOWN, NGX_ENETUNREACH, and NGX_EHOSTDOWN
Igor Sysoev <igor@sysoev.ru>
parents:
1470
diff
changeset
|
155 if (err == NGX_ECONNREFUSED |
2117
9d62abd76ea5
handle connect()'s EAGAIN on Linux
Igor Sysoev <igor@sysoev.ru>
parents:
1869
diff
changeset
|
156 #if (NGX_LINUX) |
9d62abd76ea5
handle connect()'s EAGAIN on Linux
Igor Sysoev <igor@sysoev.ru>
parents:
1869
diff
changeset
|
157 /* |
9d62abd76ea5
handle connect()'s EAGAIN on Linux
Igor Sysoev <igor@sysoev.ru>
parents:
1869
diff
changeset
|
158 * Linux returns EAGAIN instead of ECONNREFUSED |
9d62abd76ea5
handle connect()'s EAGAIN on Linux
Igor Sysoev <igor@sysoev.ru>
parents:
1869
diff
changeset
|
159 * for unix sockets if listen queue is full |
9d62abd76ea5
handle connect()'s EAGAIN on Linux
Igor Sysoev <igor@sysoev.ru>
parents:
1869
diff
changeset
|
160 */ |
9d62abd76ea5
handle connect()'s EAGAIN on Linux
Igor Sysoev <igor@sysoev.ru>
parents:
1869
diff
changeset
|
161 || err == NGX_EAGAIN |
9d62abd76ea5
handle connect()'s EAGAIN on Linux
Igor Sysoev <igor@sysoev.ru>
parents:
1869
diff
changeset
|
162 #endif |
2540 | 163 || err == NGX_ECONNRESET |
1869
192443881e51
add NGX_ENETDOWN, NGX_ENETUNREACH, and NGX_EHOSTDOWN
Igor Sysoev <igor@sysoev.ru>
parents:
1470
diff
changeset
|
164 || err == NGX_ENETDOWN |
192443881e51
add NGX_ENETDOWN, NGX_ENETUNREACH, and NGX_EHOSTDOWN
Igor Sysoev <igor@sysoev.ru>
parents:
1470
diff
changeset
|
165 || err == NGX_ENETUNREACH |
192443881e51
add NGX_ENETDOWN, NGX_ENETUNREACH, and NGX_EHOSTDOWN
Igor Sysoev <igor@sysoev.ru>
parents:
1470
diff
changeset
|
166 || err == NGX_EHOSTDOWN |
192443881e51
add NGX_ENETDOWN, NGX_ENETUNREACH, and NGX_EHOSTDOWN
Igor Sysoev <igor@sysoev.ru>
parents:
1470
diff
changeset
|
167 || err == NGX_EHOSTUNREACH) |
192443881e51
add NGX_ENETDOWN, NGX_ENETUNREACH, and NGX_EHOSTDOWN
Igor Sysoev <igor@sysoev.ru>
parents:
1470
diff
changeset
|
168 { |
541 | 169 level = NGX_LOG_ERR; |
1869
192443881e51
add NGX_ENETDOWN, NGX_ENETUNREACH, and NGX_EHOSTDOWN
Igor Sysoev <igor@sysoev.ru>
parents:
1470
diff
changeset
|
170 |
541 | 171 } else { |
172 level = NGX_LOG_CRIT; | |
173 } | |
487 | 174 |
541 | 175 ngx_log_error(level, c->log, err, "connect() to %V failed", |
884 | 176 pc->name); |
139
54307053f185
nginx-0.0.1-2003-10-07-19:30:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
137
diff
changeset
|
177 |
4421
fbae1a82de8b
Fixed error handling in ngx_event_connect_peer().
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
178 ngx_close_connection(c); |
fbae1a82de8b
Fixed error handling in ngx_event_connect_peer().
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
179 pc->connection = NULL; |
fbae1a82de8b
Fixed error handling in ngx_event_connect_peer().
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
180 |
543 | 181 return NGX_DECLINED; |
122
cd91e4a1ad0d
nginx-0.0.1-2003-07-23-17:10:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
121
diff
changeset
|
182 } |
cd91e4a1ad0d
nginx-0.0.1-2003-07-23-17:10:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
121
diff
changeset
|
183 } |
cd91e4a1ad0d
nginx-0.0.1-2003-07-23-17:10:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
121
diff
changeset
|
184 |
344
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
323
diff
changeset
|
185 if (ngx_add_conn) { |
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
323
diff
changeset
|
186 if (rc == -1) { |
487 | 187 |
344
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
323
diff
changeset
|
188 /* NGX_EINPROGRESS */ |
487 | 189 |
344
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
323
diff
changeset
|
190 return NGX_AGAIN; |
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
323
diff
changeset
|
191 } |
577 | 192 |
344
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
323
diff
changeset
|
193 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, pc->log, 0, "connected"); |
483 | 194 |
195 wev->ready = 1; | |
196 | |
344
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
323
diff
changeset
|
197 return NGX_OK; |
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
323
diff
changeset
|
198 } |
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
323
diff
changeset
|
199 |
6125
4dc8e7b62216
Removed the obsolete aio module.
Ruslan Ermilov <ru@nginx.com>
parents:
5820
diff
changeset
|
200 if (ngx_event_flags & NGX_USE_IOCP_EVENT) { |
167
8aef3c72e5da
nginx-0.0.1-2003-10-30-19:51:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
166
diff
changeset
|
201 |
455 | 202 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, pc->log, ngx_socket_errno, |
203 "connect(): %d", rc); | |
204 | |
167
8aef3c72e5da
nginx-0.0.1-2003-10-30-19:51:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
166
diff
changeset
|
205 if (ngx_blocking(s) == -1) { |
8aef3c72e5da
nginx-0.0.1-2003-10-30-19:51:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
166
diff
changeset
|
206 ngx_log_error(NGX_LOG_ALERT, pc->log, ngx_socket_errno, |
8aef3c72e5da
nginx-0.0.1-2003-10-30-19:51:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
166
diff
changeset
|
207 ngx_blocking_n " failed"); |
3271
fcd98af88df3
proxy_bind, fastcgi_bind, and memcached_bind
Igor Sysoev <igor@sysoev.ru>
parents:
2540
diff
changeset
|
208 goto failed; |
167
8aef3c72e5da
nginx-0.0.1-2003-10-30-19:51:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
166
diff
changeset
|
209 } |
8aef3c72e5da
nginx-0.0.1-2003-10-30-19:51:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
166
diff
changeset
|
210 |
8aef3c72e5da
nginx-0.0.1-2003-10-30-19:51:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
166
diff
changeset
|
211 /* |
487 | 212 * FreeBSD's aio allows to post an operation on non-connected socket. |
186
c1f3a3c7c5db
nginx-0.0.1-2003-11-17-00:49:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
169
diff
changeset
|
213 * NT does not support it. |
577 | 214 * |
169
edf29bb717da
nginx-0.0.1-2003-10-31-19:05:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
168
diff
changeset
|
215 * TODO: check in Win32, etc. As workaround we can use NGX_ONESHOT_EVENT |
167
8aef3c72e5da
nginx-0.0.1-2003-10-30-19:51:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
166
diff
changeset
|
216 */ |
577 | 217 |
166
389d7ee9fa60
nginx-0.0.1-2003-10-30-11:51:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
164
diff
changeset
|
218 rev->ready = 1; |
164
84036764e215
nginx-0.0.1-2003-10-29-11:30:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
162
diff
changeset
|
219 wev->ready = 1; |
166
389d7ee9fa60
nginx-0.0.1-2003-10-30-11:51:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
164
diff
changeset
|
220 |
164
84036764e215
nginx-0.0.1-2003-10-29-11:30:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
162
diff
changeset
|
221 return NGX_OK; |
84036764e215
nginx-0.0.1-2003-10-29-11:30:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
162
diff
changeset
|
222 } |
84036764e215
nginx-0.0.1-2003-10-29-11:30:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
162
diff
changeset
|
223 |
487 | 224 if (ngx_event_flags & NGX_USE_CLEAR_EVENT) { |
225 | |
226 /* kqueue */ | |
227 | |
137
2a615b036870
nginx-0.0.1-2003-10-03-19:50:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
136
diff
changeset
|
228 event = NGX_CLEAR_EVENT; |
2a615b036870
nginx-0.0.1-2003-10-03-19:50:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
136
diff
changeset
|
229 |
487 | 230 } else { |
231 | |
232 /* select, poll, /dev/poll */ | |
233 | |
137
2a615b036870
nginx-0.0.1-2003-10-03-19:50:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
136
diff
changeset
|
234 event = NGX_LEVEL_EVENT; |
2a615b036870
nginx-0.0.1-2003-10-03-19:50:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
136
diff
changeset
|
235 } |
2a615b036870
nginx-0.0.1-2003-10-03-19:50:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
136
diff
changeset
|
236 |
162
96993d4d5067
nginx-0.0.1-2003-10-28-00:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
161
diff
changeset
|
237 if (ngx_add_event(rev, NGX_READ_EVENT, event) != NGX_OK) { |
3271
fcd98af88df3
proxy_bind, fastcgi_bind, and memcached_bind
Igor Sysoev <igor@sysoev.ru>
parents:
2540
diff
changeset
|
238 goto failed; |
162
96993d4d5067
nginx-0.0.1-2003-10-28-00:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
161
diff
changeset
|
239 } |
96993d4d5067
nginx-0.0.1-2003-10-28-00:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
161
diff
changeset
|
240 |
137
2a615b036870
nginx-0.0.1-2003-10-03-19:50:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
136
diff
changeset
|
241 if (rc == -1) { |
2a615b036870
nginx-0.0.1-2003-10-03-19:50:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
136
diff
changeset
|
242 |
2a615b036870
nginx-0.0.1-2003-10-03-19:50:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
136
diff
changeset
|
243 /* NGX_EINPROGRESS */ |
2a615b036870
nginx-0.0.1-2003-10-03-19:50:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
136
diff
changeset
|
244 |
2a615b036870
nginx-0.0.1-2003-10-03-19:50:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
136
diff
changeset
|
245 if (ngx_add_event(wev, NGX_WRITE_EVENT, event) != NGX_OK) { |
3271
fcd98af88df3
proxy_bind, fastcgi_bind, and memcached_bind
Igor Sysoev <igor@sysoev.ru>
parents:
2540
diff
changeset
|
246 goto failed; |
137
2a615b036870
nginx-0.0.1-2003-10-03-19:50:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
136
diff
changeset
|
247 } |
2a615b036870
nginx-0.0.1-2003-10-03-19:50:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
136
diff
changeset
|
248 |
2a615b036870
nginx-0.0.1-2003-10-03-19:50:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
136
diff
changeset
|
249 return NGX_AGAIN; |
2a615b036870
nginx-0.0.1-2003-10-03-19:50:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
136
diff
changeset
|
250 } |
2a615b036870
nginx-0.0.1-2003-10-03-19:50:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
136
diff
changeset
|
251 |
257
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
252 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, pc->log, 0, "connected"); |
189
c966c09be66b
nginx-0.0.1-2003-11-18-19:49:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
186
diff
changeset
|
253 |
148
5afee0074707
nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
254 wev->ready = 1; |
5afee0074707
nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
255 |
136
da00cde00e8a
nginx-0.0.1-2003-10-02-09:39:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
256 return NGX_OK; |
3271
fcd98af88df3
proxy_bind, fastcgi_bind, and memcached_bind
Igor Sysoev <igor@sysoev.ru>
parents:
2540
diff
changeset
|
257 |
fcd98af88df3
proxy_bind, fastcgi_bind, and memcached_bind
Igor Sysoev <igor@sysoev.ru>
parents:
2540
diff
changeset
|
258 failed: |
fcd98af88df3
proxy_bind, fastcgi_bind, and memcached_bind
Igor Sysoev <igor@sysoev.ru>
parents:
2540
diff
changeset
|
259 |
4421
fbae1a82de8b
Fixed error handling in ngx_event_connect_peer().
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
260 ngx_close_connection(c); |
fbae1a82de8b
Fixed error handling in ngx_event_connect_peer().
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
261 pc->connection = NULL; |
3271
fcd98af88df3
proxy_bind, fastcgi_bind, and memcached_bind
Igor Sysoev <igor@sysoev.ru>
parents:
2540
diff
changeset
|
262 |
fcd98af88df3
proxy_bind, fastcgi_bind, and memcached_bind
Igor Sysoev <igor@sysoev.ru>
parents:
2540
diff
changeset
|
263 return NGX_ERROR; |
119
cd54bcbaf3b5
nginx-0.0.1-2003-07-21-01:15:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
264 } |
131
049e78b1f852
nginx-0.0.1-2003-08-14-10:00:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
124
diff
changeset
|
265 |
049e78b1f852
nginx-0.0.1-2003-08-14-10:00:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
124
diff
changeset
|
266 |
6530
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
267 #if (NGX_HAVE_TRANSPARENT_PROXY) |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
268 |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
269 static ngx_int_t |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
270 ngx_event_connect_set_transparent(ngx_peer_connection_t *pc, ngx_socket_t s) |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
271 { |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
272 int value; |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
273 |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
274 value = 1; |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
275 |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
276 #if defined(SO_BINDANY) |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
277 |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
278 if (setsockopt(s, SOL_SOCKET, SO_BINDANY, |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
279 (const void *) &value, sizeof(int)) == -1) |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
280 { |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
281 ngx_log_error(NGX_LOG_ALERT, pc->log, ngx_socket_errno, |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
282 "setsockopt(SO_BINDANY) failed"); |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
283 return NGX_ERROR; |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
284 } |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
285 |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
286 #else |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
287 |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
288 switch (pc->local->sockaddr->sa_family) { |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
289 |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
290 case AF_INET: |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
291 |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
292 #if defined(IP_TRANSPARENT) |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
293 |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
294 if (setsockopt(s, IPPROTO_IP, IP_TRANSPARENT, |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
295 (const void *) &value, sizeof(int)) == -1) |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
296 { |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
297 ngx_log_error(NGX_LOG_ALERT, pc->log, ngx_socket_errno, |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
298 "setsockopt(IP_TRANSPARENT) failed"); |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
299 return NGX_ERROR; |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
300 } |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
301 |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
302 #elif defined(IP_BINDANY) |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
303 |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
304 if (setsockopt(s, IPPROTO_IP, IP_BINDANY, |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
305 (const void *) &value, sizeof(int)) == -1) |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
306 { |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
307 ngx_log_error(NGX_LOG_ALERT, pc->log, ngx_socket_errno, |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
308 "setsockopt(IP_BINDANY) failed"); |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
309 return NGX_ERROR; |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
310 } |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
311 |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
312 #endif |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
313 |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
314 break; |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
315 |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
316 #if (NGX_HAVE_INET6) |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
317 |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
318 case AF_INET6: |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
319 |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
320 #if defined(IPV6_TRANSPARENT) |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
321 |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
322 if (setsockopt(s, IPPROTO_IPV6, IPV6_TRANSPARENT, |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
323 (const void *) &value, sizeof(int)) == -1) |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
324 { |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
325 ngx_log_error(NGX_LOG_ALERT, pc->log, ngx_socket_errno, |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
326 "setsockopt(IPV6_TRANSPARENT) failed"); |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
327 return NGX_ERROR; |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
328 } |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
329 |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
330 #elif defined(IPV6_BINDANY) |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
331 |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
332 if (setsockopt(s, IPPROTO_IPV6, IPV6_BINDANY, |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
333 (const void *) &value, sizeof(int)) == -1) |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
334 { |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
335 ngx_log_error(NGX_LOG_ALERT, pc->log, ngx_socket_errno, |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
336 "setsockopt(IPV6_BINDANY) failed"); |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
337 return NGX_ERROR; |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
338 } |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
339 |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
340 #endif |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
341 break; |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
342 |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
343 #endif /* NGX_HAVE_INET6 */ |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
344 |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
345 } |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
346 |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
347 #endif /* SO_BINDANY */ |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
348 |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
349 return NGX_OK; |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
350 } |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
351 |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
352 #endif |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
353 |
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6436
diff
changeset
|
354 |
884 | 355 ngx_int_t |
356 ngx_event_get_peer(ngx_peer_connection_t *pc, void *data) | |
131
049e78b1f852
nginx-0.0.1-2003-08-14-10:00:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
124
diff
changeset
|
357 { |
884 | 358 return NGX_OK; |
131
049e78b1f852
nginx-0.0.1-2003-08-14-10:00:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
124
diff
changeset
|
359 } |