瀏覽代碼

HPCC-18256 Avoid potential process termination during dynamic dll load

Signed-off-by: Gavin Halliday <gavin.halliday@lexisnexis.com>
Gavin Halliday 7 年之前
父節點
當前提交
4f479f9c28
共有 3 個文件被更改,包括 11 次插入6 次删除
  1. 7 3
      system/jlib/jlib.cpp
  2. 3 2
      system/jlib/jlib.hpp
  3. 1 1
      system/jlib/jutil.cpp

+ 7 - 3
system/jlib/jlib.cpp

@@ -134,16 +134,21 @@ void InitTable::add(boolFunc func, unsigned int priority, unsigned int modpriori
     initializers.append(iT);
     initializers.append(iT);
 }
 }
 
 
-DynamicScopeCtx::DynamicScopeCtx() : soCtx(0)
+DynamicScopeCtx::DynamicScopeCtx()
 {
 {
     dynamicScopeCtx = this;
     dynamicScopeCtx = this;
 }
 }
 
 
 DynamicScopeCtx::~DynamicScopeCtx()
 DynamicScopeCtx::~DynamicScopeCtx()
 {
 {
+    dynamicScopeCtx = NULL;
+}
+
+void DynamicScopeCtx::processInitialization(SoContext soCtx)
+{
     if (soCtx)
     if (soCtx)
     {
     {
-        // initliaze those in this context
+        // initialize those in this context
         initTable.init();
         initTable.init();
         // add to global table with patched ctx's, for use by ExitModuleObjects(ctx) call
         // add to global table with patched ctx's, for use by ExitModuleObjects(ctx) call
         ForEachItemIn(i, initTable.initializers)
         ForEachItemIn(i, initTable.initializers)
@@ -153,7 +158,6 @@ DynamicScopeCtx::~DynamicScopeCtx()
             queryInitTable()->add(iT);
             queryInitTable()->add(iT);
         }
         }
     }
     }
-    dynamicScopeCtx = NULL;
 }
 }
 
 
 ModInit::ModInit(boolFunc func, unsigned int priority, unsigned int modpriority)
 ModInit::ModInit(boolFunc func, unsigned int priority, unsigned int modpriority)

+ 3 - 2
system/jlib/jlib.hpp

@@ -315,8 +315,9 @@ struct DynamicScopeCtx
 {
 {
     DynamicScopeCtx();
     DynamicScopeCtx();
     ~DynamicScopeCtx();
     ~DynamicScopeCtx();
-    void setSoContext(SoContext _soCtx) { soCtx = _soCtx; }
-    SoContext soCtx;
+
+    void processInitialization(SoContext soCtx);
+
     InitTable initTable;
     InitTable initTable;
 };
 };
 
 

+ 1 - 1
system/jlib/jutil.cpp

@@ -475,7 +475,6 @@ HINSTANCE LoadSharedObject(const char *name, bool isGlobal, bool raiseOnError)
     }
     }
 
 
 #endif
 #endif
-    scope.setSoContext(h);
 
 
 #if defined(_WIN32)
 #if defined(_WIN32)
     SetErrorMode(oldMode);
     SetErrorMode(oldMode);
@@ -483,6 +482,7 @@ HINSTANCE LoadSharedObject(const char *name, bool isGlobal, bool raiseOnError)
     // don't think anything to do here.
     // don't think anything to do here.
 #endif
 #endif
 
 
+    scope.processInitialization(h);
     return h;
     return h;
 }
 }