ソースを参照

HPCC-2558 Fix problems deleting workunit .so/.cpp files

Currently the .so files and other files associated with a workunit are
never deleted.  This is because the representation in the workunit changed
a while back, but the code wasn't updated to match.  This patch fixes the
following:

* empty eclcc.log files are removed
* dll/so files pass the tail name to removeDll.
* workunits created by eclccserver are not marked as clones.
* non dll/so files are deleted directly (they are no longer registered with dll
  server)

Signed-off-by: Gavin Halliday <gavin.halliday@lexisnexis.com>
Gavin Halliday 12 年 前
コミット
3993eaea81
3 ファイル変更45 行追加3 行削除
  1. 37 3
      common/workunit/workunit.cpp
  2. 1 0
      ecl/eclccserver/eclccserver.cpp
  3. 7 0
      system/jlib/jcomp.cpp

+ 37 - 3
common/workunit/workunit.cpp

@@ -1866,6 +1866,25 @@ public:
     }
 };      
 
+class asyncRemoveRemoteFileWorkItem: public CInterface, implements IWorkQueueItem // class only used in asyncRemoveDll
+{
+    RemoteFilename name;
+public:
+    IMPLEMENT_IINTERFACE;
+
+    asyncRemoveRemoteFileWorkItem(const char * _ip, const char * _name)
+    {
+        SocketEndpoint ep(_ip);
+        name.setPath(ep, _name);
+    }
+    void execute()
+    {
+        Owned<IFile> file = createIFile(name);
+        PROGLOG("WU removeDll %s",file->queryFilename());
+        file->remove();
+    }
+};
+
 #define WUID_VERSION 1 // recorded in each wuid created, useful for bkwd compat. checks
 
 class CWorkUnitFactory : public CInterface, implements IWorkUnitFactory, implements IDaliClientShutdown
@@ -2263,7 +2282,13 @@ public:
 
     void asyncRemoveDll(const char * name, bool removeDlls, bool removeDirectory)
     {
-        deletedllworkq->post(new asyncRemoveDllWorkItem(name,removeDlls,removeDirectory));
+        const char * tail = pathTail(name);
+        deletedllworkq->post(new asyncRemoveDllWorkItem(tail,removeDlls,removeDirectory));
+    }
+
+    void asyncRemoveFile(const char * ip, const char * name)
+    {
+        deletedllworkq->post(new asyncRemoveRemoteFileWorkItem(ip, name));
     }
 
     ISDSManager *sdsManager;
@@ -2673,12 +2698,21 @@ void CLocalWorkUnit::cleanupAndDelete(bool deldll,bool deleteOwned)
             {
                 Owned<IConstWUAssociatedFileIterator> iter = &q->getAssociatedFiles();
                 SCMStringBuffer name;
+                SCMStringBuffer ip;
                 ForEach(*iter)
                 {
                     IConstWUAssociatedFile & cur = iter->query();
                     cur.getName(name);
-                    bool removeDir = (cur.getType() == FileTypeDll);        // this is to keep the code the same as before, but I don't know why it only does it for the dll.
-                    factory->asyncRemoveDll(name.str(), true, removeDir);
+                    if (cur.getType() == FileTypeDll)
+                    {
+                        bool removeDir = true;        // this is to keep the code the same as before, but I don't know why it only does it for the dll.
+                        factory->asyncRemoveDll(name.str(), true, removeDir);
+                    }
+                    else
+                    {
+                        cur.getIp(ip);
+                        factory->asyncRemoveFile(ip.str(), name.str());
+                    }
                 }
             }
         }

+ 1 - 0
ecl/eclccserver/eclccserver.cpp

@@ -220,6 +220,7 @@ class EclccCompileThread : public CInterface, implements IPooledThread
                     Owned<ILocalWorkUnit> embeddedWU = createLocalWorkUnit();
                     embeddedWU->loadXML(wuXML);
                     queryExtendedWU(workunit)->copyWorkUnit(embeddedWU, true);
+                    workunit->setIsClone(false);
                     SCMStringBuffer jobname;
                     if (embeddedWU->getJobName(jobname).length()) //let ECL win naming job during initial compile
                         workunit->setJobName(jobname.str());

+ 7 - 0
system/jlib/jcomp.cpp

@@ -426,6 +426,7 @@ bool CppCompiler::compile()
         cclog = queryCcLogName();
     Owned <IFile> dstfile = createIFile(cclog);
     dstfile->remove();
+
     Owned<IFileIO> dstIO = dstfile->open(IFOwrite);
     ForEachItemIn(i2, logFiles)
     {
@@ -437,6 +438,12 @@ bool CppCompiler::compile()
         }
     }
 
+    //Don't leave lots of blank log files around if the compile was successful
+    bool logIsEmpty = (dstIO->size() == 0);
+    dstIO.clear();
+    if (ret && logIsEmpty)
+        dstfile->remove();
+
     pool->joinAll(true, 1000);
     return ret;
 }