Changeset 20914

Show
Ignore:
Timestamp:
11/12/07 11:45:27 (10 months ago)
Author:
patrick
Message:

MFT r20913: Report all sem_wait(3) errors to the caller rather than just

deadlock. In nearly all cases, sem_wait(3) will succeed unless
the semaphore was not created correctly, and that is why an
assertion was being used before.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • juggler/branches/2.2/modules/vapor/vpr/md/POSIX/Sync/SemaphorePosix.h

    r20910 r20914  
    4747 
    4848#include <stdio.h> 
     49#include <cstring> 
    4950#include <semaphore.h> 
    5051#include <errno.h> 
     
    103104    *       to acquire the semaphore itself. 
    104105    * 
    105     * @throw vpr::DeadlockException is thrown if the current thread has 
    106     *        already locked this semaphore. 
     106    * @throw vpr::DeadlockException 
     107    *           Thrown if the current thread has already locked this semaphore. 
     108    * @throw vpr::LockException 
     109    *           Thrown if the lock operation fails for reasons other than 
     110    *           deadlock and interruption of a system call. 
    107111    */ 
    108112   void acquire() 
     
    116120      while ( -1 == result && EINTR == errno ); 
    117121 
    118       if ( -1 == result && EDEADLK == errno ) 
    119       { 
    120          throw vpr::DeadlockException( 
    121             "Tried to lock semaphore twice in the same thread", VPR_LOCATION 
    122          ); 
    123       } 
    124  
    125       assert(result == 0); 
    126       boost::ignore_unused_variable_warning(result); 
     122      if ( -1 == result ) 
     123      { 
     124         if ( EDEADLK == errno ) 
     125         { 
     126            throw vpr::DeadlockException( 
     127               "Tried to lock semaphore twice in the same thread", VPR_LOCATION 
     128            ); 
     129         } 
     130 
     131         std::ostringstream msg_stream; 
     132         msg_stream << "Failed to lock semaphore: " << std::strerror(errno); 
     133         throw vpr::LockException(msg_stream.str(), VPR_LOCATION); 
     134      } 
    127135   } 
    128136