annotate src/os/unix/ngx_solaris_sendfilev_chain.c @ 428:5e73d0ea4dab

nginx-0.0.11-2004-09-16-20:10:13 import
author Igor Sysoev <igor@sysoev.ru>
date Thu, 16 Sep 2004 16:10:13 +0000
parents 7650aea1816f
children 9a97dcdd2421
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
272
d4e65d74db9f nginx-0.0.2-2004-03-01-00:03:02 import
Igor Sysoev <igor@sysoev.ru>
parents: 262
diff changeset
1
d4e65d74db9f nginx-0.0.2-2004-03-01-00:03:02 import
Igor Sysoev <igor@sysoev.ru>
parents: 262
diff changeset
2 /*
d4e65d74db9f nginx-0.0.2-2004-03-01-00:03:02 import
Igor Sysoev <igor@sysoev.ru>
parents: 262
diff changeset
3 * Copyright (C) 2002-2004 Igor Sysoev, http://sysoev.ru/en/
d4e65d74db9f nginx-0.0.2-2004-03-01-00:03:02 import
Igor Sysoev <igor@sysoev.ru>
parents: 262
diff changeset
4 */
d4e65d74db9f nginx-0.0.2-2004-03-01-00:03:02 import
Igor Sysoev <igor@sysoev.ru>
parents: 262
diff changeset
5
197
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
6
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
7 #include <ngx_config.h>
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
8 #include <ngx_core.h>
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
9 #include <ngx_event.h>
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
10
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
11
428
5e73d0ea4dab nginx-0.0.11-2004-09-16-20:10:13 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
12 #define NGX_SENDFILEVECS 16
5e73d0ea4dab nginx-0.0.11-2004-09-16-20:10:13 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
13
5e73d0ea4dab nginx-0.0.11-2004-09-16-20:10:13 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
14
362
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
15 ngx_chain_t *ngx_solaris_sendfilev_chain(ngx_connection_t *c, ngx_chain_t *in,
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
16 off_t limit)
197
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
17 {
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
18 int fd;
290
87e73f067470 nginx-0.0.2-2004-03-16-10:10:12 import
Igor Sysoev <igor@sysoev.ru>
parents: 272
diff changeset
19 u_char *prev;
362
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
20 off_t fprev, sprev, send, aligned;
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
21 size_t size, sent;
197
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
22 ssize_t n;
362
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
23 ngx_int_t eintr, complete;
198
34995c5ec6c4 nginx-0.0.1-2003-11-27-22:01:37 import
Igor Sysoev <igor@sysoev.ru>
parents: 197
diff changeset
24 ngx_err_t err;
428
5e73d0ea4dab nginx-0.0.11-2004-09-16-20:10:13 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
25 sendfilevec_t *sfv, sfvs[NGX_SENDFILEVECS];
197
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
26 ngx_array_t vec;
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
27 ngx_event_t *wev;
262
8c5bdde0d9f0 nginx-0.0.2-2004-02-18-18:45:21 import
Igor Sysoev <igor@sysoev.ru>
parents: 257
diff changeset
28 ngx_chain_t *cl, *tail;
197
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
29
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
30 wev = c->write;
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
31
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
32 if (!wev->ready) {
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
33 return in;
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
34 }
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
35
362
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
36 send = 0;
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
37 complete = 0;
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
38
428
5e73d0ea4dab nginx-0.0.11-2004-09-16-20:10:13 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
39 vec.elts = sfvs;
5e73d0ea4dab nginx-0.0.11-2004-09-16-20:10:13 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
40 vec.size = sizeof(sendfilevec_t);
5e73d0ea4dab nginx-0.0.11-2004-09-16-20:10:13 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
41 vec.nalloc = NGX_SENDFILEVECS;
5e73d0ea4dab nginx-0.0.11-2004-09-16-20:10:13 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
42 vec.pool = c->pool;
5e73d0ea4dab nginx-0.0.11-2004-09-16-20:10:13 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
43
362
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
44 for ( ;; ) {
197
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
45 fd = SFV_FD_SELF;
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
46 prev = NULL;
198
34995c5ec6c4 nginx-0.0.1-2003-11-27-22:01:37 import
Igor Sysoev <igor@sysoev.ru>
parents: 197
diff changeset
47 fprev = 0;
197
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
48 sfv = NULL;
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
49 eintr = 0;
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
50 sent = 0;
362
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
51 sprev = send;
197
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
52
428
5e73d0ea4dab nginx-0.0.11-2004-09-16-20:10:13 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
53 vec.nelts = 0;
198
34995c5ec6c4 nginx-0.0.1-2003-11-27-22:01:37 import
Igor Sysoev <igor@sysoev.ru>
parents: 197
diff changeset
54
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
55 /* create the sendfilevec and coalesce the neighbouring bufs */
197
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
56
362
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
57 for (cl = in; cl && vec.nelts < IOV_MAX && send < limit; cl = cl->next)
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
58 {
344
e366ba5db8f8 nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents: 343
diff changeset
59 if (ngx_buf_special(cl->buf)) {
197
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
60 continue;
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
61 }
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
62
344
e366ba5db8f8 nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents: 343
diff changeset
63 if (ngx_buf_in_memory_only(cl->buf)) {
197
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
64 fd = SFV_FD_SELF;
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
65
362
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
66 size = cl->buf->last - cl->buf->pos;
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
67
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
68 if (send + size > limit) {
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
69 size = limit - send;
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
70 }
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
71
344
e366ba5db8f8 nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents: 343
diff changeset
72 if (prev == cl->buf->pos) {
362
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
73 sfv->sfv_len += size;
197
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
74
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
75 } else {
428
5e73d0ea4dab nginx-0.0.11-2004-09-16-20:10:13 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
76 if (!(sfv = ngx_array_push(&vec))) {
5e73d0ea4dab nginx-0.0.11-2004-09-16-20:10:13 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
77 return NGX_CHAIN_ERROR;
5e73d0ea4dab nginx-0.0.11-2004-09-16-20:10:13 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
78 }
5e73d0ea4dab nginx-0.0.11-2004-09-16-20:10:13 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
79
197
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
80 sfv->sfv_fd = SFV_FD_SELF;
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
81 sfv->sfv_flag = 0;
344
e366ba5db8f8 nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents: 343
diff changeset
82 sfv->sfv_off = (off_t) (uintptr_t) cl->buf->pos;
362
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
83 sfv->sfv_len = size;
197
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
84 }
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
85
362
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
86 prev = cl->buf->pos + size;
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
87 send += size;
197
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
88
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
89 } else {
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
90 prev = NULL;
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
91
362
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
92 size = (size_t) (cl->buf->file_last - cl->buf->file_pos);
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
93
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
94 if (send + size > limit) {
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
95 size = limit - send;
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
96
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
97 aligned = (cl->buf->file_pos + size + ngx_pagesize - 1)
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
98 & ~(ngx_pagesize - 1);
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
99
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
100 if (aligned <= cl->buf->file_last) {
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
101 size = aligned - cl->buf->file_pos;
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
102 }
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
103 }
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
104
344
e366ba5db8f8 nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents: 343
diff changeset
105 if (fd == cl->buf->file->fd && fprev == cl->buf->file_pos) {
362
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
106 sfv->sfv_len += size;
197
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
107
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
108 } else {
428
5e73d0ea4dab nginx-0.0.11-2004-09-16-20:10:13 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
109 if (!(sfv = ngx_array_push(&vec))) {
5e73d0ea4dab nginx-0.0.11-2004-09-16-20:10:13 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
110 return NGX_CHAIN_ERROR;
5e73d0ea4dab nginx-0.0.11-2004-09-16-20:10:13 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
111 }
5e73d0ea4dab nginx-0.0.11-2004-09-16-20:10:13 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
112
344
e366ba5db8f8 nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents: 343
diff changeset
113 fd = cl->buf->file->fd;
197
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
114 sfv->sfv_fd = fd;
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
115 sfv->sfv_flag = 0;
344
e366ba5db8f8 nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents: 343
diff changeset
116 sfv->sfv_off = cl->buf->file_pos;
362
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
117 sfv->sfv_len = size;
197
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
118 }
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
119
362
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
120 fprev = cl->buf->file_pos + size;
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
121 send += size;
197
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
122 }
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
123 }
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
124
198
34995c5ec6c4 nginx-0.0.1-2003-11-27-22:01:37 import
Igor Sysoev <igor@sysoev.ru>
parents: 197
diff changeset
125 n = sendfilev(c->fd, vec.elts, vec.nelts, &sent);
197
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
126
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
127 if (n == -1) {
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
128 err = ngx_errno;
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
129
257
70e1c7d2b83d nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents: 198
diff changeset
130 if (err == NGX_EAGAIN || err == NGX_EINTR) {
70e1c7d2b83d nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents: 198
diff changeset
131 if (err == NGX_EINTR) {
70e1c7d2b83d nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents: 198
diff changeset
132 eintr = 1;
70e1c7d2b83d nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents: 198
diff changeset
133 }
197
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
134
257
70e1c7d2b83d nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents: 198
diff changeset
135 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, err,
197
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
136 "sendfilev() sent only " SIZE_T_FMT " bytes",
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
137 sent);
257
70e1c7d2b83d nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents: 198
diff changeset
138
197
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
139 } else {
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
140 wev->error = 1;
257
70e1c7d2b83d nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents: 198
diff changeset
141 ngx_connection_error(c, err, "sendfilev() failed");
197
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
142 return NGX_CHAIN_ERROR;
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
143 }
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
144 }
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
145
257
70e1c7d2b83d nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents: 198
diff changeset
146 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0,
70e1c7d2b83d nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents: 198
diff changeset
147 "sendfilev: %d " SIZE_T_FMT, n, sent);
197
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
148
362
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
149 if (send - sprev == sent) {
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
150 complete = 1;
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
151 }
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
152
197
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
153 c->sent += sent;
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
154
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
155 for (cl = in; cl; cl = cl->next) {
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
156
344
e366ba5db8f8 nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents: 343
diff changeset
157 if (ngx_buf_special(cl->buf)) {
197
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
158 continue;
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
159 }
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
160
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
161 if (sent == 0) {
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
162 break;
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
163 }
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
164
344
e366ba5db8f8 nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents: 343
diff changeset
165 size = ngx_buf_size(cl->buf);
197
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
166
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
167 if (sent >= size) {
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
168 sent -= size;
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
169
344
e366ba5db8f8 nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents: 343
diff changeset
170 if (ngx_buf_in_memory(cl->buf)) {
e366ba5db8f8 nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents: 343
diff changeset
171 cl->buf->pos = cl->buf->last;
197
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
172 }
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
173
344
e366ba5db8f8 nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents: 343
diff changeset
174 if (cl->buf->in_file) {
e366ba5db8f8 nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents: 343
diff changeset
175 cl->buf->file_pos = cl->buf->file_last;
197
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
176 }
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
177
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
178 continue;
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
179 }
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
180
344
e366ba5db8f8 nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents: 343
diff changeset
181 if (ngx_buf_in_memory(cl->buf)) {
e366ba5db8f8 nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents: 343
diff changeset
182 cl->buf->pos += sent;
197
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
183 }
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
184
344
e366ba5db8f8 nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents: 343
diff changeset
185 if (cl->buf->in_file) {
e366ba5db8f8 nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents: 343
diff changeset
186 cl->buf->file_pos += sent;
197
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
187 }
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
188
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
189 break;
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
190 }
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
191
362
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
192 if (eintr) {
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
193 continue;
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
194 }
197
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
195
362
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
196 if (!complete) {
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
197 wev->ready = 0;
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
198 return cl;
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
199 }
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
200
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
201 if (send >= limit || cl == NULL) {
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
202 return cl;
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
203 }
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
204
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
205 in = cl;
197
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
206 }
0b81c7a0b133 nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
207 }