Explorar o código

Merge pull request #675 from jakesmith/loopexceptionhandling

Thor LOOP could deadlock on exception
Reviewed-by: Gavin Halliday <ghalliday@hpccsystems.com>
Gavin Halliday %!s(int64=13) %!d(string=hai) anos
pai
achega
9596bb02f8
Modificáronse 1 ficheiros con 8 adicións e 3 borrados
  1. 8 3
      thorlcr/activities/loop/thloopslave.cpp

+ 8 - 3
thorlcr/activities/loop/thloopslave.cpp

@@ -62,9 +62,9 @@ public:
     void main()
     void main()
     {
     {
         stopped = false;
         stopped = false;
+        Linked<IRowWriter> writer = smartbuf->queryWriter();
         try
         try
         {
         {
-            Linked<IRowWriter> writer = smartbuf->queryWriter();
             while (!stopped)
             while (!stopped)
             {
             {
                 OwnedConstThorRow row = in->nextRow();
                 OwnedConstThorRow row = in->nextRow();
@@ -78,8 +78,6 @@ public:
                 }
                 }
                 writer->putRow(row.getClear());
                 writer->putRow(row.getClear());
             }
             }
-            writer->flush();
-
             in->stop();
             in->stop();
         }
         }
         catch (IException *e)
         catch (IException *e)
@@ -87,6 +85,13 @@ public:
             ActPrintLog(activity, e, NULL);
             ActPrintLog(activity, e, NULL);
             exception.setown(e);
             exception.setown(e);
         }
         }
+        try { writer->flush(); }
+        catch (IException *e)
+        {
+            ActPrintLog(activity, e, "Exception in writer->flush");
+            if (!exception.get())
+                exception.setown(e);
+        }
     }
     }
     virtual const void *nextRow()
     virtual const void *nextRow()
     {
     {