Mercurial > hg > nginx-quic
annotate src/os/unix/ngx_recv.c @ 7687:69345a26ba69 quic
Split transport and crypto parts into separate files.
New files:
src/event/ngx_event_quic_protection.h
src/event/ngx_event_quic_protection.c
The protection.h header provides interface to the crypto part of the QUIC:
2 functions to initialize corresponding secrets:
ngx_quic_set_initial_secret()
ngx_quic_set_encryption_secret()
and 2 functions to deal with packet processing:
ngx_quic_encrypt()
ngx_quic_decrypt()
Also, structures representing secrets are defined there.
All functions require SSL connection and a pool, only crypto operations
inside, no access to nginx connections or events.
Currently pool->log is used for the logging (instead of original c->log).
author | Vladimir Homutov <vl@nginx.com> |
---|---|
date | Mon, 16 Mar 2020 19:00:47 +0300 |
parents | efd71d49bde0 |
children | 5119c8150478 |
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:
375
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:
375
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:
375
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:
375
diff
changeset
|
6 |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
7 |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
8 #include <ngx_config.h> |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
9 #include <ngx_core.h> |
103
6dfda4cf5200
nginx-0.0.1-2003-06-11-19:28:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
96
diff
changeset
|
10 #include <ngx_event.h> |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
11 |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
12 |
1680 | 13 ssize_t |
14 ngx_unix_recv(ngx_connection_t *c, u_char *buf, size_t size) | |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
15 { |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
16 ssize_t n; |
253
b6793bc5034b
nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
218
diff
changeset
|
17 ngx_err_t err; |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
18 ngx_event_t *rev; |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
19 |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
20 rev = c->read; |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
21 |
6507
8ee94ecd3a50
Merged implementations of ngx_unix_recv().
Valentin Bartenev <vbart@nginx.com>
parents:
6506
diff
changeset
|
22 #if (NGX_HAVE_KQUEUE) |
8ee94ecd3a50
Merged implementations of ngx_unix_recv().
Valentin Bartenev <vbart@nginx.com>
parents:
6506
diff
changeset
|
23 |
455 | 24 if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) { |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
188
diff
changeset
|
25 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0, |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
188
diff
changeset
|
26 "recv: eof:%d, avail:%d, err:%d", |
375
744ccb59062d
nginx-0.0.7-2004-07-02-19:54:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
328
diff
changeset
|
27 rev->pending_eof, rev->available, rev->kq_errno); |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
28 |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
29 if (rev->available == 0) { |
587 | 30 if (rev->pending_eof) { |
148
5afee0074707
nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
31 rev->ready = 0; |
163
fb61ba77beba
nginx-0.0.1-2003-10-28-18:45:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
148
diff
changeset
|
32 rev->eof = 1; |
fb61ba77beba
nginx-0.0.1-2003-10-28-18:45:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
148
diff
changeset
|
33 |
fb61ba77beba
nginx-0.0.1-2003-10-28-18:45:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
148
diff
changeset
|
34 if (rev->kq_errno) { |
fb61ba77beba
nginx-0.0.1-2003-10-28-18:45:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
148
diff
changeset
|
35 rev->error = 1; |
fb61ba77beba
nginx-0.0.1-2003-10-28-18:45:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
148
diff
changeset
|
36 ngx_set_socket_errno(rev->kq_errno); |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
188
diff
changeset
|
37 |
537 | 38 return ngx_connection_error(c, rev->kq_errno, |
39 "kevent() reported about an closed connection"); | |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
40 } |
163
fb61ba77beba
nginx-0.0.1-2003-10-28-18:45:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
148
diff
changeset
|
41 |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
42 return 0; |
587 | 43 |
44 } else { | |
1875
c11d96cbad75
reset ready flag if no data is available,
Igor Sysoev <igor@sysoev.ru>
parents:
1681
diff
changeset
|
45 rev->ready = 0; |
587 | 46 return NGX_AGAIN; |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
47 } |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
48 } |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
49 } |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
50 |
6507
8ee94ecd3a50
Merged implementations of ngx_unix_recv().
Valentin Bartenev <vbart@nginx.com>
parents:
6506
diff
changeset
|
51 #endif |
8ee94ecd3a50
Merged implementations of ngx_unix_recv().
Valentin Bartenev <vbart@nginx.com>
parents:
6506
diff
changeset
|
52 |
6536
f7849bfb6d21
Improved EPOLLRDHUP handling.
Valentin Bartenev <vbart@nginx.com>
parents:
6508
diff
changeset
|
53 #if (NGX_HAVE_EPOLLRDHUP) |
f7849bfb6d21
Improved EPOLLRDHUP handling.
Valentin Bartenev <vbart@nginx.com>
parents:
6508
diff
changeset
|
54 |
f7849bfb6d21
Improved EPOLLRDHUP handling.
Valentin Bartenev <vbart@nginx.com>
parents:
6508
diff
changeset
|
55 if (ngx_event_flags & NGX_USE_EPOLL_EVENT) { |
f7849bfb6d21
Improved EPOLLRDHUP handling.
Valentin Bartenev <vbart@nginx.com>
parents:
6508
diff
changeset
|
56 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0, |
f7849bfb6d21
Improved EPOLLRDHUP handling.
Valentin Bartenev <vbart@nginx.com>
parents:
6508
diff
changeset
|
57 "recv: eof:%d, avail:%d", |
f7849bfb6d21
Improved EPOLLRDHUP handling.
Valentin Bartenev <vbart@nginx.com>
parents:
6508
diff
changeset
|
58 rev->pending_eof, rev->available); |
f7849bfb6d21
Improved EPOLLRDHUP handling.
Valentin Bartenev <vbart@nginx.com>
parents:
6508
diff
changeset
|
59 |
7583
efd71d49bde0
Events: available bytes calculation via ioctl(FIONREAD).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6536
diff
changeset
|
60 if (rev->available == 0 && !rev->pending_eof) { |
6536
f7849bfb6d21
Improved EPOLLRDHUP handling.
Valentin Bartenev <vbart@nginx.com>
parents:
6508
diff
changeset
|
61 rev->ready = 0; |
f7849bfb6d21
Improved EPOLLRDHUP handling.
Valentin Bartenev <vbart@nginx.com>
parents:
6508
diff
changeset
|
62 return NGX_AGAIN; |
f7849bfb6d21
Improved EPOLLRDHUP handling.
Valentin Bartenev <vbart@nginx.com>
parents:
6508
diff
changeset
|
63 } |
f7849bfb6d21
Improved EPOLLRDHUP handling.
Valentin Bartenev <vbart@nginx.com>
parents:
6508
diff
changeset
|
64 } |
f7849bfb6d21
Improved EPOLLRDHUP handling.
Valentin Bartenev <vbart@nginx.com>
parents:
6508
diff
changeset
|
65 |
f7849bfb6d21
Improved EPOLLRDHUP handling.
Valentin Bartenev <vbart@nginx.com>
parents:
6508
diff
changeset
|
66 #endif |
f7849bfb6d21
Improved EPOLLRDHUP handling.
Valentin Bartenev <vbart@nginx.com>
parents:
6508
diff
changeset
|
67 |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
68 do { |
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
69 n = recv(c->fd, buf, size, 0); |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
70 |
253
b6793bc5034b
nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
218
diff
changeset
|
71 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0, |
6480 | 72 "recv: fd:%d %z of %uz", c->fd, n, size); |
93
738fe44c70d5
nginx-0.0.1-2003-05-21-17:28:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
91
diff
changeset
|
73 |
6506
dc1ae0056a1e
Fixed small inconsistency in handling EOF among receive functions.
Valentin Bartenev <vbart@nginx.com>
parents:
6480
diff
changeset
|
74 if (n == 0) { |
dc1ae0056a1e
Fixed small inconsistency in handling EOF among receive functions.
Valentin Bartenev <vbart@nginx.com>
parents:
6480
diff
changeset
|
75 rev->ready = 0; |
dc1ae0056a1e
Fixed small inconsistency in handling EOF among receive functions.
Valentin Bartenev <vbart@nginx.com>
parents:
6480
diff
changeset
|
76 rev->eof = 1; |
dc1ae0056a1e
Fixed small inconsistency in handling EOF among receive functions.
Valentin Bartenev <vbart@nginx.com>
parents:
6480
diff
changeset
|
77 |
6507
8ee94ecd3a50
Merged implementations of ngx_unix_recv().
Valentin Bartenev <vbart@nginx.com>
parents:
6506
diff
changeset
|
78 #if (NGX_HAVE_KQUEUE) |
8ee94ecd3a50
Merged implementations of ngx_unix_recv().
Valentin Bartenev <vbart@nginx.com>
parents:
6506
diff
changeset
|
79 |
6506
dc1ae0056a1e
Fixed small inconsistency in handling EOF among receive functions.
Valentin Bartenev <vbart@nginx.com>
parents:
6480
diff
changeset
|
80 /* |
dc1ae0056a1e
Fixed small inconsistency in handling EOF among receive functions.
Valentin Bartenev <vbart@nginx.com>
parents:
6480
diff
changeset
|
81 * on FreeBSD recv() may return 0 on closed socket |
dc1ae0056a1e
Fixed small inconsistency in handling EOF among receive functions.
Valentin Bartenev <vbart@nginx.com>
parents:
6480
diff
changeset
|
82 * even if kqueue reported about available data |
dc1ae0056a1e
Fixed small inconsistency in handling EOF among receive functions.
Valentin Bartenev <vbart@nginx.com>
parents:
6480
diff
changeset
|
83 */ |
dc1ae0056a1e
Fixed small inconsistency in handling EOF among receive functions.
Valentin Bartenev <vbart@nginx.com>
parents:
6480
diff
changeset
|
84 |
dc1ae0056a1e
Fixed small inconsistency in handling EOF among receive functions.
Valentin Bartenev <vbart@nginx.com>
parents:
6480
diff
changeset
|
85 if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) { |
dc1ae0056a1e
Fixed small inconsistency in handling EOF among receive functions.
Valentin Bartenev <vbart@nginx.com>
parents:
6480
diff
changeset
|
86 rev->available = 0; |
dc1ae0056a1e
Fixed small inconsistency in handling EOF among receive functions.
Valentin Bartenev <vbart@nginx.com>
parents:
6480
diff
changeset
|
87 } |
dc1ae0056a1e
Fixed small inconsistency in handling EOF among receive functions.
Valentin Bartenev <vbart@nginx.com>
parents:
6480
diff
changeset
|
88 |
6507
8ee94ecd3a50
Merged implementations of ngx_unix_recv().
Valentin Bartenev <vbart@nginx.com>
parents:
6506
diff
changeset
|
89 #endif |
8ee94ecd3a50
Merged implementations of ngx_unix_recv().
Valentin Bartenev <vbart@nginx.com>
parents:
6506
diff
changeset
|
90 |
6506
dc1ae0056a1e
Fixed small inconsistency in handling EOF among receive functions.
Valentin Bartenev <vbart@nginx.com>
parents:
6480
diff
changeset
|
91 return 0; |
dc1ae0056a1e
Fixed small inconsistency in handling EOF among receive functions.
Valentin Bartenev <vbart@nginx.com>
parents:
6480
diff
changeset
|
92 } |
dc1ae0056a1e
Fixed small inconsistency in handling EOF among receive functions.
Valentin Bartenev <vbart@nginx.com>
parents:
6480
diff
changeset
|
93 |
dc1ae0056a1e
Fixed small inconsistency in handling EOF among receive functions.
Valentin Bartenev <vbart@nginx.com>
parents:
6480
diff
changeset
|
94 if (n > 0) { |
dc1ae0056a1e
Fixed small inconsistency in handling EOF among receive functions.
Valentin Bartenev <vbart@nginx.com>
parents:
6480
diff
changeset
|
95 |
6507
8ee94ecd3a50
Merged implementations of ngx_unix_recv().
Valentin Bartenev <vbart@nginx.com>
parents:
6506
diff
changeset
|
96 #if (NGX_HAVE_KQUEUE) |
8ee94ecd3a50
Merged implementations of ngx_unix_recv().
Valentin Bartenev <vbart@nginx.com>
parents:
6506
diff
changeset
|
97 |
455 | 98 if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) { |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
99 rev->available -= n; |
163
fb61ba77beba
nginx-0.0.1-2003-10-28-18:45:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
148
diff
changeset
|
100 |
fb61ba77beba
nginx-0.0.1-2003-10-28-18:45:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
148
diff
changeset
|
101 /* |
583 | 102 * rev->available may be negative here because some additional |
587 | 103 * bytes may be received between kevent() and recv() |
163
fb61ba77beba
nginx-0.0.1-2003-10-28-18:45:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
148
diff
changeset
|
104 */ |
fb61ba77beba
nginx-0.0.1-2003-10-28-18:45:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
148
diff
changeset
|
105 |
144
ef8c87afcfc5
nginx-0.0.1-2003-10-12-20:49:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
103
diff
changeset
|
106 if (rev->available <= 0) { |
375
744ccb59062d
nginx-0.0.7-2004-07-02-19:54:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
328
diff
changeset
|
107 if (!rev->pending_eof) { |
148
5afee0074707
nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
108 rev->ready = 0; |
5afee0074707
nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
109 } |
5afee0074707
nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
110 |
6508
151fd02a4317
Simplified ngx_unix_recv() and ngx_readv_chain().
Ruslan Ermilov <ru@nginx.com>
parents:
6507
diff
changeset
|
111 rev->available = 0; |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
112 } |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
113 |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
114 return n; |
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
115 } |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
116 |
6507
8ee94ecd3a50
Merged implementations of ngx_unix_recv().
Valentin Bartenev <vbart@nginx.com>
parents:
6506
diff
changeset
|
117 #endif |
8ee94ecd3a50
Merged implementations of ngx_unix_recv().
Valentin Bartenev <vbart@nginx.com>
parents:
6506
diff
changeset
|
118 |
7583
efd71d49bde0
Events: available bytes calculation via ioctl(FIONREAD).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6536
diff
changeset
|
119 #if (NGX_HAVE_FIONREAD) |
efd71d49bde0
Events: available bytes calculation via ioctl(FIONREAD).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6536
diff
changeset
|
120 |
efd71d49bde0
Events: available bytes calculation via ioctl(FIONREAD).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6536
diff
changeset
|
121 if (rev->available >= 0) { |
efd71d49bde0
Events: available bytes calculation via ioctl(FIONREAD).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6536
diff
changeset
|
122 rev->available -= n; |
efd71d49bde0
Events: available bytes calculation via ioctl(FIONREAD).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6536
diff
changeset
|
123 |
efd71d49bde0
Events: available bytes calculation via ioctl(FIONREAD).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6536
diff
changeset
|
124 /* |
efd71d49bde0
Events: available bytes calculation via ioctl(FIONREAD).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6536
diff
changeset
|
125 * negative rev->available means some additional bytes |
efd71d49bde0
Events: available bytes calculation via ioctl(FIONREAD).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6536
diff
changeset
|
126 * were received between kernel notification and recv(), |
efd71d49bde0
Events: available bytes calculation via ioctl(FIONREAD).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6536
diff
changeset
|
127 * and therefore ev->ready can be safely reset even for |
efd71d49bde0
Events: available bytes calculation via ioctl(FIONREAD).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6536
diff
changeset
|
128 * edge-triggered event methods |
efd71d49bde0
Events: available bytes calculation via ioctl(FIONREAD).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6536
diff
changeset
|
129 */ |
efd71d49bde0
Events: available bytes calculation via ioctl(FIONREAD).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6536
diff
changeset
|
130 |
efd71d49bde0
Events: available bytes calculation via ioctl(FIONREAD).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6536
diff
changeset
|
131 if (rev->available < 0) { |
efd71d49bde0
Events: available bytes calculation via ioctl(FIONREAD).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6536
diff
changeset
|
132 rev->available = 0; |
efd71d49bde0
Events: available bytes calculation via ioctl(FIONREAD).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6536
diff
changeset
|
133 rev->ready = 0; |
efd71d49bde0
Events: available bytes calculation via ioctl(FIONREAD).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6536
diff
changeset
|
134 } |
efd71d49bde0
Events: available bytes calculation via ioctl(FIONREAD).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6536
diff
changeset
|
135 |
efd71d49bde0
Events: available bytes calculation via ioctl(FIONREAD).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6536
diff
changeset
|
136 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
efd71d49bde0
Events: available bytes calculation via ioctl(FIONREAD).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6536
diff
changeset
|
137 "recv: avail:%d", rev->available); |
efd71d49bde0
Events: available bytes calculation via ioctl(FIONREAD).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6536
diff
changeset
|
138 |
efd71d49bde0
Events: available bytes calculation via ioctl(FIONREAD).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6536
diff
changeset
|
139 } else if ((size_t) n == size) { |
efd71d49bde0
Events: available bytes calculation via ioctl(FIONREAD).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6536
diff
changeset
|
140 |
efd71d49bde0
Events: available bytes calculation via ioctl(FIONREAD).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6536
diff
changeset
|
141 if (ngx_socket_nread(c->fd, &rev->available) == -1) { |
efd71d49bde0
Events: available bytes calculation via ioctl(FIONREAD).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6536
diff
changeset
|
142 n = ngx_connection_error(c, ngx_socket_errno, |
efd71d49bde0
Events: available bytes calculation via ioctl(FIONREAD).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6536
diff
changeset
|
143 ngx_socket_nread_n " failed"); |
efd71d49bde0
Events: available bytes calculation via ioctl(FIONREAD).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6536
diff
changeset
|
144 break; |
efd71d49bde0
Events: available bytes calculation via ioctl(FIONREAD).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6536
diff
changeset
|
145 } |
efd71d49bde0
Events: available bytes calculation via ioctl(FIONREAD).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6536
diff
changeset
|
146 |
efd71d49bde0
Events: available bytes calculation via ioctl(FIONREAD).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6536
diff
changeset
|
147 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
efd71d49bde0
Events: available bytes calculation via ioctl(FIONREAD).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6536
diff
changeset
|
148 "recv: avail:%d", rev->available); |
efd71d49bde0
Events: available bytes calculation via ioctl(FIONREAD).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6536
diff
changeset
|
149 } |
efd71d49bde0
Events: available bytes calculation via ioctl(FIONREAD).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6536
diff
changeset
|
150 |
efd71d49bde0
Events: available bytes calculation via ioctl(FIONREAD).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6536
diff
changeset
|
151 #endif |
efd71d49bde0
Events: available bytes calculation via ioctl(FIONREAD).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6536
diff
changeset
|
152 |
6536
f7849bfb6d21
Improved EPOLLRDHUP handling.
Valentin Bartenev <vbart@nginx.com>
parents:
6508
diff
changeset
|
153 #if (NGX_HAVE_EPOLLRDHUP) |
f7849bfb6d21
Improved EPOLLRDHUP handling.
Valentin Bartenev <vbart@nginx.com>
parents:
6508
diff
changeset
|
154 |
f7849bfb6d21
Improved EPOLLRDHUP handling.
Valentin Bartenev <vbart@nginx.com>
parents:
6508
diff
changeset
|
155 if ((ngx_event_flags & NGX_USE_EPOLL_EVENT) |
f7849bfb6d21
Improved EPOLLRDHUP handling.
Valentin Bartenev <vbart@nginx.com>
parents:
6508
diff
changeset
|
156 && ngx_use_epoll_rdhup) |
f7849bfb6d21
Improved EPOLLRDHUP handling.
Valentin Bartenev <vbart@nginx.com>
parents:
6508
diff
changeset
|
157 { |
f7849bfb6d21
Improved EPOLLRDHUP handling.
Valentin Bartenev <vbart@nginx.com>
parents:
6508
diff
changeset
|
158 if ((size_t) n < size) { |
f7849bfb6d21
Improved EPOLLRDHUP handling.
Valentin Bartenev <vbart@nginx.com>
parents:
6508
diff
changeset
|
159 if (!rev->pending_eof) { |
f7849bfb6d21
Improved EPOLLRDHUP handling.
Valentin Bartenev <vbart@nginx.com>
parents:
6508
diff
changeset
|
160 rev->ready = 0; |
f7849bfb6d21
Improved EPOLLRDHUP handling.
Valentin Bartenev <vbart@nginx.com>
parents:
6508
diff
changeset
|
161 } |
f7849bfb6d21
Improved EPOLLRDHUP handling.
Valentin Bartenev <vbart@nginx.com>
parents:
6508
diff
changeset
|
162 |
f7849bfb6d21
Improved EPOLLRDHUP handling.
Valentin Bartenev <vbart@nginx.com>
parents:
6508
diff
changeset
|
163 rev->available = 0; |
f7849bfb6d21
Improved EPOLLRDHUP handling.
Valentin Bartenev <vbart@nginx.com>
parents:
6508
diff
changeset
|
164 } |
f7849bfb6d21
Improved EPOLLRDHUP handling.
Valentin Bartenev <vbart@nginx.com>
parents:
6508
diff
changeset
|
165 |
f7849bfb6d21
Improved EPOLLRDHUP handling.
Valentin Bartenev <vbart@nginx.com>
parents:
6508
diff
changeset
|
166 return n; |
f7849bfb6d21
Improved EPOLLRDHUP handling.
Valentin Bartenev <vbart@nginx.com>
parents:
6508
diff
changeset
|
167 } |
f7849bfb6d21
Improved EPOLLRDHUP handling.
Valentin Bartenev <vbart@nginx.com>
parents:
6508
diff
changeset
|
168 |
f7849bfb6d21
Improved EPOLLRDHUP handling.
Valentin Bartenev <vbart@nginx.com>
parents:
6508
diff
changeset
|
169 #endif |
f7849bfb6d21
Improved EPOLLRDHUP handling.
Valentin Bartenev <vbart@nginx.com>
parents:
6508
diff
changeset
|
170 |
5267
13c006f0c40e
Events: honor NGX_USE_GREEDY_EVENT when kqueue support is enabled.
Valentin Bartenev <vbart@nginx.com>
parents:
4412
diff
changeset
|
171 if ((size_t) n < size |
13c006f0c40e
Events: honor NGX_USE_GREEDY_EVENT when kqueue support is enabled.
Valentin Bartenev <vbart@nginx.com>
parents:
4412
diff
changeset
|
172 && !(ngx_event_flags & NGX_USE_GREEDY_EVENT)) |
13c006f0c40e
Events: honor NGX_USE_GREEDY_EVENT when kqueue support is enabled.
Valentin Bartenev <vbart@nginx.com>
parents:
4412
diff
changeset
|
173 { |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
174 rev->ready = 0; |
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
175 } |
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
176 |
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
177 return n; |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
178 } |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
179 |
253
b6793bc5034b
nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
218
diff
changeset
|
180 err = ngx_socket_errno; |
b6793bc5034b
nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
218
diff
changeset
|
181 |
b6793bc5034b
nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
218
diff
changeset
|
182 if (err == NGX_EAGAIN || err == NGX_EINTR) { |
257
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
256
diff
changeset
|
183 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, err, |
253
b6793bc5034b
nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
218
diff
changeset
|
184 "recv() not ready"); |
b6793bc5034b
nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
218
diff
changeset
|
185 n = NGX_AGAIN; |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
186 |
253
b6793bc5034b
nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
218
diff
changeset
|
187 } else { |
b6793bc5034b
nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
218
diff
changeset
|
188 n = ngx_connection_error(c, err, "recv() failed"); |
b6793bc5034b
nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
218
diff
changeset
|
189 break; |
b6793bc5034b
nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
218
diff
changeset
|
190 } |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
191 |
253
b6793bc5034b
nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
218
diff
changeset
|
192 } while (err == NGX_EINTR); |
188
0061d1f0908d
nginx-0.0.1-2003-11-18-11:04:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
184
diff
changeset
|
193 |
0061d1f0908d
nginx-0.0.1-2003-11-18-11:04:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
184
diff
changeset
|
194 rev->ready = 0; |
0061d1f0908d
nginx-0.0.1-2003-11-18-11:04:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
184
diff
changeset
|
195 |
3642 | 196 if (n == NGX_ERROR) { |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
163
diff
changeset
|
197 rev->error = 1; |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
163
diff
changeset
|
198 } |
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
163
diff
changeset
|
199 |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
200 return n; |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
201 } |