mirror of
https://github.com/pocoproject/poco.git
synced 2025-02-23 15:14:37 +01:00
NamedEvent/NamedMutex: change file open mode to read-only
This commit is contained in:
parent
40ae2aa2ed
commit
a7a8571e25
@ -57,13 +57,13 @@ NamedEventImpl::NamedEventImpl(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, 0);
|
||||
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 event %s (lockfile)", fileName), _name);
|
||||
key_t key = ftok(fileName.c_str(), 0);
|
||||
if (key == -1)
|
||||
@ -128,7 +128,7 @@ void NamedEventImpl::waitImpl()
|
||||
{
|
||||
err = semop(_semid, &op, 1);
|
||||
}
|
||||
while (err && errno == EINTR);
|
||||
while (err && errno == EINTR);
|
||||
if (err) throw SystemException("cannot wait for named event", _name);
|
||||
#endif
|
||||
}
|
||||
|
@ -57,13 +57,13 @@ 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);
|
||||
if (key == -1)
|
||||
|
Loading…
x
Reference in New Issue
Block a user