]> git.eshelyaron.com Git - emacs.git/commitdiff
* keyboard.c (tty_read_avail_input): Don't treat a -1 return from
authorStefan Monnier <monnier@iro.umontreal.ca>
Fri, 27 Mar 2009 16:14:23 +0000 (16:14 +0000)
committerStefan Monnier <monnier@iro.umontreal.ca>
Fri, 27 Mar 2009 16:14:23 +0000 (16:14 +0000)
Gpm_GetEvent as an error that justifies closing the filedescriptor.
* term.c (close_gpm): Get the filedescriptor as a (new) parameter.
(Fgpm_mouse_stop): Pass that new parameter.
* termhooks.h (close_gpm): Adjust prototype.

src/ChangeLog
src/keyboard.c
src/term.c
src/termhooks.h

index f6f8d2b89a51272664d6d8e1d4f9c713fbf83ea6..93a3810d3bd2075943808addee170dae96e44550 100644 (file)
@@ -1,3 +1,11 @@
+2009-03-27  Kevin Ryde  <user42@zip.com.au>
+
+       * keyboard.c (tty_read_avail_input): Don't treat a -1 return from
+       Gpm_GetEvent as an error that justifies closing the filedescriptor.
+       * term.c (close_gpm): Get the filedescriptor as a (new) parameter.
+       (Fgpm_mouse_stop): Pass that new parameter.
+       * termhooks.h (close_gpm): Adjust prototype.
+
 2009-03-26  Stefan Monnier  <monnier@iro.umontreal.ca>
 
        * lisp.h (Fx_focus_frame): Declare.
index 1bdf9a37b50e856b50fe111ca80720d0513a738c..527a82b55ff089a9887e7df925a2e6e6372777fc 100644 (file)
@@ -7184,17 +7184,23 @@ tty_read_avail_input (struct terminal *terminal,
   {
       Gpm_Event event;
       struct input_event hold_quit;
-      int gpm;
+      int gpm, fd = gpm_fd;
 
       EVENT_INIT (hold_quit);
       hold_quit.kind = NO_EVENT;
 
+      /* gpm==1 if event received.
+         gpm==0 if the GPM daemon has closed the connection, in which case
+                Gpm_GetEvent closes gpm_fd and clears it to -1, which is why
+               we save it in `fd' so close_gpm can remove it from the
+               select masks.
+         gpm==-1 if a protocol error or EWOULDBLOCK; the latter is normal. */
       while (gpm = Gpm_GetEvent (&event), gpm == 1) {
          nread += handle_one_term_event (tty, &event, &hold_quit);
       }
-      if (gpm < 0)
+      if (gpm == 0)
        /* Presumably the GPM daemon has closed the connection.  */
-       close_gpm ();
+       close_gpm (fd);
       if (hold_quit.kind != NO_EVENT)
          kbd_buffer_store_event (&hold_quit);
       if (nread)
index 3fbc3c46c4ddb0e743d5dde775ae949d5744d8ae..6d6bfaf412f9c10ec2835b5a7b660419d2433939 100644 (file)
@@ -3150,10 +3150,10 @@ Gpm-mouse can only be activated for one tty at a time.  */)
 }
 
 void
-close_gpm ()
+close_gpm (int fd)
 {
-  if (gpm_fd >= 0)
-    delete_gpm_wait_descriptor (gpm_fd);
+  if (fd >= 0)
+    delete_gpm_wait_descriptor (fd);
   while (Gpm_Close()); /* close all the stack */
   gpm_tty = NULL;
 }
@@ -3171,7 +3171,7 @@ DEFUN ("gpm-mouse-stop", Fgpm_mouse_stop, Sgpm_mouse_stop,
   if (!tty || gpm_tty != tty)
     return Qnil;       /* Not activated on this terminal, nothing to do.  */
 
-  close_gpm ();
+  close_gpm (gpm_fd);
   return Qnil;
 }
 #endif /* HAVE_GPM */
index d8f0cb0b2957fc312ba1e47d464f2c5d678dbcab..33d896742733701da51c73ce66fd006c59a7b328 100644 (file)
@@ -653,7 +653,7 @@ extern void delete_terminal P_ ((struct terminal *));
 extern struct terminal *initial_terminal;
 
 #ifdef HAVE_GPM
-extern void close_gpm (void);
+extern void close_gpm (int gpm_fd);
 #endif
 
 /* arch-tag: 33a00ecc-52b5-4186-a410-8801ac9f087d