You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by pc...@apache.org on 2018/05/07 19:30:57 UTC

[arrow] branch master updated: ARROW-2540: [Plasma] Create constructors & destructors for ObjectTableEntry

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 0f07171  ARROW-2540: [Plasma] Create constructors & destructors for ObjectTableEntry
0f07171 is described below

commit 0f0717148ec2a216b88f667f68d936d7f0810df8
Author: Zhijun Fu <zh...@outlook.com>
AuthorDate: Mon May 7 12:30:47 2018 -0700

    ARROW-2540: [Plasma] Create constructors & destructors for ObjectTableEntry
    
    This makes sure dlfree() is called for pointer field automatically
    
    Author: Zhijun Fu <zh...@outlook.com>
    
    Closes #1996 from zhijunfu/dlfree and squashes the following commits:
    
    9363b4c5 <Zhijun Fu> Trigger travis build
    9f56a850 <Zhijun Fu> re-trigger travis build
    3246b843 <Zhijun Fu> fix format check
    a8c67b84 <Zhijun Fu>  Create constructors & destructors for ObjectTableEntry
---
 cpp/src/plasma/plasma.cc | 11 +++++++++++
 cpp/src/plasma/plasma.h  |  4 ++++
 cpp/src/plasma/store.cc  |  3 ---
 3 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/cpp/src/plasma/plasma.cc b/cpp/src/plasma/plasma.cc
index e57049d..60b7c3f 100644
--- a/cpp/src/plasma/plasma.cc
+++ b/cpp/src/plasma/plasma.cc
@@ -26,6 +26,17 @@
 
 namespace plasma {
 
+extern "C" {
+void dlfree(void* mem);
+}
+
+ObjectTableEntry::ObjectTableEntry() : pointer(nullptr) {}
+
+ObjectTableEntry::~ObjectTableEntry() {
+  dlfree(pointer);
+  pointer = nullptr;
+}
+
 int warn_if_sigpipe(int status, int client_sock) {
   if (status >= 0) {
     return 0;
diff --git a/cpp/src/plasma/plasma.h b/cpp/src/plasma/plasma.h
index a1d6e99..7a513ea 100644
--- a/cpp/src/plasma/plasma.h
+++ b/cpp/src/plasma/plasma.h
@@ -112,6 +112,10 @@ enum object_status {
 /// This type is used by the Plasma store. It is here because it is exposed to
 /// the eviction policy.
 struct ObjectTableEntry {
+  ObjectTableEntry();
+
+  ~ObjectTableEntry();
+
   /// Object id of this object.
   ObjectID object_id;
   /// Object info like size, creation time and owner.
diff --git a/cpp/src/plasma/store.cc b/cpp/src/plasma/store.cc
index c06ad6a..6253afb 100644
--- a/cpp/src/plasma/store.cc
+++ b/cpp/src/plasma/store.cc
@@ -446,7 +446,6 @@ int PlasmaStore::abort_object(const ObjectID& object_id, Client* client) {
     return 0;
   } else {
     // The client requesting the abort is the creator. Free the object.
-    dlfree(entry->pointer);
     store_info_.objects.erase(object_id);
     return 1;
   }
@@ -474,7 +473,6 @@ int PlasmaStore::delete_object(ObjectID& object_id) {
 
   eviction_policy_.remove_object(object_id);
 
-  dlfree(entry->pointer);
   store_info_.objects.erase(object_id);
   // Inform all subscribers that the object has been deleted.
   ObjectInfoT notification;
@@ -497,7 +495,6 @@ void PlasmaStore::delete_objects(const std::vector<ObjectID>& object_ids) {
         << "To delete an object it must have been sealed.";
     ARROW_CHECK(entry->clients.size() == 0)
         << "To delete an object, there must be no clients currently using it.";
-    dlfree(entry->pointer);
     store_info_.objects.erase(object_id);
     // Inform all subscribers that the object has been deleted.
     ObjectInfoT notification;

-- 
To stop receiving notification emails like this one, please contact
pcmoritz@apache.org.