Skip to content

Instantly share code, notes, and snippets.

@ilyaevseev
Created September 7, 2017 09:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ilyaevseev/f2c57519db829329f8e9f9aff5d51789 to your computer and use it in GitHub Desktop.
Save ilyaevseev/f2c57519db829329f8e9f9aff5d51789 to your computer and use it in GitHub Desktop.
Nginx: print more info about wrong files in cache.
--- nginx-1.13.5/src/http/ngx_http_file_cache.c.orig 2017-09-05 17:59:32.000000000 +0300
+++ nginx-1.13.5/src/http/ngx_http_file_cache.c 2017-09-07 12:07:01.129832120 +0300
@@ -542,7 +542,8 @@
if ((size_t) n < c->header_start) {
ngx_log_error(NGX_LOG_CRIT, r->connection->log, 0,
- "cache file \"%s\" is too small", c->file.name.data);
+ "cache file \"%s\" is too small (actual = %z, required = %uz)",
+ c->file.name.data, n, (size_t)c->header_start);
return NGX_DECLINED;
}
@@ -550,13 +551,17 @@
if (h->version != NGX_HTTP_CACHE_VERSION) {
ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,
- "cache file \"%s\" version mismatch", c->file.name.data);
+ "cache file \"%s\" version mismatch (actual = %ui, required = %d)",
+ c->file.name.data, (ngx_uint_t)h->version, NGX_HTTP_CACHE_VERSION);
return NGX_DECLINED;
}
if (h->crc32 != c->crc32 || (size_t) h->header_start != c->header_start) {
ngx_log_error(NGX_LOG_CRIT, r->connection->log, 0,
- "cache file \"%s\" has md5 collision", c->file.name.data);
+ "cache file \"%s\" has md5 collision "
+ "(crc32: actual=%xD, required=%xD; header_start: actual=%uz, required=%uz)",
+ c->file.name.data, h->crc32, c->crc32,
+ (size_t)h->header_start, (size_t)c->header_start);
return NGX_DECLINED;
}
@@ -577,15 +582,15 @@
if ((size_t) h->body_start > c->body_start) {
ngx_log_error(NGX_LOG_CRIT, r->connection->log, 0,
- "cache file \"%s\" has too long header",
- c->file.name.data);
+ "cache file \"%s\" has too long header (actual = %uz, required = %uz)",
+ c->file.name.data, (size_t)h->body_start, (size_t)c->body_start);
return NGX_DECLINED;
}
if (h->vary_len > NGX_HTTP_CACHE_VARY_LEN) {
ngx_log_error(NGX_LOG_CRIT, r->connection->log, 0,
- "cache file \"%s\" has incorrect vary length",
- c->file.name.data);
+ "cache file \"%s\" has incorrect vary length (actual = %uz, required = %d)",
+ c->file.name.data, (size_t)h->vary_len, NGX_HTTP_CACHE_VARY_LEN);
return NGX_DECLINED;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment