shared_ptr<DNSPacket> packet;
// Fix gcc-4.0 error (on AMD64)
int fd=(int)(long)data; // gotta love C (generates a harmless warning on opteron)
+ ComboAddress remote;
+ socklen_t remotelen=sizeof(remote);
+
pthread_detach(pthread_self());
+ if(getpeername(fd, (struct sockaddr *)&remote, &remotelen) < 0) {
+ L<<Logger::Warning<<"Received question from socket which had no remote address, dropping ("<<stringerror()<<")"<<endl;
+ d_connectionroom_sem->post();
+ closesocket(fd);
+ return 0;
+ }
+
setNonBlocking(fd);
try {
int mesgsize=65535;
DLOG(L<<"TCP Connection accepted on fd "<<fd<<endl);
bool logDNSQueries= ::arg().mustDo("log-dns-queries");
for(;;) {
- ComboAddress remote;
- socklen_t remotelen=sizeof(remote);
- if(getpeername(fd, (struct sockaddr *)&remote, &remotelen) < 0) {
- L<<Logger::Warning<<"Received question from socket which had no remote address, dropping ("<<stringerror()<<")"<<endl;
- break;
- }
uint16_t pktlen;
if(!readnWithTimeout(fd, &pktlen, 2, false))