]> git.ipfire.org Git - thirdparty/asterisk.git/commit
test_astobj2_thrash: Fix multithreaded issues 79/4179/1
authorGeorge Joseph <gjoseph@digium.com>
Tue, 25 Oct 2016 16:20:16 +0000 (10:20 -0600)
committerGeorge Joseph <gjoseph@digium.com>
Tue, 25 Oct 2016 16:32:04 +0000 (11:32 -0500)
commit802bbf87524e7d1952b36cfa35444f7be129fbe6
tree8acdf13ea379b757cd7e880173496a65d2ff35e0
parent7c79b057dd3b0a06000b7bdd0583648bfc643b96
test_astobj2_thrash:  Fix multithreaded issues

The test uses 4 threads to grow, count, lookup and shrink 15K objects
in a container.  If there's only 1 execution engine available, the test
will complete in <50ms.  If each threads gets its own execution engine,
the test may timeout after 60 seconds because the count thread does a
locked ao2_callback on the whole container in a tight loop with only
a sched_yield to give up time.  The lock contention makes the test
execution times wildly variable and mostly timeout.  2 execution
engines are OK, 3 results in about 33% failure rate and >=4 causes
a 80% failure rate.

To fix, the sched_yield was changed to a usleep(500).

Also, the number of buckets specified for the container was an even
number so that was changed to the next prime number greater than
(MAX_HASH_ENTRIES / 100).  That's 151 currently.

Change-Id: I50cd2344161ea61bfe4b96d2a29a6ccf88385c77
tests/test_astobj2_thrash.c