fix_deadlock_general_service: fix deadlock when join general service.

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou 2022-05-26 17:07:00 +08:00
parent 7c2cf6c9b3
commit 7c99ac2ba2

View File

@ -89,7 +89,12 @@ impl<T: Subscriber + From<ConnInner>> Service for ServiceTmpl<T> {
fn join(&self) { fn join(&self) {
self.0.write().unwrap().active = false; self.0.write().unwrap().active = false;
self.0.write().unwrap().handle.take().map(JoinHandle::join); let handle = self.0.write().unwrap().handle.take();
if let Some(handle) = handle {
if let Err(e) = handle.join() {
log::error!("Failed to join thread for service {}, {:?}", self.name(), e);
}
}
} }
} }