]> git.kaiwu.me - nginx.git/commitdiff
Cache: improved keys zone size error reporting.
authorMaxim Dounin <mdounin@mdounin.ru>
Wed, 31 Oct 2018 13:49:40 +0000 (16:49 +0300)
committerMaxim Dounin <mdounin@mdounin.ru>
Wed, 31 Oct 2018 13:49:40 +0000 (16:49 +0300)
After this change, too small keys zones are explicitly reported as such,
much like in the other modules which use shared memory.

src/http/ngx_http_file_cache.c

index 2cf1ce4a9c82d4af49bbdc9575327b44a9d7112d..ecdf11e28797cad8b12e841cae325ac853ef31d8 100644 (file)
@@ -2418,23 +2418,32 @@ ngx_http_file_cache_set_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
 
             p = (u_char *) ngx_strchr(name.data, ':');
 
-            if (p) {
-                name.len = p - name.data;
+            if (p == NULL) {
+                ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
+                                   "invalid keys zone size \"%V\"", &value[i]);
+                return NGX_CONF_ERROR;
+            }
 
-                p++;
+            name.len = p - name.data;
 
-                s.len = value[i].data + value[i].len - p;
-                s.data = p;
+            s.data = p + 1;
+            s.len = value[i].data + value[i].len - s.data;
 
-                size = ngx_parse_size(&s);
-                if (size >= (ssize_t) (2 * ngx_pagesize)) {
-                    continue;
-                }
+            size = ngx_parse_size(&s);
+
+            if (size == NGX_ERROR) {
+                ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
+                                   "invalid keys zone size \"%V\"", &value[i]);
+                return NGX_CONF_ERROR;
             }
 
-            ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
-                               "invalid keys zone size \"%V\"", &value[i]);
-            return NGX_CONF_ERROR;
+            if (size < (ssize_t) (2 * ngx_pagesize)) {
+                ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
+                                   "keys zone \"%V\" is too small", &value[i]);
+                return NGX_CONF_ERROR;
+            }
+
+            continue;
         }
 
         if (ngx_strncmp(value[i].data, "inactive=", 9) == 0) {