From d1fd9f2303e91f9bb054c44fdccb946a19ca6cb4 Mon Sep 17 00:00:00 2001 From: Mikulas Patocka Date: Sat, 2 Mar 2019 14:26:30 +0300 Subject: [PATCH] Ticket #3208: fix failed gpm connect for vc /dev/tty0. How to reproduce the bug: * compile mc with gpm support * run the gpm daemon on the console * login to the machine with ssh from console on another machine * run mc At this situation, keyboard response will be sluggish and mc will consume CPU time when idle. The reason is that mc is trying to reopen the Gpm connection over and over again and gpm will try to close the connection over and over again (because the user is not on the local console). Signed-off-by: Mikulas Patocka Signed-off-by: Andrew Borodin --- lib/tty/key.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/tty/key.c b/lib/tty/key.c index 8bfd4dc16..bfb2ea633 100644 --- a/lib/tty/key.c +++ b/lib/tty/key.c @@ -2091,14 +2091,13 @@ tty_get_event (struct Gpm_Event *event, gboolean redo_event, gboolean block) *event = ev; return EV_MOUSE; } - else if (status == 0) /* connection closed; -1 == error */ + else if (status <= 0) /* connection closed; -1 == error */ { if (mouse_fd >= 0 && FD_ISSET (mouse_fd, &select_set)) FD_CLR (mouse_fd, &select_set); - /* Try to reopen gpm_mouse connection */ disable_mouse (); - enable_mouse (); + return EV_NONE; } } }