unified rrd locks
Costa Tsaousis (ktsaou) committed
Feb 19, 2017 at 14:43 UTC
35c1abbdc2833089667ffde39813d103e65dd54d
7 files changed
+87
-90
src/backends.c
+2
-2
@@ -314,7 +314,7 @@ void *backends_main(void *ptr) {
314
for(st = host->rrdset_root; st; st = st->next) {
315
// for each chart
316
317
- pthread_rwlock_rdlock(&st->rwlock);
317
+ rrdset_rdlock(st);
318
319
RRDDIM *rd;
320
for(rd = st->dimensions; rd; rd = rd->next) {
@@ -324,7 +324,7 @@ void *backends_main(void *ptr) {
324
chart_buffered_metrics += backend_request_formatter(b, prefix, host, (host == localhost)?hostname:host->hostname, st, rd, after, before, options);
325
}
326
327
- pthread_rwlock_unlock(&st->rwlock);
327
+ rrdset_unlock(st);
328
}
329
330
rrdhost_unlock(host);
src/health.c
+3
-3
@@ -1101,7 +1101,7 @@ void health_reload_host(RRDHOST *host) {
1101
char *path = health_config_dir();
1102
1103
// free all running alarms
1104
- rrdhost_rwlock(host);
1104
+ rrdhost_wrlock(host);
1105
health_free_host_nolock(host);
1106
rrdhost_unlock(host);
1107
@@ -1120,13 +1120,13 @@ void health_reload_host(RRDHOST *host) {
1120
}
1121
1122
// load the new alarms
1123
- rrdhost_rwlock(host);
1123
+ rrdhost_wrlock(host);
1124
health_readdir(host, path);
1125
rrdhost_unlock(host);
1126
1127
// link the loaded alarms to their charts
1128
for(st = host->rrdset_root; st ; st = st->next) {
1129
- rrdhost_rwlock(host);
1129
+ rrdhost_wrlock(host);
1130
1131
rrdsetcalc_link_matching(st);
1132
rrdcalctemplate_link_matching(st);
src/rrd.h
+12
-8
@@ -251,7 +251,7 @@ struct rrdset {
251
char *cache_dir; // the directory to store dimensions
252
char cache_filename[FILENAME_MAX+1]; // the filename to store this set
253
254
- pthread_rwlock_t rwlock;
254
+ pthread_rwlock_t rrdset_rwlock;
255
256
unsigned long counter; // the number of times we added values to this rrd
257
unsigned long counter_done; // the number of times we added values to this rrd
@@ -300,6 +300,10 @@ struct rrdset {
300
};
301
typedef struct rrdset RRDSET;
302
303
+#define rrdset_rdlock(st) pthread_rwlock_rdlock(&((st)->rrdset_rwlock))
304
+#define rrdset_wrlock(st) pthread_rwlock_wrlock(&((st)->rrdset_rwlock))
305
+#define rrdset_unlock(st) pthread_rwlock_unlock(&((st)->rrdset_rwlock))
306
+
307
// ----------------------------------------------------------------------------
308
// RRD HOST
309
@@ -319,7 +323,8 @@ struct rrdhost {
323
RRD_MEMORY_MODE rrd_memory_mode; // the memory more for the charts of this host
324
325
RRDSET *rrdset_root; // the host charts
322
- pthread_rwlock_t rrdset_root_rwlock; // lock for the host charts
326
+
327
+ pthread_rwlock_t rrdhost_rwlock; // lock for this RRDHOST
328
329
avl_tree_lock rrdset_root_index; // the host's charts index (by id)
330
avl_tree_lock rrdset_root_index_name; // the host's charts index (by name)
@@ -352,17 +357,20 @@ struct rrdhost {
357
struct rrdhost *next;
358
};
359
typedef struct rrdhost RRDHOST;
355
-
360
extern RRDHOST *localhost;
361
362
+#define rrdhost_rdlock(h) pthread_rwlock_rdlock(&((h)->rrdhost_rwlock))
363
+#define rrdhost_wrlock(h) pthread_rwlock_wrlock(&((h)->rrdhost_rwlock))
364
+#define rrdhost_unlock(h) pthread_rwlock_unlock(&((h)->rrdhost_rwlock))
365
+
366
extern void rrd_init(char *hostname);
367
368
extern RRDHOST *rrdhost_find(const char *guid, uint32_t hash);
369
extern RRDHOST *rrdhost_find_or_create(const char *hostname, const char *guid);
370
371
#ifdef NETDATA_INTERNAL_CHECKS
364
-#define rrdhost_check_wrlock(host) rrdhost_check_wrlock_int(host, __FILE__, __FUNCTION__, __LINE__)
372
#define rrdhost_check_rdlock(host) rrdhost_check_rdlock_int(host, __FILE__, __FUNCTION__, __LINE__)
373
+#define rrdhost_check_wrlock(host) rrdhost_check_wrlock_int(host, __FILE__, __FUNCTION__, __LINE__)
374
#else
375
#define rrdhost_check_rdlock(host) (void)0
376
#define rrdhost_check_wrlock(host) (void)0
@@ -371,10 +379,6 @@ extern RRDHOST *rrdhost_find_or_create(const char *hostname, const char *guid);
379
extern void rrdhost_check_wrlock_int(RRDHOST *host, const char *file, const char *function, const unsigned long line);
380
extern void rrdhost_check_rdlock_int(RRDHOST *host, const char *file, const char *function, const unsigned long line);
381
374
-extern void rrdhost_rwlock(RRDHOST *host);
375
-extern void rrdhost_rdlock(RRDHOST *host);
376
-extern void rrdhost_unlock(RRDHOST *host);
377
-
382
// ----------------------------------------------------------------------------
383
// RRDSET functions
384
src/rrd2json.c
+23
-21
@@ -2,7 +2,7 @@
2
3
void rrd_stats_api_v1_chart_with_data(RRDSET *st, BUFFER *wb, size_t *dimensions_count, size_t *memory_used)
4
{
5
- pthread_rwlock_rdlock(&st->rwlock);
5
+ rrdset_rdlock(st);
6
7
buffer_sprintf(wb,
8
"\t\t{\n"
@@ -71,7 +71,7 @@ void rrd_stats_api_v1_chart_with_data(RRDSET *st, BUFFER *wb, size_t *dimensions
71
"\n\t\t}"
72
);
73
74
- pthread_rwlock_unlock(&st->rwlock);
74
+ rrdset_unlock(st);
75
}
76
77
void rrd_stats_api_v1_chart(RRDSET *st, BUFFER *wb) {
@@ -97,7 +97,7 @@ void rrd_stats_api_v1_charts(RRDHOST *host, BUFFER *wb)
97
, host->rrd_history_entries
98
);
99
100
- pthread_rwlock_rdlock(&host->rrdset_root_rwlock);
100
+ rrdhost_rdlock(host);
101
for(st = host->rrdset_root, c = 0; st ; st = st->next) {
102
if(rrdset_flag_check(st, RRDSET_FLAG_ENABLED) && st->dimensions) {
103
if(c) buffer_strcat(wb, ",");
@@ -114,7 +114,7 @@ void rrd_stats_api_v1_charts(RRDHOST *host, BUFFER *wb)
114
if(rc->rrdset)
115
alarms++;
116
}
117
- pthread_rwlock_unlock(&host->rrdset_root_rwlock);
117
+ rrdhost_unlock(host);
118
119
buffer_sprintf(wb, "\n\t}"
120
",\n\t\"charts_count\": %zu"
@@ -150,7 +150,7 @@ static inline size_t prometheus_name_copy(char *d, const char *s, size_t usable)
150
#define PROMETHEUS_ELEMENT_MAX 256
151
152
void rrd_stats_api_v1_charts_allmetrics_prometheus(RRDHOST *host, BUFFER *wb) {
153
- pthread_rwlock_rdlock(&host->rrdset_root_rwlock);
153
+ rrdhost_rdlock(host);
154
155
char hostname[PROMETHEUS_ELEMENT_MAX + 1];
156
prometheus_name_copy(hostname, config_get("global", "hostname", "localhost"), PROMETHEUS_ELEMENT_MAX);
@@ -163,7 +163,7 @@ void rrd_stats_api_v1_charts_allmetrics_prometheus(RRDHOST *host, BUFFER *wb) {
163
164
buffer_strcat(wb, "\n");
165
if(rrdset_flag_check(st, RRDSET_FLAG_ENABLED) && st->dimensions) {
166
- pthread_rwlock_rdlock(&st->rwlock);
166
+ rrdset_rdlock(st);
167
168
// for each dimension
169
RRDDIM *rd;
@@ -196,11 +196,11 @@ void rrd_stats_api_v1_charts_allmetrics_prometheus(RRDHOST *host, BUFFER *wb) {
196
}
197
}
198
199
- pthread_rwlock_unlock(&st->rwlock);
199
+ rrdset_unlock(st);
200
}
201
}
202
203
- pthread_rwlock_unlock(&host->rrdset_root_rwlock);
203
+ rrdhost_unlock(host);
204
}
205
206
// ----------------------------------------------------------------------------
@@ -224,7 +224,7 @@ static inline size_t shell_name_copy(char *d, const char *s, size_t usable) {
224
#define SHELL_ELEMENT_MAX 100
225
226
void rrd_stats_api_v1_charts_allmetrics_shell(RRDHOST *host, BUFFER *wb) {
227
- pthread_rwlock_rdlock(&host->rrdset_root_rwlock);
227
+ rrdhost_rdlock(host);
228
229
// for each chart
230
RRDSET *st;
@@ -235,7 +235,7 @@ void rrd_stats_api_v1_charts_allmetrics_shell(RRDHOST *host, BUFFER *wb) {
235
236
buffer_sprintf(wb, "\n# chart: %s (name: %s)\n", st->id, st->name);
237
if(rrdset_flag_check(st, RRDSET_FLAG_ENABLED) && st->dimensions) {
238
- pthread_rwlock_rdlock(&st->rwlock);
238
+ rrdset_rdlock(st);
239
240
// for each dimension
241
RRDDIM *rd;
@@ -259,7 +259,7 @@ void rrd_stats_api_v1_charts_allmetrics_shell(RRDHOST *host, BUFFER *wb) {
259
260
total = roundl(total);
261
buffer_sprintf(wb, "NETDATA_%s_VISIBLETOTAL=\"%0.0Lf\" # %s\n", chart, total, st->units);
262
- pthread_rwlock_unlock(&st->rwlock);
262
+ rrdset_unlock(st);
263
}
264
}
265
@@ -287,7 +287,7 @@ void rrd_stats_api_v1_charts_allmetrics_shell(RRDHOST *host, BUFFER *wb) {
287
buffer_sprintf(wb, "NETDATA_ALARM_%s_%s_STATUS=\"%s\"\n", chart, alarm, rrdcalc_status2string(rc->status));
288
}
289
290
- pthread_rwlock_unlock(&host->rrdset_root_rwlock);
290
+ rrdhost_unlock(host);
291
}
292
293
// ----------------------------------------------------------------------------
@@ -296,7 +296,7 @@ unsigned long rrd_stats_one_json(RRDSET *st, char *options, BUFFER *wb)
296
{
297
time_t now = now_realtime_sec();
298
299
- pthread_rwlock_rdlock(&st->rwlock);
299
+ rrdset_rdlock(st);
300
301
buffer_sprintf(wb,
302
"\t\t{\n"
@@ -394,7 +394,7 @@ unsigned long rrd_stats_one_json(RRDSET *st, char *options, BUFFER *wb)
394
, memory
395
);
396
397
- pthread_rwlock_unlock(&st->rwlock);
397
+ rrdset_unlock(st);
398
return memory;
399
}
400
@@ -416,7 +416,8 @@ void rrd_stats_all_json(RRDHOST *host, BUFFER *wb)
416
417
buffer_strcat(wb, RRD_GRAPH_JSON_HEADER);
418
419
- pthread_rwlock_rdlock(&host->rrdset_root_rwlock);
419
+ rrdhost_rdlock(host);
420
+
421
for(st = host->rrdset_root, c = 0; st ; st = st->next) {
422
if(rrdset_flag_check(st, RRDSET_FLAG_ENABLED) && st->dimensions) {
423
if(c) buffer_strcat(wb, ",\n");
@@ -424,7 +425,6 @@ void rrd_stats_all_json(RRDHOST *host, BUFFER *wb)
425
c++;
426
}
427
}
427
- pthread_rwlock_unlock(&host->rrdset_root_rwlock);
428
429
buffer_sprintf(wb, "\n\t],\n"
430
"\t\"hostname\": \"%s\",\n"
@@ -437,6 +437,8 @@ void rrd_stats_all_json(RRDHOST *host, BUFFER *wb)
437
, host->rrd_history_entries
438
, memory
439
);
440
+
441
+ rrdhost_unlock(host);
442
}
443
444
@@ -1344,7 +1346,7 @@ inline static void rrdr_lock_rrdset(RRDR *r) {
1346
return;
1347
}
1348
1347
- pthread_rwlock_rdlock(&r->st->rwlock);
1349
+ rrdset_rdlock(r->st);
1350
r->has_st_lock = 1;
1351
}
1352
@@ -1355,7 +1357,7 @@ inline static void rrdr_unlock_rrdset(RRDR *r) {
1357
}
1358
1359
if(likely(r->has_st_lock)) {
1358
- pthread_rwlock_unlock(&r->st->rwlock);
1360
+ rrdset_unlock(r->st);
1361
r->has_st_lock = 0;
1362
}
1363
}
@@ -1992,7 +1994,7 @@ int rrd2format(RRDSET *st, BUFFER *wb, BUFFER *dimensions, uint32_t format, long
1994
time_t rrd_stats_json(int type, RRDSET *st, BUFFER *wb, long points, long group, int group_method, time_t after, time_t before, int only_non_zero)
1995
{
1996
int c;
1995
- pthread_rwlock_rdlock(&st->rwlock);
1997
+ rrdset_rdlock(st);
1998
1999
2000
// -------------------------------------------------------------------------
@@ -2036,7 +2038,7 @@ time_t rrd_stats_json(int type, RRDSET *st, BUFFER *wb, long points, long group,
2038
RRDDIM *rd;
2039
for( rd = st->dimensions ; rd ; rd = rd->next) dimensions++;
2040
if(!dimensions) {
2039
- pthread_rwlock_unlock(&st->rwlock);
2041
+ rrdset_unlock(st);
2042
buffer_strcat(wb, "No dimensions yet.");
2043
return 0;
2044
}
@@ -2309,6 +2311,6 @@ time_t rrd_stats_json(int type, RRDSET *st, BUFFER *wb, long points, long group,
2311
2312
debug(D_RRD_STATS, "RRD_STATS_JSON: %s total %zu bytes", st->name, wb->len);
2313
2312
- pthread_rwlock_unlock(&st->rwlock);
2314
+ rrdset_unlock(st);
2315
return last_timestamp;
2316
}
src/rrddim.c
+2
-2
@@ -178,7 +178,7 @@ RRDDIM *rrddim_add(RRDSET *st, const char *id, const char *name, collected_numbe
178
rd->rrdset = st;
179
180
// append this dimension
181
- pthread_rwlock_wrlock(&st->rwlock);
181
+ rrdset_wrlock(st);
182
if(!st->dimensions)
183
st->dimensions = rd;
184
else {
@@ -193,7 +193,7 @@ RRDDIM *rrddim_add(RRDSET *st, const char *id, const char *name, collected_numbe
193
rrddimvar_create(rd, RRDVAR_TYPE_TIME_T, NULL, "_last_collected_t", &rd->last_collected_time.tv_sec, 0);
194
}
195
196
- pthread_rwlock_unlock(&st->rwlock);
196
+ rrdset_unlock(st);
197
198
if(unlikely(rrddim_index_add(st, rd) != rd))
199
error("RRDDIM: INTERNAL ERROR: attempt to index duplicate dimension '%s' on chart '%s'", rd->id, st->id);
src/rrdhost.c
+34
-42
@@ -65,7 +65,7 @@ RRDHOST *rrdhost_create(const char *hostname,
65
host->rrd_memory_mode = memory_mode;
66
host->health_enabled = health_enabled;
67
68
- pthread_rwlock_init(&(host->rrdset_root_rwlock), NULL);
68
+ pthread_rwlock_init(&(host->rrdhost_rwlock), NULL);
69
70
rrdhost_init_hostname(host, hostname);
71
rrdhost_init_machine_guid(host, guid);
@@ -144,7 +144,7 @@ RRDHOST *rrdhost_create(const char *hostname,
144
health_alarm_log_load(host);
145
health_alarm_log_open(host);
146
147
- rrdhost_rwlock(host);
147
+ rrdhost_wrlock(host);
148
health_readdir(host, health_config_dir());
149
rrdhost_unlock(host);
150
@@ -191,45 +191,34 @@ void rrd_init(char *hostname) {
191
}
192
193
// ----------------------------------------------------------------------------
194
-// RRDHOST - locks
195
-
196
-void rrdhost_rwlock(RRDHOST *host) {
197
- debug(D_RRDHOST, "Write lock host '%s'", host->hostname);
198
- pthread_rwlock_wrlock(&host->rrdset_root_rwlock);
199
-}
200
-
201
-void rrdhost_rdlock(RRDHOST *host) {
202
- debug(D_RRDHOST, "Read lock host '%s'", host->hostname);
203
- pthread_rwlock_rdlock(&host->rrdset_root_rwlock);
204
-}
205
-
206
-void rrdhost_unlock(RRDHOST *host) {
207
- debug(D_RRDHOST, "Unlock host '%s'", host->hostname);
208
- pthread_rwlock_unlock(&host->rrdset_root_rwlock);
209
-}
194
+// RRDHOST - lock validations
195
+// there are only used when NETDATA_INTERNAL_CHECKS is set
196
197
void rrdhost_check_rdlock_int(RRDHOST *host, const char *file, const char *function, const unsigned long line) {
212
- debug(D_RRDHOST, "Read lock host '%s'", host->hostname);
198
+ debug(D_RRDHOST, "Checking read lock on host '%s'", host->hostname);
199
214
- int ret = pthread_rwlock_trywrlock(&host->rrdset_root_rwlock);
200
+ int ret = pthread_rwlock_trywrlock(&host->rrdhost_rwlock);
201
if(ret == 0)
202
fatal("RRDHOST '%s' should be read-locked, but it is not, at function %s() at line %lu of file '%s'", host->hostname, function, line, file);
203
}
204
205
void rrdhost_check_wrlock_int(RRDHOST *host, const char *file, const char *function, const unsigned long line) {
220
- debug(D_RRDHOST, "Write lock host '%s'", host->hostname);
206
+ debug(D_RRDHOST, "Checking write lock on host '%s'", host->hostname);
207
222
- int ret = pthread_rwlock_tryrdlock(&host->rrdset_root_rwlock);
208
+ int ret = pthread_rwlock_tryrdlock(&host->rrdhost_rwlock);
209
if(ret == 0)
210
fatal("RRDHOST '%s' should be write-locked, but it is not, at function %s() at line %lu of file '%s'", host->hostname, function, line, file);
211
}
212
213
+// ----------------------------------------------------------------------------
214
+// RRDHOST - free
215
+
216
void rrdhost_free(RRDHOST *host) {
217
if(!host) return;
218
219
info("Freeing all memory for host '%s'...", host->hostname);
220
232
- rrdhost_rwlock(host);
221
+ rrdhost_wrlock(host);
222
223
RRDSET *st;
224
for(st = host->rrdset_root; st ;) {
@@ -256,6 +245,25 @@ void rrdhost_free(RRDHOST *host) {
245
info("Host memory cleanup completed...");
246
}
247
248
+void rrdhost_free_all(void) {
249
+ RRDHOST *host = localhost;
250
+
251
+ // FIXME: lock all hosts
252
+
253
+ while(host) {
254
+ RRDHOST *next = host = host->next;
255
+ rrdhost_free(host);
256
+ host = next;
257
+ }
258
+
259
+ localhost = NULL;
260
+
261
+ // FIXME: unlock all hosts
262
+}
263
+
264
+// ----------------------------------------------------------------------------
265
+// RRDHOST - save
266
+
267
void rrdhost_save(RRDHOST *host) {
268
if(!host) return;
269
@@ -266,10 +274,10 @@ void rrdhost_save(RRDHOST *host) {
274
275
// we get a write lock
276
// to ensure only one thread is saving the database
269
- rrdhost_rwlock(host);
277
+ rrdhost_wrlock(host);
278
279
for(st = host->rrdset_root; st ; st = st->next) {
272
- pthread_rwlock_rdlock(&st->rwlock);
280
+ rrdset_rdlock(st);
281
282
if(st->rrd_memory_mode == RRD_MEMORY_MODE_SAVE) {
283
debug(D_RRD_STATS, "Saving stats '%s' to '%s'.", st->name, st->cache_filename);
@@ -283,28 +291,12 @@ void rrdhost_save(RRDHOST *host) {
291
}
292
}
293
286
- pthread_rwlock_unlock(&st->rwlock);
294
+ rrdset_unlock(st);
295
}
296
297
rrdhost_unlock(host);
298
}
299
292
-void rrdhost_free_all(void) {
293
- RRDHOST *host = localhost;
294
-
295
- // FIXME: lock all hosts
296
-
297
- while(host) {
298
- RRDHOST *next = host = host->next;
299
- rrdhost_free(host);
300
- host = next;
301
- }
302
-
303
- localhost = NULL;
304
-
305
- // FIXME: unlock all hosts
306
-}
307
-
300
void rrdhost_save_all(void) {
301
info("Saving database...");
302
src/rrdset.c
+11
-12
@@ -100,7 +100,6 @@ inline RRDSET *rrdset_find_byname(RRDHOST *host, const char *name) {
100
return(st);
101
}
102
103
-
103
// ----------------------------------------------------------------------------
104
// RRDSET - rename charts
105
@@ -142,11 +141,11 @@ void rrdset_set_name(RRDSET *st, const char *name) {
141
st->hash_name = simple_hash(st->name);
142
}
143
145
- pthread_rwlock_wrlock(&st->rwlock);
144
+ rrdset_wrlock(st);
145
RRDDIM *rd;
146
for(rd = st->dimensions; rd ;rd = rd->next)
147
rrddimvar_rename_all(rd);
149
- pthread_rwlock_unlock(&st->rwlock);
148
+ rrdset_unlock(st);
149
150
if(unlikely(rrdset_index_add_name(st->rrdhost, st) != st))
151
error("RRDSET: INTERNAL ERROR: attempted to index duplicate chart name '%s'", st->name);
@@ -210,7 +209,7 @@ static inline void timeval_align(struct timeval *tv, int update_every) {
209
// RRDSET - free a chart
210
211
void rrdset_free(RRDSET *st) {
213
- pthread_rwlock_wrlock(&st->rwlock);
212
+ rrdset_wrlock(st);
213
214
while(st->variables) rrdsetvar_free(st->variables);
215
while(st->alarms) rrdsetcalc_unlink(st->alarms);
@@ -225,7 +224,7 @@ void rrdset_free(RRDSET *st) {
224
if(!st->rrdfamily->use_count)
225
rrdfamily_free(st->rrdhost, st->rrdfamily);
226
228
- pthread_rwlock_unlock(&st->rwlock);
227
+ rrdset_unlock(st);
228
229
// free directly allocated memory
230
freez(st->config_section);
@@ -304,7 +303,7 @@ RRDSET *rrdset_create(RRDHOST *host, const char *type, const char *id, const cha
303
memset(&st->avlname, 0, sizeof(avl));
304
memset(&st->variables_root_index, 0, sizeof(avl_tree_lock));
305
memset(&st->dimensions_index, 0, sizeof(avl_tree_lock));
307
- memset(&st->rwlock, 0, sizeof(pthread_rwlock_t));
306
+ memset(&st->rrdset_rwlock, 0, sizeof(pthread_rwlock_t));
307
308
st->name = NULL;
309
st->type = NULL;
@@ -413,8 +412,8 @@ RRDSET *rrdset_create(RRDHOST *host, const char *type, const char *id, const cha
412
avl_init_lock(&st->dimensions_index, rrddim_compare);
413
avl_init_lock(&st->variables_root_index, rrdvar_compare);
414
416
- pthread_rwlock_init(&st->rwlock, NULL);
417
- rrdhost_rwlock(host);
415
+ pthread_rwlock_init(&st->rrdset_rwlock, NULL);
416
+ rrdhost_wrlock(host);
417
418
if(name && *name) rrdset_set_name(st, name);
419
else rrdset_set_name(st, id);
@@ -544,7 +543,7 @@ usec_t rrdset_done(RRDSET *st) {
543
error("Cannot set pthread cancel state to DISABLE.");
544
545
// a read lock is OK here
547
- pthread_rwlock_rdlock(&st->rwlock);
546
+ rrdset_rdlock(st);
547
548
/*
549
// enable the chart, if it was disabled
@@ -1072,8 +1071,8 @@ usec_t rrdset_done(RRDSET *st) {
1071
RRDDIM *last;
1072
// there is dimension to free
1073
// upgrade our read lock to a write lock
1075
- pthread_rwlock_unlock(&st->rwlock);
1076
- pthread_rwlock_wrlock(&st->rwlock);
1074
+ pthread_rwlock_unlock(&st->rrdset_rwlock);
1075
+ pthread_rwlock_wrlock(&st->rrdset_rwlock);
1076
1077
for( rd = st->dimensions, last = NULL ; likely(rd) ; ) {
1078
// remove it only it is not updated in rrd_delete_unupdated_dimensions seconds
@@ -1109,7 +1108,7 @@ usec_t rrdset_done(RRDSET *st) {
1108
}
1109
*/
1110
1112
- pthread_rwlock_unlock(&st->rwlock);
1111
+ rrdset_unlock(st);
1112
1113
if(unlikely(pthread_setcancelstate(pthreadoldcancelstate, NULL) != 0))
1114
error("Cannot set pthread cancel state to RESTORE (%d).", pthreadoldcancelstate);