mirror of
https://github.com/mutouyun/cpp-ipc.git
synced 2025-12-07 01:06:45 +08:00
open的时候不存在共享内存,则返回false,没有必要报错
This commit is contained in:
parent
df09c22738
commit
d69093462a
@ -72,7 +72,9 @@ 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) {
|
||||||
ipc::error("fail shm_open[%d]: %s\n", errno, op_name.c_str());
|
if (open != mode) {
|
||||||
|
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