summaryrefslogtreecommitdiff
path: root/src/bus-proxyd/bus-xml-policy.h
diff options
context:
space:
mode:
authorDavid Herrmann <dh.herrmann@gmail.com>2015-01-17 18:07:58 +0100
committerDavid Herrmann <dh.herrmann@gmail.com>2015-01-17 18:27:23 +0100
commitc4bc1a8434f2a34840ea6f63064fa998ecfae738 (patch)
treec10ae7cfd3864cc74fc83c997baaf45e81215b48 /src/bus-proxyd/bus-xml-policy.h
parentb58d857136496ee463223cd90af46512e9eef152 (diff)
bus-proxy: share policy between threads
This implements a shared policy cache with read-write locks. We no longer parse the XML policy in each thread. This will allow us to easily implement ReloadConfig().
Diffstat (limited to 'src/bus-proxyd/bus-xml-policy.h')
-rw-r--r--src/bus-proxyd/bus-xml-policy.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/bus-proxyd/bus-xml-policy.h b/src/bus-proxyd/bus-xml-policy.h
index 125c84cd6e..762cb663a0 100644
--- a/src/bus-proxyd/bus-xml-policy.h
+++ b/src/bus-proxyd/bus-xml-policy.h
@@ -22,6 +22,7 @@
***/
#include <inttypes.h>
+#include <pthread.h>
#include "list.h"
#include "hashmap.h"
@@ -75,6 +76,15 @@ typedef struct Policy {
Hashmap *group_items;
} Policy;
+typedef struct SharedPolicy {
+ pthread_mutex_t lock;
+ pthread_rwlock_t rwlock;
+ Policy buffer;
+ Policy *policy;
+} SharedPolicy;
+
+/* policy */
+
int policy_load(Policy *p, char **files);
void policy_free(Policy *p);
@@ -106,3 +116,15 @@ PolicyItemType policy_item_type_from_string(const char *s) _pure_;
const char* policy_item_class_to_string(PolicyItemClass t) _const_;
PolicyItemClass policy_item_class_from_string(const char *s) _pure_;
+
+/* shared policy */
+
+int shared_policy_new(SharedPolicy **out);
+SharedPolicy *shared_policy_free(SharedPolicy *sp);
+
+int shared_policy_reload(SharedPolicy *sp, char **configuration);
+int shared_policy_preload(SharedPolicy *sp, char **configuration);
+Policy *shared_policy_acquire(SharedPolicy *sp);
+void shared_policy_release(SharedPolicy *sp, Policy *p);
+
+DEFINE_TRIVIAL_CLEANUP_FUNC(SharedPolicy*, shared_policy_free);