Skip to content

Commit

Permalink
Hotfix/posix shm slash (#114)
Browse files Browse the repository at this point in the history
* Added slash prefix for POSIX shared memory files

* Fixed typo in variable name
  • Loading branch information
hannemn authored Oct 29, 2020
1 parent 07a1c4f commit 39bd1e3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions ecal/core/src/ecal_event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ namespace eCAL
m_name(name_ + "_evt"),
m_event(nullptr)
{
m_name = (m_name[0] != '/') ? "/" + m_name : m_name; // make memory file path compatible for all posix systems
m_event = named_event_open(m_name.c_str());
if(m_event == nullptr)
{
Expand Down
7 changes: 4 additions & 3 deletions ecal/core/src/io/linux/ecal_memfile_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,17 @@ namespace eCAL
oflag = O_RDONLY;
}
int previous_umask = umask(000); // set umask to nothing, so we can create files with all possible permission bits
mem_file_info_.memfile = ::shm_open(name_.c_str(), oflag, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
mem_file_info_.name = name_.size() ? ( (name_[0] != '/') ? "/" + name_ : name_) : name_; // make memory file path compatible for all posix systems
mem_file_info_.memfile = ::shm_open(mem_file_info_.name.c_str(), oflag, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
umask(previous_umask); // reset umask to previous permissions
if(mem_file_info_.memfile == -1)
{
std::cout << "shm_open failed : " << mem_file_info_.name << " errno: " << strerror(errno) << std::endl;
mem_file_info_.memfile = 0;
std::cout << "shm_open failed : " << name_ << " errno: " << strerror(errno) << std::endl;
mem_file_info_.name = "";
return(false);
}

mem_file_info_.name = name_;
mem_file_info_.size = 0;

return(true);
Expand Down

0 comments on commit 39bd1e3

Please sign in to comment.