]> git.tdb.fi Git - builder.git/commitdiff
Fix a race condition
authorMikko Rasa <tdb@tdb.fi>
Thu, 19 Jul 2012 11:42:36 +0000 (14:42 +0300)
committerMikko Rasa <tdb@tdb.fi>
Thu, 19 Jul 2012 11:42:36 +0000 (14:42 +0300)
source/internaltask.cpp
source/internaltask.h

index c117bad897365f9e4159f7c58b9f9b764f6ae13c..bcea59156be3b6ae9b70a2dad96a72bf6bc31ab7 100644 (file)
@@ -17,15 +17,16 @@ void InternalTask::start()
 
 Task::Status InternalTask::check()
 {
-       if(worker->get_status()!=RUNNING)
-               signal_finished.emit(worker->get_status()==SUCCESS);
-       return worker->get_status();
+       Status result = worker->get_status();
+       if(result!=RUNNING)
+               signal_finished.emit(result==SUCCESS);
+       return result;
 }
 
 Task::Status InternalTask::wait()
 {
        Status result;
-       while((result = worker->get_status())==RUNNING) ;
+       while((result = check())==RUNNING) ;
        return result;
 }
 
index 399e11937fe0d71e0532f85683aa48632f841286..c927b0ba9de5f0261ceb07b54860a5a89a3b044a 100644 (file)
@@ -17,7 +17,7 @@ public:
                friend class InternalTask;
 
        protected:
-               Status status;
+               volatile Status status;
 
                Worker();