Modify

Opened 6 years ago

Closed 6 years ago

#6058 closed Bugs (fixed)

semaphore_timed_wait() behaviour inconsistent with glibc sem_timedwait()

Reported by: Frank <frank.kusters@…> Owned by: Ion Gaztañaga
Milestone: To Be Determined Component: interprocess
Version: Boost Development Trunk Severity: Problem
Keywords: Cc: kees-jan.dijkzeul@…

Description

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.

Attachments (0)

Change History (3)

comment:1 Changed 6 years ago by kees-jan.dijkzeul@…

Cc: kees-jan.dijkzeul@… added

comment:2 Changed 6 years ago by Ion Gaztañaga

I think your questions means a bug in Interprocess. According to

http://pubs.opengroup.org/onlinepubs/000095399/functions/sem_timedwait.html

"Under no circumstance shall the function fail with a timeout if the semaphore can be locked immediately. The validity of the abs_timeout need not be checked if the semaphore can be locked immediately"

The implementation should not check the timeout before trying to lock the semaphore

comment:3 Changed 6 years ago by Ion Gaztañaga

Resolution: fixed
Status: newclosed

Implementation changed in Trunk and Release branches, so that a lock try is performed before checking the timeout.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Ion Gaztañaga.
The resolution will be deleted.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.