Commit 59af0bd7 authored by Daniel Drake's avatar Daniel Drake

Reject new XSMP clients earlier in the shutdown path

When we are ending the session, a new client connecting and trying to
register causes things to get confused and long delays to happen.

Move GsmXsmpServer to be managed by GsmManager, which can now tell the
server at a much earlier time when we are shutting down. Now new clients
are rejected much earlier and the confusion and delays are gone.

https://bugzilla.gnome.org/show_bug.cgi?id=688209
parent e7cbff3f
......@@ -49,6 +49,7 @@
#include "gsm-presence.h"
#include "gsm-shell.h"
#include "gsm-xsmp-server.h"
#include "gsm-xsmp-client.h"
#include "gsm-dbus-client.h"
......@@ -119,6 +120,7 @@ struct GsmManagerPrivate
GsmStore *inhibitors;
GsmStore *apps;
GsmPresence *presence;
GsmXsmpServer *xsmp_server;
char *session_name;
gboolean is_fallback_session : 1;
......@@ -1586,6 +1588,7 @@ start_phase (GsmManager *manager)
update_idle (manager);
break;
case GSM_MANAGER_PHASE_QUERY_END_SESSION:
gsm_xsmp_server_stop_accepting_new_clients (manager->priv->xsmp_server);
do_phase_query_end_session (manager);
break;
case GSM_MANAGER_PHASE_END_SESSION:
......@@ -1643,6 +1646,7 @@ gsm_manager_start (GsmManager *manager)
g_return_if_fail (GSM_IS_MANAGER (manager));
gsm_xsmp_server_start (manager->priv->xsmp_server);
gsm_manager_set_phase (manager, GSM_MANAGER_PHASE_INITIALIZATION);
debug_app_summary (manager);
start_phase (manager);
......@@ -2382,6 +2386,11 @@ gsm_manager_set_client_store (GsmManager *manager,
manager->priv->clients = store;
if (manager->priv->clients != NULL) {
if (manager->priv->xsmp_server)
g_object_unref (manager->priv->xsmp_server);
manager->priv->xsmp_server = gsm_xsmp_server_new (store);
g_signal_connect (manager->priv->clients,
"added",
G_CALLBACK (on_store_client_added),
......@@ -2509,6 +2518,8 @@ gsm_manager_dispose (GObject *object)
g_debug ("GsmManager: disposing manager");
g_clear_object (&manager->priv->xsmp_server);
if (manager->priv->clients != NULL) {
g_signal_handlers_disconnect_by_func (manager->priv->clients,
on_store_client_added,
......
......@@ -71,7 +71,7 @@ struct GsmXsmpServerPrivate
IceListenObj *xsmp_sockets;
int num_xsmp_sockets;
int num_local_xsmp_sockets;
gboolean stopping;
};
enum {
......@@ -248,6 +248,14 @@ gsm_xsmp_server_start (GsmXsmpServer *server)
}
}
void
gsm_xsmp_server_stop_accepting_new_clients (GsmXsmpServer *server)
{
g_return_if_fail (GSM_IS_XSMP_SERVER (server));
g_debug ("gsm_xsmp_server_stop_accepting_new_clients");
server->priv->stopping = TRUE;
}
static void
gsm_xsmp_server_set_client_store (GsmXsmpServer *xsmp_server,
GsmStore *store)
......@@ -319,8 +327,7 @@ accept_xsmp_connection (SmsConn sms_conn,
GsmClient *client;
GsmIceConnectionWatch *data;
/* FIXME: what about during shutdown but before gsm_xsmp_shutdown? */
if (server->priv->xsmp_sockets == NULL) {
if (server->priv->stopping) {
g_debug ("GsmXsmpServer: In shutdown, rejecting new client");
*failure_reason_ret = strdup (_("Refusing new client connection because the session is currently being shut down\n"));
......
......@@ -52,6 +52,7 @@ GType gsm_xsmp_server_get_type (void);
GsmXsmpServer * gsm_xsmp_server_new (GsmStore *client_store);
void gsm_xsmp_server_start (GsmXsmpServer *server);
void gsm_xsmp_server_stop_accepting_new_clients (GsmXsmpServer *server);
G_END_DECLS
......
......@@ -46,7 +46,6 @@
#include "gsm-session-fill.h"
#include "gsm-store.h"
#include "gsm-system.h"
#include "gsm-xsmp-server.h"
#include "gsm-fail-whale-dialog.h"
#define GSM_DBUS_NAME "org.gnome.SessionManager"
......@@ -257,7 +256,6 @@ main (int argc, char **argv)
char *display_str;
GsmManager *manager;
GsmStore *client_store;
GsmXsmpServer *xsmp_server;
static char **override_autostart_dirs = NULL;
static char *opt_session_name = NULL;
const char *session_name;
......@@ -326,8 +324,6 @@ main (int argc, char **argv)
*/
g_object_unref (gsm_get_system ());
xsmp_server = gsm_xsmp_server_new (client_store);
if (!acquire_name ()) {
gsm_fail_whale_dialog_we_failed (TRUE, TRUE, NULL);
gtk_main ();
......@@ -351,12 +347,10 @@ main (int argc, char **argv)
gsm_util_init_error (TRUE, "Failed to load session \"%s\"", session_name ? session_name : "(null)");
}
gsm_xsmp_server_start (xsmp_server);
gsm_manager_start (manager);
gtk_main ();
g_clear_object (&xsmp_server);
g_clear_object (&manager);
g_clear_object (&client_store);
g_clear_object (&bus_proxy);
......
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