comparison src/os/unix/ngx_solaris_sendfilev_chain.c @ 344:e366ba5db8f8

nginx-0.0.3-2004-06-01-10:04:46 import
author Igor Sysoev <igor@sysoev.ru>
date Tue, 01 Jun 2004 06:04:46 +0000
parents 6bdf858bff8c
children 7650aea1816f
comparison
equal deleted inserted replaced
343:6bdf858bff8c 344:e366ba5db8f8
41 NGX_CHAIN_ERROR); 41 NGX_CHAIN_ERROR);
42 42
43 /* create the sendfilevec and coalesce the neighbouring bufs */ 43 /* create the sendfilevec and coalesce the neighbouring bufs */
44 44
45 for (cl = in; cl && vec.nelts < IOV_MAX; cl = cl->next) { 45 for (cl = in; cl && vec.nelts < IOV_MAX; cl = cl->next) {
46 if (ngx_hunk_special(cl->hunk)) { 46 if (ngx_buf_special(cl->buf)) {
47 continue; 47 continue;
48 } 48 }
49 49
50 if (ngx_hunk_in_memory_only(cl->hunk)) { 50 if (ngx_buf_in_memory_only(cl->buf)) {
51 fd = SFV_FD_SELF; 51 fd = SFV_FD_SELF;
52 52
53 if (prev == cl->hunk->pos) { 53 if (prev == cl->buf->pos) {
54 sfv->sfv_len += cl->hunk->last - cl->hunk->pos; 54 sfv->sfv_len += cl->buf->last - cl->buf->pos;
55 55
56 } else { 56 } else {
57 ngx_test_null(sfv, ngx_push_array(&vec), NGX_CHAIN_ERROR); 57 ngx_test_null(sfv, ngx_push_array(&vec), NGX_CHAIN_ERROR);
58 sfv->sfv_fd = SFV_FD_SELF; 58 sfv->sfv_fd = SFV_FD_SELF;
59 sfv->sfv_flag = 0; 59 sfv->sfv_flag = 0;
60 sfv->sfv_off = (off_t) (uintptr_t) cl->hunk->pos; 60 sfv->sfv_off = (off_t) (uintptr_t) cl->buf->pos;
61 sfv->sfv_len = cl->hunk->last - cl->hunk->pos; 61 sfv->sfv_len = cl->buf->last - cl->buf->pos;
62 } 62 }
63 63
64 prev = cl->hunk->last; 64 prev = cl->buf->last;
65 65
66 } else { 66 } else {
67 prev = NULL; 67 prev = NULL;
68 68
69 if (fd == cl->hunk->file->fd && fprev == cl->hunk->file_pos) { 69 if (fd == cl->buf->file->fd && fprev == cl->buf->file_pos) {
70 sfv->sfv_len += cl->hunk->file_last - cl->hunk->file_pos; 70 sfv->sfv_len += cl->buf->file_last - cl->buf->file_pos;
71 71
72 } else { 72 } else {
73 ngx_test_null(sfv, ngx_push_array(&vec), NGX_CHAIN_ERROR); 73 ngx_test_null(sfv, ngx_push_array(&vec), NGX_CHAIN_ERROR);
74 fd = cl->hunk->file->fd; 74 fd = cl->buf->file->fd;
75 sfv->sfv_fd = fd; 75 sfv->sfv_fd = fd;
76 sfv->sfv_flag = 0; 76 sfv->sfv_flag = 0;
77 sfv->sfv_off = cl->hunk->file_pos; 77 sfv->sfv_off = cl->buf->file_pos;
78 sfv->sfv_len = cl->hunk->file_last - cl->hunk->file_pos; 78 sfv->sfv_len = cl->buf->file_last - cl->buf->file_pos;
79 } 79 }
80 80
81 fprev = cl->hunk->file_last; 81 fprev = cl->buf->file_last;
82 } 82 }
83 } 83 }
84 84
85 /* 85 /*
86 * the tail is the rest of the chain that exceedes a single 86 * the tail is the rest of the chain that exceedes a single
115 115
116 c->sent += sent; 116 c->sent += sent;
117 117
118 for (cl = in; cl; cl = cl->next) { 118 for (cl = in; cl; cl = cl->next) {
119 119
120 if (ngx_hunk_special(cl->hunk)) { 120 if (ngx_buf_special(cl->buf)) {
121 continue; 121 continue;
122 } 122 }
123 123
124 if (sent == 0) { 124 if (sent == 0) {
125 break; 125 break;
126 } 126 }
127 127
128 size = ngx_hunk_size(cl->hunk); 128 size = ngx_buf_size(cl->buf);
129 129
130 if (sent >= size) { 130 if (sent >= size) {
131 sent -= size; 131 sent -= size;
132 132
133 if (cl->hunk->type & NGX_HUNK_IN_MEMORY) { 133 if (ngx_buf_in_memory(cl->buf)) {
134 cl->hunk->pos = cl->hunk->last; 134 cl->buf->pos = cl->buf->last;
135 } 135 }
136 136
137 if (cl->hunk->type & NGX_HUNK_FILE) { 137 if (cl->buf->in_file) {
138 cl->hunk->file_pos = cl->hunk->file_last; 138 cl->buf->file_pos = cl->buf->file_last;
139 } 139 }
140 140
141 continue; 141 continue;
142 } 142 }
143 143
144 if (cl->hunk->type & NGX_HUNK_IN_MEMORY) { 144 if (ngx_buf_in_memory(cl->buf)) {
145 cl->hunk->pos += sent; 145 cl->buf->pos += sent;
146 } 146 }
147 147
148 if (cl->hunk->type & NGX_HUNK_FILE) { 148 if (cl->buf->in_file) {
149 cl->hunk->file_pos += sent; 149 cl->buf->file_pos += sent;
150 } 150 }
151 151
152 break; 152 break;
153 } 153 }
154 154