diff options
author | Stelios Fragkakis <52996999+stelfrag@users.noreply.github.com> | 2021-03-23 14:41:53 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-23 14:41:53 +0200 |
commit | 0f78020f043c184a0d292e2247d12649ad3ebaea (patch) | |
tree | c086acca601d107319ebb2bb262db550a1ebc14e | |
parent | 5c19ffa98bd571d6829c2c7ff0c29576a835834b (diff) |
Add lock check to avoid shutdown when compiled with internal and locking checks (#10835)
-rw-r--r-- | web/api/formatters/value/value.c | 3 | ||||
-rw-r--r-- | web/api/queries/rrdr.c | 6 | ||||
-rw-r--r-- | web/api/queries/rrdr.h | 1 |
3 files changed, 7 insertions, 3 deletions
diff --git a/web/api/formatters/value/value.c b/web/api/formatters/value/value.c index aea6c162b0..a69af61658 100644 --- a/web/api/formatters/value/value.c +++ b/web/api/formatters/value/value.c @@ -4,7 +4,8 @@ inline calculated_number rrdr2value(RRDR *r, long i, RRDR_OPTIONS options, int *all_values_are_null) { - rrdset_check_rdlock(r->st); + if (r->st_needs_lock) + rrdset_check_rdlock(r->st); long c; RRDDIM *d; diff --git a/web/api/queries/rrdr.c b/web/api/queries/rrdr.c index 9d28ae9e85..b64868222d 100644 --- a/web/api/queries/rrdr.c +++ b/web/api/queries/rrdr.c @@ -100,7 +100,7 @@ inline void rrdr_free(RRDR *r) RRDR *rrdr_create(struct rrdset *st, long n, struct context_param *context_param_list) { - if(unlikely(!st)) { + if (unlikely(!st)) { error("NULL value given!"); return NULL; } @@ -108,8 +108,10 @@ RRDR *rrdr_create(struct rrdset *st, long n, struct context_param *context_param RRDR *r = callocz(1, sizeof(RRDR)); r->st = st; - if (!context_param_list || (context_param_list && !(context_param_list->flags & CONTEXT_FLAGS_ARCHIVE))) + if (!context_param_list || !(context_param_list->flags & CONTEXT_FLAGS_ARCHIVE)) { rrdr_lock_rrdset(r); + r->st_needs_lock = 1; + } RRDDIM *temp_rd = context_param_list ? context_param_list->rd : NULL; RRDDIM *rd; diff --git a/web/api/queries/rrdr.h b/web/api/queries/rrdr.h index 4d349c3050..d95c108575 100644 --- a/web/api/queries/rrdr.h +++ b/web/api/queries/rrdr.h @@ -73,6 +73,7 @@ typedef struct rrdresult { time_t after; int has_st_lock; // if st is read locked by us + uint8_t st_needs_lock; // if ST should be locked // internal rrd2rrdr() members below this point struct { |