Now catching and ignoring errors when writing to a socket in those

cases where errors were not being caught, typically when responding
to some other socket or protocol error.
This commit is contained in:
crs 2003-01-12 16:08:45 +00:00
parent 780a6fd13d
commit b2e11d3d35
1 changed files with 30 additions and 5 deletions

View File

@ -1289,7 +1289,12 @@ CServer::runClient(void* vsocket)
catch (XDuplicateClient& e) { catch (XDuplicateClient& e) {
// client has duplicate name // client has duplicate name
LOG((CLOG_WARN "a client with name \"%s\" is already connected", e.getName().c_str())); LOG((CLOG_WARN "a client with name \"%s\" is already connected", e.getName().c_str()));
CProtocolUtil::writef(proxy->getOutputStream(), kMsgEBusy); try {
CProtocolUtil::writef(proxy->getOutputStream(), kMsgEBusy);
}
catch (XSocket&) {
// ignore
}
delete proxy; delete proxy;
delete socket; delete socket;
return; return;
@ -1297,7 +1302,12 @@ CServer::runClient(void* vsocket)
catch (XUnknownClient& e) { catch (XUnknownClient& e) {
// client has unknown name // client has unknown name
LOG((CLOG_WARN "a client with name \"%s\" is not in the map", e.getName().c_str())); LOG((CLOG_WARN "a client with name \"%s\" is not in the map", e.getName().c_str()));
CProtocolUtil::writef(proxy->getOutputStream(), kMsgEUnknown); try {
CProtocolUtil::writef(proxy->getOutputStream(), kMsgEUnknown);
}
catch (XSocket&) {
// ignore
}
delete proxy; delete proxy;
delete socket; delete socket;
return; return;
@ -1324,7 +1334,12 @@ CServer::runClient(void* vsocket)
catch (XBadClient&) { catch (XBadClient&) {
// client not behaving // client not behaving
LOG((CLOG_WARN "protocol error from client \"%s\"", proxy->getName().c_str())); LOG((CLOG_WARN "protocol error from client \"%s\"", proxy->getName().c_str()));
CProtocolUtil::writef(proxy->getOutputStream(), kMsgEBad); try {
CProtocolUtil::writef(proxy->getOutputStream(), kMsgEBad);
}
catch (XSocket& e) {
// ignore. client probably aborted the connection.
}
} }
catch (XBase& e) { catch (XBase& e) {
// misc error // misc error
@ -1434,13 +1449,23 @@ CServer::handshakeClient(IDataSocket* socket)
catch (XIncompatibleClient& e) { catch (XIncompatibleClient& e) {
// client is incompatible // client is incompatible
LOG((CLOG_WARN "client \"%s\" has incompatible version %d.%d)", name.c_str(), e.getMajor(), e.getMinor())); LOG((CLOG_WARN "client \"%s\" has incompatible version %d.%d)", name.c_str(), e.getMajor(), e.getMinor()));
CProtocolUtil::writef(output, kMsgEIncompatible, try {
CProtocolUtil::writef(output, kMsgEIncompatible,
kProtocolMajorVersion, kProtocolMinorVersion); kProtocolMajorVersion, kProtocolMinorVersion);
}
catch (XSocket& e) {
// ignore
}
} }
catch (XBadClient&) { catch (XBadClient&) {
// client not behaving // client not behaving
LOG((CLOG_WARN "protocol error from client \"%s\"", name.c_str())); LOG((CLOG_WARN "protocol error from client \"%s\"", name.c_str()));
CProtocolUtil::writef(output, kMsgEBad); try {
CProtocolUtil::writef(output, kMsgEBad);
}
catch (XSocket& e) {
// ignore. client probably aborted the connection.
}
} }
catch (XBase& e) { catch (XBase& e) {
// misc error // misc error