You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by mm...@apache.org on 2020/10/19 18:51:15 UTC

[pulsar] branch master updated: [C++] Client is allocating buffer bigger than needed (#8283)

This is an automated email from the ASF dual-hosted git repository.

mmerli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar.git


The following commit(s) were added to refs/heads/master by this push:
     new 62f250c  [C++] Client is allocating buffer bigger than needed (#8283)
62f250c is described below

commit 62f250c16648f9eb18cf0446738f1dbc3bf6b054
Author: Matteo Merli <mm...@apache.org>
AuthorDate: Mon Oct 19 11:50:49 2020 -0700

    [C++] Client is allocating buffer bigger than needed (#8283)
    
    * [C++] Client is allocating buffer bigger than needed
    
    * Removed `std::min()` as it was wrong
---
 pulsar-client-cpp/lib/Commands.cc | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/pulsar-client-cpp/lib/Commands.cc b/pulsar-client-cpp/lib/Commands.cc
index 2327906..e53d801 100644
--- a/pulsar-client-cpp/lib/Commands.cc
+++ b/pulsar-client-cpp/lib/Commands.cc
@@ -674,8 +674,7 @@ uint64_t Commands::serializeSingleMessageInBatchWithPayload(const Message& msg,
         LOG_DEBUG("remaining size of batchPayLoad buffer ["
                   << batchPayLoad.writableBytes() << "] can't accomodate new payload [" << requiredSpace
                   << "] - expanding the batchPayload buffer");
-        SharedBuffer buffer = SharedBuffer::allocate(batchPayLoad.readableBytes() +
-                                                     std::max(requiredSpace, maxMessageSizeInBytes));
+        SharedBuffer buffer = SharedBuffer::allocate(batchPayLoad.readableBytes() + requiredSpace);
         // Adding batch created so far
         buffer.write(batchPayLoad.data(), batchPayLoad.readableBytes());
         batchPayLoad = buffer;