James Hunt has proposed merging lp:~jamesodhunt/upstart/bugs-1235649+1203595 into lp:upstart.
Requested reviews: Upstart Reviewers (upstart-reviewers) Related bugs: Bug #1203595 in upstart : "session init, not available on dbus?" https://bugs.launchpad.net/upstart/+bug/1203595 Bug #1235649 in upstart : "uevent spam causes libdbus client code in session upstart to consume massive amounts of memory on Ubuntu Touch" https://bugs.launchpad.net/upstart/+bug/1235649 For more details, see: https://code.launchpad.net/~jamesodhunt/upstart/bugs-1235649+1203595/+merge/191852 Make a Session Init connect to the D-Bus session bus as well as the private socket. -- https://code.launchpad.net/~jamesodhunt/upstart/bugs-1235649+1203595/+merge/191852 Your team Upstart Reviewers is requested to review the proposed merge of lp:~jamesodhunt/upstart/bugs-1235649+1203595 into lp:upstart.
=== modified file 'ChangeLog' --- ChangeLog 2013-10-04 21:34:25 +0000 +++ ChangeLog 2013-10-18 18:22:59 +0000 @@ -1,4 +1,9 @@ -2013-01-04 Steve Langasek <[email protected] +2013-10-18 James Hunt <[email protected]> + + * Connect to the D-Bus session bus as well as using a private socket + when running as a Session Init (LP: #1203595, #1235649). + +2013-10-04 Steve Langasek <[email protected] * extra/upstart-local-bridge.c: use SOCKET_PATH in our event environment, instead of clobbering PATH. (LP: #1235480) === modified file 'init/control.c' --- init/control.c 2013-04-22 10:30:09 +0000 +++ init/control.c 2013-10-18 18:22:59 +0000 @@ -81,11 +81,19 @@ * * If TRUE, connect to the D-Bus session bus rather than the system bus. * - * Used for testing. + * Used for testing to simulate (as far as possible) a system-like init + * when running as a non-priv user. **/ int use_session_bus = FALSE; /** + * dbus_bus_type: + * + * Type of D-Bus bus to connect to. + **/ +DBusBusType dbus_bus_type; + +/** * control_server_address: * * Address on which the control server may be reached. @@ -258,16 +266,19 @@ control_init (); - control_handle_bus_type (); + dbus_bus_type = control_get_bus_type (); /* Connect to the D-Bus System Bus and hook everything up into * our own main loop automatically. */ - conn = nih_dbus_bus (use_session_bus ? DBUS_BUS_SESSION : DBUS_BUS_SYSTEM, - control_disconnected); + conn = nih_dbus_bus (dbus_bus_type, control_disconnected); if (! conn) return -1; + nih_debug ("Connected to D-Bus %s bus", + dbus_bus_type == DBUS_BUS_SESSION + ? "session" : "system"); + /* Register objects on the bus. */ control_register_all (conn); @@ -345,7 +356,9 @@ dbus_error_init (&error); - nih_warn (_("Disconnected from system bus")); + nih_warn (_("Disconnected from D-Bus %s bus"), + dbus_bus_type == DBUS_BUS_SESSION + ? "session" : "system"); control_bus = NULL; } @@ -817,19 +830,23 @@ } /** - * control_handle_bus_type: + * control_get_bus_type: * * Determine D-Bus bus type to connect to. + * + * Returns: Type of D-Bus bus to connect to. **/ -void -control_handle_bus_type (void) +DBusBusType +control_get_bus_type (void) { if (getenv (USE_SESSION_BUS_ENV)) use_session_bus = TRUE; - if (use_session_bus) - nih_debug ("Using session bus"); + return (use_session_bus || user_mode) + ? DBUS_BUS_SESSION + : DBUS_BUS_SYSTEM; } + /** * control_notify_disk_writeable: * @data: not used, === modified file 'init/control.h' --- init/control.h 2013-05-08 16:21:08 +0000 +++ init/control.h 2013-10-18 18:22:59 +0000 @@ -134,7 +134,11 @@ const char *log_priority) __attribute__ ((warn_unused_result)); -void control_handle_bus_type (void); +DBusBusType control_get_bus_type (void) + __attribute__ ((warn_unused_result)); + +const char *control_get_bus_name (void) + __attribute__ ((warn_unused_result)); void control_prepare_reexec (void); === modified file 'init/main.c' --- init/main.c 2013-07-31 09:28:48 +0000 +++ init/main.c 2013-10-18 18:22:59 +0000 @@ -128,7 +128,7 @@ extern int default_console; extern int write_state_file; extern char *log_dir; - +extern DBusBusType dbus_bus_type; /** * options: @@ -213,7 +213,8 @@ if (disable_job_logging) nih_debug ("Job logging disabled"); - control_handle_bus_type (); + if (getenv (USE_SESSION_BUS_ENV)) + use_session_bus = TRUE; if (! user_mode) no_inherit_env = TRUE; @@ -933,14 +934,20 @@ NihSignal *signal) { if (! control_bus) { - nih_info (_("Reconnecting to system bus")); + char *dbus_bus_name; + + dbus_bus_name = dbus_bus_type == DBUS_BUS_SESSION + ? "session" : "system"; + + nih_info (_("Reconnecting to D-Bus %s bus"), + dbus_bus_name); if (control_bus_open () < 0) { NihError *err; err = nih_error_get (); - nih_warn ("%s: %s", _("Unable to connect to the system bus"), - err->message); + nih_warn (_("Unable to connect to the D-Bus %s bus: %s"), + dbus_bus_name, err->message); nih_free (err); } }
-- upstart-devel mailing list [email protected] Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/upstart-devel
