Subject: xdmcp for X server fixed
To: None <port-hp300@NetBSD.ORG>
From: Daniel Hagerty <hag@gnu.ai.mit.edu>
List: port-hp300
Date: 01/11/1996 02:29:44
	I tracked the problem down in the xdmcp code for the X
server. The server builds up a list of supported interfaces to send in
the xdmcp manage packet, but the code for dealing with SIOCGIFCONF was
totally botched; it would never have worked on a 4.4 based system (and
I don't think it would really do the completely right thing on *any*
system, if I understand how SIOCGIFCONF works).
	I also found a bug of some sort relating to server resets; the
server would get a bus error in topcat.c:topcatScreenInit(). I just
randomly discovered that inserting a usleep(500) at the appropriate
point made the problem go away. It's hardware; well beyond me right
now (if someone has any idea why this problem existed and why my
kludge made it go away, I'd love to hear about it).
	For those who'd like a new server with xdmcp support, I put a
copy of it up for at ftp://alpha.gnu.ai.mit.edu/hag/XhpBSD.gz

	Would anyone be interested in me building a new binary set for
NetBSD 1.1? (for putting on ftp.netbsd.org perhaps?) I'm going to be
playing a bit with the X stuff sometime soon anyway, so packaging it
up would be easy for me to do too.

	Diffs for the X source are appended.

----------------------------------------------------------------------
diff -crsP mit/server/os/access.c.orig mit/server/os/access.c
*** mit/server/os/access.c.orig	Wed Jan 10 11:56:01 1996
--- mit/server/os/access.c	Thu Jan 11 01:33:17 1996
***************
*** 229,236 ****
      ifc.ifc_buf = buf;
      if (ioctl (fd, (int) SIOCGIFCONF, (pointer) &ifc) < 0)
          Error ("Getting interface configuration");
!     for (ifr = ifc.ifc_req, n = ifc.ifc_len / sizeof (struct ifreq); --n >= 0;
!      ifr++)
      {
  	len = sizeof(ifr->ifr_addr);
  #ifdef DNETCONN
--- 229,244 ----
      ifc.ifc_buf = buf;
      if (ioctl (fd, (int) SIOCGIFCONF, (pointer) &ifc) < 0)
          Error ("Getting interface configuration");
!     for (ifr = ifc.ifc_req
! #ifdef __NetBSD__
! 	 ; (char *)ifr < ifc.ifc_buf + ifc.ifc_len;
! 	 ifr = (struct ifreq *)((char *)ifr + sizeof (struct ifreq) +
! 		(ifr->ifr_addr.sa_len > sizeof (ifr->ifr_addr) ?
! 		 ifr->ifr_addr.sa_len - sizeof (ifr->ifr_addr) : 0))
! #else
! 	 , n = ifc.ifc_len / sizeof (struct ifreq); --n >= 0; ifr++
! #endif
! 	 )
      {
  	len = sizeof(ifr->ifr_addr);
  #ifdef DNETCONN
diff -crsP mit/server/ddx/hpbsd/topcat/topcat.c.orig mit/server/ddx/hpbsd/topcat/topcat.c
*** mit/server/ddx/hpbsd/topcat/topcat.c.orig	Wed Mar 24 21:50:52 1993
--- mit/server/ddx/hpbsd/topcat/topcat.c	Thu Jan 11 02:00:19 1996
***************
*** 508,513 ****
--- 508,518 ----
      {
          char *foo = (char *) gp_hardware;
  
+ 	/* Whee, hardware is involved. I have no clue about such
+ 	   things, but adding this here seemed to make the server
+ 	   behave better (no core dump). */
+ 	usleep(500);
+     
  	*((short *)(foo + 0x4510)) = 0x0;	/* VB      */
  	*((short *)(foo + 0x4512)) = 0x0;	/* TCNTRL  */
  	*((short *)(foo + 0x4514)) = 0x0;	/* ACNTRL  */