~didrocks/lightdm/packaging-cleanup

« back to all changes in this revision

Viewing changes to src/seat-unity.c

  • Committer: Tarmac
  • Author(s): Robert Ancell
  • Date: 2013-05-31 05:06:10 UTC
  • mfrom: (1611.1.1 lightdm-unity)
  • Revision ID: tarmac-20130531050610-i2dcmnk1k4ync29k
Stop reading from the compositor pipe when it closes.

Approved by Robert Ancell, PS Jenkins bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
169
169
    gsize n_to_read = 0;
170
170
    guint16 id, payload_length;
171
171
    guint8 *payload;
 
172
  
 
173
    if (condition == G_IO_HUP)
 
174
    {
 
175
        g_debug ("Compositor closed communication channel");
 
176
        return FALSE;
 
177
    }
172
178
 
173
179
    /* Work out how much required for a message */
174
180
    if (seat->priv->read_buffer_n_used < 4)
183
189
    if (n_to_read > 0)
184
190
    {
185
191
        gsize n_total, n_read = 0;
 
192
        GIOStatus status;
186
193
        GError *error = NULL;
187
194
 
188
195
        n_total = seat->priv->read_buffer_n_used + n_to_read;
189
196
        if (seat->priv->read_buffer_length < n_total)
190
197
            seat->priv->read_buffer = g_realloc (seat->priv->read_buffer, n_total);
191
198
 
192
 
        g_io_channel_read_chars (source,
193
 
                                 seat->priv->read_buffer + seat->priv->read_buffer_n_used,
194
 
                                 n_to_read,
195
 
                                 &n_read,
196
 
                                 &error);
 
199
        status = g_io_channel_read_chars (source,
 
200
                                          seat->priv->read_buffer + seat->priv->read_buffer_n_used,
 
201
                                          n_to_read,
 
202
                                          &n_read,
 
203
                                          &error);
197
204
        if (error)
198
205
            g_warning ("Failed to read from compositor: %s", error->message);
 
206
        if (status != G_IO_STATUS_NORMAL)
 
207
            return TRUE;
199
208
        g_clear_error (&error);
200
209
        seat->priv->read_buffer_n_used += n_read;
201
210
    }
323
332
 
324
333
    /* Listen for messages from the compositor */
325
334
    SEAT_UNITY (seat)->priv->from_compositor_channel = g_io_channel_unix_new (SEAT_UNITY (seat)->priv->from_compositor_pipe[0]);
326
 
    g_io_add_watch (SEAT_UNITY (seat)->priv->from_compositor_channel, G_IO_IN, read_cb, seat);
 
335
    g_io_add_watch (SEAT_UNITY (seat)->priv->from_compositor_channel, G_IO_IN | G_IO_HUP, read_cb, seat);
327
336
 
328
337
    /* Setup logging */
329
338
    dir = config_get_string (config_get_instance (), "LightDM", "log-directory");