Skip to content

Commit

Permalink
THRIFT-5779: Fix Thrift server getting killed for incomplete requests
Browse files Browse the repository at this point in the history
  • Loading branch information
anshulmgupta committed Apr 23, 2024
1 parent 4a280d5 commit 917012e
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/cpp/src/thrift/transport/TServerSocket.cpp
Expand Up @@ -593,6 +593,7 @@ bool TServerSocket::isUnixDomainSocket() const {
}

shared_ptr<TTransport> TServerSocket::acceptImpl() {
try_again:
if (serverSocket_ == THRIFT_INVALID_SOCKET) {
throw TTransportException(TTransportException::NOT_OPEN, "TServerSocket not listening");
}
Expand Down Expand Up @@ -654,8 +655,15 @@ shared_ptr<TTransport> TServerSocket::acceptImpl() {

if (clientSocket == THRIFT_INVALID_SOCKET) {
int errno_copy = THRIFT_GET_SOCKET_ERROR;
GlobalOutput.perror("TServerSocket::acceptImpl() ::accept() ", errno_copy);
throw TTransportException(TTransportException::UNKNOWN, "accept()", errno_copy);
// In case of an ECONNABORTED error or any other error with the accept
// call retry the accept again instead of raising the exception which
// might kill the thrift server and hence making the thrift server
// unresponsive. The error can happen when accept syscall call, waiting
// for an incoming connection, or receiving a connection that terminates
// before the accept process completes, hence killing the thrift serve
GlobalOutput.perror("TServerSocket::acceptImpl() ::accept() Retrying ",
errno_copy);
goto try_again;
}

// Make sure client socket is blocking
Expand Down

0 comments on commit 917012e

Please sign in to comment.