Merge branch 'poco-1.7.9' into poco-1.8.0

This commit is contained in:
Günter Obiltschnig
2017-09-11 21:08:04 +02:00
4 changed files with 17 additions and 9 deletions

View File

@@ -55,15 +55,15 @@ NamedMutexImpl::NamedMutexImpl(const std::string& name):
std::string fileName = getFileName();
#if defined(sun) || defined(__APPLE__) || defined(__osf__) || defined(__QNX__) || defined(_AIX)
_sem = sem_open(fileName.c_str(), O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO, 1);
if ((long) _sem == (long) SEM_FAILED)
if ((long) _sem == (long) SEM_FAILED)
throw SystemException(Poco::format("cannot create named mutex %s (sem_open() failed, errno=%d)", fileName, errno), _name);
#else
int fd = open(fileName.c_str(), O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
int fd = open(fileName.c_str(), O_RDONLY | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
if (fd != -1)
close(fd);
else
else
throw SystemException(Poco::format("cannot create named mutex %s (lockfile)", fileName), _name);
key_t key = ftok(fileName.c_str(), 0);
key_t key = ftok(fileName.c_str(), 'p');
if (key == -1)
throw SystemException(Poco::format("cannot create named mutex %s (ftok() failed, errno=%d)", fileName, errno), _name);
_semid = semget(key, 1, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH | IPC_CREAT | IPC_EXCL);