|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r82802 - in trunk: boost/interprocess libs/interprocess/doc
From: igaztanaga_at_[hidden]
Date: 2013-02-10 06:18:58
Author: igaztanaga
Date: 2013-02-10 06:18:57 EST (Sun, 10 Feb 2013)
New Revision: 82802
URL: http://svn.boost.org/trac/boost/changeset/82802
Log:
Fixes #7928
Text files modified:
trunk/boost/interprocess/shared_memory_object.hpp | 21 ++++++++++++++-------
trunk/libs/interprocess/doc/interprocess.qbk | 3 ++-
2 files changed, 16 insertions(+), 8 deletions(-)
Modified: trunk/boost/interprocess/shared_memory_object.hpp
==============================================================================
--- trunk/boost/interprocess/shared_memory_object.hpp (original)
+++ trunk/boost/interprocess/shared_memory_object.hpp 2013-02-10 06:18:57 EST (Sun, 10 Feb 2013)
@@ -320,20 +320,27 @@
break;
case ipcdetail::DoOpenOrCreate:
{
- oflag |= O_CREAT;
- //We need a loop to change permissions correctly using fchmod, since
- //with "O_CREAT only" shm_open we don't know if we've created or opened the file.
+ oflag |= (O_CREAT | O_EXCL);
+ //We need a create/open loop to change permissions correctly using fchmod, since
+ //with "O_CREAT" only we don't know if we've created or opened the shm.
while(1){
+ //Try to create shared memory
m_handle = shm_open(m_filename.c_str(), oflag, unix_perm);
+ //If successful change real permissions
if(m_handle >= 0){
::fchmod(m_handle, unix_perm);
- break;
}
+ //If already exists, try to open
else if(errno == EEXIST){
- if((m_handle = shm_open(m_filename.c_str(), oflag, unix_perm)) >= 0 || errno != ENOENT){
- break;
+ m_handle = shm_open(m_filename.c_str(), oflag, unix_perm);
+ //If open fails and errno tells the file does not exist
+ //(shm was removed between creation and opening tries), just retry
+ if(m_handle < 0 && errno == ENOENT){
+ continue;
}
}
+ //Exit retries
+ break;
}
}
break;
@@ -345,7 +352,7 @@
}
//Check for error
- if(m_handle == -1){
+ if(m_handle < 0){
error_info err = errno;
this->priv_close();
throw interprocess_exception(err);
Modified: trunk/libs/interprocess/doc/interprocess.qbk
==============================================================================
--- trunk/libs/interprocess/doc/interprocess.qbk (original)
+++ trunk/libs/interprocess/doc/interprocess.qbk 2013-02-10 06:18:57 EST (Sun, 10 Feb 2013)
@@ -6717,7 +6717,8 @@
[@https://svn.boost.org/trac/boost/ticket/7598 #7598],
[@https://svn.boost.org/trac/boost/ticket/7682 #7682],
[@https://svn.boost.org/trac/boost/ticket/7923 #7923],
- [@https://svn.boost.org/trac/boost/ticket/7924 #7924].
+ [@https://svn.boost.org/trac/boost/ticket/7924 #7924],
+ [@https://svn.boost.org/trac/boost/ticket/7928 #7928].
[endsect]
[section:release_notes_boost_1_53_00 Boost 1.53 Release]
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk