]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
daemon: improve error reporting related to cache configuration
authorPetr Špaček <petr.spacek@nic.cz>
Tue, 22 Aug 2017 16:20:21 +0000 (18:20 +0200)
committerPetr Špaček <petr.spacek@nic.cz>
Tue, 22 Aug 2017 16:20:21 +0000 (18:20 +0200)
Confusion related to wrong cache configuration is more frequent than it
should be. Hopefully this will enable users to help themselves.

daemon/bindings.c
lib/cache.c
lib/cdb_lmdb.c

index 5930f48aead457dd8a79244b5ce706079ac45d26..6eb95e990a61f1647a156962ef2f9ba314a842b2 100644 (file)
@@ -668,8 +668,12 @@ static int cache_open(lua_State *L)
        };
        int ret = kr_cache_open(&engine->resolver.cache, api, &opts, engine->pool);
        if (ret != 0) {
-               format_error(L, "can't open cache");
-               lua_error(L);
+               char cwd[PATH_MAX];
+               if(getcwd(cwd, sizeof(cwd)) == NULL) {
+                       const char errprefix[] = "<invalid working directory>";
+                       strncpy(cwd, errprefix, sizeof(cwd));
+               }
+               return luaL_error(L, "can't open cache path '%s'; working directory '%s'", opts.path, cwd);
        }
 
        /* Store current configuration */
index c3d793d404f03e5bee4a5b4579389788bfb49035..3ab1e66a17fe480024aaa3045b36970c0e5d8f58 100644 (file)
@@ -63,7 +63,7 @@ static int assert_right_version(struct kr_cache *cache)
                /* Version doesn't match. Recreate cache and write version key. */
                ret = cache_op(cache, count);
                if (ret != 0) { /* Non-empty cache, purge it. */
-                       kr_log_info("[cache] purging cache\n");
+                       kr_log_info("[cache] incompatible cache database detected, purging\n");
                        ret = cache_purge(cache);
                }
                /* Either purged or empty. */
index 444abbfea268879577b3ea9c8e5b5ddb4da97aae..1161872d3058a9075337fccce0a7a6d9cd735c3e 100644 (file)
@@ -52,6 +52,7 @@ static int lmdb_error(int error)
        case ENOSPC:
                return kr_error(ENOSPC);
        default:
+               kr_log_info("[cache] LMDB error: %s\n", mdb_strerror(error));
                return -abs(error);
        }
 }
@@ -220,9 +221,9 @@ static int cdb_init(knot_db_t **db, struct kr_cdb_opts *opts, knot_mm_t *pool)
        auto_free char *lockfile = kr_strcatdup(2, opts->path, "/.cachelock");
        if (lockfile) {
                if (unlink(lockfile) == 0) {
-                       kr_log_info("[system] cache: cleared stale lockfile '%s'\n", lockfile);
+                       kr_log_info("[cache] cleared stale lockfile '%s'\n", lockfile);
                } else if (errno != ENOENT) {
-                       kr_log_info("[system] cache: failed to clear stale lockfile '%s': %s\n", lockfile,
+                       kr_log_info("[cache] failed to clear stale lockfile '%s': %s\n", lockfile,
                                    strerror(errno));
                }
        }