[gnome-builder] pty: tweak watch priorities



commit 395e688efa26d07e31e12f936d9736ac9e49093b
Author: Christian Hergert <chergert redhat com>
Date:   Mon Jan 29 20:44:52 2018 -0800

    pty: tweak watch priorities
    
    These more closely match what VTE uses for it's priorities.

 src/libide/util/ptyintercept.c | 17 +++++++++++++----
 src/libide/util/ptyintercept.h |  2 ++
 2 files changed, 15 insertions(+), 4 deletions(-)
---
diff --git a/src/libide/util/ptyintercept.c b/src/libide/util/ptyintercept.c
index a0d63a853..2756287d8 100644
--- a/src/libide/util/ptyintercept.c
+++ b/src/libide/util/ptyintercept.c
@@ -42,6 +42,10 @@
  * us to break some deadlock scenarios.
  */
 #define CHANNEL_BUFFER_SIZE (4096 * 4)
+#define SLAVE_READ_PRIORITY   G_PRIORITY_HIGH
+#define SLAVE_WRITE_PRIORITY  G_PRIORITY_DEFAULT_IDLE
+#define MASTER_READ_PRIORITY  G_PRIORITY_DEFAULT_IDLE
+#define MASTER_WRITE_PRIORITY G_PRIORITY_HIGH
 
 
 static void     _pty_intercept_side_close (pty_intercept_side_t *side);
@@ -269,7 +273,7 @@ _pty_intercept_out_cb (GIOChannel   *channel,
   us->out_watch = 0;
   them->in_watch =
     g_io_add_watch_full (them->channel,
-                         G_PRIORITY_DEFAULT,
+                         them->read_prio,
                          G_IO_IN | G_IO_ERR | G_IO_HUP,
                          _pty_intercept_in_cb,
                          self, NULL);
@@ -363,7 +367,7 @@ _pty_intercept_in_cb (GIOChannel   *channel,
            */
           them->out_bytes = g_bytes_new (wrbuf, n_read);
           them->out_watch = g_io_add_watch_full (them->channel,
-                                                 G_PRIORITY_DEFAULT,
+                                                 them->write_prio,
                                                  G_IO_OUT | G_IO_ERR | G_IO_HUP,
                                                  _pty_intercept_out_cb,
                                                  self, NULL);
@@ -473,6 +477,11 @@ pty_intercept_init (pty_intercept_t *self,
   if (main_context == NULL)
     main_context = g_main_context_get_thread_default ();
 
+  self->master.read_prio = MASTER_READ_PRIORITY;
+  self->master.write_prio = MASTER_WRITE_PRIORITY;
+  self->slave.read_prio = SLAVE_READ_PRIORITY;
+  self->slave.write_prio = SLAVE_WRITE_PRIORITY;
+
   self->master.channel = g_io_channel_unix_new (pty_fd_steal (&master_fd));
   self->slave.channel = g_io_channel_unix_new (pty_fd_steal (&slave_fd));
 
@@ -487,14 +496,14 @@ pty_intercept_init (pty_intercept_t *self,
 
   self->master.in_watch =
     g_io_add_watch_full (self->master.channel,
-                         G_PRIORITY_DEFAULT,
+                         self->master.read_prio,
                          G_IO_IN | G_IO_ERR | G_IO_HUP,
                          _pty_intercept_in_cb,
                          self, NULL);
 
   self->slave.in_watch =
     g_io_add_watch_full (self->slave.channel,
-                         G_PRIORITY_DEFAULT,
+                         self->slave.read_prio,
                          G_IO_IN | G_IO_ERR | G_IO_HUP,
                          _pty_intercept_in_cb,
                          self, NULL);
diff --git a/src/libide/util/ptyintercept.h b/src/libide/util/ptyintercept.h
index b4637cf9e..3138863dd 100644
--- a/src/libide/util/ptyintercept.h
+++ b/src/libide/util/ptyintercept.h
@@ -41,6 +41,8 @@ struct _pty_intercept_side_t
   GIOChannel               *channel;
   guint                     in_watch;
   guint                     out_watch;
+  gint                      read_prio;
+  gint                      write_prio;
   GBytes                   *out_bytes;
   pty_intercept_callback_t  callback;
   gpointer                  callback_data;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]