node: Always notify the service of a fetch result
Even if the peer is no longer connected.
This commit is contained in:
parent
395d317954
commit
53ecc88437
|
|
@ -409,34 +409,34 @@ where
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
let Peer::Connected {
|
if let Peer::Connected { link, streams, .. } = peer {
|
||||||
nid, link, streams, ..
|
// Nb. It's possible that the stream would already be unregistered if we received an
|
||||||
} = peer
|
// early "close" from the remote. Otherwise, we unregister it here and send the "close"
|
||||||
else {
|
// ourselves.
|
||||||
|
if let Some(s) = streams.unregister(&task.stream) {
|
||||||
|
log::debug!(
|
||||||
|
target: "wire", "Stream {} of {} closing with {} byte(s) sent and {} byte(s) received",
|
||||||
|
task.stream, task.remote, s.sent_bytes, s.received_bytes
|
||||||
|
);
|
||||||
|
let frame = Frame::control(
|
||||||
|
*link,
|
||||||
|
frame::Control::Close {
|
||||||
|
stream: task.stream,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
self.actions.push_back(Action::Send(fd, frame.to_bytes()));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// If the peer disconnected, we'll get here, but we still want to let the service know
|
||||||
|
// about the fetch result, so we don't return here.
|
||||||
log::warn!(target: "wire", "Peer {nid} is not connected; ignoring fetch result");
|
log::warn!(target: "wire", "Peer {nid} is not connected; ignoring fetch result");
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Nb. It's possible that the stream would already be unregistered if we received an early
|
|
||||||
// "close" from the remote. Otherwise, we unregister it here and send the "close" ourselves.
|
|
||||||
if let Some(s) = streams.unregister(&task.stream) {
|
|
||||||
log::debug!(
|
|
||||||
target: "wire", "Stream {} of {} closing with {} byte(s) sent and {} byte(s) received",
|
|
||||||
task.stream, task.remote, s.sent_bytes, s.received_bytes
|
|
||||||
);
|
|
||||||
let frame = Frame::control(
|
|
||||||
*link,
|
|
||||||
frame::Control::Close {
|
|
||||||
stream: task.stream,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
self.actions.push_back(Action::Send(fd, frame.to_bytes()));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Only call into the service if we initiated this fetch.
|
// Only call into the service if we initiated this fetch.
|
||||||
match task.result {
|
match task.result {
|
||||||
FetchResult::Initiator { rid, result } => {
|
FetchResult::Initiator { rid, result } => {
|
||||||
self.service.fetched(rid, *nid, result);
|
self.service.fetched(rid, nid, result);
|
||||||
}
|
}
|
||||||
FetchResult::Responder { rid, result } => {
|
FetchResult::Responder { rid, result } => {
|
||||||
if let Some(rid) = rid {
|
if let Some(rid) = rid {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue