From 667f7e60744657f69afd6bafa67d0f42dc96f97b Mon Sep 17 00:00:00 2001 From: Bert Hubert Date: Thu, 20 Apr 2006 06:55:40 +0000 Subject: [PATCH] work around 3.4.4 compiler bugs (freebsd 6 system compiler) git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@749 d19b8d6e-7fed-0310-83ef-9ca221ded41b --- pdns/pdns_recursor.cc | 92 +++++++++++++++++++++---------------------- 1 file changed, 46 insertions(+), 46 deletions(-) diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index 7e50478e5..7e8e8cb2a 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -528,7 +528,7 @@ void startDoResolve(void *p) close(dc->d_socket); } else { - any_cast(g_fdm->getReadParameter(dc->d_socket)).state=TCPConnection::BYTE0; + any_cast(g_fdm->getReadParameter(dc->d_socket))->state=TCPConnection::BYTE0; struct timeval now; gettimeofday(&now, 0); // needs to be updated g_fdm->setReadTTD(dc->d_socket, now, g_tcpTimeout); @@ -587,69 +587,69 @@ void makeControlChannelSocket() void handleRunningTCPQuestion(int fd, boost::any& var) { - TCPConnection& conn=any_cast(var); + TCPConnection* conn=any_cast(var); - if(conn.state==TCPConnection::BYTE0) { - int bytes=read(conn.fd,conn.data,2); + if(conn->state==TCPConnection::BYTE0) { + int bytes=read(conn->fd,conn->data,2); if(bytes==1) - conn.state=TCPConnection::BYTE1; + conn->state=TCPConnection::BYTE1; if(bytes==2) { - conn.qlen=(conn.data[0]<<8)+conn.data[1]; - conn.bytesread=0; - conn.state=TCPConnection::GETQUESTION; + conn->qlen=(conn->data[0]<<8)+conn->data[1]; + conn->bytesread=0; + conn->state=TCPConnection::GETQUESTION; } if(!bytes || bytes < 0) { - TCPConnection tmp(conn); + TCPConnection tmp(*conn); g_fdm->removeReadFD(fd); tmp.closeAndCleanup(); return; } } - else if(conn.state==TCPConnection::BYTE1) { - int bytes=read(conn.fd,conn.data+1,1); + else if(conn->state==TCPConnection::BYTE1) { + int bytes=read(conn->fd,conn->data+1,1); if(bytes==1) { - conn.state=TCPConnection::GETQUESTION; - conn.qlen=(conn.data[0]<<8)+conn.data[1]; - conn.bytesread=0; + conn->state=TCPConnection::GETQUESTION; + conn->qlen=(conn->data[0]<<8)+conn->data[1]; + conn->bytesread=0; } if(!bytes || bytes < 0) { if(g_logCommonErrors) - L<remote.toString() <<" disconnected after first byte"<removeReadFD(fd); tmp.closeAndCleanup(); // conn loses validity here.. return; } } - else if(conn.state==TCPConnection::GETQUESTION) { - int bytes=read(conn.fd,conn.data + conn.bytesread,conn.qlen - conn.bytesread); + else if(conn->state==TCPConnection::GETQUESTION) { + int bytes=read(conn->fd,conn->data + conn->bytesread,conn->qlen - conn->bytesread); if(!bytes || bytes < 0) { - L<remote.toString() <<" disconnected while reading question body"<removeReadFD(fd); tmp.closeAndCleanup(); // conn loses validity here.. return; } - conn.bytesread+=bytes; - if(conn.bytesread==conn.qlen) { - conn.state=TCPConnection::DONE; // this makes us immune from timeouts, from now on *we* are responsible + conn->bytesread+=bytes; + if(conn->bytesread==conn->qlen) { + conn->state=TCPConnection::DONE; // this makes us immune from timeouts, from now on *we* are responsible DNSComboWriter* dc=0; try { - dc=new DNSComboWriter(conn.data, conn.qlen, g_now); + dc=new DNSComboWriter(conn->data, conn->qlen, g_now); } catch(MOADNSException &mde) { g_stats.clientParseError++; - L<remote.toString() <removeReadFD(fd); tmp.closeAndCleanup(); return; } - dc->setSocket(conn.fd); + dc->setSocket(conn->fd); dc->d_tcp=true; - dc->setRemote(&conn.remote); + dc->setRemote(&conn->remote); if(dc->d_mdp.d_header.qr) L<(var); - // cerr<<"handleTCPClientReadable called for fd "<getHandle()<(var); + // cerr<<"handleTCPClientReadable called for fd "<inNeeded: "<inNeeded<<", "<sock->getHandle()< buffer(new char[pident.inNeeded]); + shared_array buffer(new char[pident->inNeeded]); - int ret=read(fd, buffer.get(), pident.inNeeded); + int ret=read(fd, buffer.get(), pident->inNeeded); if(ret > 0) { - pident.inMSG.append(&buffer[0], &buffer[ret]); - pident.inNeeded-=ret; - if(!pident.inNeeded) { - // cerr<<"Got entire load of "<inMSG.append(&buffer[0], &buffer[ret]); + pident->inNeeded-=ret; + if(!pident->inNeeded) { + // cerr<<"Got entire load of "<inMSG.size()<<" bytes"<inMSG; g_fdm->removeReadFD(fd); MT->sendEvent(pid, &msg); } else { - // cerr<<"Still have "<inNeeded<<" left to go"<removeReadFD(fd); // pident might now be invalid (it isn't, but still) string empty; MT->sendEvent(tmp, &empty); // this conveys error status @@ -1044,19 +1044,19 @@ void handleTCPClientReadable(int fd, boost::any& var) void handleTCPClientWritable(int fd, boost::any& var) { - PacketID& pid=any_cast(var); + PacketID* pid=any_cast(var); - int ret=write(fd, pid.outMSG.c_str(), pid.outMSG.size() - pid.outPos); + int ret=write(fd, pid->outMSG.c_str(), pid->outMSG.size() - pid->outPos); if(ret > 0) { - pid.outPos+=ret; - if(pid.outPos==pid.outMSG.size()) { - PacketID tmp=pid; + pid->outPos+=ret; + if(pid->outPos==pid->outMSG.size()) { + PacketID tmp=*pid; g_fdm->removeWriteFD(fd); MT->sendEvent(tmp, &tmp.outMSG); // send back what we sent to convey everything is ok } } else { // error or EOF - PacketID tmp(pid); + PacketID tmp(*pid); g_fdm->removeWriteFD(fd); string sent; MT->sendEvent(tmp, &sent); // we convey error status by sending empty string -- 2.49.0