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

[iotdb] 01/01: [IOTDB-1679] client-cpp: Session descontruction need release server resource. (#3964)

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

haonan pushed a commit to branch iotdb1679
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit 2e6310bb8c2998e7f9d7c0597ed7548c1a89ff3f
Author: Jamber <ja...@sina.com>
AuthorDate: Wed Sep 15 16:43:11 2021 +0800

    [IOTDB-1679] client-cpp: Session descontruction need release server resource. (#3964)
---
 client-cpp/src/main/Session.cpp                   | 6 ++++++
 client-cpp/src/main/Session.h                     | 2 ++
 example/client-cpp-example/src/SessionExample.cpp | 4 +++-
 3 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/client-cpp/src/main/Session.cpp b/client-cpp/src/main/Session.cpp
index 2c56492..fdb1c00 100644
--- a/client-cpp/src/main/Session.cpp
+++ b/client-cpp/src/main/Session.cpp
@@ -345,6 +345,12 @@ void SessionDataSet::closeOperationHandle() {
     }
 }
 
+/**
+ * When delete variable, make sure release all resource.
+ */
+Session::~Session() {
+    close();
+}
 
 /**
    * check whether the batch has been sorted
diff --git a/client-cpp/src/main/Session.h b/client-cpp/src/main/Session.h
index 54dd353..e3e2e20 100644
--- a/client-cpp/src/main/Session.h
+++ b/client-cpp/src/main/Session.h
@@ -649,6 +649,8 @@ public:
         this->zoneId = "UTC+08:00";
     }
 
+    ~Session();
+
     void open();
 
     void open(bool enableRPCCompression);
diff --git a/example/client-cpp-example/src/SessionExample.cpp b/example/client-cpp-example/src/SessionExample.cpp
index 24bb013..7be7269 100644
--- a/example/client-cpp-example/src/SessionExample.cpp
+++ b/example/client-cpp-example/src/SessionExample.cpp
@@ -303,6 +303,8 @@ int main() {
     deleteTimeseries();
 
     session->close();
-    
+
+    delete session;
+
     return 0;
 }