Skip to content

Commit

Permalink
glibc-tests, tst-cond20: Release mutex after signal/broadcast
Browse files Browse the repository at this point in the history
Commit 6ff45b6 ("glibc-tests: Fix races on condvar destroy")
erroneously moved the pi_cond_destroy() call into the same block of code
which does the 'cond' condvar signaling under mutex 'mut' protection.

This in effect blocks all waiters on the 'cond' from acquiring the mutex
and completing the wake-up until after pi_cond_destroy() is called. This
was not the original intent of this test.

Release the 'mut' which gives waiters a chance to race for it. Re-acquire
it before calling pi_cond_destroy() per librtpi API requirements.

As a side effect this makes the increased timeout introduced by commit
da49252 ("glibc-tests: Increase timeout for tst-cond20") unnecessary.
Remove it.

Signed-off-by: Gratian Crisan <[email protected]>
  • Loading branch information
gratian committed Jan 9, 2024
1 parent b20cff1 commit aeefe12
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tests/glibc-tests/tst-cond20.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,15 @@ static int do_test(void)
pi_cond_signal(&cond, &mut);
pi_cond_broadcast(&cond, &mut);
}
pi_mutex_unlock(&mut);

pi_mutex_lock(&mut);
err = pi_cond_destroy(&cond);
if (err) {
printf("pi_cond_destroy failed: %s\n",
strerror(err));
return 1;
}

pi_mutex_unlock(&mut);

/* Now clobber the cond variable which has been successfully
Expand Down Expand Up @@ -157,5 +158,4 @@ static int do_test(void)
return 0;
}

#define TIMEOUT 40
#include "test-driver.c"

0 comments on commit aeefe12

Please sign in to comment.