fetch: re-work transport::done signal call

The protocol requires that the fetcher signals to the remote that it
is done with the fetching process, so that the remote can exit out of
its upload-pack process.

The first change is that the `done` signal can happen before the
validation, since nothing else needs to be fetched.

The second change is that the fetcher does not care if the remote
responds to this signal since it has the data required for validation
and applying the changes to its refdb. Thus, if an error is
encountered then it is logged, but the rest of the process proceeds as
normal.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
This commit is contained in:
Fintan Halpenny 2024-03-11 11:38:48 +01:00 committed by cloudhead
parent c02ff1e47e
commit b1435629f9
No known key found for this signature in database
2 changed files with 18 additions and 10 deletions

View File

@ -9,18 +9,19 @@ mod refs;
mod stage;
mod state;
use gix_protocol::handshake;
pub use handle::Handle;
pub use policy::{Allowed, BlockList, Scope};
use radicle::storage::ReadRepository as _;
pub use state::{FetchLimit, FetchResult};
pub use transport::Transport;
use std::io;
use std::time::Instant;
use gix_protocol::handshake;
pub use handle::Handle;
pub use policy::{Allowed, BlockList, Scope};
pub use state::{FetchLimit, FetchResult};
pub use transport::Transport;
use radicle::crypto::PublicKey;
use radicle::storage::refs::RefsAt;
use radicle::storage::ReadRepository as _;
use state::FetchState;
use thiserror::Error;

View File

@ -441,6 +441,16 @@ impl FetchState {
start.elapsed().as_millis()
);
// N.b. signal to exit the upload-pack sequence
// We're finished fetching on this side, and all that's left
// is validation.
match handle.transport.done() {
Ok(()) => log::debug!(target: "fetch", "Sent done signal to remote {remote}"),
Err(err) => {
log::warn!(target: "fetch", "Attempted to send done to remote {remote}: {err}")
}
}
// Run validation of signed refs, pruning any offending
// remotes from the tips, thus not updating the production Git
// repository.
@ -543,9 +553,6 @@ impl FetchState {
}
}
}
// N.b. signal to exit the upload-pack sequence
handle.transport.done()?;
log::debug!(
target: "fetch",
"Validated {} remotes ({}ms)",