This is an automated email from the ASF dual-hosted git repository.
xyz pushed a commit to branch branch-2.10
in repository https://gitbox.apache.org/repos/asf/pulsar.git
The following commit(s) were added to refs/heads/branch-2.10 by this push:
new b5b8cb0 [C++] Fix segmentation fault when creating socket failed
(#14834)
b5b8cb0 is described below
commit b5b8cb0075e228a1fba2d2ee9b4ab9ff37b3a4b7
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 79297f8..4a1b3a4 100644
--- a/pulsar-client-cpp/lib/ClientConnection.cc
+++ b/pulsar-client-cpp/lib/ClientConnection.cc
@@ -1551,7 +1551,9 @@ void ClientConnection::close(Result result) {
consumerStatsRequestTimer_.reset();
}
- connectTimeoutTask_->stop();
+ if (connectTimeoutTask_) {
+ connectTimeoutTask_->stop();
+ }
lock.unlock();
LOG_INFO(cnxString_ << "Connection closed");