Skip to content

Commit

Permalink
refs #4387 fixed a race condition in max-threads-count.qtest
Browse files Browse the repository at this point in the history
  • Loading branch information
davidnich committed Jan 14, 2022
1 parent 8d5ebfb commit cf87aca
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions examples/test/qore/threads/max-threads-count.qtest
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ public class MaxThreadCountTest inherits QUnit::Test {
q = new Queue();
}

t() {
t(Counter c) {
on_exit c.dec();
q.get();
q.push(1);
}
Expand All @@ -34,16 +35,27 @@ public class MaxThreadCountTest inherits QUnit::Test {
testSkip("skipping max thread test due to environment variable");
}

int limit = 0;

Counter c();
try {
while (True) {
background t();
c.inc();
on_error c.dec();
background t(c);
}
} catch (hash<ExceptionInfo> ex) {
assertEq("THREAD-CREATION-FAILURE", ex.err, "found threads count limit");
limit = num_threads();
q.push(1);
}

int nt = num_threads();
assertTrue(nt > 1, "number of threads is " + nt);
if (m_options.verbose > 2) {
printf("max thread limit detected: %d\n", limit);
}

assertGt(1, limit);
c.waitForZero();
assertEq(1, num_threads());
}
}

0 comments on commit cf87aca

Please sign in to comment.