summaryrefslogtreecommitdiff
path: root/src/greeter.c
diff options
context:
space:
mode:
authorRobert Ancell <robert.ancell@canonical.com>2015-03-09 16:38:14 +1300
committerRobert Ancell <robert.ancell@canonical.com>2015-03-09 16:38:14 +1300
commitff1af54f1c1455af8519094b72cd6f1079f0abe4 (patch)
tree45c562256720d3c7aff22e43c1c24338b441bddd /src/greeter.c
parent0ef2e85c2ba9ed9ce56d7b00ff91ee94832bf1e9 (diff)
downloadlightdm-git-ff1af54f1c1455af8519094b72cd6f1079f0abe4.tar.gz
Close greeter pipe when greeter exits - this was leaking file descriptors for each time you returned to the greeter
Diffstat (limited to 'src/greeter.c')
-rw-r--r--src/greeter.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/greeter.c b/src/greeter.c
index e1d47f86..b0b672b2 100644
--- a/src/greeter.c
+++ b/src/greeter.c
@@ -76,6 +76,8 @@ struct GreeterPrivate
gboolean guest_account_authenticated;
/* Communication channels to communicate with */
+ int to_greeter_input;
+ int from_greeter_output;
GIOChannel *to_greeter_channel;
GIOChannel *from_greeter_channel;
guint from_greeter_watch;
@@ -954,6 +956,7 @@ greeter_start (Session *session)
{
Greeter *greeter = GREETER (session);
int to_greeter_pipe[2], from_greeter_pipe[2];
+ int to_greeter_output, from_greeter_input;
gboolean result = FALSE;
gchar *value;
GError *error = NULL;
@@ -964,12 +967,16 @@ greeter_start (Session *session)
g_warning ("Failed to create pipes: %s", strerror (errno));
return FALSE;
}
- greeter->priv->to_greeter_channel = g_io_channel_unix_new (to_greeter_pipe[1]);
+ to_greeter_output = to_greeter_pipe[0];
+ greeter->priv->to_greeter_input = to_greeter_pipe[1];
+ greeter->priv->to_greeter_channel = g_io_channel_unix_new (greeter->priv->to_greeter_input);
g_io_channel_set_encoding (greeter->priv->to_greeter_channel, NULL, &error);
if (error)
g_warning ("Failed to set encoding on to greeter channel to binary: %s\n", error->message);
g_clear_error (&error);
- greeter->priv->from_greeter_channel = g_io_channel_unix_new (from_greeter_pipe[0]);
+ greeter->priv->from_greeter_output = from_greeter_pipe[0];
+ from_greeter_input = from_greeter_pipe[1];
+ greeter->priv->from_greeter_channel = g_io_channel_unix_new (greeter->priv->from_greeter_output);
g_io_channel_set_encoding (greeter->priv->from_greeter_channel, NULL, &error);
if (error)
g_warning ("Failed to set encoding on from greeter channel to binary: %s\n", error->message);
@@ -978,22 +985,22 @@ greeter_start (Session *session)
greeter->priv->from_greeter_watch = g_io_add_watch (greeter->priv->from_greeter_channel, G_IO_IN | G_IO_HUP, read_cb, greeter);
/* Let the greeter session know how to communicate with the daemon */
- value = g_strdup_printf ("%d", from_greeter_pipe[1]);
+ value = g_strdup_printf ("%d", from_greeter_input);
session_set_env (SESSION (greeter), "LIGHTDM_TO_SERVER_FD", value);
g_free (value);
- value = g_strdup_printf ("%d", to_greeter_pipe[0]);
+ value = g_strdup_printf ("%d", to_greeter_output);
session_set_env (SESSION (greeter), "LIGHTDM_FROM_SERVER_FD", value);
g_free (value);
/* Don't allow the daemon end of the pipes to be accessed in child processes */
- fcntl (to_greeter_pipe[1], F_SETFD, FD_CLOEXEC);
- fcntl (from_greeter_pipe[0], F_SETFD, FD_CLOEXEC);
+ fcntl (greeter->priv->to_greeter_input, F_SETFD, FD_CLOEXEC);
+ fcntl (greeter->priv->from_greeter_output, F_SETFD, FD_CLOEXEC);
result = SESSION_CLASS (greeter_parent_class)->start (session);
/* Close the session ends of the pipe */
- close (to_greeter_pipe[0]);
- close (from_greeter_pipe[1]);
+ close (to_greeter_output);
+ close (from_greeter_input);
return result;
}
@@ -1049,6 +1056,8 @@ greeter_finalize (GObject *object)
g_signal_handlers_disconnect_matched (self->priv->authentication_session, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, self);
g_object_unref (self->priv->authentication_session);
}
+ close (self->priv->to_greeter_input);
+ close (self->priv->from_greeter_output);
if (self->priv->to_greeter_channel)
g_io_channel_unref (self->priv->to_greeter_channel);
if (self->priv->from_greeter_channel)