Modify

Opened 6 years ago

Closed 6 years ago

#5622 closed Bugs (fixed)

interprocess::named_semaphore::remove return value broken on POSIX systems

Reported by: Horst Schirmeier <horst@…> Owned by: Ion Gaztañaga
Milestone: To Be Determined Component: interprocess
Version: Boost Development Trunk Severity: Problem
Keywords: Cc:

Description

static bool named_semaphore::remove(const char *name) is documented as "Returns false on error", which is broken on POSIX platforms if BOOST_INTERPROCESS_NAMED_SEMAPHORE_USES_POSIX_SEMAPHORES is enabled.

named_semaphore::remove() (interprocess/sync/named_semaphore.hpp:166) calls static bool detail::named_semaphore_wrapper::remove(const char *name), which (interprocess/sync/posix/semaphore_wrapper.hpp:229) calls inline bool semaphore_unlink(const char *name) (:106). This function uses the POSIX API call sem_unlink() (:115) to do the unlinking:

return 0 != sem_unlink(sem_str.c_str());

This makes semaphore_unlink() return false if sem_unlink() returns 0. POSIX' sem_unlink() is documented to return 0 on success, though: "Upon successful completion, the sem_unlink() function shall return a value of 0." (POSIX API docs) interprocess/sync/posix/semaphore_wrapper.hpp:115 should be changed to the following:

return 0 == sem_unlink(sem_str.c_str());

Attachments (2)

syncbug.cc (423 bytes) - added by Horst Schirmeier <horst@…> 6 years ago.
Code snippet to reproduce the bug
remove-semaphore.diff (504 bytes) - added by Horst Schirmeier <horst@…> 6 years ago.
Patch for expected behaviour (against current development trunk SVN head)

Download all attachments as: .zip

Change History (3)

Changed 6 years ago by Horst Schirmeier <horst@…>

Attachment: syncbug.cc added

Code snippet to reproduce the bug

Changed 6 years ago by Horst Schirmeier <horst@…>

Attachment: remove-semaphore.diff added

Patch for expected behaviour (against current development trunk SVN head)

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

Resolution: fixed
Status: newclosed

Thanks for the report. Fixed in trunk.

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.