Forráskód Böngészése

HPCC-13574 EclAgent should not keep wu locked over esp soapcalls

Reorganized the code a little to minimize the duration of the workunit lock
during fileservices operations, and in particular to ensure that it is not
held over any calls to ESP functions.

Signed-off-by: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 10 éve
szülő
commit
5b81b5c502
1 módosított fájl, 9 hozzáadás és 13 törlés
  1. 9 13
      plugins/fileservices/fileservices.cpp

+ 9 - 13
plugins/fileservices/fileservices.cpp

@@ -521,7 +521,6 @@ static void blockUntilComplete(const char * label, IClientFileSpray &server, ICo
 
     while(true)
     {
-        Owned<IWorkUnit> wu = ctx->updateWorkUnit(); // may return NULL
 
         Owned<IClientGetDFUWorkunit> req = server.createGetDFUWorkunitRequest();
         req->setWuid(wuid);
@@ -536,8 +535,10 @@ static void blockUntilComplete(const char * label, IClientFileSpray &server, ICo
         }
 
         IConstDFUWorkunit & dfuwu = result->getResult();
-
+        bool aborting = false;
+        Owned<IWorkUnit> wu = ctx->updateWorkUnit(); // may return NULL
         if (wu.get()) { // if updatable (e.g. not hthor with no agent context)
+            aborting = wu->aborting();
             StringBuffer wuScope, ElapsedLabel, RemainingLabel;
             wuScope.appendf("%s-%s", label, dfuwu.getID());
             ElapsedLabel.append(wuScope).append(" (Elapsed) ");
@@ -548,6 +549,7 @@ static void blockUntilComplete(const char * label, IClientFileSpray &server, ICo
             updateWorkunitTimeStat(wu, SSTdfuworkunit, wuScope, StTimeRemaining, RemainingLabel, milliToNano(dfuwu.getSecsLeft()*1000));
             wu->setApplicationValue(label, dfuwu.getID(), dfuwu.getSummaryMessage(), true);
             wu->commit();
+            wu.clear();
         }
 
         DFUstate state = (DFUstate)dfuwu.getState();
@@ -570,29 +572,23 @@ static void blockUntilComplete(const char * label, IClientFileSpray &server, ICo
         case DFUstate_aborted:
         case DFUstate_failed:
             throw MakeStringException(0, "DFUServer Error %s", dfuwu.getSummaryMessage());
-            return;
 
         case DFUstate_finished:
             return;
         }
 
-        if (wu.get()&&wu->aborting())
+        if (aborting)
         {
             Owned<IClientAbortDFUWorkunit> abortReq = server.createAbortDFUWorkunitRequest();
             abortReq->setWuid(wuid);
             Linked<IClientAbortDFUWorkunitResponse> abortResp = server.AbortDFUWorkunit(abortReq);
 
-            {   //  Add warning of DFU Abort Request - should this be information  ---
-                StringBuffer s("DFU Workunit Abort Requested for ");
-                s.append(wuid);
-                WUmessage(ctx,SeverityWarning,"blockUntilComplete",s.str());
-            }
-
-            wu->setState(WUStateAborting);
+            //  Add warning of DFU Abort Request - should this be information  ---
+            StringBuffer s("DFU Workunit Abort Requested for ");
+            s.append(wuid);
+            WUmessage(ctx,SeverityWarning,"blockUntilComplete",s.str());
             throw MakeStringException(0, "Workunit abort request received");
-
         }
-        wu.clear();
 
         if (time.timedout()) {
             unsigned left = dfuwu.getSecsLeft();