[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Help: Looking at the Sun makes you blind...



Quoting Eli Barzilay:
> So, I have that cute program that takes any simple I/O thing and turns
> it into a server.  It worked perfectly well, until I moved from a
> "SunOS 5.8" to a "SunOS 5.7" (Maybe they are Solaris 2.x?).  Anyway,
> the perfect cute program soon turned into a monster...  It started to
> mysteriously drop characters at weird places, and after a while it
> would just stop responding.  After lots of attempts, to localize the
> problem, I minimized it to starting the program: [...]

[Eli also sent me mxpost, on request, so I could see the bug in
action.]

I'm fairly certain that I've fixed this bug. A revised port.c has been
committed and v200-tagged.

The bug is not specific to any version of SunOS (Eli was just unlucky),
but it is specific to SunOS and HP/UX; for those two OSes, select()
doesn't work on certain file descriptors, such as descriptors attached
to /dev/null.

fd_char_ready() (in port.c) must use an alternate test method when
select() might not have worked. The alternate test ends up reading a
character, and the code to save the character was missing a line:

#ifdef SOME_FDS_ARE_NOT_SELECTABLE
    /* Try a non-blocking read: */
    ...
	if (c != EOF) {
	  fip->buffpos = 0; /* <------------------ this was missing */
	  fip->buffer[0] = (unsigned char)c;
	  fip->bufcount = 1;
	}
    ...
#endif


Matthew