diff options
author | Markos Fountoulakis <44345837+mfundul@users.noreply.github.com> | 2019-10-11 17:39:17 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-11 17:39:17 +0300 |
commit | 6c2bab0543ee8df1df0ef4b4f4633841f6de9d7f (patch) | |
tree | 8d9007204479be3cbb3840a22711c952ecf574e8 /database/rrddim.c | |
parent | af1596e8357d2116f5faf690e1d7f01e2d701eb5 (diff) |
Fix dbengine not working when mmap fails (#7065)
Diffstat (limited to 'database/rrddim.c')
-rw-r--r-- | database/rrddim.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/database/rrddim.c b/database/rrddim.c index 8ab5a72371..32e3cf1e7f 100644 --- a/database/rrddim.c +++ b/database/rrddim.c @@ -217,9 +217,9 @@ RRDDIM *rrddim_add_custom(RRDSET *st, const char *id, const char *name, collecte snprintfz(fullfilename, FILENAME_MAX, "%s/%s.db", st->cache_dir, filename); if(memory_mode == RRD_MEMORY_MODE_SAVE || memory_mode == RRD_MEMORY_MODE_MAP || - memory_mode == RRD_MEMORY_MODE_RAM || memory_mode == RRD_MEMORY_MODE_DBENGINE) { + memory_mode == RRD_MEMORY_MODE_RAM) { rd = (RRDDIM *)mymmap( - (memory_mode == RRD_MEMORY_MODE_RAM || memory_mode == RRD_MEMORY_MODE_DBENGINE)?NULL:fullfilename + (memory_mode == RRD_MEMORY_MODE_RAM) ? NULL : fullfilename , size , ((memory_mode == RRD_MEMORY_MODE_MAP) ? MAP_SHARED : MAP_PRIVATE) , 1 @@ -240,7 +240,7 @@ RRDDIM *rrddim_add_custom(RRDSET *st, const char *id, const char *name, collecte struct timeval now; now_realtime_timeval(&now); - if(memory_mode == RRD_MEMORY_MODE_RAM || memory_mode == RRD_MEMORY_MODE_DBENGINE) { + if(memory_mode == RRD_MEMORY_MODE_RAM) { memset(rd, 0, size); } else { @@ -292,7 +292,10 @@ RRDDIM *rrddim_add_custom(RRDSET *st, const char *id, const char *name, collecte if(unlikely(!rd)) { // if we didn't manage to get a mmap'd dimension, just create one rd = callocz(1, size); - rd->rrd_memory_mode = (memory_mode == RRD_MEMORY_MODE_NONE) ? RRD_MEMORY_MODE_NONE : RRD_MEMORY_MODE_ALLOC; + if (memory_mode == RRD_MEMORY_MODE_DBENGINE) + rd->rrd_memory_mode = RRD_MEMORY_MODE_DBENGINE; + else + rd->rrd_memory_mode = (memory_mode == RRD_MEMORY_MODE_NONE) ? RRD_MEMORY_MODE_NONE : RRD_MEMORY_MODE_ALLOC; } rd->memsize = size; @@ -460,7 +463,6 @@ void rrddim_free(RRDSET *st, RRDDIM *rd) case RRD_MEMORY_MODE_SAVE: case RRD_MEMORY_MODE_MAP: case RRD_MEMORY_MODE_RAM: - case RRD_MEMORY_MODE_DBENGINE: debug(D_RRD_CALLS, "Unmapping dimension '%s'.", rd->name); freez((void *)rd->id); freez(rd->cache_filename); @@ -469,6 +471,7 @@ void rrddim_free(RRDSET *st, RRDDIM *rd) case RRD_MEMORY_MODE_ALLOC: case RRD_MEMORY_MODE_NONE: + case RRD_MEMORY_MODE_DBENGINE: debug(D_RRD_CALLS, "Removing dimension '%s'.", rd->name); freez((void *)rd->id); freez(rd->cache_filename); |