Jens Geyer created THRIFT-6227:
----------------------------------
Summary: C++: TServerSocket::listen() leaks a socket for every
failed bind attempt when retries are enabled
Key: THRIFT-6227
URL: https://issues.apache.org/jira/browse/THRIFT-6227
Project: Thrift
Issue Type: Bug
Components: C++ - Library
Reporter: Jens Geyer
With {{setRetryLimit()}} greater than 0, each pass of the TCP bind loop in
{{TServerSocket::listen()}} ({{TServerSocket.cpp}}, around line 517 on master)
does
{code:cpp}
serverSocket_ = socket(trybind->ai_family, trybind->ai_socktype,
trybind->ai_protocol);
{code}
without closing the descriptor from the previous pass, whose {{bind()}} failed.
Every failed attempt leaks one socket. The Unix domain socket branch above it
creates its socket once, before the loop, and is not affected.
Suggested fix: close {{serverSocket_}} before the next attempt. Found while
looking at THRIFT-6191.
_Drafted with AI assistance (Claude Opus 5); reviewed and filed by Jens Geyer._
--
This message was sent by Atlassian Jira
(v8.20.10#820010)