Improved cache idle performance
This commit is contained in:
@ -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,14 +142,18 @@ int cache_process() {
|
||||
}
|
||||
fclose(file);
|
||||
cache[i].is_updating = 0;
|
||||
cache_changed = 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;
|
||||
}
|
||||
|
||||
|
10
src/config.c
10
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));
|
||||
|
Reference in New Issue
Block a user