This is an automated email from the ASF dual-hosted git repository.
xyz pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/pulsar-client-cpp.git
The following commit(s) were added to refs/heads/main by this push:
new 77e0c22 Fix an unbalanced release of the producer's pending semaphore
(#392)
77e0c22 is described below
commit 77e0c22690cde3bb340f353fd6d6e7dd0e1cd45c
Author: erobot <[email protected]>
AuthorDate: Mon Feb 5 10:40:52 2024 +0800
Fix an unbalanced release of the producer's pending semaphore (#392)
### Motivation
Current code releases the producer's pending semaphore twice when batch is
off and message is too big. The unbalanced release overflows the semaphore, and
subsequent sends will fail with ProducerQueueIsFull.
### Modifications
Remove the redundant semaphore release as the necessary release will be
done in `handleFailedResult`.
---
lib/ProducerImpl.cc | 1 -
tests/ProducerTest.cc | 2 ++
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/lib/ProducerImpl.cc b/lib/ProducerImpl.cc
index 2e5cd44..14a74c6 100644
--- a/lib/ProducerImpl.cc
+++ b/lib/ProducerImpl.cc
@@ -630,7 +630,6 @@ void ProducerImpl::sendAsyncWithStatsUpdate(const Message&
msg, SendCallback&& c
const uint32_t msgHeadersAndPayloadSize = msgMetadataSize +
payloadSize;
if (msgHeadersAndPayloadSize > maxMessageSize) {
lock.unlock();
- releaseSemaphoreForSendOp(*op);
LOG_WARN(getName()
<< " - compressed Message size " <<
msgHeadersAndPayloadSize << " cannot exceed "
<< maxMessageSize << " bytes unless chunking is
enabled");
diff --git a/tests/ProducerTest.cc b/tests/ProducerTest.cc
index bb58a4e..21e491d 100644
--- a/tests/ProducerTest.cc
+++ b/tests/ProducerTest.cc
@@ -243,6 +243,8 @@ TEST_P(ProducerTest, testMaxMessageSize) {
ASSERT_EQ(ResultMessageTooBig,
producer.send(MessageBuilder().setContent(std::string(maxMessageSize,
'b')).build()));
+ ASSERT_EQ(ResultOk,
producer.send(MessageBuilder().setContent(msg).build()));
+
client.close();
}