mirror of
https://github.com/pocoproject/poco.git
synced 2025-01-18 00:15:27 +01:00
trunk/branch integration: bugfix
This commit is contained in:
parent
60bbdd7a6e
commit
6951be35de
@ -60,24 +60,24 @@ SharedMemoryImpl::SharedMemoryImpl(const std::string& name, std::size_t size, Sh
|
|||||||
_name.append("tmp/");
|
_name.append("tmp/");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
_name.append(name);
|
_name.append(name);
|
||||||
|
|
||||||
int flags = O_CREAT;
|
int flags = _server ? O_CREAT : 0;
|
||||||
if (_access == SharedMemory::AM_WRITE)
|
if (_access == SharedMemory::AM_WRITE)
|
||||||
flags |= O_RDWR;
|
flags |= O_RDWR;
|
||||||
else
|
else
|
||||||
flags |= O_RDONLY;
|
flags |= O_RDONLY;
|
||||||
|
|
||||||
// open the shared memory segment
|
// open the shared memory segment
|
||||||
_fd = ::shm_open(_name.c_str(), flags, S_IRUSR | S_IWUSR);
|
_fd = ::shm_open(_name.c_str(), flags, S_IRUSR | S_IWUSR);
|
||||||
if (_fd == -1)
|
if (_fd == -1)
|
||||||
throw SystemException("Cannot create shared memory object", _name);
|
throw SystemException("Cannot create shared memory object", _name);
|
||||||
|
|
||||||
// now set the correct size for the segment
|
// now set the correct size for the segment
|
||||||
if (-1 == ::ftruncate(_fd, size))
|
if (_server && -1 == ::ftruncate(_fd, size))
|
||||||
{
|
{
|
||||||
::close(_fd);
|
::close(_fd);
|
||||||
_fd = -1;
|
_fd = -1;
|
||||||
::shm_unlink(_name.c_str());
|
::shm_unlink(_name.c_str());
|
||||||
throw SystemException("Cannot resize shared memory object", _name);
|
throw SystemException("Cannot resize shared memory object", _name);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user