From xemacs-m  Thu Aug 14 10:59:59 1997
Received: from newman.aventail.com (root@newman.aventail.com [199.238.236.1])
	by xemacs.org (8.8.5/8.8.5) with ESMTP id KAA14728
	for <xemacs-beta@xemacs.org>; Thu, 14 Aug 1997 10:59:58 -0500 (CDT)
Received: from kramer.in.aventail.com (wmperry@kramer.in.aventail.com [192.168.1.12])
	by newman.aventail.com (8.8.5/8.8.5) with ESMTP id IAA01470
	for <xemacs-beta@xemacs.org>; Thu, 14 Aug 1997 08:59:43 -0700 (PDT)
Received: (from wmperry@localhost)
	by kramer.in.aventail.com (8.8.5/8.8.5) id IAA20822;
	Thu, 14 Aug 1997 08:58:49 -0700
Date: Thu, 14 Aug 1997 08:58:49 -0700
Message-Id: <199708141558.IAA20822@kramer.in.aventail.com>
From: "William M. Perry" <wmperry@aventail.com>
To: xemacs-beta@xemacs.org
Subject: [PATCH] potential GPM fix for select_filedesc failed assertion
Errors-to: wmperry@aventail.com
Reply-to: wmperry@aventail.com
X-Face: O~Rn;(l][/-o1sALg4A@xpE:9-"'IR[%;,,!m7</SYF`{vYQ(&RI1&EiH[FvT;J}@f!4kfz
 x_!Y#=y{Uuj9GvUi=cPuajQ(Z42R[wE@{G,sn$qGr5g/wnb*"*ktI+,CD}1Z'wxrM2ag-r0p5I6\nA
 [WJopW_J.WY;

*** gpmevent.c	1997/08/14 15:56:34	1.1
--- gpmevent.c	1997/08/14 15:56:38
***************
*** 23,32 ****
  #include <linux/keyboard.h> 
  #endif
  
- extern SELECT_TYPE input_wait_mask, non_fake_input_wait_mask;
- extern SELECT_TYPE process_only_mask, device_only_mask;
- void select_filedesc (int fd, Lisp_Object what);
- 
  int handle_gpm_read(struct Lisp_Event *event, struct console *con, int fd)
  {
    Gpm_Event ev;
--- 23,28 ----

*** event-Xt.c	1997/08/14 15:53:02	1.1
--- event-Xt.c	1997/08/14 15:55:36
***************
*** 1758,1764 ****
    /* On a stream device (ie: noninteractive), bad things can happen. */
    if (EQ (CONSOLE_TYPE (con), Qtty)) {
      mousefd = CONSOLE_TTY_MOUSE_FD (con);
!     if (mousefd >= 0) {
        select_filedesc (mousefd, console);
      }
    }
--- 1758,1771 ----
    /* On a stream device (ie: noninteractive), bad things can happen. */
    if (EQ (CONSOLE_TYPE (con), Qtty)) {
      mousefd = CONSOLE_TTY_MOUSE_FD (con);
! 	/* We check filedesc_to_what_closure[fd] here because if you run
! 	** XEmacs from a TTY, it will fire up GPM, select the mouse fd, then
! 	** if you run gnuattach to connect to another TTY, it will fire up
! 	** GPM again, and try to reselect the mouse fd.  GPM uses the same
! 	** fd for every connection apparently, and select_filedesc will
! 	** fail its assertion if we try to select it twice.
! 	*/
!     if ((mousefd >= 0) && !filedesc_to_what_closure[mousefd]) {
        select_filedesc (mousefd, console);
      }
    }

