Browse Source

HPCC-8882 Common up and clean up rowset releasing code.

Signed-off-by: Gavin Halliday <gavin.halliday@lexisnexis.com>
Gavin Halliday 12 years ago
parent
commit
e4c352d294
5 changed files with 30 additions and 44 deletions
  1. 3 14
      ecl/hthor/hthor.cpp
  2. 3 14
      roxie/ccd/ccdmain.cpp
  3. 19 2
      roxie/roxiemem/roxiemem.cpp
  4. 2 0
      roxie/roxiemem/roxiemem.hpp
  5. 3 14
      thorlcr/thorutil/thmem.cpp

+ 3 - 14
ecl/hthor/hthor.cpp

@@ -9970,27 +9970,16 @@ public:
     }
     virtual void releaseRowset(unsigned count, byte * * rowset) const
     {
-        if (rowset)
-        {
-            if (!roxiemem::HeapletBase::isShared(rowset))
-            {
-                byte * * finger = rowset;
-                while (count--)
-                    releaseHThorRow(*finger++);
-            }
-            releaseHThorRow(rowset);
-        }
+        ReleaseRoxieRowset(count, rowset);
     }
     virtual void * linkRow(const void * row) const
     {
-        if (row) 
-            linkHThorRow(row);
+        linkHThorRow(row);
         return const_cast<void *>(row);
     }
     virtual byte * * linkRowset(byte * * rowset) const
     {
-        if (rowset)
-            linkHThorRow(rowset);
+        linkHThorRow(rowset);
         return const_cast<byte * *>(rowset);
     }
 } callbackHook;

+ 3 - 14
roxie/ccd/ccdmain.cpp

@@ -415,27 +415,16 @@ public:
     }
     virtual void releaseRowset(unsigned count, byte * * rowset) const
     {
-        if (rowset)
-        {
-            if (!roxiemem::HeapletBase::isShared(rowset))
-            {
-                byte * * finger = rowset;
-                while (count--)
-                    ReleaseRoxieRow(*finger++);
-            }
-            ReleaseRoxieRow(rowset);
-        }
+        ReleaseRoxieRowset(count, rowset);
     }
     virtual void * linkRow(const void * row) const
     {
-        if (row) 
-            LinkRoxieRow(row);
+        LinkRoxieRow(row);
         return const_cast<void *>(row);
     }
     virtual byte * * linkRowset(byte * * rowset) const
     {
-        if (rowset)
-            LinkRoxieRow(rowset);
+        LinkRoxieRow(rowset);
         return const_cast<byte * *>(rowset);
     }
 } callbackHook;

+ 19 - 2
roxie/roxiemem/roxiemem.cpp

@@ -719,6 +719,23 @@ void HeapletBase::release(const void *ptr)
     }
 }
 
+
+void HeapletBase::releaseRowset(unsigned count, byte * * rowset)
+{
+    if (rowset)
+    {
+        //MORE: There is a small window of simultaneous releases that could lead to the children being leaked
+        if (!isShared(rowset))
+        {
+            byte * * finger = rowset;
+            while (count--)
+                release(*finger++);
+        }
+        release(rowset);
+    }
+}
+
+
 void HeapletBase::link(const void *ptr)
 {
     if (isValidRoxiePtr(ptr))
@@ -4884,8 +4901,8 @@ protected:
 
 };
 
-const memsize_t hugeMemorySize = 0x110000000;
-const memsize_t hugeAllocSize = 0x100000001;
+const memsize_t hugeMemorySize = (memsize_t)0x110000000;
+const memsize_t hugeAllocSize = (memsize_t)0x100000001;
 // const memsize_t initialAllocSize = hugeAllocSize/2; // need to support expand block for that to fit
 const memsize_t initialAllocSize = 0x100;
 

+ 2 - 0
roxie/roxiemem/roxiemem.hpp

@@ -128,6 +128,7 @@ public:
     }
 
     static void release(const void *ptr);
+    static void releaseRowset(unsigned count, byte * * rowset);
     static bool isShared(const void *ptr);
     static void link(const void *ptr);
     static memsize_t capacity(const void *ptr);
@@ -254,6 +255,7 @@ public:
 #define ReleaseRoxieRow(row) roxiemem::HeapletBase::release(row)
 #define ReleaseClearRoxieRow(row) roxiemem::HeapletBase::releaseClear(row)
 #define LinkRoxieRow(row) roxiemem::HeapletBase::link(row)
+#define ReleaseRoxieRowset(cnt, rowset) roxiemem::HeapletBase::releaseRowset(cnt, rowset)
 
 //Functions to determine information about roxie rows
 #define RoxieRowCapacity(row)  roxiemem::HeapletBase::capacity(row)

+ 3 - 14
thorlcr/thorutil/thmem.cpp

@@ -1761,27 +1761,16 @@ public:
     }
     virtual void releaseRowset(unsigned count, byte * * rowset) const
     {
-        if (rowset)
-        {
-            if (!roxiemem::HeapletBase::isShared(rowset))
-            {
-                byte * * finger = rowset;
-                while (count--)
-                    ReleaseThorRow(*finger++);
-            }
-            ReleaseThorRow(rowset);
-        }
+        ReleaseRoxieRowset(count, rowset);
     }
     virtual void *linkRow(const void * row) const
     {
-        if (row) 
-            LinkThorRow(row);
+        LinkThorRow(row);
         return const_cast<void *>(row);
     }
     virtual byte * * linkRowset(byte * * rowset) const
     {
-        if (rowset)
-            LinkThorRow(rowset);
+        LinkThorRow(rowset);
         return const_cast<byte * *>(rowset);
     }
 };