Summary:ASTERISK-20240: Incorrect work of __ast_rwlock_timed[rd|wr]lock() functions on OpenBSD
Reporter:Egor Gorlin (chip)Labels:
Date Opened:2012-08-16 06:25:23Date Closed:2012-08-27 11:48:07
Versions:Frequency of
Environment:Open BSD, Mac OS X and similarAttachments:( 0) lock.c.patch
Description:I faced problem with {{pthread_rwlock_timed\[rd|wr\]lock()}} in my project: these functions are not implemented on OpenBSD/MacOS and similar systems.
Luckily i found the solution in Asterisk (dev/Asterisk/main/lock.c) but it seems to be implemented incorrectly.

In {{pthread_rwlock_timed\[rd|wr\]lock()}} second argument is {{const struct timespec *abs_timeout}}, which represents time since UNIX epoch till timeout.
In {{__ast_rwlock_timed\[rd|wr\]lock()}} implementation for OpenBSD this argument is treated as relative timeout:
difference between {{ast_tvnow()}} and {{struct timeval _start}} is compared to {{abs_timeout}}. That's incorrect.
Comments:By: Egor Gorlin (chip) 2012-08-16 06:31:55.198-0500

Here is the patch.

By: Egor Gorlin (chip) 2012-08-17 10:53:59.038-0500

reupload patch due to license status update