diff options
author | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2011-03-04 14:17:32 +0000 |
---|---|---|
committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2011-03-07 17:48:57 +0000 |
commit | 1f9bfce5a88f03037244b8a85379e46cbc812c6e (patch) | |
tree | ca68fb1c2285b2c46e9e309fda8300fe601dceed | |
parent | 81ca5ee36d115134643d875d325d36e270af85ef (diff) |
Add a configure option to disable the message cache
The option is called "enable" even though the default is on, to avoid
confusing people with double-negatives.
-rw-r--r-- | cmake/CMakeLists.txt | 2 | ||||
-rw-r--r-- | cmake/config.h.cmake | 2 | ||||
-rw-r--r-- | configure.ac | 9 | ||||
-rw-r--r-- | dbus/dbus-message.c | 19 |
4 files changed, 32 insertions, 0 deletions
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 13cdb741..b789eae8 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -94,6 +94,8 @@ endif(NOT WIN32) #AC_ARG_ENABLE(asserts, AS_HELP_STRING([--enable-asserts],[include assertion checks]),enable_asserts=$enableval,enable_asserts=$USE_MAINTAINER_MODE) OPTION(DBUS_DISABLE_ASSERTS "Disable assertion checking" OFF) +OPTION(DBUS_ENABLE_MESSAGE_CACHE "Enable a global message cache" ON) + # do config checks INCLUDE(ConfigureChecks.cmake) diff --git a/cmake/config.h.cmake b/cmake/config.h.cmake index 295e0284..b945c3d5 100644 --- a/cmake/config.h.cmake +++ b/cmake/config.h.cmake @@ -51,6 +51,8 @@ #cmakedefine DBUS_ENABLE_VERBOSE_MODE 1 #cmakedefine DBUS_DISABLE_ASSERTS 1 #cmakedefine DBUS_DISABLE_CHECKS 1 +#cmakedefine DBUS_ENABLE_MESSAGE_CACHE 1 + /* xmldocs */ /* doxygen */ #cmakedefine DBUS_GCOV_ENABLED 1 diff --git a/configure.ac b/configure.ac index 6013699a..f07b607b 100644 --- a/configure.ac +++ b/configure.ac @@ -1622,6 +1622,15 @@ AH_VERBATIM(_DARWIN_ENVIRON, #endif ]) +AC_ARG_ENABLE([message-cache], + [AS_HELP_STRING([--disable-message-cache], + [disable the global DBusMessage cache])], + [], [enable_message_cache=yes]) +if test "x$enable_message_cache" = xyes; then + AC_DEFINE([DBUS_ENABLE_MESSAGE_CACHE], [1], + [Define to use a global DBusMessage cache]) +fi + AC_CONFIG_FILES([ Doxyfile dbus/versioninfo.rc diff --git a/dbus/dbus-message.c b/dbus/dbus-message.c index 22e71a67..0a9a81a6 100644 --- a/dbus/dbus-message.c +++ b/dbus/dbus-message.c @@ -463,7 +463,11 @@ _dbus_message_set_signature (DBusMessage *message, /** Avoid caching too many messages */ #define MAX_MESSAGE_CACHE_SIZE 5 +/* We define this even if the message cache is disabled globally, to avoid + * having to conditionalize it in dbus-threads.c */ _DBUS_DEFINE_GLOBAL_LOCK (message_cache); + +#ifdef DBUS_ENABLE_MESSAGE_CACHE static DBusMessage *message_cache[MAX_MESSAGE_CACHE_SIZE]; static int message_cache_count = 0; static dbus_bool_t message_cache_shutdown_registered = FALSE; @@ -545,6 +549,17 @@ dbus_message_get_cached (void) return message; } +#else /* not DBUS_ENABLE_MESSAGE_CACHE */ + +static inline DBusMessage * +dbus_message_get_cached (void) +{ + return NULL; +} + +#endif /* not DBUS_ENABLE_MESSAGE_CACHE */ + + #ifdef HAVE_UNIX_FD_PASSING static void close_unix_fds(int *fds, unsigned *n_fds) @@ -596,6 +611,7 @@ free_counter (void *element, static void dbus_message_cache_or_finalize (DBusMessage *message) { +#ifdef DBUS_ENABLE_MESSAGE_CACHE dbus_bool_t was_cached; int i; @@ -667,6 +683,9 @@ dbus_message_cache_or_finalize (DBusMessage *message) if (!was_cached) dbus_message_finalize (message); +#else /* !DBUS_ENABLE_MESSAGE_CACHE */ + dbus_message_finalize (message); +#endif /* !DBUS_ENABLE_MESSAGE_CACHE */ } #ifndef DBUS_DISABLE_CHECKS |