Browse Source

HPCC-10925 Allow new process group creation to be configured

Signed-off-by: Gavin Halliday <gavin.halliday@lexisnexis.com>
Gavin Halliday 11 years ago
parent
commit
cf906f84b2
6 changed files with 25 additions and 16 deletions
  1. 1 1
      ecl/eclcc/eclcc.cpp
  2. 8 6
      ecl/hqlcpp/hqlecl.cpp
  3. 1 1
      ecl/hqlcpp/hqlecl.hpp
  4. 10 4
      system/jlib/jcomp.cpp
  5. 4 3
      system/jlib/jmisc.cpp
  6. 1 1
      system/jlib/jmisc.hpp

+ 1 - 1
ecl/eclcc/eclcc.cpp

@@ -708,7 +708,7 @@ void EclCC::instantECL(EclCompileInstance & instance, IWorkUnit *wu, const char
             bool optSaveCpp = optSaveTemps || optNoCompile || wu->getDebugValueBool("saveCppTempFiles", false);
             //New scope - testing things are linked correctly
             {
-                Owned<IHqlExprDllGenerator> generator = createDllGenerator(errs, processName.toCharArray(), NULL, wu, templateDir, optTargetClusterType, this, false);
+                Owned<IHqlExprDllGenerator> generator = createDllGenerator(errs, processName.toCharArray(), NULL, wu, templateDir, optTargetClusterType, this, false, false);
 
                 setWorkunitHash(wu, instance.query);
                 if (!optShared)

+ 8 - 6
ecl/hqlcpp/hqlecl.cpp

@@ -60,8 +60,8 @@ class NullContextCallback : public CInterface, implements ICodegenContextCallbac
 class HqlDllGenerator : public CInterface, implements IHqlExprDllGenerator, implements IAbortRequestCallback
 {
 public:
-    HqlDllGenerator(IErrorReceiver * _errs, const char * _wuname, const char * _targetdir, IWorkUnit * _wu, const char * _template_dir, ClusterType _targetClusterType, ICodegenContextCallback * _ctxCallback, bool _checkForLocalFileUploads) :
-        errs(_errs), wuname(_wuname), targetDir(_targetdir), wu(_wu), template_dir(_template_dir), targetClusterType(_targetClusterType), ctxCallback(_ctxCallback), checkForLocalFileUploads(_checkForLocalFileUploads)
+    HqlDllGenerator(IErrorReceiver * _errs, const char * _wuname, const char * _targetdir, IWorkUnit * _wu, const char * _template_dir, ClusterType _targetClusterType, ICodegenContextCallback * _ctxCallback, bool _checkForLocalFileUploads, bool _okToAbort) :
+        errs(_errs), wuname(_wuname), targetDir(_targetdir), wu(_wu), template_dir(_template_dir), targetClusterType(_targetClusterType), ctxCallback(_ctxCallback), checkForLocalFileUploads(_checkForLocalFileUploads), okToAbort(_okToAbort)
     {
         if (!ctxCallback)
             ctxCallback.setown(new NullContextCallback);
@@ -121,6 +121,7 @@ protected:
     bool noOutput;
     EclGenerateTarget generateTarget;
     bool deleteGenerated;
+    bool okToAbort;
 };
 
 
@@ -529,7 +530,8 @@ bool HqlDllGenerator::doCompile(ICppCompiler * compiler)
     wu->getDebugValue("compileOptions", optionAdaptor);
     compiler->addCompileOption(options.str());
 
-    compiler->setAbortChecker(this);
+    if (okToAbort)
+        compiler->setAbortChecker(this);
 
     MTIME_SECTION (timer, "Compile_code");
     unsigned time = msTick();
@@ -605,14 +607,14 @@ offset_t HqlDllGenerator::getGeneratedSize() const
 
 extern HQLCPP_API double getECLcomplexity(IHqlExpression * exprs, IErrorReceiver * errs, IWorkUnit *wu, ClusterType targetClusterType)
 {
-    HqlDllGenerator generator(errs, "unknown", NULL, wu, NULL, targetClusterType, NULL, false);
+    HqlDllGenerator generator(errs, "unknown", NULL, wu, NULL, targetClusterType, NULL, false, false);
     return generator.getECLcomplexity(exprs);
 }
 
 
-extern HQLCPP_API IHqlExprDllGenerator * createDllGenerator(IErrorReceiver * errs, const char *wuname, const char * targetdir, IWorkUnit *wu, const char * template_dir, ClusterType targetClusterType, ICodegenContextCallback *ctxCallback, bool checkForLocalFileUploads)
+extern HQLCPP_API IHqlExprDllGenerator * createDllGenerator(IErrorReceiver * errs, const char *wuname, const char * targetdir, IWorkUnit *wu, const char * template_dir, ClusterType targetClusterType, ICodegenContextCallback *ctxCallback, bool checkForLocalFileUploads, bool okToAbort)
 {
-    return new HqlDllGenerator(errs, wuname, targetdir, wu, template_dir, targetClusterType, ctxCallback, checkForLocalFileUploads);
+    return new HqlDllGenerator(errs, wuname, targetdir, wu, template_dir, targetClusterType, ctxCallback, checkForLocalFileUploads, okToAbort);
 }
 
 /*

+ 1 - 1
ecl/hqlcpp/hqlecl.hpp

@@ -51,7 +51,7 @@ public:
     virtual void setSaveGeneratedFiles(bool value) = 0;
 };
 
-extern HQLCPP_API IHqlExprDllGenerator * createDllGenerator(IErrorReceiver * errs, const char *wuname, const char * targetdir, IWorkUnit *wu, const char * template_dir, ClusterType targetClusterType, ICodegenContextCallback * ctxCallback, bool checkForLocalFileUploads);
+extern HQLCPP_API IHqlExprDllGenerator * createDllGenerator(IErrorReceiver * errs, const char *wuname, const char * targetdir, IWorkUnit *wu, const char * template_dir, ClusterType targetClusterType, ICodegenContextCallback * ctxCallback, bool checkForLocalFileUploads, bool okToAbort);
 
 
 //Extract a single level of external libraries.

+ 10 - 4
system/jlib/jcomp.cpp

@@ -737,11 +737,16 @@ class CCompilerWorker : public CInterface, implements IPooledThread
 public:
     IMPLEMENT_IINTERFACE;
 
-    CCompilerWorker(CppCompiler * _compiler) : compiler(_compiler)  { handle = 0; aborted = false; }
+    CCompilerWorker(CppCompiler * _compiler, bool _okToAbort) : compiler(_compiler), okToAbort(_okToAbort)
+    {
+        handle = 0;
+        aborted = false;
+    }
     bool canReuse()             { return true; }
     bool stop()
     {
-        interrupt_program(handle, true);
+        if (okToAbort)
+            interrupt_program(handle, true);
         aborted = true;
         return true;
     }
@@ -755,7 +760,7 @@ public:
         handle = 0;
         try
         {
-            success = invoke_program(params->cmdline, runcode, false, params->logfile, &handle);
+            success = invoke_program(params->cmdline, runcode, false, params->logfile, &handle, false, okToAbort);
             if (success)
                 wait_program(handle, runcode, true);
         }
@@ -781,9 +786,10 @@ private:
     Owned<CCompilerThreadParam> params;
     HANDLE handle;
     bool aborted;
+    bool okToAbort;
 };
 
 IPooledThread *CppCompiler::createNew()
 {
-    return new CCompilerWorker(this);
+    return new CCompilerWorker(this, (abortChecker != NULL));
 }

+ 4 - 3
system/jlib/jmisc.cpp

@@ -404,7 +404,7 @@ jlib_decl char* readarg(char*& curptr)
 }
 
 #ifdef _WIN32
-bool invoke_program(const char *command_line, DWORD &runcode, bool wait, const char *outfile, HANDLE *rethandle, bool throwException)
+bool invoke_program(const char *command_line, DWORD &runcode, bool wait, const char *outfile, HANDLE *rethandle, bool throwException, bool newProcessGroup)
 {
     runcode = 0;
     if (rethandle)
@@ -504,7 +504,7 @@ void close_program(HANDLE handle)
 
 
 #else
-bool invoke_program(const char *command_line, DWORD &runcode, bool wait, const char *outfile, HANDLE *rethandle, bool throwException)
+bool invoke_program(const char *command_line, DWORD &runcode, bool wait, const char *outfile, HANDLE *rethandle, bool throwException, bool newProcessGroup)
 {
     runcode = 0;
     if (rethandle)
@@ -516,7 +516,8 @@ bool invoke_program(const char *command_line, DWORD &runcode, bool wait, const c
     if (pid == 0) 
     {
         //Force the child process into its own process group, so we can terminate it and its children.
-        setpgid(0,0);
+        if (newProcessGroup)
+            setpgid(0,0);
         if (outfile&&*outfile) {
             int outh = open(outfile, O_CREAT|O_WRONLY|O_TRUNC, S_IRUSR|S_IWUSR);
             if(outh > 0)

+ 1 - 1
system/jlib/jmisc.hpp

@@ -84,7 +84,7 @@ jlib_decl FILE *xfopen(const char *path, const char *mode);
 jlib_decl const char * queryCcLogName();
 jlib_decl StringBuffer& queryCcLogName(const char* wuid, StringBuffer& logname);
 jlib_decl char* readarg(char*& curptr);
-jlib_decl bool invoke_program(const char *command_line, DWORD &runcode, bool wait=true, const char *outfile=NULL, HANDLE *rethandle=NULL, bool throwException = false);
+jlib_decl bool invoke_program(const char *command_line, DWORD &runcode, bool wait=true, const char *outfile=NULL, HANDLE *rethandle=NULL, bool throwException = false, bool newProcessGroup = false);
 jlib_decl bool wait_program(HANDLE handle,DWORD &runcode,bool block=true);
 jlib_decl bool interrupt_program(HANDLE handle, bool killChildren, int signum=0); // no signum means use default