Mercurial > hg > nginx-quic
annotate src/os/win32/ngx_wsarecv.c @ 7963:d33e17499088
Version bump.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Tue, 26 May 2020 22:03:00 +0300 |
parents | efd71d49bde0 |
children | 56819a9491fe |
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:
292
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:
292
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:
292
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:
292
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 |
1680 | 13 ssize_t |
14 ngx_wsarecv(ngx_connection_t *c, u_char *buf, size_t size) | |
103
6dfda4cf5200
nginx-0.0.1-2003-06-11-19:28:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
15 { |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
16 int rc; |
280
7c7183b3ea8b
nginx-0.0.2-2004-03-05-11:34:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
278
diff
changeset
|
17 u_long bytes, flags; |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
18 WSABUF wsabuf[1]; |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
19 ngx_err_t err; |
5360
3d2d3e1cf427
Win32: MinGW GCC compatibility.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
20 ngx_int_t n; |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
21 ngx_event_t *rev; |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
22 |
292
a472bfb778b3
nginx-0.0.3-2004-03-17-00:26:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
282
diff
changeset
|
23 wsabuf[0].buf = (char *) buf; |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
24 wsabuf[0].len = size; |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
25 flags = 0; |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
26 bytes = 0; |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
27 |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
28 rc = WSARecv(c->fd, wsabuf, 1, &bytes, &flags, NULL, NULL); |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
29 |
278
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
184
diff
changeset
|
30 ngx_log_debug4(NGX_LOG_DEBUG_EVENT, c->log, 0, |
461 | 31 "WSARecv: fd:%d rc:%d %ul of %z", c->fd, rc, bytes, size); |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
32 |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
33 rev = c->read; |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
34 |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
35 if (rc == -1) { |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
36 rev->ready = 0; |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
37 err = ngx_socket_errno; |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
38 |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
39 if (err == WSAEWOULDBLOCK) { |
278
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
184
diff
changeset
|
40 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, err, |
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
184
diff
changeset
|
41 "WSARecv() not ready"); |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
42 return NGX_AGAIN; |
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 |
2775 | 45 n = ngx_connection_error(c, err, "WSARecv() failed"); |
278
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
184
diff
changeset
|
46 |
3642 | 47 if (n == NGX_ERROR) { |
2775 | 48 rev->error = 1; |
49 } | |
50 | |
51 return n; | |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
52 } |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
53 |
7583
efd71d49bde0
Events: available bytes calculation via ioctl(FIONREAD).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5360
diff
changeset
|
54 #if (NGX_HAVE_FIONREAD) |
efd71d49bde0
Events: available bytes calculation via ioctl(FIONREAD).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5360
diff
changeset
|
55 |
efd71d49bde0
Events: available bytes calculation via ioctl(FIONREAD).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5360
diff
changeset
|
56 if (rev->available >= 0 && bytes > 0) { |
efd71d49bde0
Events: available bytes calculation via ioctl(FIONREAD).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5360
diff
changeset
|
57 rev->available -= bytes; |
efd71d49bde0
Events: available bytes calculation via ioctl(FIONREAD).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5360
diff
changeset
|
58 |
efd71d49bde0
Events: available bytes calculation via ioctl(FIONREAD).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5360
diff
changeset
|
59 /* |
efd71d49bde0
Events: available bytes calculation via ioctl(FIONREAD).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5360
diff
changeset
|
60 * negative rev->available means some additional bytes |
efd71d49bde0
Events: available bytes calculation via ioctl(FIONREAD).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5360
diff
changeset
|
61 * were received between kernel notification and WSARecv(), |
efd71d49bde0
Events: available bytes calculation via ioctl(FIONREAD).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5360
diff
changeset
|
62 * and therefore ev->ready can be safely reset even for |
efd71d49bde0
Events: available bytes calculation via ioctl(FIONREAD).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5360
diff
changeset
|
63 * edge-triggered event methods |
efd71d49bde0
Events: available bytes calculation via ioctl(FIONREAD).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5360
diff
changeset
|
64 */ |
efd71d49bde0
Events: available bytes calculation via ioctl(FIONREAD).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5360
diff
changeset
|
65 |
efd71d49bde0
Events: available bytes calculation via ioctl(FIONREAD).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5360
diff
changeset
|
66 if (rev->available < 0) { |
efd71d49bde0
Events: available bytes calculation via ioctl(FIONREAD).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5360
diff
changeset
|
67 rev->available = 0; |
efd71d49bde0
Events: available bytes calculation via ioctl(FIONREAD).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5360
diff
changeset
|
68 rev->ready = 0; |
efd71d49bde0
Events: available bytes calculation via ioctl(FIONREAD).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5360
diff
changeset
|
69 } |
efd71d49bde0
Events: available bytes calculation via ioctl(FIONREAD).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5360
diff
changeset
|
70 |
efd71d49bde0
Events: available bytes calculation via ioctl(FIONREAD).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5360
diff
changeset
|
71 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
efd71d49bde0
Events: available bytes calculation via ioctl(FIONREAD).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5360
diff
changeset
|
72 "WSARecv: avail:%d", rev->available); |
efd71d49bde0
Events: available bytes calculation via ioctl(FIONREAD).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5360
diff
changeset
|
73 |
efd71d49bde0
Events: available bytes calculation via ioctl(FIONREAD).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5360
diff
changeset
|
74 } else if (bytes == size) { |
efd71d49bde0
Events: available bytes calculation via ioctl(FIONREAD).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5360
diff
changeset
|
75 |
efd71d49bde0
Events: available bytes calculation via ioctl(FIONREAD).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5360
diff
changeset
|
76 if (ngx_socket_nread(c->fd, &rev->available) == -1) { |
efd71d49bde0
Events: available bytes calculation via ioctl(FIONREAD).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5360
diff
changeset
|
77 n = ngx_connection_error(c, ngx_socket_errno, |
efd71d49bde0
Events: available bytes calculation via ioctl(FIONREAD).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5360
diff
changeset
|
78 ngx_socket_nread_n " failed"); |
efd71d49bde0
Events: available bytes calculation via ioctl(FIONREAD).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5360
diff
changeset
|
79 |
efd71d49bde0
Events: available bytes calculation via ioctl(FIONREAD).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5360
diff
changeset
|
80 if (n == NGX_ERROR) { |
efd71d49bde0
Events: available bytes calculation via ioctl(FIONREAD).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5360
diff
changeset
|
81 rev->error = 1; |
efd71d49bde0
Events: available bytes calculation via ioctl(FIONREAD).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5360
diff
changeset
|
82 } |
efd71d49bde0
Events: available bytes calculation via ioctl(FIONREAD).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5360
diff
changeset
|
83 |
efd71d49bde0
Events: available bytes calculation via ioctl(FIONREAD).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5360
diff
changeset
|
84 return n; |
efd71d49bde0
Events: available bytes calculation via ioctl(FIONREAD).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5360
diff
changeset
|
85 } |
efd71d49bde0
Events: available bytes calculation via ioctl(FIONREAD).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5360
diff
changeset
|
86 |
efd71d49bde0
Events: available bytes calculation via ioctl(FIONREAD).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5360
diff
changeset
|
87 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
efd71d49bde0
Events: available bytes calculation via ioctl(FIONREAD).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5360
diff
changeset
|
88 "WSARecv: avail:%d", rev->available); |
efd71d49bde0
Events: available bytes calculation via ioctl(FIONREAD).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5360
diff
changeset
|
89 } |
efd71d49bde0
Events: available bytes calculation via ioctl(FIONREAD).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5360
diff
changeset
|
90 |
efd71d49bde0
Events: available bytes calculation via ioctl(FIONREAD).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5360
diff
changeset
|
91 #endif |
efd71d49bde0
Events: available bytes calculation via ioctl(FIONREAD).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5360
diff
changeset
|
92 |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
93 if (bytes < size) { |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
94 rev->ready = 0; |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
95 } |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
96 |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
97 if (bytes == 0) { |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
98 rev->eof = 1; |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
99 } |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
100 |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
101 return bytes; |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
102 } |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
103 |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
104 |
1680 | 105 ssize_t |
106 ngx_overlapped_wsarecv(ngx_connection_t *c, u_char *buf, size_t size) | |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
107 { |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
108 int rc; |
280
7c7183b3ea8b
nginx-0.0.2-2004-03-05-11:34:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
278
diff
changeset
|
109 u_long bytes, flags; |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
110 WSABUF wsabuf[1]; |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
111 ngx_err_t err; |
5360
3d2d3e1cf427
Win32: MinGW GCC compatibility.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
112 ngx_int_t n; |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
113 ngx_event_t *rev; |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
114 LPWSAOVERLAPPED ovlp; |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
115 |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
116 rev = c->read; |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
117 |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
118 if (!rev->ready) { |
282
30310107dbc9
nginx-0.0.2-2004-03-09-22:47:07 import
Igor Sysoev <igor@sysoev.ru>
parents:
280
diff
changeset
|
119 ngx_log_error(NGX_LOG_ALERT, c->log, 0, "second wsa post"); |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
120 return NGX_AGAIN; |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
121 } |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
122 |
278
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
184
diff
changeset
|
123 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
184
diff
changeset
|
124 "rev->complete: %d", rev->complete); |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
125 |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
126 if (rev->complete) { |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
127 rev->complete = 0; |
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 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
|
130 if (rev->ovlp.error) { |
278
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
184
diff
changeset
|
131 ngx_connection_error(c, rev->ovlp.error, "WSARecv() failed"); |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
132 return NGX_ERROR; |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
133 } |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
134 |
461 | 135 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0, |
136 "WSARecv ovlp: fd:%d %ul of %z", | |
137 c->fd, rev->available, size); | |
138 | |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
139 return rev->available; |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
140 } |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
141 |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
142 if (WSAGetOverlappedResult(c->fd, (LPWSAOVERLAPPED) &rev->ovlp, |
2776 | 143 &bytes, 0, NULL) |
144 == 0) | |
145 { | |
278
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
184
diff
changeset
|
146 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:
184
diff
changeset
|
147 "WSARecv() or WSAGetOverlappedResult() failed"); |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
148 return NGX_ERROR; |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
149 } |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
150 |
461 | 151 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0, |
152 "WSARecv: fd:%d %ul of %z", c->fd, bytes, size); | |
153 | |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
154 return bytes; |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
155 } |
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 ovlp = (LPWSAOVERLAPPED) &rev->ovlp; |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
158 ngx_memzero(ovlp, sizeof(WSAOVERLAPPED)); |
292
a472bfb778b3
nginx-0.0.3-2004-03-17-00:26:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
282
diff
changeset
|
159 wsabuf[0].buf = (char *) buf; |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
160 wsabuf[0].len = size; |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
161 flags = 0; |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
162 bytes = 0; |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
163 |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
164 rc = WSARecv(c->fd, wsabuf, 1, &bytes, &flags, ovlp, NULL); |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
165 |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
166 rev->complete = 0; |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
167 |
278
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
184
diff
changeset
|
168 ngx_log_debug4(NGX_LOG_DEBUG_EVENT, c->log, 0, |
461 | 169 "WSARecv ovlp: fd:%d rc:%d %ul of %z", |
170 c->fd, rc, bytes, size); | |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
171 |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
172 if (rc == -1) { |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
173 err = ngx_socket_errno; |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
174 if (err == WSA_IO_PENDING) { |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
175 rev->active = 1; |
461 | 176 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, err, |
177 "WSARecv() posted"); | |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
178 return NGX_AGAIN; |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
179 } |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
180 |
2775 | 181 n = ngx_connection_error(c, err, "WSARecv() failed"); |
182 | |
3642 | 183 if (n == NGX_ERROR) { |
2775 | 184 rev->error = 1; |
185 } | |
186 | |
187 return n; | |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
188 } |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
189 |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
190 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
|
191 |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
192 /* |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
193 * if a socket was bound with I/O completion port |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
194 * then GetQueuedCompletionStatus() would anyway return its status |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
195 * despite that WSARecv() was already complete |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
196 */ |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
197 |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
198 rev->active = 1; |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
199 return NGX_AGAIN; |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
200 } |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
201 |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
202 if (bytes == 0) { |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
203 rev->eof = 1; |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
204 rev->ready = 0; |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
205 |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
206 } else { |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
207 rev->ready = 1; |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
208 } |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
209 |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
210 rev->active = 0; |
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 return bytes; |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
213 } |