Browse Source

Merge remote-tracking branch 'origin/candidate-5.6.4' into candidate-6.0.0

Signed-off-by: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 9 years ago
parent
commit
0941fad488
2 changed files with 15 additions and 13 deletions
  1. 4 4
      ecl/eclccserver/vchooks/git.sh
  2. 11 9
      system/jlib/jthread.cpp

+ 4 - 4
ecl/eclccserver/vchooks/git.sh

@@ -51,11 +51,11 @@ function fetch_repo {
     fi
 
     if [ -n "$wu_git_branch" ]; then
-        if [ -z "$git_branch_locked" ]; then
+        if [ -z "$git_branch_locked" -o "$git_branch_locked" == "0" ]; then
+            git_branch=$wu_git_branch
+        else
             echo "GIT: Overriding branch is not allowed" 1>&2
             exit 2
-        else
-            git_branch=$wu_git_branch
         fi
     fi
 
@@ -153,4 +153,4 @@ else
     echo GIT: calling eclcc $GIT_INCLUDE_PATH "$@"  1>&2
   fi
   eclcc $GIT_INCLUDE_PATH "$@"
-fi
+fi

+ 11 - 9
system/jlib/jthread.cpp

@@ -634,7 +634,6 @@ void CAsyncFor::For(unsigned num,unsigned maxatonce,bool abortFollowingException
     }
     Mutex errmutex;
     Semaphore ready;
-    Semaphore finished;
     IException *e=NULL;
     Owned<IShuffledIterator> shuffler;
     if (shuffled) {
@@ -665,13 +664,12 @@ void CAsyncFor::For(unsigned num,unsigned maxatonce,bool abortFollowingException
         public:
             Mutex *errmutex;
             Semaphore &ready;
-            Semaphore &finished;
             int timeout;
             IException *&erre;
             unsigned idx;
             CAsyncFor *self;
-            cdothread(CAsyncFor *_self,unsigned _idx,Semaphore &_ready,Semaphore &_finished,Mutex *_errmutex,IException *&_e)
-                : Thread("CAsyncFor"),ready(_ready),finished(_finished),erre(_e)
+            cdothread(CAsyncFor *_self,unsigned _idx,Semaphore &_ready,Mutex *_errmutex,IException *&_e)
+                : Thread("CAsyncFor"),ready(_ready),erre(_e)
             {
                 errmutex =_errmutex;
                 idx = _idx;
@@ -699,7 +697,6 @@ void CAsyncFor::For(unsigned num,unsigned maxatonce,bool abortFollowingException
                 }
 #endif
                 ready.signal();
-                finished.signal();
                 return 0;
             }
         };
@@ -707,14 +704,19 @@ void CAsyncFor::For(unsigned num,unsigned maxatonce,bool abortFollowingException
             maxatonce = num;
         for (i=0;(i<num)&&(i<maxatonce);i++)
             ready.signal();
+        IArrayOf<Thread> started;
+        started.ensure(num);
         for (i=0;i<num;i++) {
             ready.wait();
             if (abortFollowingException && e) break;
-            Thread *thread = new cdothread(this,shuffled?shuffler->lookup(i):i,ready,finished,&errmutex,e);
-            thread->startRelease();
+            Owned<Thread> thread = new cdothread(this,shuffled?shuffler->lookup(i):i,ready,&errmutex,e);
+            thread->start();
+            started.append(*thread.getClear());
+        }
+        ForEachItemIn(idx, started)
+        {
+            started.item(idx).join();
         }
-        while (i--) 
-            finished.wait();
     }
     if (e)
         throw e;