[Pdns-users] recursor going opaque + nonblocking sockets?

bert hubert ahu at ds9a.nl
Mon Sep 6 14:39:44 UTC 2004


Christopher,

I've fixed your bug #12 (http://ds9a.nl/cgi-bin/cvstrac/pdns/tktview?tn=12)

But I'm wondering about bug #13:

--- pdns-2.9.16.orig/pdns/pdns_recursor.cc +++ pdns-2.9.16/pdns/pdns_recursor.cc 
@@ -238,6 +238,8 @@ 
 } if(!tries) throw AhuException("Resolver binding to local socket: "+stringerror()); 
+ Utility::setNonBlocking(d_clientsock); 
 } 
 void makeTCPServerSocket() 

@@ -270,6 +272,7 @@ 
 	exit(1); 
 } 
+ Utility::setNonBlocking(d_tcpserversock);
  listen(d_tcpserversock, 128); 
  } 

@@ -300,6 +303,7 @@ 
 if (bind(d_serversock, (struct sockaddr *)&sin, sizeof(sin))<0) 
	throw AhuException("Resolver binding to server socket: "+stringerror()); L<<Logger::Error<<"Incoming query source port: "<<arg().asNum("local-port")<<endl; 
+ Utility::setNonBlocking(d_serversock); }


Setting d_tcpserversock to nonblocking is indeed recommended by Stevens. If
d_clientsock is unable to ever unable to send, pdns should wait. Not a lot
of reason to barge onwards then as the kernel is then unable to send packets
anyhow.

Same for d_serversock - I'm unaware of there ever being the possibility for
select returning that there is a datagram which there then isn't at read()
time.

I've changed to code to set the tcp server socket to nonblocking, and to be
on the safe side, d_serversock too. I do want to block on d_clientsock.

Thanks!

-- 
http://www.PowerDNS.com      Open source, database driven DNS Software 
http://lartc.org           Linux Advanced Routing & Traffic Control HOWTO


More information about the Pdns-users mailing list