Changeset 1241
- Timestamp:
- 07/25/08 22:19:30 (4 months ago)
- Files:
-
- trunk/pdns/pdns/tcpreceiver.cc (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/pdns/pdns/tcpreceiver.cc
r1215 r1241 25 25 #include <string> 26 26 #include "tcpreceiver.hh" 27 #include "sstuff.hh" 27 28 28 29 #include <errno.h> … … 89 90 ret=waitForData(fd, 5); 90 91 if(ret < 0) 91 throw runtime_error("Waiting for data read");92 throw NetworkError("Waiting for data read"); 92 93 if(!ret) 93 throw runtime_error("Timeout reading data");94 throw NetworkError("Timeout reading data"); 94 95 continue; 95 96 } 96 97 else 97 throw AhuException("Reading data: "+stringerror());98 throw NetworkError("Reading data: "+stringerror()); 98 99 } 99 100 if(!ret) { … … 101 102 return 0; 102 103 else 103 throw AhuException("Did not fulfill read from TCP due to EOF");104 throw NetworkError("Did not fulfill read from TCP due to EOF"); 104 105 } 105 106 … … 122 123 ret=waitForRWData(fd, false, 5, 0); 123 124 if(ret < 0) 124 throw runtime_error("Waiting for data write");125 throw NetworkError("Waiting for data write"); 125 126 if(!ret) 126 throw runtime_error("Timeout writing data");127 throw NetworkError("Timeout writing data"); 127 128 continue; 128 129 } 129 130 else 130 throw AhuException("Writing data: "+stringerror());131 throw NetworkError("Writing data: "+stringerror()); 131 132 } 132 133 if(!ret) { 133 throw AhuException("Did not fulfill TCP write due to EOF");134 throw NetworkError("Did not fulfill TCP write due to EOF"); 134 135 } 135 136 … … 149 150 if((err=connect(clisock, remote, socklen))<0 && WSAGetLastError() != WSAEWOULDBLOCK ) 150 151 #endif // WIN32 151 throw AhuException("connect: "+stringerror());152 throw NetworkError("connect: "+stringerror()); 152 153 153 154 if(!err) … … 156 157 err=waitForRWData(fd, false, 5, 0); 157 158 if(err == 0) 158 throw AhuException("Timeout connecting to remote");159 throw NetworkError("Timeout connecting to remote"); 159 160 if(err < 0) 160 throw AhuException("Error connecting to remote");161 throw NetworkError("Error connecting to remote"); 161 162 162 163 if(getsockopt(fd, SOL_SOCKET,SO_ERROR,(char *)&err,&len)<0) 163 throw AhuException("Error connecting to remote: "+stringerror()); // Solaris164 throw NetworkError("Error connecting to remote: "+stringerror()); // Solaris 164 165 165 166 if(err) 166 throw AhuException("Error connecting to remote: "+string(strerror(err)));167 throw NetworkError("Error connecting to remote: "+string(strerror(err))); 167 168 168 169 done: … … 184 185 readnWithTimeout(fd, mesg, pktlen); 185 186 } 186 catch( AhuException& ae) {187 throw AhuException("Error reading DNS data from TCP client "+remote.toString()+": "+ae.reason);187 catch(NetworkError& ae) { 188 throw NetworkError("Error reading DNS data from TCP client "+remote.toString()+": "+ae.what()); 188 189 } 189 190 … … 192 193 int sock=socket(AF_INET, SOCK_STREAM, 0); 193 194 if(sock < 0) 194 throw AhuException("Error making TCP connection socket to recursor: "+stringerror());195 throw NetworkError("Error making TCP connection socket to recursor: "+stringerror()); 195 196 196 197 Utility::setNonBlocking(sock); … … 222 223 writenWithTimeout(packet->getSocket(), answer, len); 223 224 } 224 catch( AhuException& ae) {225 catch(NetworkError& ae) { 225 226 close(sock); 226 throw AhuException("While proxying a question to recursor "+st.host+": " +ae.reason);227 throw NetworkError("While proxying a question to recursor "+st.host+": " +ae.what()); 227 228 } 228 229 close(sock);