[2548] in Athena Bugs
toehold fix.
daemon@ATHENA.MIT.EDU (John D. Kubiatowicz)
Wed Jul 12 09:31:29 1989
To: bugs@ATHENA.MIT.EDU
Cc: probe@ATHENA.MIT.EDU, epeisach@ATHENA.MIT.EDU
Date: Wed, 12 Jul 89 09:30:50 EDT
From: John D. Kubiatowicz <kubitron@ATHENA.MIT.EDU>
I have one fix in addition to your retry count on opening the server. If
both the xterm and the server die (such as when you kill the server),
it is possible that the wait call will return the pid of the xterm even
though the server is dead. As a result, the server will sit as a
"zombie" process until the open attempt times out. The following
fix executes wait3 calls both before and during the retry loop. This
will permit the detection of a dead server immediately.
This seems to solve a long-standing problem that the parallax workstations
have had... sigh.
--KUBI--
*** /tmp/,RCSt1004631 Wed Jul 12 09:23:20 1989
--- /tmp/,RCSt2004631 Wed Jul 12 09:23:20 1989
***************
*** 1,10 ****
/*
* $Source: /afs/athena.mit.edu/mit/plx/src/toehold/RCS/toehold.c,v $
! * $Header: toehold.c,v 1.1 89/07/12 08:29:28 kubitron Exp $
*/
#ifndef lint
! static char *rcsid_toehold_c = "$Header: toehold.c,v 1.1 89/07/12 08:29:28 kubitron Exp $";
#endif lint
#include <stdio.h>
--- 1,10 ----
/*
* $Source: /afs/athena.mit.edu/mit/plx/src/toehold/RCS/toehold.c,v $
! * $Header: toehold.c,v 1.2 89/07/12 09:21:04 kubitron Exp $
*/
#ifndef lint
! static char *rcsid_toehold_c = "$Header: toehold.c,v 1.2 89/07/12 09:21:04 kubitron Exp $";
#endif lint
#include <stdio.h>
***************
*** 251,265 ****
}
/* If xterm exited, clean up utmp and such */
else if(npid == pid) {
! /* to avoid race problems here, we do the following:
! (1) open connection to server.
! (2) reset server via SIGHUP
! (3) excercise connection
! (4) when connection is broken, continue cleanup
! The added max count is in case the socket /tmp/.X11-unix/X0
! disappears - causing toehold to never open the display
! */
while(!(display = XOpenDisplay(DISPLAY))) {
sleep(X_WAIT_INTERVAL);
if(tries++ > X_OPEN_WAIT)
die(2); /* Never returns */
--- 251,272 ----
}
/* If xterm exited, clean up utmp and such */
else if(npid == pid) {
! /*
! * to avoid race problems here, we do the following:
! * (0) see if server is already a S_ZOMB
! * (1) open connection to server.
! * (2) reset server via SIGHUP
! * (3) excercise connection
! * (4) when connection is broken, continue cleanup
! * The added max count is in case the socket /tmp/.X11-unix/X0
! * disappears - causing toehold to never open the display
! */
!
! if (wait3(0,WNOHANG,0) == wpid)
! die(2); /* server is dead */
while(!(display = XOpenDisplay(DISPLAY))) {
+ if (wait3(0,WNOHANG,0) == wpid)
+ die(2); /* oops! server is dead */
sleep(X_WAIT_INTERVAL);
if(tries++ > X_OPEN_WAIT)
die(2); /* Never returns */