emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master 3e92b98: Never pass an invalid X connection descrip


From: Dmitry Antipov
Subject: [Emacs-diffs] master 3e92b98: Never pass an invalid X connection descriptor to an input reading loop
Date: Thu, 11 Dec 2014 13:27:09 +0000

branch: master
commit 3e92b9882bc5218a5b5962f9e85d0cbca719afc8
Author: Dmitry Antipov <address@hidden>
Commit: Dmitry Antipov <address@hidden>

    Never pass an invalid X connection descriptor to an input reading loop
    
    Fixes: debbugs:19147
    
    * xterm.c (x_delete_terminal): Call emacs_close for X connection
    descriptor if called from x_connection_closed and always delete
    this descriptor from keyboard waiting set (Bug#19147).
---
 src/ChangeLog |    6 ++++++
 src/xterm.c   |   25 +++++++++++++++----------
 2 files changed, 21 insertions(+), 10 deletions(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index 2a6e237..27c0858 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,9 @@
+2014-12-11  Dmitry Antipov  <address@hidden>
+
+       * xterm.c (x_delete_terminal): Call emacs_close for X connection
+       descriptor if called from x_connection_closed and always delete
+       this descriptor from keyboard waiting set (Bug#19147).
+
 2014-12-10  Eli Zaretskii  <address@hidden>
 
        * bidi.c (BIDI_CACHE_MAX_ELTS_PER_SLOT): New macro.
diff --git a/src/xterm.c b/src/xterm.c
index 98f2a27..1ccc38c 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -11318,8 +11318,7 @@ x_delete_terminal (struct terminal *terminal)
     xim_close_dpy (dpyinfo);
 #endif
 
-  /* If called from x_connection_closed, the display may already be closed
-     and dpyinfo->display was set to 0 to indicate that.  */
+  /* Normally, the display is available...  */
   if (dpyinfo->display)
     {
       x_destroy_all_bitmaps (dpyinfo);
@@ -11360,17 +11359,23 @@ x_delete_terminal (struct terminal *terminal)
       XCloseDisplay (dpyinfo->display);
 #endif
 #endif /* ! USE_GTK */
-
-      /* No more input on this descriptor.  Do not close it because
-        it's already closed by X(t)CloseDisplay (Bug#18403).  */
-      eassert (0 <= dpyinfo->connection);
-      delete_keyboard_wait_descriptor (dpyinfo->connection);
-
-      /* Mark as dead. */
+      /* Do not close the connection here because it's already closed
+        by X(t)CloseDisplay (Bug#18403).  */
       dpyinfo->display = NULL;
-      dpyinfo->connection = -1;
     }
 
+  /* ...but if called from x_connection_closed, the display may already
+     be closed and dpyinfo->display was set to 0 to indicate that.  Since
+     X server is most likely gone, explicit close is the only reliable
+     way to continue and avoid Bug#19147.  */
+  else if (dpyinfo->connection >= 0)
+    emacs_close (dpyinfo->connection);
+
+  /* No more input on this descriptor.  */
+  delete_keyboard_wait_descriptor (dpyinfo->connection);
+  /* Mark as dead. */
+  dpyinfo->connection = -1;
+
   x_delete_display (dpyinfo);
   unblock_input ();
 }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]