Refactor sysvmq::unlink_*
and check for error
Use `sysvmq::id_from_key(key)` to receive the id of a queue identified with `key`. Here an error check is added as well. Adapt `Sysv::Unlink::run()` to comply with that change.
This commit is contained in:
parent
0bff16f5b2
commit
4a4bb07b19
1 changed files with 5 additions and 2 deletions
|
@ -69,10 +69,13 @@ pub fn unlink_id(id: i32) -> Result<(), SysvMqError> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn unlink_key(key: i32) -> Result<(), SysvMqError> {
|
pub fn id_from_key(key: i32) -> Result<i32, SysvMqError> {
|
||||||
let id = unsafe { msgget(key, 0) };
|
let id = unsafe { msgget(key, 0) };
|
||||||
|
|
||||||
unlink_id(id)
|
match id {
|
||||||
|
-1 => Err(SysvMqError::ErrnoError(Errno::from_i32(errno()).desc())),
|
||||||
|
id => Ok(id),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct SysvMq<T> {
|
pub struct SysvMq<T> {
|
||||||
|
|
Loading…
Reference in a new issue