-#define rrd_rdlock() pthread_rwlock_rdlock(&rrd_rwlock)
-#define rrd_wrlock() pthread_rwlock_wrlock(&rrd_rwlock)
-#define rrd_unlock() pthread_rwlock_unlock(&rrd_rwlock)
+
+static inline void rrd_rdlock() {
+ if(unlikely(pthread_rwlock_rdlock(&rrd_rwlock) != 0))
+ error("Cannot read lock the RRD database.");
+}
+
+static inline void rrd_wrlock() {
+ if(unlikely(pthread_rwlock_wrlock(&rrd_rwlock) != 0))
+ error("Cannot write lock the RRD database.");
+}
+
+static inline void rrd_unlock() {
+ if(unlikely(pthread_rwlock_unlock(&rrd_rwlock) != 0))
+ error("Cannot unlock the RRD database.");
+}
+
+static inline void rrdset_rdlock(RRDSET *st) {
+ if(unlikely(pthread_rwlock_rdlock(&st->rrdset_rwlock) != 0))
+ error("Cannot read lock RRDSET '%s' of host '%s'", st->id, st->rrdhost->hostname);
+}
+
+static inline void rrdset_wrlock(RRDSET *st) {
+ if(unlikely(pthread_rwlock_wrlock(&st->rrdset_rwlock) != 0))
+ error("Cannot write lock RRDSET '%s' of host '%s'", st->id, st->rrdhost->hostname);
+}
+
+static inline void rrdset_unlock(RRDSET *st) {
+ if(unlikely(pthread_rwlock_unlock(&st->rrdset_rwlock) != 0))
+ error("Cannot unlock RRDSET '%s' of host '%s'", st->id, st->rrdhost->hostname);
+}