Date: Wed, 23 Sep 1998 12:30:06 -0600 From: Warner Losh <imp@village.org> To: Don Lewis <Don.Lewis@tsc.tdk.com> Cc: Graham Wheeler <gram@cdsec.com>, hackers@FreeBSD.ORG Subject: Re: The inetd realloc problem: an observation Message-ID: <199809231830.MAA22650@harmony.village.org> In-Reply-To: Your message of "Tue, 22 Sep 1998 15:59:39 PDT." <199809222259.PAA19262@salsa.gv.tsc.tdk.com> References: <199809222259.PAA19262@salsa.gv.tsc.tdk.com>
next in thread | previous in thread | raw e-mail | index | archive | help
In message <199809222259.PAA19262@salsa.gv.tsc.tdk.com> Don Lewis writes: : I thought of a more elegant way of handling the timeout problem. Before : starting the select loop, create a pipe. Add the fd of the read end of the : pipe to the list of descriptors passed to select. In each of the signal : handlers, write a single character to the pipe in addition to setting the : flag. When select indicates that the pipe has data to read, block : the signals that have handlers, read a character from the pipe, test : and clear each of the flags, execute the appropriate code for each flag, : and unblock signals. We used this in OI to implement a "safe" signal callback. Since we already had a select loop, we just addedt his pipe to the loop. We registered signal handlers and when the signal came in, we'd write the signal number to this pipe. When the select fired, we knew it was a "safe" time to do anything at all, so we called the user's callback. This worked well on all systems that we tested from FreeBSD to Solaris to IRIX. We didn't bother blocking the signals since we didn't care if the signal came in 10 times or once, since we'd have 10 callbacks or one for the user. This worked really well for things like SIGIO and SIGCHLD which the user wanted to catch. Since all we were doing in the signal handler was writing a single byte with a WRITE call, this was safe and portable. I can't take credit for thinking of this. One of the OI users at bbn (later at centerline) sent us this suggestiong back in early 1991 or so. Warner 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?199809231830.MAA22650>