Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

THRIFT-5779: Fix Thrift server getting killed for incomplete requests #2964

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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