comparison src/http/ngx_http_upstream.c @ 4895:508e61393b6c

Event pipe: fixed handling of buf_to_file data. Input filter might free a buffer if there is no data in it, and in case of first buffer (used for cache header and request header, aka p->buf_to_file) this resulted in cache corruption. Buffer memory was reused to read upstream response before headers were written to disk. Fix is to avoid moving pointers in ngx_event_pipe_add_free_buf() to a buffer start if we were asked to free a buffer used by p->buf_to_file. This fixes occasional cache file corruption, usually resulted in "cache file ... has md5 collision" alerts. Reported by Anatoli Marinov.
author Maxim Dounin <mdounin@mdounin.ru>
date Tue, 30 Oct 2012 11:14:24 +0000
parents f88555d76886
children e62219793beb
comparison
equal deleted inserted replaced
4894:0156fd6f48fa 4895:508e61393b6c
2285 if (p->buf_to_file == NULL) { 2285 if (p->buf_to_file == NULL) {
2286 ngx_http_upstream_finalize_request(r, u, 0); 2286 ngx_http_upstream_finalize_request(r, u, 0);
2287 return; 2287 return;
2288 } 2288 }
2289 2289
2290 p->buf_to_file->start = u->buffer.start;
2290 p->buf_to_file->pos = u->buffer.start; 2291 p->buf_to_file->pos = u->buffer.start;
2291 p->buf_to_file->last = u->buffer.pos; 2292 p->buf_to_file->last = u->buffer.pos;
2292 p->buf_to_file->temporary = 1; 2293 p->buf_to_file->temporary = 1;
2293 } 2294 }
2294 2295