NONBLOCKing close blocks in named (fwd) (Fyi)

Mr. James W. Laferriere babydr at baby-dragons.com
Sun Sep 19 04:30:08 UTC 1999


	Hello All, In a discussion between the people below a possible
	bug under newer linux's may have been found .  Hth,  JimL

 --- Begin include message ---
---------- Forwarded message ----------
Date: Sat, 18 Sep 1999 10:09:01 -0400
From: Simon Kirby <sim at netnation.com>
To: Steven Clarke <Steven.Clarke at ThePLAnet.net>
Cc: linux-kernel at vger.rutgers.edu, Alan Cox <alan at lxorguk.ukuu.org.uk>
Subject: Re: NONBLOCKing close blocks in named

On Sat, Sep 18, 1999 at 01:11:38AM +0100, Steven Clarke wrote:

> On Fri, 17 Sep 1999, Alan Cox wrote:
> 
> > > If a socket file description has the O_NONBLOCK flag set, a close syscall
> > > should return almost straight away, right? 
> > 
> > If SO_LINGER is set the close() blocks. If SO_LINGER is not set it doesnt
> > block. Ok thats the theory anyway.
> > 
> > Check the SO_LINGER settings
> 
> Should have mentioned that I checked that. According to the strace,
> SO_LINGER hasn't been set or unset on that file descriptor (curiously, it
> had been set on a previous socket from the same IP and with the same file
> descriptor number).
> 
> Even where the LINGER was set (elsewhere in the code) it was set to 120
> (units - seconds? - claims to be hundreths of seconds in the setsockopt
> man page but I think that's wrong).  In the problem that I demonstrated,
> close took 11 minutes to return! 
> 
> I'm tempted to comment out the only SO_LINGER entry in BIND (it doesn't
> seem to be needed) to see it help - I'm not sure.

We had to do this on our nameservers to stop similar problems.  Removing
SO_LINGER fixed it.

I created this (cheap) patch that seems to do the trick:

diff -ru src/bin/named/ns_main.c bind-8.2.1/bin/named/ns_main.c
--- src/bin/named/ns_main.c	Thu Jun 17 19:26:54 1999
+++ bind-8.2.1/bin/named/ns_main.c	Thu Jun 24 13:31:22 1999
@@ -1719,6 +1719,7 @@
  */
 int
 sq_openw(struct qstream *qs, int buflen) {
+#undef SO_LINGER
 #ifdef SO_LINGER	/* XXX */
 	static const struct linger ll = { 1, 120 };
 #endif

Against 8.2.1 in this case.  Should also apply to 8.1.2.

Simon-
 --- End include message ---
       +-----------------------------------------------------------------+
       | James   W.   Laferriere | System   Techniques | Give me VMS     |
       | Network        Engineer | 25416       22nd So |   Give me Linux |
       | babydr at baby-dragons.com | DesMoines  WA 98198 |     only on AXP |
       +-----------------------------------------------------------------+



More information about the bind-workers mailing list