Commit e03d9ad1 authored by Lubomir Rintel's avatar Lubomir Rintel 🥕
Browse files

dbus: don't even bother connecting in configure-and-quit mode

It makes no sense, results in unnecessary complexity both in code and in
code comments.
parent ce4dbd7d
...@@ -397,8 +397,13 @@ main (int argc, char *argv[]) ...@@ -397,8 +397,13 @@ main (int argc, char *argv[])
NM_CONFIG_KEYFILE_KEY_MAIN_AUTH_POLKIT, NM_CONFIG_KEYFILE_KEY_MAIN_AUTH_POLKIT,
NM_CONFIG_DEFAULT_MAIN_AUTH_POLKIT_BOOL)); NM_CONFIG_DEFAULT_MAIN_AUTH_POLKIT_BOOL));
if (!nm_dbus_manager_acquire_bus (nm_dbus_manager_get ())) if (!nm_config_get_configure_and_quit (config)) {
goto done_no_manager; /* D-Bus is useless in configure and quit mode -- we're eventually dropping
* off and potential clients would have no way of knowing whether we're
* finished already or didn't start yet. */
if (!nm_dbus_manager_acquire_bus (nm_dbus_manager_get ()))
goto done_no_manager;
}
manager = nm_manager_setup (); manager = nm_manager_setup ();
nm_dbus_manager_start (nm_dbus_manager_get(), nm_dbus_manager_start (nm_dbus_manager_get(),
......
...@@ -1480,7 +1480,11 @@ nm_dbus_manager_start (NMDBusManager *self, ...@@ -1480,7 +1480,11 @@ nm_dbus_manager_start (NMDBusManager *self,
g_return_if_fail (NM_IS_DBUS_MANAGER (self)); g_return_if_fail (NM_IS_DBUS_MANAGER (self));
priv = NM_DBUS_MANAGER_GET_PRIVATE (self); priv = NM_DBUS_MANAGER_GET_PRIVATE (self);
g_return_if_fail (priv->connection);
if (!priv->connection) {
/* Do nothing. We're presumably in the configure-and-quit mode. */
return;
}
priv->set_property_handler = set_property_handler; priv->set_property_handler = set_property_handler;
priv->set_property_handler_data = set_property_handler_data; priv->set_property_handler_data = set_property_handler_data;
...@@ -1505,29 +1509,17 @@ nm_dbus_manager_acquire_bus (NMDBusManager *self) ...@@ -1505,29 +1509,17 @@ nm_dbus_manager_acquire_bus (NMDBusManager *self)
priv = NM_DBUS_MANAGER_GET_PRIVATE (self); priv = NM_DBUS_MANAGER_GET_PRIVATE (self);
/* we will create the D-Bus connection and registering the name synchronously. /* Create the D-Bus connection and registering the name synchronously.
* The reason why that is necessary is because: * That is necessary because we need to exit right away if we can't
* (1) if we are unable to create a D-Bus connection, it means D-Bus is not * acquire the name despite connecting to the bus successfully.
* available and we run in D-Bus less mode. We do not support creating * It means that something is gravely broken -- such as another NetworkManager
* a D-Bus connection later on. This disconnected mode is useful for initrd * instance running. */
* (well, currently not yet, but will be).
* (2) if we are able to create the connection and register the name,
* all is good and we run with D-Bus. Note that D-Bus disconnects
* from D-Bus are ignored. Essentially, we do not support restarting
* D-Bus.
* (3) if we are able to create the connection but registration fails,
* it means that something is borked. Quite possibly another NetworkManager
* instance is running. We need to exit right away.
* To appease (1) and (3), we cannot initialize synchronously, because we need
* to know right away whether another NetworkManager instance is running (3).
**/
connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM,
NULL, NULL,
&error); &error);
if (!connection) { if (!connection) {
_LOGI ("cannot connect to D-Bus and proceed without (%s)", error->message); _LOGI ("cannot connect to D-Bus: %s", error->message);
return TRUE; return FALSE;
} }
g_dbus_connection_set_exit_on_close (connection, FALSE); g_dbus_connection_set_exit_on_close (connection, FALSE);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment