comparison src/http/ngx_http_copy_filter_module.c @ 522:1bc8c12d80ec NGINX_0_8_13

nginx 0.8.13 *) Bugfix: in the "aio sendfile" directive. the bug had appeared in 0.8.12. *) Bugfix: nginx could not be built without the --with-file-aio option on FreeBSD; the bug had appeared in 0.8.12.
author Igor Sysoev <http://sysoev.ru>
date Mon, 31 Aug 2009 00:00:00 +0400
parents d41628eb4d0a
children 80f7156c2965
comparison
equal deleted inserted replaced
521:9917c53346ac 522:1bc8c12d80ec
131 #endif 131 #endif
132 132
133 r->request_output = 1; 133 r->request_output = 1;
134 } 134 }
135 135
136 rc = ngx_output_chain(ctx, in); 136 for ( ;; ) {
137 137 rc = ngx_output_chain(ctx, in);
138 if (ctx->in == NULL) { 138
139 r->buffered &= ~NGX_HTTP_COPY_BUFFERED; 139 if (ctx->in == NULL) {
140 140 r->buffered &= ~NGX_HTTP_COPY_BUFFERED;
141 } else { 141
142 r->buffered |= NGX_HTTP_COPY_BUFFERED; 142 } else {
143 } 143 r->buffered |= NGX_HTTP_COPY_BUFFERED;
144 144 }
145 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, c->log, 0, 145
146 "http copy filter: %i \"%V?%V\"", rc, &r->uri, &r->args); 146 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, c->log, 0,
147 147 "http copy filter: %i \"%V?%V\"", rc, &r->uri, &r->args);
148 #if (NGX_HAVE_AIO_SENDFILE) 148
149 149 #if (NGX_HAVE_FILE_AIO && NGX_HAVE_AIO_SENDFILE)
150 if (c->busy_sendfile) { 150
151 off_t offset; 151 if (c->busy_sendfile) {
152 ngx_file_t *file; 152 ssize_t n;
153 ngx_http_ephemeral_t *e; 153 off_t offset;
154 154 ngx_file_t *file;
155 file = c->busy_sendfile->file; 155 ngx_http_ephemeral_t *e;
156 offset = c->busy_sendfile->file_pos; 156
157 157 file = c->busy_sendfile->file;
158 if (file->aio) { 158 offset = c->busy_sendfile->file_pos;
159 c->aio_sendfile = (offset != file->aio->last_offset); 159
160 file->aio->last_offset = offset; 160 if (file->aio) {
161 161 c->aio_sendfile = (offset != file->aio->last_offset);
162 if (c->aio_sendfile == 0) { 162 file->aio->last_offset = offset;
163 ngx_log_error(NGX_LOG_ALERT, c->log, 0, 163
164 "sendfile(%V) returned busy again", &file->name); 164 if (c->aio_sendfile == 0) {
165 ngx_log_error(NGX_LOG_ALERT, c->log, 0,
166 "sendfile(%V) returned busy again",
167 &file->name);
168 }
165 } 169 }
166 } 170
167 171 c->busy_sendfile = NULL;
168 c->busy_sendfile = NULL; 172 e = (ngx_http_ephemeral_t *) &r->uri_start;
169 e = (ngx_http_ephemeral_t *) &r->uri_start; 173
170 174 n = ngx_file_aio_read(file, e->preload, 4, offset, r->pool);
171 (void) ngx_file_aio_read(file, e->preload, 4, offset, r->pool); 175
172 176 if (n > 0) {
173 if (file->aio) { 177 continue;
174 file->aio->data = r; 178 }
175 file->aio->handler = ngx_http_copy_aio_sendfile_event_handler; 179
176 180 rc = n;
177 r->main->blocked++; 181
178 r->aio = 1; 182 if (file->aio) {
179 } 183 file->aio->data = r;
180 } 184 file->aio->handler = ngx_http_copy_aio_sendfile_event_handler;
181 185
182 #endif 186 r->main->blocked++;
183 187 r->aio = 1;
184 return rc; 188 }
189 }
190 #endif
191
192 return rc;
193 }
185 } 194 }
186 195
187 196
188 #if (NGX_HAVE_FILE_AIO) 197 #if (NGX_HAVE_FILE_AIO)
189 198