소스 검색

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

+ 3 - 2
system/jlib/jlib.hpp

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

+ 1 - 1
system/jlib/jutil.cpp

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