From 3aef45d35bab536aaf3ad1ea040b70ea3f0612c0 Mon Sep 17 00:00:00 2001 From: marha Date: Wed, 6 Oct 2010 16:03:47 +0000 Subject: Solved reentrancy problem in commandqueue --- tools/mhmake/src/commandqueue.h | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'tools/mhmake/src/commandqueue.h') diff --git a/tools/mhmake/src/commandqueue.h b/tools/mhmake/src/commandqueue.h index 3642d2f1d..d29057443 100644 --- a/tools/mhmake/src/commandqueue.h +++ b/tools/mhmake/src/commandqueue.h @@ -31,36 +31,34 @@ typedef pid_t mh_pid_t; class commandqueue { - struct activeentry + struct activeentry : public refbase { refptr pTarget; vector::const_iterator CurrentCommandIt; string Command; md5_context md5ctx; bool IgnoreError; - void clear() - { - pTarget=NULL; - Command.clear(); - #ifdef _DEBUG - md5ctx.Data.clear(); - #endif - } }; private: queue< refptr > m_Queue; unsigned m_MaxNrCommandsInParallel; mh_pid_t *m_pActiveProcesses; - activeentry *m_pActiveEntries; + refptr *m_pActiveEntries; unsigned m_NrActiveEntries; + mh_pid_t m_DummyWaitHandle; private: - void ThrowCommandExecutionError(activeentry *pActiveEntry); - void AddActiveEntry(activeentry &ActiveEntry, mh_pid_t ActiveProcess); + void ThrowCommandExecutionError(refptr pActiveEntry); + refptr CreateActiveEntry(void); + unsigned GetActiveEntryId(const refptr pActiveEntry) const; void RemoveActiveEntry(unsigned Entry); + void RemoveActiveEntry(refptr pActiveEntry) + { + RemoveActiveEntry(GetActiveEntryId(pActiveEntry)); + } bool StartExecuteCommands(const refptr &pTarget); - bool StartExecuteNextCommand(activeentry *pActiveEntry, mh_pid_t *pActiveProcess); - void TargetBuildFinished(activeentry *pActiveEntry); + bool StartExecuteNextCommand(refptr pActiveEntry, mh_pid_t *pActiveProcess); + void TargetBuildFinished(refptr pActiveEntry); public: commandqueue(); -- cgit v1.2.3