Mercurial > hg > nginx-quic
annotate src/os/win32/ngx_wsasend_chain.c @ 8360:98c4020f1c9a quic
HTTP/3: keepalive timeout.
This timeout limits the time when no client request streams exist.
author | Roman Arutyunyan <arut@nginx.com> |
---|---|
date | Tue, 30 Mar 2021 16:48:38 +0300 |
parents | 2cd019520210 |
children | ecf2a9002b37 |
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 |
461 | 13 #define NGX_WSABUFS 8 |
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); | |
577 | 50 vec.nalloc = NGX_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 |
461 | 62 for (cl = in; |
63 cl && vec.nelts < ngx_max_wsabufs && send < limit; | |
64 cl = cl->next) | |
65 { | |
66 if (ngx_buf_special(cl->buf)) { | |
67 continue; | |
68 } | |
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 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
|
71 |
461 | 72 if (send + size > limit) { |
73 size = (u_long) (limit - send); | |
74 } | |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
75 |
461 | 76 if (prev == cl->buf->pos) { |
77 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
|
78 |
461 | 79 } else { |
501 | 80 wsabuf = ngx_array_push(&vec); |
81 if (wsabuf == NULL) { | |
461 | 82 return NGX_CHAIN_ERROR; |
83 } | |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
84 |
461 | 85 wsabuf->buf = (char *) cl->buf->pos; |
86 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
|
87 } |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
88 |
461 | 89 prev = cl->buf->last; |
90 send += size; | |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
91 } |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
92 |
461 | 93 sent = 0; |
94 | |
95 rc = WSASend(c->fd, vec.elts, vec.nelts, &sent, 0, NULL, NULL); | |
96 | |
97 if (rc == -1) { | |
98 err = ngx_errno; | |
99 | |
100 if (err == WSAEWOULDBLOCK) { | |
101 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, err, | |
102 "WSASend() not ready"); | |
103 | |
104 } else { | |
105 wev->error = 1; | |
106 ngx_connection_error(c, err, "WSASend() failed"); | |
107 return NGX_CHAIN_ERROR; | |
108 } | |
109 } | |
110 | |
111 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0, | |
112 "WSASend: fd:%d, s:%ul", c->fd, sent); | |
113 | |
114 c->sent += sent; | |
115 | |
5912
de68ed551bfb
Renamed ngx_handle_sent_chain() to ngx_chain_update_sent().
Valentin Bartenev <vbart@nginx.com>
parents:
5875
diff
changeset
|
116 in = ngx_chain_update_sent(in, sent); |
461 | 117 |
5851
150df089fe47
Removed the "complete" variable from various send chain functions.
Valentin Bartenev <vbart@nginx.com>
parents:
5850
diff
changeset
|
118 if (send - prev_send != sent) { |
461 | 119 wev->ready = 0; |
5853
a6e83ac70af9
Reduced difference between the send chain functions.
Valentin Bartenev <vbart@nginx.com>
parents:
5851
diff
changeset
|
120 return in; |
461 | 121 } |
122 | |
5853
a6e83ac70af9
Reduced difference between the send chain functions.
Valentin Bartenev <vbart@nginx.com>
parents:
5851
diff
changeset
|
123 if (send >= limit || in == NULL) { |
a6e83ac70af9
Reduced difference between the send chain functions.
Valentin Bartenev <vbart@nginx.com>
parents:
5851
diff
changeset
|
124 return in; |
461 | 125 } |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
126 } |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
127 } |
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 |
501 | 130 ngx_chain_t * |
131 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
|
132 { |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
133 int rc; |
292
a472bfb778b3
nginx-0.0.3-2004-03-17-00:26:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
280
diff
changeset
|
134 u_char *prev; |
473 | 135 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
|
136 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
|
137 ngx_event_t *wev; |
461 | 138 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
|
139 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
|
140 LPWSAOVERLAPPED ovlp; |
501 | 141 LPWSABUF wsabuf; |
461 | 142 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
|
143 |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
144 wev = c->write; |
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 if (!wev->ready) { |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
147 return in; |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
148 } |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
149 |
461 | 150 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
151 "wev->complete: %d", wev->complete); | |
152 | |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
153 if (!wev->complete) { |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
154 |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
155 /* post the overlapped WSASend() */ |
473 | 156 |
157 /* the maximum limit size is the maximum u_long value - the page size */ | |
158 | |
5875 | 159 if (limit == 0 || limit > (off_t) (NGX_MAX_UINT32_VALUE - ngx_pagesize)) |
160 { | |
473 | 161 limit = NGX_MAX_UINT32_VALUE - ngx_pagesize; |
162 } | |
577 | 163 |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
164 /* |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
165 * 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
|
166 * 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
|
167 */ |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
168 |
461 | 169 vec.elts = wsabufs; |
170 vec.nelts = 0; | |
171 vec.size = sizeof(WSABUF); | |
577 | 172 vec.nalloc = NGX_WSABUFS; |
461 | 173 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
|
174 |
461 | 175 send = 0; |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
176 prev = NULL; |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
177 wsabuf = NULL; |
577 | 178 |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
179 /* 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
|
180 |
461 | 181 for (cl = in; |
182 cl && vec.nelts < ngx_max_wsabufs && send < limit; | |
183 cl = cl->next) | |
184 { | |
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 { |
501 | 199 wsabuf = ngx_array_push(&vec); |
200 if (wsabuf == NULL) { | |
461 | 201 return NGX_CHAIN_ERROR; |
202 } | |
203 | |
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
|
204 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
|
205 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
|
206 } |
461 | 207 |
208 prev = cl->buf->last; | |
209 send += size; | |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
210 } |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
211 |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
212 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
|
213 ngx_memzero(ovlp, sizeof(WSAOVERLAPPED)); |
577 | 214 |
461 | 215 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
|
216 |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
217 wev->complete = 0; |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
218 |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
219 if (rc == -1) { |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
220 err = ngx_errno; |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
221 |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
222 if (err == WSA_IO_PENDING) { |
461 | 223 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, err, |
224 "WSASend() posted"); | |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
225 wev->active = 1; |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
226 return in; |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
227 |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
228 } else { |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
229 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
|
230 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
|
231 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
|
232 } |
577 | 233 |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
234 } 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
|
235 |
6474 | 236 /* |
237 * if a socket was bound with I/O completion port then | |
238 * GetQueuedCompletionStatus() would anyway return its status | |
239 * despite that WSASend() was already complete | |
240 */ | |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
241 |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
242 wev->active = 1; |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
243 return in; |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
244 } |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
245 |
461 | 246 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0, |
247 "WSASend: fd:%d, s:%ul", c->fd, sent); | |
248 | |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
249 } else { |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
250 |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
251 /* 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
|
252 |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
253 wev->complete = 0; |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
254 wev->active = 0; |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
255 |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
256 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
|
257 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
|
258 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
|
259 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
|
260 } |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
261 |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
262 sent = wev->available; |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
263 |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
264 } else { |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
265 if (WSAGetOverlappedResult(c->fd, (LPWSAOVERLAPPED) &wev->ovlp, |
2776 | 266 &sent, 0, NULL) |
267 == 0) | |
268 { | |
278
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
269 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
|
270 "WSASend() or WSAGetOverlappedResult() failed"); |
577 | 271 |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
272 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
|
273 } |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
274 } |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
275 } |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
276 |
461 | 277 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0, |
278 "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
|
279 |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
280 c->sent += sent; |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
281 |
5912
de68ed551bfb
Renamed ngx_handle_sent_chain() to ngx_chain_update_sent().
Valentin Bartenev <vbart@nginx.com>
parents:
5875
diff
changeset
|
282 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
|
283 |
5853
a6e83ac70af9
Reduced difference between the send chain functions.
Valentin Bartenev <vbart@nginx.com>
parents:
5851
diff
changeset
|
284 if (in) { |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
285 wev->ready = 0; |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
286 |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
287 } else { |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
288 wev->ready = 1; |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
289 } |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
290 |
5853
a6e83ac70af9
Reduced difference between the send chain functions.
Valentin Bartenev <vbart@nginx.com>
parents:
5851
diff
changeset
|
291 return in; |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
292 } |