You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by xy...@apache.org on 2025/04/28 03:20:43 UTC
(pulsar-client-cpp) branch branch-3.7 updated (115d64a -> 7d994db)
This is an automated email from the ASF dual-hosted git repository.
xyz pushed a change to branch branch-3.7
in repository https://gitbox.apache.org/repos/asf/pulsar-client-cpp.git
from 115d64a Release 3.7.0
new dfa854b Fix an issue where zero queue consumers are unable to receive messages after topic unloading (#473)
new 5c928d4 Make it optional to link statically to libgcc and libstdc++ (#474)
new 7f85d53 Fix multi-topics-consumer new topic listeners stuck in paused state (#481)
new bc22fc4 fix: ignore ping command in connection keepalive logic (#480)
new 7d994db Bump curl, openssl, zlib to address CVEs (#482)
The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.github/workflows/ci-pr-validation.yaml | 2 +-
lib/CMakeLists.txt | 3 +-
lib/ClientConnection.cc | 4 +-
lib/ConsumerImpl.cc | 68 +++++++++++++++----
lib/HTTPLookupService.cc | 12 +---
lib/{DeadLetterPolicyImpl.h => JsonUtils.h} | 21 ++++--
lib/PatternMultiTopicsConsumerImpl.cc | 3 +
lib/Schema.cc | 9 +--
perf/PerfConsumer.cc | 2 +
perf/PerfProducer.cc | 2 +
pkg/deb/build-deb.sh | 2 +-
pkg/mac/build-static-library.sh | 2 +-
pkg/mac/vcpkg-curl-patch.diff | 17 ++---
pkg/rpm/SPECS/pulsar-client.spec | 1 +
tests/ZeroQueueSizeTest.cc | 100 ++++++++++++++++++++++++++++
vcpkg | 2 +-
vcpkg.json | 26 ++++++--
17 files changed, 220 insertions(+), 56 deletions(-)
copy lib/{DeadLetterPolicyImpl.h => JsonUtils.h} (67%)
(pulsar-client-cpp) 05/05: Bump curl, openssl, zlib to address CVEs (#482)
Posted by xy...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
xyz pushed a commit to branch branch-3.7
in repository https://gitbox.apache.org/repos/asf/pulsar-client-cpp.git
commit 7d994db53774f8e85ccbab002950e74e20d74660
Author: Yunze Xu <xy...@163.com>
AuthorDate: Fri Apr 25 17:37:57 2025 +0800
Bump curl, openssl, zlib to address CVEs (#482)
- openssl 3.1.4 -> 3.5.0
- zlib 1.3 -> 1.3.1
- curl 8.4.0 -> 8.13.0
Keep the `protobuf` to an old version (3.21.12) because it's the last release that supports C++11, see https://protobuf.dev/news/2022-08-03/
Keep the `asio` version not changed (1.28.2) because there are some APIs removed.
(cherry picked from commit eede80b62fbf6c2b26607cec1ce1e0b4e9d857fa)
---
.github/workflows/ci-pr-validation.yaml | 2 +-
lib/HTTPLookupService.cc | 12 +++-------
lib/JsonUtils.h | 41 +++++++++++++++++++++++++++++++++
lib/Schema.cc | 9 ++------
perf/PerfConsumer.cc | 2 ++
perf/PerfProducer.cc | 2 ++
pkg/mac/build-static-library.sh | 2 +-
pkg/mac/vcpkg-curl-patch.diff | 17 +++++++-------
vcpkg | 2 +-
vcpkg.json | 26 ++++++++++++++++-----
10 files changed, 82 insertions(+), 33 deletions(-)
diff --git a/.github/workflows/ci-pr-validation.yaml b/.github/workflows/ci-pr-validation.yaml
index 5cb18df..861b0d9 100644
--- a/.github/workflows/ci-pr-validation.yaml
+++ b/.github/workflows/ci-pr-validation.yaml
@@ -48,7 +48,7 @@ jobs:
strategy:
matrix:
# TODO: support build on macos-14
- os: [ubuntu-20.04]
+ os: [ubuntu-latest]
steps:
- name: checkout
diff --git a/lib/HTTPLookupService.cc b/lib/HTTPLookupService.cc
index 93b9db4..60b5343 100644
--- a/lib/HTTPLookupService.cc
+++ b/lib/HTTPLookupService.cc
@@ -26,6 +26,7 @@
#include "CurlWrapper.h"
#include "ExecutorService.h"
#include "Int64SerDes.h"
+#include "JsonUtils.h"
#include "LogUtils.h"
#include "NamespaceName.h"
#include "SchemaUtils.h"
@@ -409,15 +410,8 @@ void HTTPLookupService::handleGetSchemaHTTPRequest(GetSchemaPromise promise, con
promise.setFailed(ResultInvalidMessage);
return;
}
- std::stringstream keyStream;
- ptree::write_json(keyStream, kvRoot.get_child("key"), false);
- std::stringstream valueStream;
- ptree::write_json(valueStream, kvRoot.get_child("value"), false);
- auto keyData = keyStream.str();
- auto valueData = valueStream.str();
- // Remove the last line break.
- keyData.pop_back();
- valueData.pop_back();
+ const auto keyData = toJson(kvRoot.get_child("key"));
+ const auto valueData = toJson(kvRoot.get_child("value"));
schemaData = mergeKeyValueSchema(keyData, valueData);
}
diff --git a/lib/JsonUtils.h b/lib/JsonUtils.h
new file mode 100644
index 0000000..841eb5e
--- /dev/null
+++ b/lib/JsonUtils.h
@@ -0,0 +1,41 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+#pragma once
+
+#include <boost/property_tree/json_parser.hpp>
+#include <sstream>
+#include <string>
+
+namespace pulsar {
+
+template <typename Ptree>
+inline std::string toJson(const Ptree& pt) {
+ std::ostringstream oss;
+ boost::property_tree::write_json(oss, pt, false);
+ // For Boost < 1.86, boost::property_tree will write a endline at the end
+#if BOOST_VERSION < 108600
+ auto s = oss.str();
+ s.pop_back();
+ return s;
+#else
+ return oss.str();
+#endif
+}
+
+} // namespace pulsar
diff --git a/lib/Schema.cc b/lib/Schema.cc
index d77822a..c8f8b4d 100644
--- a/lib/Schema.cc
+++ b/lib/Schema.cc
@@ -25,11 +25,10 @@
#include <map>
#include <memory>
+#include "JsonUtils.h"
#include "SchemaUtils.h"
using boost::property_tree::ptree;
-using boost::property_tree::read_json;
-using boost::property_tree::write_json;
PULSAR_PUBLIC std::ostream &operator<<(std::ostream &s, pulsar::SchemaType schemaType) {
return s << strSchemaType(schemaType);
@@ -170,11 +169,7 @@ SchemaInfo::SchemaInfo(const SchemaInfo &keySchema, const SchemaInfo &valueSchem
for (auto &entry : properties) {
pt.put(entry.first, entry.second);
}
- std::ostringstream buf;
- write_json(buf, pt, false);
- auto s = buf.str();
- s.pop_back();
- return s;
+ return toJson(pt);
};
StringMap properties;
diff --git a/perf/PerfConsumer.cc b/perf/PerfConsumer.cc
index 424809b..7a707a1 100644
--- a/perf/PerfConsumer.cc
+++ b/perf/PerfConsumer.cc
@@ -19,6 +19,8 @@
#include <lib/LogUtils.h>
DECLARE_LOG_OBJECT()
+// Don't remove this line because p_square_quantile.hpp requires including <algorithm> on some platforms
+#include <algorithm>
#include <chrono>
#include <fstream>
#include <functional>
diff --git a/perf/PerfProducer.cc b/perf/PerfProducer.cc
index cbfef68..17e70cd 100644
--- a/perf/PerfProducer.cc
+++ b/perf/PerfProducer.cc
@@ -19,6 +19,8 @@
#include <lib/LogUtils.h>
DECLARE_LOG_OBJECT()
+// Don't remove this line because p_square_quantile.hpp requires including <algorithm> on some platforms
+#include <algorithm>
#include <boost/accumulators/accumulators.hpp>
#include <boost/accumulators/statistics/mean.hpp>
#include <boost/accumulators/statistics/p_square_quantile.hpp>
diff --git a/pkg/mac/build-static-library.sh b/pkg/mac/build-static-library.sh
index 88b674b..449222b 100755
--- a/pkg/mac/build-static-library.sh
+++ b/pkg/mac/build-static-library.sh
@@ -48,7 +48,7 @@ git commit -m "Update version"
COMMIT_ID=$(git log --pretty=oneline | head -n 1 | awk '{print $1}')
cd ..
sed -i.bak "s/.*builtin-baseline.*/ \"builtin-baseline\": \"$COMMIT_ID\",/" vcpkg.json
-sed -i.bak "s/\"version>=\": \"8\.4\.0\"/\"version>=\": \"8.4.0#1\"/" vcpkg.json
+sed -i.bak "s/\"version>=\": \"8\.13\.0#1\"/\"version>=\": \"8.13.0#2\"/" vcpkg.json
INSTALL_DIR=$PWD/pkg/mac/.install
set -x
diff --git a/pkg/mac/vcpkg-curl-patch.diff b/pkg/mac/vcpkg-curl-patch.diff
index e619e29..c932fee 100644
--- a/pkg/mac/vcpkg-curl-patch.diff
+++ b/pkg/mac/vcpkg-curl-patch.diff
@@ -1,8 +1,8 @@
diff --git a/ports/curl/portfile.cmake b/ports/curl/portfile.cmake
-index bdc544e9e..340d93865 100644
+index 427bccb217..ddfd75d30f 100644
--- a/ports/curl/portfile.cmake
+++ b/ports/curl/portfile.cmake
-@@ -64,6 +64,10 @@ if(VCPKG_TARGET_IS_WINDOWS)
+@@ -62,6 +62,10 @@ if(VCPKG_TARGET_IS_WINDOWS)
list(APPEND OPTIONS -DENABLE_UNICODE=ON)
endif()
@@ -10,18 +10,19 @@ index bdc544e9e..340d93865 100644
+ list(APPEND OPTIONS -DENABLE_IPV6=OFF)
+endif()
+
+ vcpkg_find_acquire_program(PKGCONFIG)
+
vcpkg_cmake_configure(
- SOURCE_PATH "${SOURCE_PATH}"
- OPTIONS
diff --git a/ports/curl/vcpkg.json b/ports/curl/vcpkg.json
-index e028d3897..a63858e34 100644
+index 31955859d0..50e619b846 100644
--- a/ports/curl/vcpkg.json
+++ b/ports/curl/vcpkg.json
-@@ -1,6 +1,7 @@
+@@ -1,7 +1,7 @@
{
"name": "curl",
- "version": "8.4.0",
-+ "port-version": 1,
+ "version": "8.13.0",
+- "port-version": 1,
++ "port-version": 2,
"description": "A library for transferring data with URLs",
"homepage": "https://curl.se/",
"license": "curl AND ISC AND BSD-3-Clause",
diff --git a/vcpkg b/vcpkg
index 97dd267..d6995a0 160000
--- a/vcpkg
+++ b/vcpkg
@@ -1 +1 @@
-Subproject commit 97dd26728e3856ed1ab62ee74ee3a391d9c81d19
+Subproject commit d6995a0cf3cafda5e9e52749fad075dd62bfd90c
diff --git a/vcpkg.json b/vcpkg.json
index 5ff4410..ec9aabd 100644
--- a/vcpkg.json
+++ b/vcpkg.json
@@ -1,8 +1,8 @@
{
"name": "pulsar-cpp",
- "version": "3.5.0",
+ "version": "3.8.0",
"description": "Pulsar C++ SDK",
- "builtin-baseline": "b051745c68faa6f65c493371d564c4eb8af34dad",
+ "builtin-baseline": "d6995a0cf3cafda5e9e52749fad075dd62bfd90c",
"dependencies": [
{
"name": "asio",
@@ -15,6 +15,10 @@
"name": "boost-accumulators",
"version>=": "1.83.0"
},
+ {
+ "name": "boost-format",
+ "version>=": "1.83.0"
+ },
{
"name": "boost-property-tree",
"version>=": "1.83.0"
@@ -25,7 +29,7 @@
"features": [
"openssl"
],
- "version>=": "8.4.0"
+ "version>=": "8.13.0#1"
},
{
"name": "dlfcn-win32",
@@ -33,7 +37,7 @@
},
{
"name": "openssl",
- "version>=": "3.1.4#1"
+ "version>=": "3.5.0"
},
{
"name": "protobuf",
@@ -45,7 +49,7 @@
},
{
"name": "zlib",
- "version>=": "1.3"
+ "version>=": "1.3.1"
},
{
"name": "zstd",
@@ -71,5 +75,15 @@
}
]
}
- }
+ },
+ "overrides": [
+ {
+ "name": "asio",
+ "version": "1.28.2"
+ },
+ {
+ "name": "protobuf",
+ "version": "3.21.12"
+ }
+ ]
}
(pulsar-client-cpp) 01/05: Fix an issue where zero queue consumers are unable to receive messages after topic unloading (#473)
Posted by xy...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
xyz pushed a commit to branch branch-3.7
in repository https://gitbox.apache.org/repos/asf/pulsar-client-cpp.git
commit dfa854be93798b419fef55dca0bddbbec5f320b8
Author: Masahiro Sakamoto <ma...@lycorp.co.jp>
AuthorDate: Sat Feb 8 14:46:42 2025 +0900
Fix an issue where zero queue consumers are unable to receive messages after topic unloading (#473)
(cherry picked from commit afeac788d1e951951516b7aabee4c70af579dda2)
---
lib/ConsumerImpl.cc | 68 +++++++++++++++++++++++-------
tests/ZeroQueueSizeTest.cc | 100 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 154 insertions(+), 14 deletions(-)
diff --git a/lib/ConsumerImpl.cc b/lib/ConsumerImpl.cc
index d540849..250845b 100644
--- a/lib/ConsumerImpl.cc
+++ b/lib/ConsumerImpl.cc
@@ -310,15 +310,23 @@ Result ConsumerImpl::handleCreateConsumer(const ClientConnectionPtr& cnx, Result
if (result == ResultOk) {
LOG_INFO(getName() << "Created consumer on broker " << cnx->cnxString());
{
- Lock lock(mutex_);
+ Lock mutexLock(mutex_);
setCnx(cnx);
incomingMessages_.clear();
possibleSendToDeadLetterTopicMessages_.clear();
state_ = Ready;
backoff_.reset();
- // Complicated logic since we don't have a isLocked() function for mutex
- if (waitingForZeroQueueSizeMessage) {
- sendFlowPermitsToBroker(cnx, 1);
+ if (!messageListener_ && config_.getReceiverQueueSize() == 0) {
+ // Complicated logic since we don't have a isLocked() function for mutex
+ if (waitingForZeroQueueSizeMessage) {
+ sendFlowPermitsToBroker(cnx, 1);
+ }
+ // Note that the order of lock acquisition must be mutex_ -> pendingReceiveMutex_,
+ // otherwise a deadlock will occur.
+ Lock pendingReceiveMutexLock(pendingReceiveMutex_);
+ if (!pendingReceives_.empty()) {
+ sendFlowPermitsToBroker(cnx, pendingReceives_.size());
+ }
}
availablePermits_ = 0;
}
@@ -915,7 +923,6 @@ Result ConsumerImpl::fetchSingleMessageFromBroker(Message& msg) {
}
// Using RAII for locking
- ClientConnectionPtr currentCnx = getCnx().lock();
Lock lock(mutexForReceiveWithZeroQueueSize);
// Just being cautious
@@ -924,9 +931,18 @@ Result ConsumerImpl::fetchSingleMessageFromBroker(Message& msg) {
getName() << "The incoming message queue should never be greater than 0 when Queue size is 0");
incomingMessages_.clear();
}
- waitingForZeroQueueSizeMessage = true;
- sendFlowPermitsToBroker(currentCnx, 1);
+ {
+ // Lock mutex_ to prevent a race condition with handleCreateConsumer.
+ // If handleCreateConsumer is executed after setting waitingForZeroQueueSizeMessage to true and
+ // before calling sendFlowPermitsToBroker, the result may be that a flow permit is sent twice.
+ Lock lock(mutex_);
+ waitingForZeroQueueSizeMessage = true;
+ // If connection_ is nullptr, sendFlowPermitsToBroker does nothing.
+ // In other words, a flow permit will not be sent until setCnx(cnx) is executed in
+ // handleCreateConsumer.
+ sendFlowPermitsToBroker(getCnx().lock(), 1);
+ }
while (true) {
if (!incomingMessages_.pop(msg)) {
@@ -939,6 +955,7 @@ Result ConsumerImpl::fetchSingleMessageFromBroker(Message& msg) {
Lock localLock(mutex_);
// if message received due to an old flow - discard it and wait for the message from the
// latest flow command
+ ClientConnectionPtr currentCnx = getCnx().lock();
if (msg.impl_->cnx_ == currentCnx.get()) {
waitingForZeroQueueSizeMessage = false;
// Can't use break here else it may trigger a race with connection opened.
@@ -966,19 +983,42 @@ void ConsumerImpl::receiveAsync(ReceiveCallback callback) {
return;
}
- Lock lock(pendingReceiveMutex_);
+ if (messageListener_) {
+ LOG_ERROR(getName() << "Can not receive when a listener has been set");
+ callback(ResultInvalidConfiguration, msg);
+ return;
+ }
+
+ Lock mutexlock(mutex_, std::defer_lock);
+ if (config_.getReceiverQueueSize() == 0) {
+ // Lock mutex_ to prevent a race condition with handleCreateConsumer.
+ // If handleCreateConsumer is executed after pushing the callback to pendingReceives_ and
+ // before calling sendFlowPermitsToBroker, the result may be that a flow permit is sent twice.
+ // Note that the order of lock acquisition must be mutex_ -> pendingReceiveMutex_,
+ // otherwise a deadlock will occur.
+ mutexlock.lock();
+ }
+
+ Lock pendingReceiveMutexLock(pendingReceiveMutex_);
if (incomingMessages_.pop(msg, std::chrono::milliseconds(0))) {
- lock.unlock();
+ pendingReceiveMutexLock.unlock();
+ if (config_.getReceiverQueueSize() == 0) {
+ mutexlock.unlock();
+ }
messageProcessed(msg);
msg = interceptors_->beforeConsume(Consumer(shared_from_this()), msg);
callback(ResultOk, msg);
+ } else if (config_.getReceiverQueueSize() == 0) {
+ pendingReceives_.push(callback);
+ // If connection_ is nullptr, sendFlowPermitsToBroker does nothing.
+ // In other words, a flow permit will not be sent until setCnx(cnx) is executed in
+ // handleCreateConsumer.
+ sendFlowPermitsToBroker(getCnx().lock(), 1);
+ pendingReceiveMutexLock.unlock();
+ mutexlock.unlock();
} else {
pendingReceives_.push(callback);
- lock.unlock();
-
- if (config_.getReceiverQueueSize() == 0) {
- sendFlowPermitsToBroker(getCnx().lock(), 1);
- }
+ pendingReceiveMutexLock.unlock();
}
}
diff --git a/tests/ZeroQueueSizeTest.cc b/tests/ZeroQueueSizeTest.cc
index 644f42c..b3ed066 100644
--- a/tests/ZeroQueueSizeTest.cc
+++ b/tests/ZeroQueueSizeTest.cc
@@ -27,6 +27,7 @@
#include <mutex>
#include "ConsumerTest.h"
+#include "HttpHelper.h"
#include "lib/Latch.h"
#include "lib/LogUtils.h"
@@ -37,6 +38,7 @@ using namespace pulsar;
static int totalMessages = 10;
static int globalCount = 0;
static std::string lookupUrl = "pulsar://localhost:6650";
+static std::string adminUrl = "http://localhost:8080";
static std::string contentBase = "msg-";
static void messageListenerFunction(Consumer consumer, const Message& msg, Latch& latch) {
@@ -287,3 +289,101 @@ TEST(ZeroQueueSizeTest, testPauseResumeNoReconnection) {
client.close();
}
+
+class ZeroQueueSizeTest : public ::testing::TestWithParam<bool> {};
+
+TEST_P(ZeroQueueSizeTest, testReceptionAfterUnloading) {
+ Client client(lookupUrl);
+ auto isAsync = GetParam();
+ std::string topicName = "zero-queue-size-reception-after-unloading";
+ if (isAsync) {
+ topicName += "-async";
+ }
+ std::string subName = "my-sub";
+
+ Producer producer;
+ Result result = client.createProducer(topicName, producer);
+ ASSERT_EQ(ResultOk, result);
+
+ Consumer consumer;
+ ConsumerConfiguration consConfig;
+ consConfig.setReceiverQueueSize(0);
+ result = client.subscribe(topicName, subName, consConfig, consumer);
+ ASSERT_EQ(ResultOk, result);
+
+ for (int i = 0; i < totalMessages / 2; i++) {
+ std::ostringstream ss;
+ ss << contentBase << i;
+ Message msg = MessageBuilder().setContent(ss.str()).build();
+ result = producer.send(msg);
+ ASSERT_EQ(ResultOk, result);
+ }
+
+ for (int i = 0; i < totalMessages / 2; i++) {
+ ASSERT_EQ(0, ConsumerTest::getNumOfMessagesInQueue(consumer));
+ std::ostringstream ss;
+ ss << contentBase << i;
+ if (isAsync) {
+ Latch latch(1);
+ consumer.receiveAsync([&consumer, &ss, &latch](Result res, const Message& receivedMsg) {
+ ASSERT_EQ(ResultOk, consumer.acknowledge(receivedMsg));
+ ASSERT_EQ(ss.str(), receivedMsg.getDataAsString());
+ ASSERT_EQ(0, ConsumerTest::getNumOfMessagesInQueue(consumer));
+ latch.countdown();
+ });
+ ASSERT_TRUE(latch.wait(std::chrono::seconds(10)));
+ } else {
+ Message receivedMsg;
+ consumer.receive(receivedMsg);
+ ASSERT_EQ(ResultOk, consumer.acknowledge(receivedMsg));
+ ASSERT_EQ(ss.str(), receivedMsg.getDataAsString());
+ ASSERT_EQ(0, ConsumerTest::getNumOfMessagesInQueue(consumer));
+ }
+ }
+
+ // Wait for messages to be delivered while performing `receive` or `receiveAsync` in a separate thread.
+ // At this time, the value of availablePermits should be 1.
+ std::thread consumeThread([&consumer, &isAsync] {
+ for (int i = totalMessages / 2; i < totalMessages; i++) {
+ ASSERT_EQ(0, ConsumerTest::getNumOfMessagesInQueue(consumer));
+ std::ostringstream ss;
+ ss << contentBase << i;
+ if (isAsync) {
+ Latch latch(1);
+ consumer.receiveAsync([&consumer, &ss, &latch](Result res, const Message& receivedMsg) {
+ ASSERT_EQ(ResultOk, consumer.acknowledge(receivedMsg));
+ ASSERT_EQ(ss.str(), receivedMsg.getDataAsString());
+ ASSERT_EQ(0, ConsumerTest::getNumOfMessagesInQueue(consumer));
+ latch.countdown();
+ });
+ ASSERT_TRUE(latch.wait(std::chrono::seconds(10)));
+ } else {
+ Message receivedMsg;
+ consumer.receive(receivedMsg);
+ ASSERT_EQ(ResultOk, consumer.acknowledge(receivedMsg));
+ ASSERT_EQ(ss.str(), receivedMsg.getDataAsString());
+ ASSERT_EQ(0, ConsumerTest::getNumOfMessagesInQueue(consumer));
+ }
+ }
+ });
+ std::this_thread::sleep_for(std::chrono::seconds(1));
+
+ int res = makePutRequest(adminUrl + "/admin/v2/persistent/public/default/" + topicName + "/unload", "");
+ ASSERT_TRUE(res / 100 == 2) << "res: " << res;
+
+ for (int i = totalMessages / 2; i < totalMessages; i++) {
+ std::ostringstream ss;
+ ss << contentBase << i;
+ Message msg = MessageBuilder().setContent(ss.str()).build();
+ result = producer.send(msg);
+ ASSERT_EQ(ResultOk, result);
+ }
+
+ consumeThread.join();
+ consumer.unsubscribe();
+ consumer.close();
+ producer.close();
+ client.close();
+}
+
+INSTANTIATE_TEST_CASE_P(Pulsar, ZeroQueueSizeTest, ::testing::Values(false, true));
(pulsar-client-cpp) 04/05: fix: ignore ping command in connection keepalive logic (#480)
Posted by xy...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
xyz pushed a commit to branch branch-3.7
in repository https://gitbox.apache.org/repos/asf/pulsar-client-cpp.git
commit bc22fc4d5d7b9f8b801a25c4eb7a24da924da882
Author: erobot <er...@users.noreply.github.com>
AuthorDate: Wed Apr 23 10:12:45 2025 +0800
fix: ignore ping command in connection keepalive logic (#480)
Fixes #479
### Motivation
The current keepalive logic is too lenient – merely receiving ping commands can keep the connection alive.
### Modifications
Ignore ping command in connection keepalive logic.
(cherry picked from commit f37bf928e61296a8416693aa2a6afbc0ca2c8a82)
---
lib/ClientConnection.cc | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/lib/ClientConnection.cc b/lib/ClientConnection.cc
index 2037722..d036491 100644
--- a/lib/ClientConnection.cc
+++ b/lib/ClientConnection.cc
@@ -924,7 +924,9 @@ void ClientConnection::handleIncomingCommand(BaseCommand& incomingCmd) {
case Ready: {
// Since we are receiving data from the connection, we are assuming that for now the
// connection is still working well.
- havePendingPingRequest_ = false;
+ if (incomingCmd.type() != BaseCommand::PING) {
+ havePendingPingRequest_ = false;
+ }
// Handle normal commands
switch (incomingCmd.type()) {
(pulsar-client-cpp) 02/05: Make it optional to link statically to libgcc and libstdc++ (#474)
Posted by xy...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
xyz pushed a commit to branch branch-3.7
in repository https://gitbox.apache.org/repos/asf/pulsar-client-cpp.git
commit 5c928d41f5099710fea1a991487667919f88bf8f
Author: Yunze Xu <xy...@163.com>
AuthorDate: Sat Feb 8 17:41:46 2025 +0800
Make it optional to link statically to libgcc and libstdc++ (#474)
(cherry picked from commit d3fd6b2afa2c8ca0df77d60c8e5b9169a0e081ce)
---
lib/CMakeLists.txt | 3 ++-
pkg/deb/build-deb.sh | 2 +-
pkg/rpm/SPECS/pulsar-client.spec | 1 +
3 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
index f578c29..21b308c 100644
--- a/lib/CMakeLists.txt
+++ b/lib/CMakeLists.txt
@@ -76,6 +76,7 @@ target_include_directories(PULSAR_OBJECT_LIB PUBLIC
"${CMAKE_SOURCE_DIR}/include"
"${CMAKE_BINARY_DIR}/include")
+option(LINK_STATIC_GCC_CXX "Link statically to libgcc and libstdc++" OFF)
include(CheckCXXSymbolExists)
if (BUILD_DYNAMIC_LIB)
add_library(pulsarShared SHARED $<TARGET_OBJECTS:PULSAR_OBJECT_LIB>)
@@ -94,7 +95,7 @@ if (BUILD_DYNAMIC_LIB)
target_link_options(pulsarShared PRIVATE -Wl,-Bsymbolic)
endif ()
check_cxx_symbol_exists(__GLIBCXX__ iostream GLIBCXX)
- if (GLIBCXX)
+ if (GLIBCXX AND LINK_STATIC_GCC_CXX)
target_link_libraries(pulsarShared PUBLIC -static-libgcc -static-libstdc++)
endif ()
endif()
diff --git a/pkg/deb/build-deb.sh b/pkg/deb/build-deb.sh
index 8415056..1dabb9f 100755
--- a/pkg/deb/build-deb.sh
+++ b/pkg/deb/build-deb.sh
@@ -41,7 +41,7 @@ pushd $CPP_DIR
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
chmod +x $(find . -name "*.sh")
-cmake . -DBUILD_TESTS=OFF -DBUILD_PERF_TOOLS=OFF -DLINK_STATIC=ON
+cmake . -DBUILD_TESTS=OFF -DBUILD_PERF_TOOLS=OFF -DLINK_STATIC=ON -DLINK_STATIC_GCC_CXX=ON
make -j 3
popd
diff --git a/pkg/rpm/SPECS/pulsar-client.spec b/pkg/rpm/SPECS/pulsar-client.spec
index 425eec5..41a2e58 100644
--- a/pkg/rpm/SPECS/pulsar-client.spec
+++ b/pkg/rpm/SPECS/pulsar-client.spec
@@ -55,6 +55,7 @@ static library.
%build
git clone https://github.com/microsoft/vcpkg.git
cmake -B build -DINTEGRATE_VCPKG=ON -DCMAKE_BUILD_TYPE=Release \
+ -DLINK_STATIC_GCC_CXX=ON \
-DBUILD_TESTS=OFF -DBUILD_DYNAMIC_LIB=ON -DBUILD_STATIC_LIB=ON
cmake --build build -j8
./build-support/merge_archives_vcpkg.sh $PWD/build
(pulsar-client-cpp) 03/05: Fix multi-topics-consumer new topic listeners stuck in paused state (#481)
Posted by xy...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
xyz pushed a commit to branch branch-3.7
in repository https://gitbox.apache.org/repos/asf/pulsar-client-cpp.git
commit 7f85d53e21c8dc3534e6fa5d9246b41bd78f7dfa
Author: Brett <38...@users.noreply.github.com>
AuthorDate: Tue Apr 22 01:45:54 2025 -0500
Fix multi-topics-consumer new topic listeners stuck in paused state (#481)
This was introduced in v3.7.0 via #447, which contained a change that attempted to fix an issue where a pre-mature ack of a message before a multi-topic subscriber was ready could have caused a crash. To fix the original bug, all multi-topic subscriptions are started with their message listener paused. They later get un-paused once all topics are successfully subscribed and connected. However, on a regex subscription when new topics are discovered, they also start in a paused state, [...]
This change adds a call to resume any new listeners after new topics are added.
(cherry picked from commit 0a9b7d9e7b5c8e2ddb111c30d242793217c68c65)
---
lib/PatternMultiTopicsConsumerImpl.cc | 3 +++
1 file changed, 3 insertions(+)
diff --git a/lib/PatternMultiTopicsConsumerImpl.cc b/lib/PatternMultiTopicsConsumerImpl.cc
index 4fc7bb6..73aa874 100644
--- a/lib/PatternMultiTopicsConsumerImpl.cc
+++ b/lib/PatternMultiTopicsConsumerImpl.cc
@@ -118,6 +118,9 @@ void PatternMultiTopicsConsumerImpl::timerGetTopicsOfNamespace(const Result resu
// callback method when added topics all subscribed.
ResultCallback topicsAddedCallback = [this, topicsRemoved, topicsRemovedCallback](Result result) {
if (result == ResultOk) {
+ if (messageListener_) {
+ resumeMessageListener();
+ }
// call to unsubscribe all removed topics.
onTopicsRemoved(topicsRemoved, topicsRemovedCallback);
} else {