Mercurial > hg > nginx-quic
annotate src/os/unix/ngx_writev_chain.c @ 6402:7296b38f6416
Core: added support for more than 64 CPUs in worker_cpu_affinity.
author | Vladimir Homutov <vl@nginx.com> |
---|---|
date | Thu, 18 Feb 2016 13:58:49 +0300 |
parents | 2c64b69daec5 |
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:
429
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:
429
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:
429
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:
429
diff
changeset
|
6 |
93
738fe44c70d5
nginx-0.0.1-2003-05-21-17:28:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
7 |
738fe44c70d5
nginx-0.0.1-2003-05-21-17:28:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
8 #include <ngx_config.h> |
738fe44c70d5
nginx-0.0.1-2003-05-21-17:28:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
9 #include <ngx_core.h> |
144
ef8c87afcfc5
nginx-0.0.1-2003-10-12-20:49:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
103
diff
changeset
|
10 #include <ngx_event.h> |
93
738fe44c70d5
nginx-0.0.1-2003-05-21-17:28:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
11 |
738fe44c70d5
nginx-0.0.1-2003-05-21-17:28:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
12 |
501 | 13 ngx_chain_t * |
14 ngx_writev_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit) | |
93
738fe44c70d5
nginx-0.0.1-2003-05-21-17:28:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
15 { |
5913
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
16 ssize_t n, sent; |
473 | 17 off_t send, prev_send; |
429
694cd6cdb714
nginx-0.0.11-2004-09-17-20:07:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
375
diff
changeset
|
18 ngx_chain_t *cl; |
694cd6cdb714
nginx-0.0.11-2004-09-17-20:07:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
375
diff
changeset
|
19 ngx_event_t *wev; |
5913
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
20 ngx_iovec_t vec; |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
21 struct iovec iovs[NGX_IOVS_PREALLOCATE]; |
93
738fe44c70d5
nginx-0.0.1-2003-05-21-17:28:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
22 |
198
34995c5ec6c4
nginx-0.0.1-2003-11-27-22:01:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
23 wev = c->write; |
34995c5ec6c4
nginx-0.0.1-2003-11-27-22:01:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
24 |
34995c5ec6c4
nginx-0.0.1-2003-11-27-22:01:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
25 if (!wev->ready) { |
144
ef8c87afcfc5
nginx-0.0.1-2003-10-12-20:49:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
103
diff
changeset
|
26 return in; |
ef8c87afcfc5
nginx-0.0.1-2003-10-12-20:49:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
103
diff
changeset
|
27 } |
ef8c87afcfc5
nginx-0.0.1-2003-10-12-20:49:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
103
diff
changeset
|
28 |
469 | 29 #if (NGX_HAVE_KQUEUE) |
257
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
198
diff
changeset
|
30 |
587 | 31 if ((ngx_event_flags & NGX_USE_KQUEUE_EVENT) && wev->pending_eof) { |
537 | 32 (void) ngx_connection_error(c, wev->kq_errno, |
33 "kevent() reported about an closed connection"); | |
257
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
198
diff
changeset
|
34 wev->error = 1; |
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
198
diff
changeset
|
35 return NGX_CHAIN_ERROR; |
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
198
diff
changeset
|
36 } |
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
198
diff
changeset
|
37 |
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
198
diff
changeset
|
38 #endif |
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
198
diff
changeset
|
39 |
473 | 40 /* the maximum limit size is the maximum size_t value - the page size */ |
41 | |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
597
diff
changeset
|
42 if (limit == 0 || limit > (off_t) (NGX_MAX_SIZE_T_VALUE - ngx_pagesize)) { |
477 | 43 limit = NGX_MAX_SIZE_T_VALUE - ngx_pagesize; |
473 | 44 } |
45 | |
362
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
343
diff
changeset
|
46 send = 0; |
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
343
diff
changeset
|
47 |
5913
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
48 vec.iovs = iovs; |
5854
b63e829621ab
Generalized definitions of the number of preallocated iovec's.
Valentin Bartenev <vbart@nginx.com>
parents:
5853
diff
changeset
|
49 vec.nalloc = NGX_IOVS_PREALLOCATE; |
429
694cd6cdb714
nginx-0.0.11-2004-09-17-20:07:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
375
diff
changeset
|
50 |
362
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
343
diff
changeset
|
51 for ( ;; ) { |
473 | 52 prev_send = send; |
93
738fe44c70d5
nginx-0.0.1-2003-05-21-17:28:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
53 |
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:
290
diff
changeset
|
54 /* create the iovec and coalesce the neighbouring bufs */ |
184
1bf718ce0dde
nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
170
diff
changeset
|
55 |
5913
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
56 cl = ngx_output_chain_to_iovec(&vec, in, limit - send, c->log); |
93
738fe44c70d5
nginx-0.0.1-2003-05-21-17:28:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
57 |
5913
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
58 if (cl == NGX_CHAIN_ERROR) { |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
59 return NGX_CHAIN_ERROR; |
93
738fe44c70d5
nginx-0.0.1-2003-05-21-17:28:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
60 } |
738fe44c70d5
nginx-0.0.1-2003-05-21-17:28:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
61 |
5913
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
62 if (cl && cl->buf->in_file) { |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
63 ngx_log_error(NGX_LOG_ALERT, c->log, 0, |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
64 "file buf in writev " |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
65 "t:%d r:%d f:%d %p %p-%p %p %O-%O", |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
66 cl->buf->temporary, |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
67 cl->buf->recycled, |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
68 cl->buf->in_file, |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
69 cl->buf->start, |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
70 cl->buf->pos, |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
71 cl->buf->last, |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
72 cl->buf->file, |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
73 cl->buf->file_pos, |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
74 cl->buf->file_last); |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
75 |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
76 ngx_debug_point(); |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
77 |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
78 return NGX_CHAIN_ERROR; |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
79 } |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
80 |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
81 send += vec.size; |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
82 |
5917
2c64b69daec5
Moved writev() handling code to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5913
diff
changeset
|
83 n = ngx_writev(c, &vec); |
257
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
198
diff
changeset
|
84 |
5917
2c64b69daec5
Moved writev() handling code to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5913
diff
changeset
|
85 if (n == NGX_ERROR) { |
2c64b69daec5
Moved writev() handling code to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5913
diff
changeset
|
86 return NGX_CHAIN_ERROR; |
93
738fe44c70d5
nginx-0.0.1-2003-05-21-17:28:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
87 } |
738fe44c70d5
nginx-0.0.1-2003-05-21-17:28:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
88 |
5917
2c64b69daec5
Moved writev() handling code to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5913
diff
changeset
|
89 sent = (n == NGX_AGAIN) ? 0 : n; |
93
738fe44c70d5
nginx-0.0.1-2003-05-21-17:28:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
90 |
198
34995c5ec6c4
nginx-0.0.1-2003-11-27-22:01:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
91 c->sent += sent; |
93
738fe44c70d5
nginx-0.0.1-2003-05-21-17:28:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
92 |
5912
de68ed551bfb
Renamed ngx_handle_sent_chain() to ngx_chain_update_sent().
Valentin Bartenev <vbart@nginx.com>
parents:
5868
diff
changeset
|
93 in = ngx_chain_update_sent(in, sent); |
93
738fe44c70d5
nginx-0.0.1-2003-05-21-17:28:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
94 |
5851
150df089fe47
Removed the "complete" variable from various send chain functions.
Valentin Bartenev <vbart@nginx.com>
parents:
5850
diff
changeset
|
95 if (send - prev_send != sent) { |
362
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
343
diff
changeset
|
96 wev->ready = 0; |
5853
a6e83ac70af9
Reduced difference between the send chain functions.
Valentin Bartenev <vbart@nginx.com>
parents:
5851
diff
changeset
|
97 return in; |
362
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
343
diff
changeset
|
98 } |
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
343
diff
changeset
|
99 |
5853
a6e83ac70af9
Reduced difference between the send chain functions.
Valentin Bartenev <vbart@nginx.com>
parents:
5851
diff
changeset
|
100 if (send >= limit || in == NULL) { |
a6e83ac70af9
Reduced difference between the send chain functions.
Valentin Bartenev <vbart@nginx.com>
parents:
5851
diff
changeset
|
101 return in; |
362
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
343
diff
changeset
|
102 } |
93
738fe44c70d5
nginx-0.0.1-2003-05-21-17:28:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
103 } |
738fe44c70d5
nginx-0.0.1-2003-05-21-17:28:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
104 } |
5913
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
105 |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
106 |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
107 ngx_chain_t * |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
108 ngx_output_chain_to_iovec(ngx_iovec_t *vec, ngx_chain_t *in, size_t limit, |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
109 ngx_log_t *log) |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
110 { |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
111 size_t total, size; |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
112 u_char *prev; |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
113 ngx_uint_t n; |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
114 struct iovec *iov; |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
115 |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
116 iov = NULL; |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
117 prev = NULL; |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
118 total = 0; |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
119 n = 0; |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
120 |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
121 for ( /* void */ ; in && total < limit; in = in->next) { |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
122 |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
123 if (ngx_buf_special(in->buf)) { |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
124 continue; |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
125 } |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
126 |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
127 if (in->buf->in_file) { |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
128 break; |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
129 } |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
130 |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
131 if (!ngx_buf_in_memory(in->buf)) { |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
132 ngx_log_error(NGX_LOG_ALERT, log, 0, |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
133 "bad buf in output chain " |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
134 "t:%d r:%d f:%d %p %p-%p %p %O-%O", |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
135 in->buf->temporary, |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
136 in->buf->recycled, |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
137 in->buf->in_file, |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
138 in->buf->start, |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
139 in->buf->pos, |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
140 in->buf->last, |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
141 in->buf->file, |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
142 in->buf->file_pos, |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
143 in->buf->file_last); |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
144 |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
145 ngx_debug_point(); |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
146 |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
147 return NGX_CHAIN_ERROR; |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
148 } |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
149 |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
150 size = in->buf->last - in->buf->pos; |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
151 |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
152 if (size > limit - total) { |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
153 size = limit - total; |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
154 } |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
155 |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
156 if (prev == in->buf->pos) { |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
157 iov->iov_len += size; |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
158 |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
159 } else { |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
160 if (n == vec->nalloc) { |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
161 break; |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
162 } |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
163 |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
164 iov = &vec->iovs[n++]; |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
165 |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
166 iov->iov_base = (void *) in->buf->pos; |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
167 iov->iov_len = size; |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
168 } |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
169 |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
170 prev = in->buf->pos + size; |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
171 total += size; |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
172 } |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
173 |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
174 vec->count = n; |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
175 vec->size = total; |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
176 |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
177 return in; |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
178 } |
5917
2c64b69daec5
Moved writev() handling code to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5913
diff
changeset
|
179 |
2c64b69daec5
Moved writev() handling code to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5913
diff
changeset
|
180 |
2c64b69daec5
Moved writev() handling code to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5913
diff
changeset
|
181 ssize_t |
2c64b69daec5
Moved writev() handling code to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5913
diff
changeset
|
182 ngx_writev(ngx_connection_t *c, ngx_iovec_t *vec) |
2c64b69daec5
Moved writev() handling code to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5913
diff
changeset
|
183 { |
2c64b69daec5
Moved writev() handling code to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5913
diff
changeset
|
184 ssize_t n; |
2c64b69daec5
Moved writev() handling code to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5913
diff
changeset
|
185 ngx_err_t err; |
2c64b69daec5
Moved writev() handling code to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5913
diff
changeset
|
186 |
2c64b69daec5
Moved writev() handling code to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5913
diff
changeset
|
187 eintr: |
2c64b69daec5
Moved writev() handling code to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5913
diff
changeset
|
188 |
2c64b69daec5
Moved writev() handling code to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5913
diff
changeset
|
189 n = writev(c->fd, vec->iovs, vec->count); |
2c64b69daec5
Moved writev() handling code to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5913
diff
changeset
|
190 |
2c64b69daec5
Moved writev() handling code to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5913
diff
changeset
|
191 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0, |
2c64b69daec5
Moved writev() handling code to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5913
diff
changeset
|
192 "writev: %z of %uz", n, vec->size); |
2c64b69daec5
Moved writev() handling code to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5913
diff
changeset
|
193 |
2c64b69daec5
Moved writev() handling code to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5913
diff
changeset
|
194 if (n == -1) { |
2c64b69daec5
Moved writev() handling code to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5913
diff
changeset
|
195 err = ngx_errno; |
2c64b69daec5
Moved writev() handling code to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5913
diff
changeset
|
196 |
2c64b69daec5
Moved writev() handling code to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5913
diff
changeset
|
197 switch (err) { |
2c64b69daec5
Moved writev() handling code to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5913
diff
changeset
|
198 case NGX_EAGAIN: |
2c64b69daec5
Moved writev() handling code to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5913
diff
changeset
|
199 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, err, |
2c64b69daec5
Moved writev() handling code to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5913
diff
changeset
|
200 "writev() not ready"); |
2c64b69daec5
Moved writev() handling code to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5913
diff
changeset
|
201 return NGX_AGAIN; |
2c64b69daec5
Moved writev() handling code to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5913
diff
changeset
|
202 |
2c64b69daec5
Moved writev() handling code to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5913
diff
changeset
|
203 case NGX_EINTR: |
2c64b69daec5
Moved writev() handling code to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5913
diff
changeset
|
204 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, err, |
2c64b69daec5
Moved writev() handling code to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5913
diff
changeset
|
205 "writev() was interrupted"); |
2c64b69daec5
Moved writev() handling code to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5913
diff
changeset
|
206 goto eintr; |
2c64b69daec5
Moved writev() handling code to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5913
diff
changeset
|
207 |
2c64b69daec5
Moved writev() handling code to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5913
diff
changeset
|
208 default: |
2c64b69daec5
Moved writev() handling code to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5913
diff
changeset
|
209 c->write->error = 1; |
2c64b69daec5
Moved writev() handling code to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5913
diff
changeset
|
210 ngx_connection_error(c, err, "writev() failed"); |
2c64b69daec5
Moved writev() handling code to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5913
diff
changeset
|
211 return NGX_ERROR; |
2c64b69daec5
Moved writev() handling code to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5913
diff
changeset
|
212 } |
2c64b69daec5
Moved writev() handling code to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5913
diff
changeset
|
213 } |
2c64b69daec5
Moved writev() handling code to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5913
diff
changeset
|
214 |
2c64b69daec5
Moved writev() handling code to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5913
diff
changeset
|
215 return n; |
2c64b69daec5
Moved writev() handling code to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5913
diff
changeset
|
216 } |