@cryptotaxi247 / netdata-1 / commits / 0f78020f0

Add lock check to avoid shutdown when compiled with internal and locking checks (#10835)

Stelios Fragkakis committed Mar 23, 2021 at 14:41 UTC 0f78020f043c184a0d292e2247d12649ad3ebaea
3 files changed +7 -3
web/api/formatters/value/value.c
+2 -1
@@ -4,7 +4,8 @@
4
5
6 inline calculated_number rrdr2value(RRDR *r, long i, RRDR_OPTIONS options, int *all_values_are_null) {
7 - rrdset_check_rdlock(r->st);
7 + if (r->st_needs_lock)
8 + rrdset_check_rdlock(r->st);
9
10 long c;
11 RRDDIM *d;
web/api/queries/rrdr.c
+4 -2
@@ -100,7 +100,7 @@ inline void rrdr_free(RRDR *r)
100
101 RRDR *rrdr_create(struct rrdset *st, long n, struct context_param *context_param_list)
102 {
103 - if(unlikely(!st)) {
103 + if (unlikely(!st)) {
104 error("NULL value given!");
105 return NULL;
106 }
@@ -108,8 +108,10 @@ RRDR *rrdr_create(struct rrdset *st, long n, struct context_param *context_param
108 RRDR *r = callocz(1, sizeof(RRDR));
109 r->st = st;
110
111 - if (!context_param_list || (context_param_list && !(context_param_list->flags & CONTEXT_FLAGS_ARCHIVE)))
111 + if (!context_param_list || !(context_param_list->flags & CONTEXT_FLAGS_ARCHIVE)) {
112 rrdr_lock_rrdset(r);
113 + r->st_needs_lock = 1;
114 + }
115
116 RRDDIM *temp_rd = context_param_list ? context_param_list->rd : NULL;
117 RRDDIM *rd;
web/api/queries/rrdr.h
+1
@@ -73,6 +73,7 @@ typedef struct rrdresult {
73 time_t after;
74
75 int has_st_lock; // if st is read locked by us
76 + uint8_t st_needs_lock; // if ST should be locked
77
78 // internal rrd2rrdr() members below this point
79 struct {