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/");
|
||||
#endif
|
||||
|
||||
_name.append(name);
|
||||
_name.append(name);
|
||||
|
||||
int flags = O_CREAT;
|
||||
if (_access == SharedMemory::AM_WRITE)
|
||||
flags |= O_RDWR;
|
||||
else
|
||||
int flags = _server ? O_CREAT : 0;
|
||||
if (_access == SharedMemory::AM_WRITE)
|
||||
flags |= O_RDWR;
|
||||
else
|
||||
flags |= O_RDONLY;
|
||||
|
||||
// open the shared memory segment
|
||||
_fd = ::shm_open(_name.c_str(), flags, S_IRUSR | S_IWUSR);
|
||||
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
|
||||
if (-1 == ::ftruncate(_fd, size))
|
||||
{
|
||||
::close(_fd);
|
||||
_fd = -1;
|
||||
// now set the correct size for the segment
|
||||
if (_server && -1 == ::ftruncate(_fd, size))
|
||||
{
|
||||
::close(_fd);
|
||||
_fd = -1;
|
||||
::shm_unlink(_name.c_str());
|
||||
throw SystemException("Cannot resize shared memory object", _name);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user