Skip to content
Snippets Groups Projects
Commit 760b2987 authored by Nicolas Pope's avatar Nicolas Pope
Browse files

Dont close socket on non errors

parent 260e67f8
No related branches found
No related tags found
No related merge requests found
Pipeline #29481 failed
......@@ -205,7 +205,7 @@ class Peer {
protected:
void data(); // Process one message from socket
void socketError(); // Process one error from socket
bool socketError(); // Process one error from socket
void error(int e);
bool _data();
......
......@@ -401,7 +401,7 @@ void Peer::_badClose(bool retry) {
}
}
void Peer::socketError() {
bool Peer::socketError() {
int err;
#ifdef WIN32
int optlen = sizeof(err);
......@@ -410,11 +410,14 @@ void Peer::socketError() {
#endif
getsockopt(sock_, SOL_SOCKET, SO_ERROR, (char*)&err, &optlen);
if (err == 0) return false;
// Must close before log since log may try to send over net causing
// more socket errors...
_badClose();
if (err != 0) LOG(ERROR) << "Socket: " << uri_ << " - error " << err;
LOG(ERROR) << "Socket: " << uri_ << " - error " << err;
return true;
}
void Peer::error(int e) {
......
......@@ -445,10 +445,11 @@ void Universe::_run() {
if (sock == INVALID_SOCKET) continue;
if (FD_ISSET(sock, &impl_->sfderror_)) {
s->socketError();
if (s->socketError()) {
s->close();
continue; // No point in reading data...
}
}
//If message received from this client then deal with it
if (FD_ISSET(sock, &impl_->sfdread_)) {
s->data();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment