#include <cassert>
#include <list>
#include <iostream>
+#include <errno.h>
#include <boost/foreach.hpp>
#include <boost/algorithm/string/case_conv.hpp>
// socket-level errors
virtual void handleError(int error)
- {
+ {
+ if (error == ENOENT) {
+ // name lookup failure, abandon all requests on this connection
+ sentRequests.clear();
+ queuedRequests.clear();
+ }
+
NetChat::handleError(error);
if (activeRequest) {
SG_LOG(SG_IO, SG_INFO, "HTTP socket error");
if (!addr.isValid()) {
SG_LOG(SG_IO, SG_WARN, "Network: host lookup failed:" << host);
- handleError (0);
+ handleError (ENOENT);
close();
return -1;
}
SG_LOG(SG_IO, SG_WARN, "Network:" << getHandle() << ": unhandled accept");
}
-void NetChannel::handleError (int error) {
- SG_LOG(SG_IO, SG_WARN,"Network:" << getHandle() << ": errno: " << strerror(errno) <<"(" << errno << ")");
+void NetChannel::handleError (int error)
+{
+ // warn about address lookup failures seperately, don't warn again.
+ // (and we (ab-)use ENOENT to mean 'name not found'.
+ if (error != ENOENT) {
+ SG_LOG(SG_IO, SG_WARN,"Network:" << getHandle() << ": errno: " << strerror(errno) <<"(" << errno << ")");
+ }
}
} // of namespace simgear