mirror of
https://github.com/pocoproject/poco.git
synced 2025-03-10 12:21:09 +01:00
Poco::NamedMutex and Poco::NamedEvent (System V Semaphores implementation): files are now opened with O_RDONLY | O_CREAT instead of O_WRONLY | O_CREAT, allowing sharing between different users. Furthermore, ftok() is called with 'p' as project ID argument.
This commit is contained in:
parent
7896a1b7dd
commit
33bc8b5011
@ -58,12 +58,12 @@ NamedEventImpl::NamedEventImpl(const std::string& name):
|
|||||||
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);
|
throw SystemException(Poco::format("cannot create named mutex %s (sem_open() failed, errno=%d)", fileName, errno), _name);
|
||||||
#else
|
#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)
|
if (fd != -1)
|
||||||
close(fd);
|
close(fd);
|
||||||
else
|
else
|
||||||
throw SystemException(Poco::format("cannot create named event %s (lockfile)", fileName), _name);
|
throw SystemException(Poco::format("cannot create named event %s (lockfile)", fileName), _name);
|
||||||
key_t key = ftok(fileName.c_str(), 0);
|
key_t key = ftok(fileName.c_str(), 'p');
|
||||||
if (key == -1)
|
if (key == -1)
|
||||||
throw SystemException(Poco::format("cannot create named mutex %s (ftok() failed, errno=%d)", fileName, errno), _name);
|
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);
|
_semid = semget(key, 1, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH | IPC_CREAT | IPC_EXCL);
|
||||||
|
@ -58,12 +58,12 @@ NamedMutexImpl::NamedMutexImpl(const std::string& name):
|
|||||||
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);
|
throw SystemException(Poco::format("cannot create named mutex %s (sem_open() failed, errno=%d)", fileName, errno), _name);
|
||||||
#else
|
#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)
|
if (fd != -1)
|
||||||
close(fd);
|
close(fd);
|
||||||
else
|
else
|
||||||
throw SystemException(Poco::format("cannot create named mutex %s (lockfile)", fileName), _name);
|
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)
|
if (key == -1)
|
||||||
throw SystemException(Poco::format("cannot create named mutex %s (ftok() failed, errno=%d)", fileName, errno), _name);
|
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);
|
_semid = semget(key, 1, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH | IPC_CREAT | IPC_EXCL);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user