Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix close #92

Merged
merged 1 commit into from
Apr 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1152,7 +1152,7 @@ where
Err(timer::Error::shutdown())
}
})
.map_err(|err| warn!("{}", err));
.map_err(|err| debug!("notify close by: {}", err));

// If set more than once, the older task will stop when sender dropped
self.service_notify_signals
Expand Down Expand Up @@ -1203,7 +1203,7 @@ where
Err(timer::Error::shutdown())
}
})
.map_err(|err| warn!("{}", err));
.map_err(|err| debug!("session notify close by: {}", err));

// If set more than once, the older task will stop when sender dropped
if let Some(session) = self.sessions.get_mut(&session_id) {
Expand Down
21 changes: 13 additions & 8 deletions src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ where
version,
});
tokio::spawn(send_task.map(|_| ()).map_err(|err| {
error!("stream send back error: {:?}", err);
debug!("stream send back error: {:?}", err);
}));
}
None => {
Expand All @@ -232,7 +232,7 @@ where
proto_name: Some(name),
});
tokio::spawn(send_task.map(|_| ()).map_err(|err| {
error!("select error send back error: {:?}", err);
debug!("select error send back error: {:?}", err);
}));
}
},
Expand All @@ -241,7 +241,7 @@ where
let send_task =
event_sender.send(ProtocolEvent::SelectError { proto_name: None });
tokio::spawn(send_task.map(|_| ()).map_err(|err| {
error!("select error send back error: {:?}", err);
debug!("select error send back error: {:?}", err);
}));
}
}
Expand Down Expand Up @@ -298,7 +298,7 @@ where
self.write_buf.push_back(e.into_inner());
self.notify();
} else {
error!("session send to sub stream error: {}", e);
debug!("session send to sub stream error: {}", e);
}
}
};
Expand All @@ -310,7 +310,7 @@ where
self.write_buf.push_back(e.into_inner());
self.notify();
} else {
error!("session send to sub stream error: {}", e);
debug!("session send to sub stream error: {}", e);
}
}
};
Expand Down Expand Up @@ -483,9 +483,14 @@ where

/// Close session
fn close_session(&mut self) {
let _ = self
.service_sender
.try_send(SessionEvent::SessionClose { id: self.id });
tokio::spawn(
self.service_sender
.clone()
.send(SessionEvent::SessionClose { id: self.id })
.map(|_| ())
.map_err(|e| error!("session close event send to service error: {:?}", e)),
);

self.sub_streams.clear();
self.service_receiver.close();
self.proto_event_receiver.close();
Expand Down
16 changes: 11 additions & 5 deletions src/substream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,16 @@ where
fn close_proto_stream(&mut self) {
self.event_receiver.close();
let _ = self.sub_stream.get_mut().shutdown();
self.output_event(ProtocolEvent::Close {
id: self.id,
proto_id: self.proto_id,
});
tokio::spawn(
self.event_sender
.clone()
.send(ProtocolEvent::Close {
id: self.id,
proto_id: self.proto_id,
})
.map(|_| ())
.map_err(|e| debug!("stream close event send to session error: {:?}", e)),
);
}

/// Handling commands send by session
Expand All @@ -152,7 +158,7 @@ where
// Whether it is a read send error or a flush error,
// the most essential problem is that there is a problem with the external network.
// Close the protocol stream directly.
warn!(
debug!(
"protocol [{}] close because of extern network",
self.proto_id
);
Expand Down