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) {
// client has duplicate name
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 socket;
return;
@ -1297,7 +1302,12 @@ CServer::runClient(void* vsocket)
catch (XUnknownClient& e) {
// client has unknown name
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 socket;
return;
@ -1324,7 +1334,12 @@ CServer::runClient(void* vsocket)
catch (XBadClient&) {
// client not behaving
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) {
// misc error
@ -1434,13 +1449,23 @@ CServer::handshakeClient(IDataSocket* socket)
catch (XIncompatibleClient& e) {
// client is incompatible
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);
}
catch (XSocket& e) {
// ignore
}
}
catch (XBadClient&) {
// client not behaving
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) {
// misc error