Opened 8 years ago

Closed 8 years ago

#11119 closed Bugs (fixed)

mutex::unlock must not throw

Reported by: viboes Owned by: viboes
Milestone: Boost 1.58.0 Component: thread
Version: Boost 1.57.0 Severity: Problem
Keywords: Cc:

Description (last modified by viboes)

The Mutex requirements say

m.unlock();

Requires:

    The current thread owns m. 
Synchronization:

    This operation synchronizes with subsequent lock operations that obtain ownership on the same object. 
Effects:

    Releases a lock on m by the current thread. 
Return type:

    void. 
Throws:

    Nothing. 

However mutex::unlock throws an exception.

void unlock()
{
    int res = posix::pthread_mutex_unlock(&m);
    if (res)
    {
        boost::throw_exception(lock_error(res,"boost: mutex unlock failed in pthread_mutex_unlock"));
    }
}

Change History (3)

comment:1 by viboes, 8 years ago

Description: modified (diff)
Owner: changed from Anthony Williams to viboes
Status: newassigned

comment:2 by viboes, 8 years ago

Summary: mutex::lock must not throwmutex::unlock must not throw

comment:3 by viboes, 8 years ago

Milestone: To Be DeterminedBoost 1.58.0
Resolution: fixed
Status: assignedclosed
        void unlock()
        {
            int res = posix::pthread_mutex_unlock(&m);
            (void)res;
            BOOST_ASSERT(res == 0);
//            if (res)
//            {
//                boost::throw_exception(lock_error(res,"boost: mutex unlock failed in pthread_mutex_unlock"));
//            }
        }
Note: See TracTickets for help on using tickets.