From 61f225cd803592b0ab27305ca8405b7d1979c793 Mon Sep 17 00:00:00 2001 From: Matt Fischer Date: Wed, 20 Feb 2013 15:23:42 -0600 Subject: [PATCH] Make default number of Unix fds configurable QNX has an arbitrary limit to the number of file descriptors which may be passed in a message, which is smaller than the current default. This change therefore changes the default from a hardcoded constant, to a variable which is determined at configure time by looking at the host operating system. --- bus/config-parser.c | 6 +++--- cmake/config.h.cmake | 2 ++ configure.ac | 10 ++++++++++ dbus/dbus-message.c | 2 +- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/bus/config-parser.c b/bus/config-parser.c index 1d1b8bf..ff73ed0 100644 --- a/bus/config-parser.c +++ b/bus/config-parser.c @@ -420,9 +420,9 @@ bus_config_parser_new (const DBusString *basedir, maximum number of file descriptors we can receive. Picking a high value here thus translates directly to more memory allocation. */ - parser->limits.max_incoming_unix_fds = 1024*4; - parser->limits.max_outgoing_unix_fds = 1024*4; - parser->limits.max_message_unix_fds = 1024; + parser->limits.max_incoming_unix_fds = DBUS_DEFAULT_MESSAGE_UNIX_FDS*4; + parser->limits.max_outgoing_unix_fds = DBUS_DEFAULT_MESSAGE_UNIX_FDS*4; + parser->limits.max_message_unix_fds = DBUS_DEFAULT_MESSAGE_UNIX_FDS; /* Making this long means the user has to wait longer for an error * message if something screws up, but making it too short means diff --git a/cmake/config.h.cmake b/cmake/config.h.cmake index 76ccb86..b0dde3d 100644 --- a/cmake/config.h.cmake +++ b/cmake/config.h.cmake @@ -82,6 +82,8 @@ # define DBUS_ENABLE_X11_AUTOLAUNCH 1 #endif +#define DBUS_DEFAULT_MESSAGE_UNIX_FDS 1024 + #define _DBUS_VA_COPY_ASSIGN(a1,a2) { a1 = a2; } #cmakedefine DBUS_VA_COPY_FUNC diff --git a/configure.ac b/configure.ac index 9b578ed..2d019de 100644 --- a/configure.ac +++ b/configure.ac @@ -1291,6 +1291,16 @@ if test x$with_valgrind != xno; then AC_DEFINE([WITH_VALGRIND], [1], [Define to add Valgrind instrumentation]) fi +# Determine maximum number of Unix fds which may be passed +AS_CASE([$host_os], + [*qnx*], + [default_message_unix_fds=256], + [*], + [default_message_unix_fds=1024]) +AC_DEFINE_UNQUOTED([DBUS_DEFAULT_MESSAGE_UNIX_FDS], + [$default_message_unix_fds], + [Default for dbus_connection_get_max_message_unix_fds()]) + #### Set up final flags LIBDBUS_LIBS="$THREAD_LIBS $NETWORK_libs" AC_SUBST([LIBDBUS_LIBS]) diff --git a/dbus/dbus-message.c b/dbus/dbus-message.c index 71bcee6..619bc69 100644 --- a/dbus/dbus-message.c +++ b/dbus/dbus-message.c @@ -3802,7 +3802,7 @@ _dbus_message_loader_new (void) SCM_RIGHTS works we need to preallocate an fd array of the maximum number of unix fds we want to receive in advance. A try-and-reallocate loop is not possible. */ - loader->max_message_unix_fds = 1024; + loader->max_message_unix_fds = DBUS_DEFAULT_MESSAGE_UNIX_FDS; if (!_dbus_string_init (&loader->data)) { -- 1.8.0.msysgit.0