diff options
author | Sangyoon Jang <s89.jang@samsung.com> | 2014-01-09 10:04:30 +0900 |
---|---|---|
committer | Lubomir Rintel <lkundrak@v3.sk> | 2015-02-11 11:55:32 +0100 |
commit | 57730f279bca618cac2bc8de51f8b4dafc30259a (patch) | |
tree | bd5c231ace7901b7eeaf7607ba588df242fd6c95 | |
parent | 5629feee42c036359a66ef9e799242bc7754b50f (diff) |
[daemon-fix] Changed the way of make bus address when the address is not given
When the autolaunch enabled (when using dbus-launch), the bus will be addressed
by the member 'listen' of config file
It has to decide the autolaunch address at run-time instead of compile-time
-rw-r--r-- | bus/bus.c | 132 | ||||
-rw-r--r-- | configure.ac | 3 | ||||
-rw-r--r-- | dbus/dbus-sysdeps-unix.c | 5 |
3 files changed, 83 insertions, 57 deletions
@@ -273,6 +273,47 @@ setup_server (BusContext *context, return TRUE; } +#ifdef ENABLE_KDBUS_TRANSPORT +static int +init_server_for_kdbus (BusContext *context, + const char *address, + DBusError *error) +{ + DBusBusType type; + DBusServer* server; + char* bus_address; + + if (!strcmp (context->type, "system")) + type = DBUS_BUS_SYSTEM; + else if (!strcmp (context->type, "session")) + type = DBUS_BUS_SESSION; + else + type = DBUS_BUS_STARTER; + + bus_address = make_kdbus_bus (type, address, error); + if (bus_address == NULL) + return -1; + + server = empty_server_init (bus_address); + if (server == NULL) + { + free (bus_address); + return -1; + } + if (!_dbus_list_append (&context->servers, server)) + { + free (bus_address); + return -2; + } + + context->myKdbusConnection = daemon_as_client (type, bus_address, error); + if (context->myKdbusConnection == NULL) + return -1; + + return 0; +} +#endif + /* This code only gets executed the first time the * config files are parsed. It is not executed * when config files are reloaded. @@ -437,39 +478,16 @@ process_config_first_time_only (BusContext *context, { #ifdef ENABLE_KDBUS_TRANSPORT if(!strncmp(_dbus_string_get_const_data(address), "kdbus:", strlen("kdbus:"))) - { - DBusBusType type; - DBusServer* server; - char* bus_address; - - if(!strcmp (context->type, "system")) - type = DBUS_BUS_SYSTEM; - else if(!strcmp (context->type, "session")) - type = DBUS_BUS_SESSION; - else - type = DBUS_BUS_STARTER; - - bus_address = make_kdbus_bus(type, _dbus_string_get_const_data(address), error); - if(bus_address == NULL) - goto failed; - - server = empty_server_init(bus_address); - if(server == NULL) - { - free(bus_address); - goto failed; - } - - if (!_dbus_list_append (&context->servers, server)) - { - free(bus_address); - goto oom; - } - - context->myKdbusConnection = daemon_as_client(type, bus_address, error); - if(context->myKdbusConnection == NULL) - goto failed; - } + { + int ret; + + ret = init_server_for_kdbus (context, _dbus_string_get_const_data (address), error); + + if (ret == -1) + goto failed; + else if (ret == -2) + goto oom; + } else #endif { @@ -496,27 +514,43 @@ process_config_first_time_only (BusContext *context, addresses = bus_config_parser_get_addresses (parser); link = _dbus_list_get_first_link (addresses); - while (link != NULL) +#ifdef ENABLE_KDBUS_TRANSPORT + if (!strcmp (link->data, "kdbus:")) { - DBusServer *server; + int ret; - server = dbus_server_listen (link->data, error); - if (server == NULL) - { - _DBUS_ASSERT_ERROR_IS_SET (error); - goto failed; - } - else if (!setup_server (context, server, auth_mechanisms, error)) - { - _DBUS_ASSERT_ERROR_IS_SET (error); - goto failed; - } + ret = init_server_for_kdbus (context, link->data, error); - if (!_dbus_list_append (&context->servers, server)) + if (ret == -1) + goto failed; + else if (ret == -2) goto oom; - - link = _dbus_list_get_next_link (addresses, link); } + else +#endif + { + while (link != NULL) + { + DBusServer *server; + + server = dbus_server_listen (link->data, error); + if (server == NULL) + { + _DBUS_ASSERT_ERROR_IS_SET (error); + goto failed; + } + else if (!setup_server (context, server, auth_mechanisms, error)) + { + _DBUS_ASSERT_ERROR_IS_SET (error); + goto failed; + } + + if (!_dbus_list_append (&context->servers, server)) + goto oom; + + link = _dbus_list_get_next_link (addresses, link); + } + } } context->fork = bus_config_parser_get_fork (parser); diff --git a/configure.ac b/configure.ac index c3d4f957..e07367f9 100644 --- a/configure.ac +++ b/configure.ac @@ -1723,9 +1723,6 @@ elif test x$dbus_win = xyes; then # branch of the conditional because the default might conceivably # change (see #38201) DBUS_SESSION_BUS_CONNECT_ADDRESS="autolaunch:" -elif test x$enable_kdbus_transport = xyes; then - # Autolaunching kdbus bus instead of the ordinary socket - DBUS_SESSION_BUS_CONNECT_ADDRESS="autolaunch:scope=kdbus" else # The default on all other Unix platforms (notably Linux) # is to use auto-launching - this works a bit differently on Mac OS X diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c index 4fc51852..fe891ab7 100644 --- a/dbus/dbus-sysdeps-unix.c +++ b/dbus/dbus-sysdeps-unix.c @@ -3568,11 +3568,6 @@ _dbus_get_autolaunch_address (const char *scope, ++i; argv[i] = "--close-stderr"; ++i; - if(strcmp(scope, "kdbus") == 0) - { - argv[i] = "--kdbus"; - ++i; - } argv[i] = NULL; ++i; |