Show
Ignore:
Timestamp:
01/21/10 23:14:31 (3 years ago)
Author:
saturday06
Message:

sem

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/objective-cplusplus/i3/trunk/src/mil/include/mil/Synchronize.h

    r36495 r36497  
    116116             << reinterpret_cast<uintptr_t>(this); 
    117117 
    118         psem = sem_open(name.str().c_str(), 
    119                         /*O_CREAT |*/ O_EXCL, S_IRUSR | S_IWUSR | S_IXUSR, 0); 
    120         if (reinterpret_cast<int>(psem) == -1) { 
    121             halt << "sem_open() failed"; 
    122         } 
    123  
     118        psem = sem_open(name.str().c_str(), O_CREAT | O_EXCL, S_IRUSR | S_IWUSR | S_IXUSR, 0); 
     119        if (psem != SEM_FAILED) { 
     120            return; 
     121        } 
     122        if (errno == EEXIST) { 
     123            debug << "semaphore [" << name.str() << "] is already exists."; 
     124            psem = sem_open(name.str().c_str(), O_EXCL, S_IRUSR | S_IWUSR | S_IXUSR, 0); 
     125            if (psem != SEM_FAILED) { 
     126                return; 
     127            } 
     128        } 
     129        halt << "sem_open() failed"; 
    124130    } 
    125131