This is an automated email from the ASF dual-hosted git repository. xyz pushed a commit to branch branch-2.8 in repository https://gitbox.apache.org/repos/asf/pulsar.git
commit 99b9dad6dcc833e986de29a8314adb4c8b705035 Author: Yunze Xu <[email protected]> AuthorDate: Thu Mar 24 15:29:16 2022 +0800 [C++] Fix segmentation fault when creating socket failed (#14834) ### Motivation https://github.com/apache/pulsar/pull/14823 fixes the flaky `testConnectTimeout` but it's also a regression of https://github.com/apache/pulsar/pull/14587. Because when the fd limit is reached, the `connectionTimeoutTask_` won't be initialized with a non-null value. Calling `stop` method on it directly will cause segmentation fault. See https://github.com/apache/pulsar/blob/0fe921f32cefe7648ca428cd9861f9163c69767d/pulsar-client-cpp/lib/ClientConnection.cc#L178-L185 ### Modifications Add the null check for `connectionTimeoutTask_` in `ClientConnection::close`. (cherry picked from commit 54c368ed3744a40240205c17bdcac5cef48130e4) --- pulsar-client-cpp/lib/ClientConnection.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pulsar-client-cpp/lib/ClientConnection.cc b/pulsar-client-cpp/lib/ClientConnection.cc index 2747de0..8802187 100644 --- a/pulsar-client-cpp/lib/ClientConnection.cc +++ b/pulsar-client-cpp/lib/ClientConnection.cc @@ -1526,7 +1526,9 @@ void ClientConnection::close(Result result) { consumerStatsRequestTimer_.reset(); } - connectTimeoutTask_->stop(); + if (connectTimeoutTask_) { + connectTimeoutTask_->stop(); + } lock.unlock(); LOG_INFO(cnxString_ << "Connection closed");
