Re: Posix mutex working in Linux but not Solaris On Fri, 8 Feb 2008 16:41:20 -0800 (PST) Cheng <cheng.stillsea@gmail.com> wrote:
> Here it is:
>
> bool
> posixMutex::isProcessLocked() const
> {
> return (m_lockingProcessID == getThisProcessID() &
> m_state.m_lockCount != 0);
> }
yup, that's your race.
what's happening is that you are setting the m_lockingProcessID and
m_state with mutex held, but testing them without mutex held. classic.
> So what else should it check in your opinion? Thank you.
it would be more educational for you if you try to figure it out
first. between the above, and my earlier post saying what I assumed
isProcessLocked() was doing (if it were correct), you have the answer.
it's not *what else*, it's what instead.
where did you get this code? you said it was from an online source.
-frank |