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
5use git_features::{progress, progress::Progress};5use git_features::{progress, progress::Progress};
6use git_transport::{6use git_transport::{
7 client,7 client,
8 client::{ProtocolDecision, SetServiceResponse, TransportV2Ext},8 client::{SetServiceResponse, TransportV2Ext},
9 Service,9 Service,
10};10};
11use maybe_async::maybe_async;11use maybe_async::maybe_async;
@@ -36,6 +36,7 @@ where · 24 unmodified lines
36 progress.init(None, progress::steps());36 progress.init(None, progress::steps());
37 progress.set_name("handshake");37 progress.set_name("handshake");
38 progress.step();38 progress.step();
39 let supported_versions: Vec<_> = transport.supported_protocol_versions().into();
39 let result = transport.handshake(Service::UploadPack).await;40 let result = transport.handshake(Service::UploadPack).await;
40 let SetServiceResponse {41 let SetServiceResponse {
41 actual_protocol,42 actual_protocol,
@@ -71,15 +72,10 @@ where · 29 unmodified lines
71 Err(err) => Err(err),72 Err(err) => Err(err),
72 }?;73 }?;
73 74
74 match transport.supports_advertised_version(actual_protocol) {75 if !supported_versions.is_empty() && !supported_versions.contains(&actual_protocol) {
75 ProtocolDecision::Continue => {}76 return Err(Error::TransportProtocolPolicyViolation {
76 ProtocolDecision::CloseConnectionImmediately => {77 actual_version: actual_protocol,
77 drop(refs);78 });
78 transport.close().await;
79 return Err((Error::TransportProtocolPolicyViolation {
80 actual_version: actual_protocol,
81 }));
82 }
83 }79 }
84 80
85 let parsed_refs = match refs {81 let parsed_refs = match refs {