From: Mikko Rasa Date: Thu, 19 Jul 2012 11:42:36 +0000 (+0300) Subject: Fix a race condition X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=740d7cdd71fc2f068e44bfc6c8cc7e9565de16f6;p=builder.git Fix a race condition --- diff --git a/source/internaltask.cpp b/source/internaltask.cpp index c117bad..bcea591 100644 --- a/source/internaltask.cpp +++ b/source/internaltask.cpp @@ -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; } diff --git a/source/internaltask.h b/source/internaltask.h index 399e119..c927b0b 100644 --- a/source/internaltask.h +++ b/source/internaltask.h @@ -17,7 +17,7 @@ public: friend class InternalTask; protected: - Status status; + volatile Status status; Worker();