You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ro...@apache.org on 2021/09/16 02:28:26 UTC

[iotdb] branch rel/0.12 updated: [IOTDB-1678] Fix client-cpp session bug: can cause connection leak. (#3962) (#3973)

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

rong pushed a commit to branch rel/0.12
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/rel/0.12 by this push:
     new 75032c2  [IOTDB-1678] Fix client-cpp session bug: can cause connection leak. (#3962) (#3973)
75032c2 is described below

commit 75032c2d2dd5003126d62e3a555706714c9068f2
Author: Haonan <hh...@outlook.com>
AuthorDate: Thu Sep 16 10:27:47 2021 +0800

    [IOTDB-1678] Fix client-cpp session bug: can cause connection leak. (#3962) (#3973)
    
    Co-authored-by: Jamber <ja...@sina.com>
---
 client-cpp/src/main/Session.cpp | 4 ++--
 client-cpp/src/main/Session.h   | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/client-cpp/src/main/Session.cpp b/client-cpp/src/main/Session.cpp
index 6b217ae..cd26f29 100644
--- a/client-cpp/src/main/Session.cpp
+++ b/client-cpp/src/main/Session.cpp
@@ -496,7 +496,7 @@ void Session::open(bool enableRPCCompression, int connectionTimeoutInMs) {
         return;
     }
     shared_ptr <TSocket> socket(new TSocket(host, rpcPort));
-    shared_ptr <TTransport> transport(new TFramedTransport(socket));
+    transport = std::make_shared<TFramedTransport> (socket);
     socket->setConnTimeout(connectionTimeoutInMs);
     if (!transport->isOpen()) {
         try {
@@ -562,7 +562,7 @@ void Session::close() {
                 string("Error occurs when closing session at server. Maybe server is down. ") + e.what());
     }
     isClosed = true;
-    if (transport != NULL) {
+    if (transport != nullptr) {
         transport->close();
     }
 }
diff --git a/client-cpp/src/main/Session.h b/client-cpp/src/main/Session.h
index e3e2e20..726cfdc 100644
--- a/client-cpp/src/main/Session.h
+++ b/client-cpp/src/main/Session.h
@@ -587,7 +587,7 @@ private:
     std::string password;
     TSProtocolVersion::type protocolVersion = TSProtocolVersion::IOTDB_SERVICE_PROTOCOL_V3;
     std::shared_ptr <TSIServiceIf> client;
-    std::shared_ptr <apache::thrift::transport::TSocket> transport;
+    std::shared_ptr <TTransport> transport;
     bool isClosed = true;
     int64_t sessionId;
     int64_t statementId;