summaryrefslogtreecommitdiff
path: root/lib/northbound.h
diff options
context:
space:
mode:
authorRenato Westphal <renato@opensourcerouting.org>2019-04-03 16:31:18 -0300
committerRenato Westphal <renato@opensourcerouting.org>2019-04-26 18:04:22 -0300
commit83981138fe8c1e0a40b8dede74eca65449dda5de (patch)
treecd22f38c39e38eb1fb9f0dd7354fe19480523fba /lib/northbound.h
parent364ad673c885d741d575e97dbae70bf6d7c8f36e (diff)
lib: introduce a read-write lock for northbound configurations
The upcoming gRPC-based northbound plugin will run on a separate pthread, and it will need to have access to the running configuration global variable. Introduce a rw-lock to control concurrent access to the running configuration. Add the lock inside the "nb_config" structure so that it can be used to protect candidate configurations as well (this might be necessary depending on the threading scheme of future northbound plugins). Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
Diffstat (limited to 'lib/northbound.h')
-rw-r--r--lib/northbound.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/northbound.h b/lib/northbound.h
index dca33b905f..909bb08ebe 100644
--- a/lib/northbound.h
+++ b/lib/northbound.h
@@ -422,8 +422,19 @@ enum nb_client {
/* Northbound configuration. */
struct nb_config {
+ /* Configuration data. */
struct lyd_node *dnode;
+
+ /* Configuration version. */
uint32_t version;
+
+ /*
+ * Lock protecting this structure. The use of this lock is always
+ * necessary when reading or modifying the global running configuration.
+ * For candidate configurations, use of this lock is optional depending
+ * on the threading scheme of the northbound plugin.
+ */
+ pthread_rwlock_t lock;
};
/* Northbound configuration callback. */