History

[transport] unsupported protocol versions now abort the fetch operation

We don't close the connection because the borrow checker won't let us, but that's probably already and happens in other places as well in case there is an error. Transports probably close on drop, right? What about async drop? Maybe we are leaking all the time, unless people use `&mut transport`.

Sebastian Thiel committed 5 years ago

Commit 812aa3b1 parent 2b220f011 files · +49 −55Browse files

Showing the changes to git-protocol/src/fetch/function.rs (1 of 11 files). Show all

Unified · Split

git-protocol/src/fetch/function.rs+6−10
@@ -5,7 +5,7 @@ use crate::{ · 4 unmodified lines
55 use git_features::{progress, progress::Progress};
66 use git_transport::{
77 client,
8− client::{ProtocolDecision, SetServiceResponse, TransportV2Ext},
8+ client::{SetServiceResponse, TransportV2Ext},
99 Service,
1010 };
1111 use maybe_async::maybe_async;
@@ -36,6 +36,7 @@ where · 24 unmodified lines
3636 progress.init(None, progress::steps());
3737 progress.set_name("handshake");
3838 progress.step();
39+ let supported_versions: Vec<_> = transport.supported_protocol_versions().into();
3940 let result = transport.handshake(Service::UploadPack).await;
4041 let SetServiceResponse {
4142 actual_protocol,
@@ -71,15 +72,10 @@ where · 29 unmodified lines
7172 Err(err) => Err(err),
7273 }?;
7374
74− match transport.supports_advertised_version(actual_protocol) {
75− ProtocolDecision::Continue => {}
76− ProtocolDecision::CloseConnectionImmediately => {
77− drop(refs);
78− transport.close().await;
79− return Err((Error::TransportProtocolPolicyViolation {
80− actual_version: actual_protocol,
81− }));
82− }
75+ if !supported_versions.is_empty() && !supported_versions.contains(&actual_protocol) {
76+ return Err(Error::TransportProtocolPolicyViolation {
77+ actual_version: actual_protocol,
78+ });
8379 }
8480
8581 let parsed_refs = match refs {