mirror of
https://github.com/mutouyun/cpp-ipc.git
synced 2025-12-06 16:56:45 +08:00
Merge pull request #139 from aengusjiang/master
acquire 仅open不存在的shm不应该打印错误日志
This commit is contained in:
commit
f3bf137668
@ -72,7 +72,10 @@ id_t acquire(char const * name, std::size_t size, unsigned mode) {
|
|||||||
S_IRGRP | S_IWGRP |
|
S_IRGRP | S_IWGRP |
|
||||||
S_IROTH | S_IWOTH);
|
S_IROTH | S_IWOTH);
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
|
// only open shm not log error when file not exist
|
||||||
|
if (open != mode || ENOENT != errno) {
|
||||||
ipc::error("fail shm_open[%d]: %s\n", errno, op_name.c_str());
|
ipc::error("fail shm_open[%d]: %s\n", errno, op_name.c_str());
|
||||||
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
::fchmod(fd, S_IRUSR | S_IWUSR |
|
::fchmod(fd, S_IRUSR | S_IWUSR |
|
||||||
|
|||||||
@ -78,8 +78,12 @@ bool handle::acquire(char const * name, std::size_t size, unsigned mode) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
release();
|
release();
|
||||||
|
const auto id = shm::acquire(name, size, mode);
|
||||||
|
if (!id) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
impl(p_)->id_ = id;
|
||||||
impl(p_)->n_ = name;
|
impl(p_)->n_ = name;
|
||||||
impl(p_)->id_ = shm::acquire(name, size, mode);
|
|
||||||
impl(p_)->m_ = shm::get_mem(impl(p_)->id_, &(impl(p_)->s_));
|
impl(p_)->m_ = shm::get_mem(impl(p_)->id_, &(impl(p_)->s_));
|
||||||
return valid();
|
return valid();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user