Fix panic when dropping unix socket
When a unix socket only calls function listen, its object is not created but its status becomes listening. At this time closing the socket would cause a panic before this commit.
This commit is contained in:
parent
9815523a95
commit
58403f8415
@ -286,8 +286,10 @@ impl UnixSocket {
|
||||
impl Drop for UnixSocket {
|
||||
fn drop(&mut self) {
|
||||
if let Status::Listening = self.status {
|
||||
let path = &self.obj.as_ref().unwrap().path;
|
||||
UnixSocketObject::remove(path);
|
||||
// Only remove the object when there is one
|
||||
if let Some(obj) = self.obj.as_ref() {
|
||||
UnixSocketObject::remove(&obj.path);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user