Improved cache idle performance
This commit is contained in:
13
src/cache.c
13
src/cache.c
@ -68,6 +68,7 @@ int cache_process() {
|
|||||||
int compress;
|
int compress;
|
||||||
SHA_CTX ctx;
|
SHA_CTX ctx;
|
||||||
unsigned char hash[SHA_DIGEST_LENGTH];
|
unsigned char hash[SHA_DIGEST_LENGTH];
|
||||||
|
int cache_changed = 0;
|
||||||
while (cache_continue) {
|
while (cache_continue) {
|
||||||
for (int i = 0; i < FILE_CACHE_SIZE; i++) {
|
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) {
|
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);
|
fclose(file);
|
||||||
cache[i].is_updating = 0;
|
cache[i].is_updating = 0;
|
||||||
|
cache_changed = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cache_file = fopen("/var/necronda-server/cache", "wb");
|
if (cache_changed) {
|
||||||
fwrite(cache, sizeof(cache_entry), FILE_CACHE_SIZE , cache_file);
|
cache_file = fopen("/var/necronda-server/cache", "wb");
|
||||||
fclose(cache_file);
|
fwrite(cache, sizeof(cache_entry), FILE_CACHE_SIZE, cache_file);
|
||||||
sleep(1);
|
fclose(cache_file);
|
||||||
|
} else {
|
||||||
|
sleep(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
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);
|
tmp_config[i - 1].rev_proxy.port = (unsigned short) strtoul(source, NULL, 10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
free(conf);
|
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);
|
int shm_id = shmget(SHM_KEY_CONFIG, 0, 0);
|
||||||
if (shm_id < 0) {
|
if (shm_id < 0) {
|
||||||
fprintf(stderr, ERR_STR "Unable to get shared memory id: %s" CLR_STR "\n", strerror(errno));
|
fprintf(stderr, ERR_STR "Unable to get shared memory id: %s" CLR_STR "\n", strerror(errno));
|
||||||
|
Reference in New Issue
Block a user