Mercurial > hg > nginx-quic
annotate src/os/win32/ngx_wsasend_chain.c @ 8717:e06283038ec8 quic
QUIC: clear SSL_OP_ENABLE_MIDDLEBOX_COMPAT on SSL context switch.
The SSL_OP_ENABLE_MIDDLEBOX_COMPAT option is provided by QuicTLS and enabled
by default in the newly created SSL contexts. SSL_set_quic_method() is used
to clear it, which is required for SSL handshake to work on QUIC connections.
Switching context in the ngx_http_ssl_servername() SNI callback overrides SSL
options from the new SSL context. This results in the option set again.
Fix is to explicitly clear it when switching to another SSL context.
Initially reported here (in Russian):
http://mailman.nginx.org/pipermail/nginx-ru/2021-November/063989.html
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Tue, 07 Dec 2021 15:49:51 +0300 |
parents | ecf2a9002b37 |
children |
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:
363
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:
363
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:
363
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:
363
diff
changeset
|
6 |
103
6dfda4cf5200
nginx-0.0.1-2003-06-11-19:28:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
7 |
6dfda4cf5200
nginx-0.0.1-2003-06-11-19:28:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
8 #include <ngx_config.h> |
6dfda4cf5200
nginx-0.0.1-2003-06-11-19:28:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
9 #include <ngx_core.h> |
6dfda4cf5200
nginx-0.0.1-2003-06-11-19:28:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
10 #include <ngx_event.h> |
6dfda4cf5200
nginx-0.0.1-2003-06-11-19:28:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
11 |
6dfda4cf5200
nginx-0.0.1-2003-06-11-19:28:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
12 |
8535
ecf2a9002b37
Win32: use only preallocated memory in send/recv chain functions.
Ruslan Ermilov <ru@nginx.com>
parents:
6474
diff
changeset
|
13 #define NGX_WSABUFS 64 |
461 | 14 |
15 | |
501 | 16 ngx_chain_t * |
17 ngx_wsasend_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit) | |
103
6dfda4cf5200
nginx-0.0.1-2003-06-11-19:28:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
18 { |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
19 int rc; |
292
a472bfb778b3
nginx-0.0.3-2004-03-17-00:26:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
280
diff
changeset
|
20 u_char *prev; |
473 | 21 u_long size, sent, send, prev_send; |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
22 ngx_err_t err; |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
23 ngx_event_t *wev; |
461 | 24 ngx_array_t vec; |
501 | 25 ngx_chain_t *cl; |
461 | 26 LPWSABUF wsabuf; |
27 WSABUF wsabufs[NGX_WSABUFS]; | |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
28 |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
29 wev = c->write; |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
30 |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
31 if (!wev->ready) { |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
32 return in; |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
33 } |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
34 |
473 | 35 /* the maximum limit size is the maximum u_long value - the page size */ |
36 | |
5873
35b8e5e98508
Win32: suppressed warnings by "-Werror=sign-compare".
Kouhei Sutou <kou@cozmixng.org>
parents:
5853
diff
changeset
|
37 if (limit == 0 || limit > (off_t) (NGX_MAX_UINT32_VALUE - ngx_pagesize)) { |
473 | 38 limit = NGX_MAX_UINT32_VALUE - ngx_pagesize; |
39 } | |
40 | |
461 | 41 send = 0; |
42 | |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
43 /* |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
44 * WSABUFs must be 4-byte aligned otherwise |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
45 * WSASend() will return undocumented WSAEINVAL error. |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
46 */ |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
47 |
461 | 48 vec.elts = wsabufs; |
49 vec.size = sizeof(WSABUF); | |
8535
ecf2a9002b37
Win32: use only preallocated memory in send/recv chain functions.
Ruslan Ermilov <ru@nginx.com>
parents:
6474
diff
changeset
|
50 vec.nalloc = ngx_min(NGX_WSABUFS, ngx_max_wsabufs); |
461 | 51 vec.pool = c->pool; |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
52 |
461 | 53 for ( ;; ) { |
54 prev = NULL; | |
55 wsabuf = NULL; | |
473 | 56 prev_send = send; |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
57 |
461 | 58 vec.nelts = 0; |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
59 |
461 | 60 /* create the WSABUF and coalesce the neighbouring bufs */ |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
61 |
8535
ecf2a9002b37
Win32: use only preallocated memory in send/recv chain functions.
Ruslan Ermilov <ru@nginx.com>
parents:
6474
diff
changeset
|
62 for (cl = in; cl && send < limit; cl = cl->next) { |
ecf2a9002b37
Win32: use only preallocated memory in send/recv chain functions.
Ruslan Ermilov <ru@nginx.com>
parents:
6474
diff
changeset
|
63 |
461 | 64 if (ngx_buf_special(cl->buf)) { |
65 continue; | |
66 } | |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
67 |
461 | 68 size = cl->buf->last - cl->buf->pos; |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
69 |
461 | 70 if (send + size > limit) { |
71 size = (u_long) (limit - send); | |
72 } | |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
73 |
461 | 74 if (prev == cl->buf->pos) { |
75 wsabuf->len += cl->buf->last - cl->buf->pos; | |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
76 |
461 | 77 } else { |
8535
ecf2a9002b37
Win32: use only preallocated memory in send/recv chain functions.
Ruslan Ermilov <ru@nginx.com>
parents:
6474
diff
changeset
|
78 if (vec.nelts == vec.nalloc) { |
ecf2a9002b37
Win32: use only preallocated memory in send/recv chain functions.
Ruslan Ermilov <ru@nginx.com>
parents:
6474
diff
changeset
|
79 break; |
ecf2a9002b37
Win32: use only preallocated memory in send/recv chain functions.
Ruslan Ermilov <ru@nginx.com>
parents:
6474
diff
changeset
|
80 } |
ecf2a9002b37
Win32: use only preallocated memory in send/recv chain functions.
Ruslan Ermilov <ru@nginx.com>
parents:
6474
diff
changeset
|
81 |
501 | 82 wsabuf = ngx_array_push(&vec); |
83 if (wsabuf == NULL) { | |
461 | 84 return NGX_CHAIN_ERROR; |
85 } | |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
86 |
461 | 87 wsabuf->buf = (char *) cl->buf->pos; |
88 wsabuf->len = cl->buf->last - cl->buf->pos; | |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
89 } |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
90 |
461 | 91 prev = cl->buf->last; |
92 send += size; | |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
93 } |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
94 |
461 | 95 sent = 0; |
96 | |
97 rc = WSASend(c->fd, vec.elts, vec.nelts, &sent, 0, NULL, NULL); | |
98 | |
99 if (rc == -1) { | |
100 err = ngx_errno; | |
101 | |
102 if (err == WSAEWOULDBLOCK) { | |
103 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, err, | |
104 "WSASend() not ready"); | |
105 | |
106 } else { | |
107 wev->error = 1; | |
108 ngx_connection_error(c, err, "WSASend() failed"); | |
109 return NGX_CHAIN_ERROR; | |
110 } | |
111 } | |
112 | |
113 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0, | |
114 "WSASend: fd:%d, s:%ul", c->fd, sent); | |
115 | |
116 c->sent += sent; | |
117 | |
5912
de68ed551bfb
Renamed ngx_handle_sent_chain() to ngx_chain_update_sent().
Valentin Bartenev <vbart@nginx.com>
parents:
5875
diff
changeset
|
118 in = ngx_chain_update_sent(in, sent); |
461 | 119 |
5851
150df089fe47
Removed the "complete" variable from various send chain functions.
Valentin Bartenev <vbart@nginx.com>
parents:
5850
diff
changeset
|
120 if (send - prev_send != sent) { |
461 | 121 wev->ready = 0; |
5853
a6e83ac70af9
Reduced difference between the send chain functions.
Valentin Bartenev <vbart@nginx.com>
parents:
5851
diff
changeset
|
122 return in; |
461 | 123 } |
124 | |
5853
a6e83ac70af9
Reduced difference between the send chain functions.
Valentin Bartenev <vbart@nginx.com>
parents:
5851
diff
changeset
|
125 if (send >= limit || in == NULL) { |
a6e83ac70af9
Reduced difference between the send chain functions.
Valentin Bartenev <vbart@nginx.com>
parents:
5851
diff
changeset
|
126 return in; |
461 | 127 } |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
128 } |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
129 } |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
130 |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
131 |
501 | 132 ngx_chain_t * |
133 ngx_overlapped_wsasend_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit) | |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
134 { |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
135 int rc; |
292
a472bfb778b3
nginx-0.0.3-2004-03-17-00:26:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
280
diff
changeset
|
136 u_char *prev; |
473 | 137 u_long size, send, sent; |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
138 ngx_err_t err; |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
139 ngx_event_t *wev; |
461 | 140 ngx_array_t vec; |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
141 ngx_chain_t *cl; |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
142 LPWSAOVERLAPPED ovlp; |
501 | 143 LPWSABUF wsabuf; |
461 | 144 WSABUF wsabufs[NGX_WSABUFS]; |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
145 |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
146 wev = c->write; |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
147 |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
148 if (!wev->ready) { |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
149 return in; |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
150 } |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
151 |
461 | 152 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
153 "wev->complete: %d", wev->complete); | |
154 | |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
155 if (!wev->complete) { |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
156 |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
157 /* post the overlapped WSASend() */ |
473 | 158 |
159 /* the maximum limit size is the maximum u_long value - the page size */ | |
160 | |
5875 | 161 if (limit == 0 || limit > (off_t) (NGX_MAX_UINT32_VALUE - ngx_pagesize)) |
162 { | |
473 | 163 limit = NGX_MAX_UINT32_VALUE - ngx_pagesize; |
164 } | |
577 | 165 |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
166 /* |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
167 * WSABUFs must be 4-byte aligned otherwise |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
168 * WSASend() will return undocumented WSAEINVAL error. |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
169 */ |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
170 |
461 | 171 vec.elts = wsabufs; |
172 vec.nelts = 0; | |
173 vec.size = sizeof(WSABUF); | |
8535
ecf2a9002b37
Win32: use only preallocated memory in send/recv chain functions.
Ruslan Ermilov <ru@nginx.com>
parents:
6474
diff
changeset
|
174 vec.nalloc = ngx_min(NGX_WSABUFS, ngx_max_wsabufs); |
461 | 175 vec.pool = c->pool; |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
176 |
461 | 177 send = 0; |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
178 prev = NULL; |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
179 wsabuf = NULL; |
577 | 180 |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
181 /* create the WSABUF and coalesce the neighbouring bufs */ |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
182 |
8535
ecf2a9002b37
Win32: use only preallocated memory in send/recv chain functions.
Ruslan Ermilov <ru@nginx.com>
parents:
6474
diff
changeset
|
183 for (cl = in; cl && send < limit; cl = cl->next) { |
ecf2a9002b37
Win32: use only preallocated memory in send/recv chain functions.
Ruslan Ermilov <ru@nginx.com>
parents:
6474
diff
changeset
|
184 |
461 | 185 if (ngx_buf_special(cl->buf)) { |
186 continue; | |
187 } | |
188 | |
189 size = cl->buf->last - cl->buf->pos; | |
190 | |
191 if (send + size > limit) { | |
192 size = (u_long) (limit - send); | |
193 } | |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
194 |
343
6bdf858bff8c
nginx-0.0.3-2004-05-28-19:49:23 import; rename ngx_hunk_t to ngx_buf_t
Igor Sysoev <igor@sysoev.ru>
parents:
292
diff
changeset
|
195 if (prev == cl->buf->pos) { |
6bdf858bff8c
nginx-0.0.3-2004-05-28-19:49:23 import; rename ngx_hunk_t to ngx_buf_t
Igor Sysoev <igor@sysoev.ru>
parents:
292
diff
changeset
|
196 wsabuf->len += cl->buf->last - cl->buf->pos; |
461 | 197 |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
198 } else { |
8535
ecf2a9002b37
Win32: use only preallocated memory in send/recv chain functions.
Ruslan Ermilov <ru@nginx.com>
parents:
6474
diff
changeset
|
199 if (vec.nelts == vec.nalloc) { |
ecf2a9002b37
Win32: use only preallocated memory in send/recv chain functions.
Ruslan Ermilov <ru@nginx.com>
parents:
6474
diff
changeset
|
200 break; |
ecf2a9002b37
Win32: use only preallocated memory in send/recv chain functions.
Ruslan Ermilov <ru@nginx.com>
parents:
6474
diff
changeset
|
201 } |
ecf2a9002b37
Win32: use only preallocated memory in send/recv chain functions.
Ruslan Ermilov <ru@nginx.com>
parents:
6474
diff
changeset
|
202 |
501 | 203 wsabuf = ngx_array_push(&vec); |
204 if (wsabuf == NULL) { | |
461 | 205 return NGX_CHAIN_ERROR; |
206 } | |
207 | |
343
6bdf858bff8c
nginx-0.0.3-2004-05-28-19:49:23 import; rename ngx_hunk_t to ngx_buf_t
Igor Sysoev <igor@sysoev.ru>
parents:
292
diff
changeset
|
208 wsabuf->buf = (char *) cl->buf->pos; |
6bdf858bff8c
nginx-0.0.3-2004-05-28-19:49:23 import; rename ngx_hunk_t to ngx_buf_t
Igor Sysoev <igor@sysoev.ru>
parents:
292
diff
changeset
|
209 wsabuf->len = cl->buf->last - cl->buf->pos; |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
210 } |
461 | 211 |
212 prev = cl->buf->last; | |
213 send += size; | |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
214 } |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
215 |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
216 ovlp = (LPWSAOVERLAPPED) &c->write->ovlp; |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
217 ngx_memzero(ovlp, sizeof(WSAOVERLAPPED)); |
577 | 218 |
461 | 219 rc = WSASend(c->fd, vec.elts, vec.nelts, &sent, 0, ovlp, NULL); |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
220 |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
221 wev->complete = 0; |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
222 |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
223 if (rc == -1) { |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
224 err = ngx_errno; |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
225 |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
226 if (err == WSA_IO_PENDING) { |
461 | 227 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, err, |
228 "WSASend() posted"); | |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
229 wev->active = 1; |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
230 return in; |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
231 |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
232 } else { |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
233 wev->error = 1; |
278
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
234 ngx_connection_error(c, err, "WSASend() failed"); |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
235 return NGX_CHAIN_ERROR; |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
236 } |
577 | 237 |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
238 } else if (ngx_event_flags & NGX_USE_IOCP_EVENT) { |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
239 |
6474 | 240 /* |
241 * if a socket was bound with I/O completion port then | |
242 * GetQueuedCompletionStatus() would anyway return its status | |
243 * despite that WSASend() was already complete | |
244 */ | |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
245 |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
246 wev->active = 1; |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
247 return in; |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
248 } |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
249 |
461 | 250 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0, |
251 "WSASend: fd:%d, s:%ul", c->fd, sent); | |
252 | |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
253 } else { |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
254 |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
255 /* the overlapped WSASend() complete */ |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
256 |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
257 wev->complete = 0; |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
258 wev->active = 0; |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
259 |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
260 if (ngx_event_flags & NGX_USE_IOCP_EVENT) { |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
261 if (wev->ovlp.error) { |
278
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
262 ngx_connection_error(c, wev->ovlp.error, "WSASend() failed"); |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
263 return NGX_CHAIN_ERROR; |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
264 } |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
265 |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
266 sent = wev->available; |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
267 |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
268 } else { |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
269 if (WSAGetOverlappedResult(c->fd, (LPWSAOVERLAPPED) &wev->ovlp, |
2776 | 270 &sent, 0, NULL) |
271 == 0) | |
272 { | |
278
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
273 ngx_connection_error(c, ngx_socket_errno, |
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
274 "WSASend() or WSAGetOverlappedResult() failed"); |
577 | 275 |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
276 return NGX_CHAIN_ERROR; |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
277 } |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
278 } |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
279 } |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
280 |
461 | 281 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0, |
282 "WSASend ovlp: fd:%d, s:%ul", c->fd, sent); | |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
283 |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
284 c->sent += sent; |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
285 |
5912
de68ed551bfb
Renamed ngx_handle_sent_chain() to ngx_chain_update_sent().
Valentin Bartenev <vbart@nginx.com>
parents:
5875
diff
changeset
|
286 in = ngx_chain_update_sent(in, sent); |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
287 |
5853
a6e83ac70af9
Reduced difference between the send chain functions.
Valentin Bartenev <vbart@nginx.com>
parents:
5851
diff
changeset
|
288 if (in) { |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
289 wev->ready = 0; |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
290 |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
291 } else { |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
292 wev->ready = 1; |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
293 } |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
294 |
5853
a6e83ac70af9
Reduced difference between the send chain functions.
Valentin Bartenev <vbart@nginx.com>
parents:
5851
diff
changeset
|
295 return in; |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
296 } |