Commit b8242eeb authored by KO Myung-Hun's avatar KO Myung-Hun Committed by Jean-Baptiste Kempf

src: os2: fix locking at quit

Sometimes, especially at quit, vlc_cond_(timed)wait() may be called
very frequently. And this may exceed the limit the post count of
OS/2 event semaphore. As a result, waiting thread numbers cannot be
calculated properly.

To avoid this, increase/decrease waiting thread numbers in
vlc_cond_wait_common() instead of separating it into vlc_cond_signal()
and vlc_cond_wait_common().
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 2febabcd
...@@ -350,18 +350,6 @@ void vlc_cond_signal (vlc_cond_t *p_condvar) ...@@ -350,18 +350,6 @@ void vlc_cond_signal (vlc_cond_t *p_condvar)
DosWaitEventSem (p_condvar->hevAck, SEM_INDEFINITE_WAIT); DosWaitEventSem (p_condvar->hevAck, SEM_INDEFINITE_WAIT);
DosResetEventSem (p_condvar->hevAck, &ulPost); DosResetEventSem (p_condvar->hevAck, &ulPost);
while (ulPost-- > 0)
__atomic_decrement (&p_condvar->waiters);
/* Already timed out ? */
if (__atomic_cmpxchg32 (&p_condvar->waiters, 0, 0) &&
__atomic_cmpxchg32 (&p_condvar->signaled, 1, 1))
{
/* Clear signaled status */
__atomic_xchg (&p_condvar->signaled, 0);
DosResetEventSem (p_condvar->hev, &ulPost);
}
} }
} }
...@@ -380,12 +368,12 @@ static int vlc_cond_wait_common (vlc_cond_t *p_condvar, vlc_mutex_t *p_mutex, ...@@ -380,12 +368,12 @@ static int vlc_cond_wait_common (vlc_cond_t *p_condvar, vlc_mutex_t *p_mutex,
ULONG ulPost; ULONG ulPost;
ULONG rc; ULONG rc;
__atomic_increment (&p_condvar->waiters);
do do
{ {
vlc_testcancel(); vlc_testcancel();
__atomic_increment (&p_condvar->waiters);
vlc_mutex_unlock (p_mutex); vlc_mutex_unlock (p_mutex);
do do
...@@ -396,6 +384,8 @@ static int vlc_cond_wait_common (vlc_cond_t *p_condvar, vlc_mutex_t *p_mutex, ...@@ -396,6 +384,8 @@ static int vlc_cond_wait_common (vlc_cond_t *p_condvar, vlc_mutex_t *p_mutex,
} while (rc == NO_ERROR && } while (rc == NO_ERROR &&
__atomic_cmpxchg32 (&p_condvar->signaled, 0, 1) == 0); __atomic_cmpxchg32 (&p_condvar->signaled, 0, 1) == 0);
__atomic_decrement (&p_condvar->waiters);
DosPostEventSem (p_condvar->hevAck); DosPostEventSem (p_condvar->hevAck);
vlc_mutex_lock (p_mutex); vlc_mutex_lock (p_mutex);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment