[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
Re: CWaiter is broken in SPTK [was: Problem with starting CPPSERV]
It worked after reinstalling SPTK.
Thanks everyone for the help.
> Interesting. The latest version is using the 'correct' way. Can you try to
> figure it out? If you can't - just remove that mutex lock/unlock in SVN ..
>
> 2007/3/13, Ilya A. Volynets-Evenbakh <ilya@total-knowledge.com>:
>>
>> OK. I had to look at the bug. It is, indeed breakage caused by
>> SPTK upgrade.
>>
>> Specific change in question is this:
>>
>> http://gateway.total-knowledge.com/websvn/diff.php?repname=SPTK&path=%2Ftrunk%2Fsrc%2Futils%2FCWaiter.cpp&rev=230&sc=1
>>
>> Attached patch reverses the breakage part. I'll commit it some time
>> soon.
>> To be specific: it is expected that CWaiter::waitForSignal() caller
>> locks the
>> waiter. Otherwise the whole paradigm makes no sense.
>>
>>
>> --
>> Ilya A. Volynets-Evenbakh
>> Total Knowledge. CTO
>> http://www.total-knowledge.com
>>
>>
>> Index: src/utils/CWaiter.cpp
>> ===================================================================
>> --- src/utils/CWaiter.cpp (revision 265)
>> +++ src/utils/CWaiter.cpp (working copy)
>> @@ -64,24 +64,22 @@
>> }
>>
>> int CWaiter::waitForSignal(int timeout) {
>> - int rc = 0;
>> #ifndef _WIN32
>> - pthread_mutex_lock(&m_waiter);
>> if (timeout > 0) {
>> int secs = timeout / 1000;
>> int msecs = timeout % 1000;
>> struct timespec abstime = { time(NULL) + secs, msecs * 1000L
>> };
>> int rc =
>> pthread_cond_timedwait(&m_condition,&m_waiter,&abstime);
>> - rc = -1;
>> + if(rc != 0)
>> + return -1;
>> } else
>> pthread_cond_wait(&m_condition,&m_waiter);
>>
>> - pthread_mutex_unlock(&m_waiter);
>> #else
>> WaitForSingleObject(m_waiter,timeout);
>> #endif
>>
>> - return rc;
>> + return 0;
>> }
>>
>> void CWaiter::sendSignalNoLock() {
>>
>>
>
>
> --
> Alexey Parshin,
> http://www.sptk.net
>