Mercurial > hg > nginx-quic
comparison src/http/ngx_http_file_cache.c @ 5736:2fe1967f8854
Cache: version in cache files.
This allows to change the structure of cache files without spamming logs
with false alerts.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Thu, 26 Jun 2014 02:27:21 +0400 |
parents | 25ade23cf281 |
children | 44b9ab7752e3 |
comparison
equal
deleted
inserted
replaced
5735:5fb1e57c758a | 5736:2fe1967f8854 |
---|---|
496 return NGX_DECLINED; | 496 return NGX_DECLINED; |
497 } | 497 } |
498 | 498 |
499 h = (ngx_http_file_cache_header_t *) c->buf->pos; | 499 h = (ngx_http_file_cache_header_t *) c->buf->pos; |
500 | 500 |
501 if (h->version != NGX_HTTP_CACHE_VERSION) { | |
502 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, | |
503 "cache file \"%s\" version mismatch", c->file.name.data); | |
504 return NGX_DECLINED; | |
505 } | |
506 | |
501 if (h->crc32 != c->crc32) { | 507 if (h->crc32 != c->crc32) { |
502 ngx_log_error(NGX_LOG_CRIT, r->connection->log, 0, | 508 ngx_log_error(NGX_LOG_CRIT, r->connection->log, 0, |
503 "cache file \"%s\" has md5 collision", c->file.name.data); | 509 "cache file \"%s\" has md5 collision", c->file.name.data); |
504 return NGX_DECLINED; | 510 return NGX_DECLINED; |
505 } | 511 } |
873 | 879 |
874 c = r->cache; | 880 c = r->cache; |
875 | 881 |
876 ngx_memzero(h, sizeof(ngx_http_file_cache_header_t)); | 882 ngx_memzero(h, sizeof(ngx_http_file_cache_header_t)); |
877 | 883 |
884 h->version = NGX_HTTP_CACHE_VERSION; | |
878 h->valid_sec = c->valid_sec; | 885 h->valid_sec = c->valid_sec; |
879 h->last_modified = c->last_modified; | 886 h->last_modified = c->last_modified; |
880 h->date = c->date; | 887 h->date = c->date; |
881 h->crc32 = c->crc32; | 888 h->crc32 = c->crc32; |
882 h->valid_msec = (u_short) c->valid_msec; | 889 h->valid_msec = (u_short) c->valid_msec; |
1040 ngx_read_file_n " read only %z of %z from \"%s\"", | 1047 ngx_read_file_n " read only %z of %z from \"%s\"", |
1041 n, sizeof(ngx_http_file_cache_header_t), file.name.data); | 1048 n, sizeof(ngx_http_file_cache_header_t), file.name.data); |
1042 goto done; | 1049 goto done; |
1043 } | 1050 } |
1044 | 1051 |
1045 if (h.last_modified != c->last_modified | 1052 if (h.version != NGX_HTTP_CACHE_VERSION |
1053 || h.last_modified != c->last_modified | |
1046 || h.crc32 != c->crc32 | 1054 || h.crc32 != c->crc32 |
1047 || h.header_start != c->header_start | 1055 || h.header_start != c->header_start |
1048 || h.body_start != c->body_start) | 1056 || h.body_start != c->body_start) |
1049 { | 1057 { |
1050 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | 1058 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
1058 * notably h.valid_sec and h.date | 1066 * notably h.valid_sec and h.date |
1059 */ | 1067 */ |
1060 | 1068 |
1061 ngx_memzero(&h, sizeof(ngx_http_file_cache_header_t)); | 1069 ngx_memzero(&h, sizeof(ngx_http_file_cache_header_t)); |
1062 | 1070 |
1071 h.version = NGX_HTTP_CACHE_VERSION; | |
1063 h.valid_sec = c->valid_sec; | 1072 h.valid_sec = c->valid_sec; |
1064 h.last_modified = c->last_modified; | 1073 h.last_modified = c->last_modified; |
1065 h.date = c->date; | 1074 h.date = c->date; |
1066 h.crc32 = c->crc32; | 1075 h.crc32 = c->crc32; |
1067 h.valid_msec = (u_short) c->valid_msec; | 1076 h.valid_msec = (u_short) c->valid_msec; |