From: veit@borneo.gmd.de (Holger Veit)
Subject: Re: [386bsd] X broken with new patchkit ?
Organization: GMD
Date: Thu, 28 Jan 1993 09:16:50 GMT

In article <4374@wzv.win.tue.nl>, guido@gvr.win.tue.nl (Guido van Rooij) writes:
|> I installed the new patchkit a few days ago. I also had keycap-0.1.1 (codrv)
|> installed. This used to work fine, but now that I've installed the new
|> patchkit, the keyboard isn't functioning quite well anymore when using X.
|> Symptoms are that after pressing a key you have to wiat several seconds
|> for the key to become visible on your xterm UNLESS you move your mouse..
|> then the char immediately shows up. Anyone having the same behaviour?
|> 
|> 
|> -Guido

I already replied to you by email, but this seems to be a more general issue.
The patchkit has (at least one) builtin incompatibility regarding the behaviour
of select(2). In the patchkit there is a change in the kernel that lets select
wait on a process's pid rather than a pointer to its struct proc. This is
actually a patch which should be 386bsd-0.2 stuff, and shouldn't have gone
into the patchkit. Anyway, since codrv aka keycap has a select stub, there are
necessary changes (see below). Andrew Chernov (ache@astral.msk.su) was so kind
to prepare a fix for this, before I did, and sent it to me; the following patch
should fix the problem (ONLY IF YOU HAVE PATCHKIT-2 INSTALLED!!!) The below patch
is the only fix added to the last BUGLIST.151292 at /usr/src/sys.extras/veit-console
at ref.tfs.com, the actual version is BUGLIST.270193.

Holger

----CUT HERE---
BUG 15: There are problems with the new patchkit-0.2.

FIX 15:	The latest patchkit-0.2 introduces an incompatibility regarding
	the interpretation of the wait argument for selections.
	It does no longer use struct *proc, but the pid_t instead.
	The following patch kindly prepared by Andrew A. Chernow
	(ache@astral.msk.su) will fix this. This will be default in
	the next version of codrv.
	DON'T APPLY THIS PATCH IF YOU DON'T HAVE THE NEW PATCHKIT!!!

*** co_hdr.h.sel	Sun Nov 22 18:35:19 1992
--- co_hdr.h	Wed Jan 27 16:21:51 1993
***************
*** 122,128 ****
  	int	cs_timo;	/* timeouts since interrupt (unused) */
  	u_long	cs_wedgecnt;	/* times restarted (unused)*/
  	u_long	cs_ovfl;	/* buffer overflows */
! 	struct proc *cs_selp;	/* Process waiting for select call */
  	int	cs_pgid;	/* Process group for ASYNC I/O */
  /*XXX*/	struct tty *cs_constty;	/* used to restore constty if */
  				/* anyone dares to steal CONSOLE during raw open */
--- 122,128 ----
  	int	cs_timo;	/* timeouts since interrupt (unused) */
  	u_long	cs_wedgecnt;	/* times restarted (unused)*/
  	u_long	cs_ovfl;	/* buffer overflows */
! 	pid_t   cs_rsel;        /* Process waiting for select call */
  	int	cs_pgid;	/* Process group for ASYNC I/O */
  /*XXX*/	struct tty *cs_constty;	/* used to restore constty if */
  				/* anyone dares to steal CONSOLE during raw open */
*** co_kbd.c.sel	Wed Jan 27 15:23:03 1993
--- co_kbd.c	Wed Jan 27 16:31:57 1993
***************
*** 138,144 ****
  	initrb(&co_buf);
  
  	/* signal opening process only */
! 	consoftc.cs_selp = 0;
  	consoftc.cs_pgid = p->p_pid;
  
  	return 0;
--- 138,144 ----
  	initrb(&co_buf);
  
  	/* signal opening process only */
! 	consoftc.cs_rsel = 0;
  	consoftc.cs_pgid = p->p_pid;
  
  	return 0;
***************
*** 156,162 ****
  	if (minor(dev)==0x80) return 0;
  
  	consoftc.cs_flags &= ~(CO_OPENRAW|CO_ASYNC);
! 	consoftc.cs_selp = 0;
  	consoftc.cs_pgid = 0;
  
  	/* do we need to restore console?
--- 156,162 ----
  	if (minor(dev)==0x80) return 0;
  
  	consoftc.cs_flags &= ~(CO_OPENRAW|CO_ASYNC);
! 	consoftc.cs_rsel = 0;
  	consoftc.cs_pgid = 0;
  
  	/* do we need to restore console?
***************
*** 277,285 ****
  
  	if (!(consoftc.cs_flags & CO_OPENRAW))
  		return;
! 	if (consoftc.cs_selp) {
! 		selwakeup(consoftc.cs_selp,0);
! 		consoftc.cs_selp = 0;
  	}
  	if (consoftc.cs_flags & CO_ASYNC) {
  		if (consoftc.cs_pgid < 0)
--- 277,285 ----
  
  	if (!(consoftc.cs_flags & CO_OPENRAW))
  		return;
! 	if (consoftc.cs_rsel) {
! 		selwakeup(consoftc.cs_rsel,0);
! 		consoftc.cs_rsel = 0;
  	}
  	if (consoftc.cs_flags & CO_ASYNC) {
  		if (consoftc.cs_pgid < 0)
***************
*** 306,312 ****
  			splx(s);
  			return 1;
  		}
! 		consoftc.cs_selp = p;
  	}
  	splx(s);
  	return 0;
--- 306,312 ----
  			splx(s);
  			return 1;
  		}
! 		consoftc.cs_rsel = p->p_pid;
  	}
  	splx(s);
  	return 0;
***************
*** 1182,1188 ****
  				consoftc.cs_flags |= CO_OPENRAW;
  			ofl = 0;
  		}
! 		consoftc.cs_selp = 0;
  		break;
  	case KBDRESET8042:
  		doreset();
--- 1182,1188 ----
  				consoftc.cs_flags |= CO_OPENRAW;
  			ofl = 0;
  		}
! 		consoftc.cs_rsel = 0;
  		break;
  	case KBDRESET8042:
  		doreset();

---CUT HERE---



-- 
         Dr. Holger Veit                   | INTERNET: veit@fanoe.gmd.de
|  |   / GMD-SET German National Research  | Phone: (+49) 2241 14 2448
|__|  /  Center for Computer Science       | Fax:   (+49) 2241 14 2342
|  | /   P.O. Box 13 16                    |    Three lines Signature space
|  |/    Schloss Birlinghoven              |    available for rent. Nearly
         DW-5205 St. Augustin, Germany     |    unused, good conditions