Ticket #6058 (closed Bugs: fixed)
semaphore_timed_wait() behaviour inconsistent with glibc sem_timedwait()
|Reported by:||Frank <frank.kusters@…>||Owned by:||igaztanaga|
|Milestone:||To Be Determined||Component:||interprocess|
|Version:||Boost Development Trunk||Severity:||Problem|
What should boost::interprocess::interprocess_semaphore::timed_wait(abs_time) return when the absolute time it is given, is in the past, but the semaphore is available?
The boost documentation in interprocess_semaphore.hpp is not very clear, but it does suggest that it should return true.
The implementation in semaphore_wrapper.hpp does the following:
If BOOST_INTERPROCESS_POSIX_TIMEOUTS is defined, sem_timedwait() is called from semaphore.h. If the macro is not defined, it will use its own implementation, which first looks at the time, and will thus return false in this case. This is in contradiction with the documentation.
sem_timedwait in semaphore.c, however, will first try to acquire the lock, and if it could not get a lock, look at the time. Thus the end result will be true, which is inconsistent with the boost version.
Please note that the POSIX documentation is unclear on this topic too, so the semaphore.c implementation might vary from system to system. I am talking about the GNU version.