Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 4 Jun 1998 01:55:26 -0700
From:      Don Lewis <Don.Lewis@tsc.tdk.com>
To:        dk+@ua.net, barry@lustig.com
Cc:        freebsd-hackers@FreeBSD.ORG, serge@yahoo.com
Subject:   Re: Code Logic Question in 2.2 RELENG
Message-ID:  <199806040855.BAA06987@salsa.gv.tsc.tdk.com>
In-Reply-To: Dmitry Kohmanyuk <dk@dog.farm.org> "Re: Code Logic Question in 2.2 RELENG" (Jun  3, 11:14pm)

next in thread | previous in thread | raw e-mail | index | archive | help
On Jun 3, 11:14pm, Dmitry Kohmanyuk wrote:
} Subject: Re: Code Logic Question in 2.2 RELENG
} In article <19980603171959.17140.qmail@devious.lustig.com> you wrote:
} >   Does it make sense to have portmap fail when svc_run returns or would it  
} > make more sense to try and recover and restart the loop?  I've had portmap  
} > abort a few times now, and the only easy remedy is a reboot of the machine.   
} > If I try and restart portmap, I have to find all of the programs that  
} > registered with it and restart them.  Any suggestions?  By the way, this is  
} > from RELENG_2_2 cvsupped yesterday.
} 
} > This is from portmap.c:
} 
} >         /* additional initializations */
} >         check_startup();
} >         (void)signal(SIGCHLD, reap);
} >         svc_run();
} >         syslog(LOG_ERR, "svc_run returned unexpectedly");
} >         abort();
} 
} this bites me from time to time... see end of this message for workaround...
} 
} > This is from svc_run.c in libc:
} > void
} > svc_run()
} > {
} > #ifdef FD_SETSIZE
} >         fd_set readfds;
} > #else
} >       int readfds;
} > #endif /* def FD_SETSIZE */
} 
} >         for (;;) {
} > #ifdef FD_SETSIZE
} >                 readfds = svc_fdset;
} > #else
} >                 readfds = svc_fds;
} > #endif /* def FD_SETSIZE */
} >                 switch (select(_rpc_dtablesize(), &readfds, NULL, NULL,
} >                                (struct timeval *)0)) {
} >                 case -1:
} >                         if (errno == EINTR) {
} >                                 continue;
} >                         }
} >                         perror("svc_run: - select failed");
} >                         return;
} >                 case 0:
} >                         continue;
} >                 default:
} >                         svc_getreqset(&readfds);
} >                 }
} >         }
} > }
} 
} what bothers me here is how come that select() returns -1 and yet
} errno != EINTR.  According to man page, it should be then one of
} EBADF or EINVAL, none of which can occur...

Well, there's a call to perror().  What does it say errno is?  My
suspicion is that it is ECHILD.  My somewhat dated copy of portmap.c
has the following code:

void
reap()
{
        while (wait3((int *)NULL, WNOHANG, (struct rusage *)NULL) > 0);
}

If portmap receives two signals closely spaced in time, the first
signal will interrupt the select() call, and if reap() is called
after select() has set errno and returned, the wait3() call in reap()
will stomp errno.  I've fixed similar problems by saving errno at the
beginning of a signal handler and restoring it at the end.  I'm not
sure what ANSI and POSIX have to say about this and I don't know if
you can do this if you are using threads and have a per-thread errno,
but it has worked for me.

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199806040855.BAA06987>