diff --git a/src/cache.c b/src/cache.c index 3c74938..f04b70d 100644 --- a/src/cache.c +++ b/src/cache.c @@ -68,6 +68,7 @@ int cache_process() { int compress; SHA_CTX ctx; unsigned char hash[SHA_DIGEST_LENGTH]; + int cache_changed = 0; while (cache_continue) { for (int i = 0; i < FILE_CACHE_SIZE; i++) { if (cache[i].filename[0] != 0 && cache[i].meta.etag[0] == 0 && !cache[i].is_updating) { @@ -141,13 +142,17 @@ int cache_process() { } fclose(file); cache[i].is_updating = 0; + cache_changed = 1; } } - cache_file = fopen("/var/necronda-server/cache", "wb"); - fwrite(cache, sizeof(cache_entry), FILE_CACHE_SIZE , cache_file); - fclose(cache_file); - sleep(1); + if (cache_changed) { + cache_file = fopen("/var/necronda-server/cache", "wb"); + fwrite(cache, sizeof(cache_entry), FILE_CACHE_SIZE, cache_file); + fclose(cache_file); + } else { + sleep(1); + } } return 0; } diff --git a/src/config.c b/src/config.c index 47a0cd9..89e3024 100644 --- a/src/config.c +++ b/src/config.c @@ -175,9 +175,17 @@ int config_load(const char *filename) { tmp_config[i - 1].rev_proxy.port = (unsigned short) strtoul(source, NULL, 10); } } - free(conf); + for (int j = 0; j < i - 1; j++) { + if (tmp_config[j].type == CONFIG_TYPE_LOCAL) { + char *webroot = tmp_config[j].local.webroot; + if (webroot[strlen(webroot) - 1] == '/') { + webroot[strlen(webroot) - 1] = 0; + } + } + } + int shm_id = shmget(SHM_KEY_CONFIG, 0, 0); if (shm_id < 0) { fprintf(stderr, ERR_STR "Unable to get shared memory id: %s" CLR_STR "\n", strerror(errno));