diff --git a/libc3/facts.c b/libc3/facts.c
index e73069c..7205986 100644
--- a/libc3/facts.c
+++ b/libc3/facts.c
@@ -73,6 +73,7 @@ void facts_clean (s_facts *facts)
skiplist_delete__fact(facts->index_spo);
set_clean__fact(&facts->facts);
set_clean__tag(&facts->tags);
+ pthread_rwlock_destroy(&facts->rwlock);
}
void facts_close (s_facts *facts)
@@ -201,6 +202,8 @@ s_facts * facts_init (s_facts *facts)
assert(facts->index_osp);
facts->index_osp->compare = compare_fact_osp;
facts->log = NULL;
+ if (pthread_rwlock_init(&facts->rwlock, NULL))
+ errx(1, "pthread_rwlock_init");
return facts;
}
diff --git a/libc3/types.h b/libc3/types.h
index c515ed7..216c2ff 100644
--- a/libc3/types.h
+++ b/libc3/types.h
@@ -18,6 +18,7 @@
#include <stdio.h>
#include <sys/types.h>
#include <ffi.h>
+#include <pthread.h>
#include "config.h"
#include "sha1.h"
#include "../libtommath/tommath.h"
@@ -409,6 +410,7 @@ struct facts {
s_skiplist__fact *index_pos;
s_skiplist__fact *index_osp;
s_log *log;
+ pthread_rwlock_t rwlock;
};
struct facts_cursor {