From 7f0ff25b7a056570e2435a88b9bb736501aaa12b Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sat, 2 Aug 2014 14:31:18 -0700 Subject: [PATCH] Avoid 100% CPU utilization on ssh session exit. * src/xterm.h (struct x_display_info): New member 'connection'. * src/xterm.c (x_term_init, x_delete_terminal): Set and use it, so that x_delete_terminal has a file descriptor to pass to delete_keyboard_wait_descriptor. Fixes: debbugs:17691 --- src/ChangeLog | 8 ++++++++ src/xterm.c | 9 ++++----- src/xterm.h | 3 +++ 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 13415734c79..b85aee0d35a 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ +2014-08-02 Paul Eggert + + Avoid 100% CPU utilization on ssh session exit (Bug#17691). + * xterm.h (struct x_display_info): New member 'connection'. + * xterm.c (x_term_init, x_delete_terminal): Set and use it, + so that x_delete_terminal has a file descriptor to pass to + delete_keyboard_wait_descriptor. + 2014-08-01 Eli Zaretskii Fix display of R2L lines when the last character fits only partially. diff --git a/src/xterm.c b/src/xterm.c index ed98fb10b89..7723f1af77f 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -9932,6 +9932,7 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) dpyinfo->name_list_element = Fcons (display_name, Qnil); dpyinfo->display = dpy; + dpyinfo->connection = ConnectionNumber (dpyinfo->display); /* Set the name of the terminal. */ terminal->name = xlispstrdup (display_name); @@ -10360,7 +10361,6 @@ void x_delete_terminal (struct terminal *terminal) { struct x_display_info *dpyinfo = terminal->display_info.x; - int connection = -1; /* Protect against recursive calls. delete_frame in delete_terminal calls us back when it deletes our last frame. */ @@ -10379,8 +10379,6 @@ x_delete_terminal (struct terminal *terminal) and dpyinfo->display was set to 0 to indicate that. */ if (dpyinfo->display) { - connection = ConnectionNumber (dpyinfo->display); - x_destroy_all_bitmaps (dpyinfo); XSetCloseDownMode (dpyinfo->display, DestroyAll); @@ -10422,11 +10420,12 @@ x_delete_terminal (struct terminal *terminal) } /* No more input on this descriptor. */ - if (connection != -1) - delete_keyboard_wait_descriptor (connection); + if (0 <= dpyinfo->connection) + delete_keyboard_wait_descriptor (dpyinfo->connection); /* Mark as dead. */ dpyinfo->display = NULL; + dpyinfo->connection = -1; x_delete_display (dpyinfo); unblock_input (); } diff --git a/src/xterm.h b/src/xterm.h index 50df88cb592..2bed0d1d5d1 100644 --- a/src/xterm.h +++ b/src/xterm.h @@ -137,6 +137,9 @@ struct x_display_info /* This says how to access this display in Xlib. */ Display *display; + /* A connection number (file descriptor) for the display. */ + int connection; + /* This is a cons cell of the form (NAME . FONT-LIST-CACHE). */ Lisp_Object name_list_element; -- 2.39.5