Fixed IO service shutdown (#3286)

Former-commit-id: feba57498d122773d4aeb567d1bf2c25f5853ed4
This commit is contained in:
Arkadiy Paronyan 2016-11-08 21:07:18 +01:00
parent a573b0d3e3
commit 972f1b11d6
1 changed files with 3 additions and 0 deletions

View File

@ -433,6 +433,9 @@ impl<Message> IoService<Message> where Message: Send + Sync + Clone + 'static {
impl<Message> Drop for IoService<Message> where Message: Send + Sync + Clone {
fn drop(&mut self) {
trace!(target: "shutdown", "[IoService] Closing...");
// Clear handlers so that shared pointers are not stuck on stack
// in Channel::send_sync
self.handlers.write().clear();
self.host_channel.lock().send(IoMessage::Shutdown).unwrap_or_else(|e| warn!("Error on IO service shutdown: {:?}", e));
if let Some(thread) = self.thread.take() {
thread.join().unwrap_or_else(|e| {