From 45fbe937d7ca8d0da9ea276d57bc70ebd41c285e Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 17 May 2013 03:13:58 +0200 Subject: bus: add minimal locking around the memfd cache We want to allow clients to process an sd_bus_message on a different thread than it was received on. Since unreffing a bus message might readd some of its memfds to the memfd cache add some minimal locking around the cache. --- src/libsystemd-bus/bus-internal.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/libsystemd-bus/bus-internal.h') diff --git a/src/libsystemd-bus/bus-internal.h b/src/libsystemd-bus/bus-internal.h index b6975c54a2..8f87bea781 100644 --- a/src/libsystemd-bus/bus-internal.h +++ b/src/libsystemd-bus/bus-internal.h @@ -24,6 +24,7 @@ #include #include #include +#include #include "hashmap.h" #include "prioq.h" @@ -169,6 +170,13 @@ struct sd_bus { void *kdbus_buffer; + /* We do locking around the memfd cache, since we want to + * allow people to process a sd_bus_message in a different + * thread then it was generated on and free it there. Since + * adding something to the memfd cache might happen when a + * message is released, we hence need to protect this bit with + * a mutex. */ + pthread_mutex_t memfd_cache_mutex; struct memfd_cache memfd_cache[MEMFD_CACHE_MAX]; unsigned n_memfd_cache; -- cgit v1.2.3-54-g00ecf