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`.
Showing the changes to git-protocol/src/fetch/function.rs (1 of 11 files). Show all
Unified · Split
| @@ -5,7 +5,7 @@ use crate::{ · 4 unmodified lines | ||
| 5 | 5 | use git_features::{progress, progress::Progress}; |
| 6 | 6 | use git_transport::{ |
| 7 | 7 | client, |
| 8 | − client::{ProtocolDecision, SetServiceResponse, TransportV2Ext}, | |
| 8 | + client::{SetServiceResponse, TransportV2Ext}, | |
| 9 | 9 | Service, |
| 10 | 10 | }; |
| 11 | 11 | use maybe_async::maybe_async; |
| @@ -36,6 +36,7 @@ where · 24 unmodified lines | ||
| 36 | 36 | progress.init(None, progress::steps()); |
| 37 | 37 | progress.set_name("handshake"); |
| 38 | 38 | progress.step(); |
| 39 | + let supported_versions: Vec<_> = transport.supported_protocol_versions().into(); | |
| 39 | 40 | let result = transport.handshake(Service::UploadPack).await; |
| 40 | 41 | let SetServiceResponse { |
| 41 | 42 | actual_protocol, |
| @@ -71,15 +72,10 @@ where · 29 unmodified lines | ||
| 71 | 72 | Err(err) => Err(err), |
| 72 | 73 | }?; |
| 73 | 74 | |
| 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 | + }); | |
| 83 | 79 | } |
| 84 | 80 | |
| 85 | 81 | let parsed_refs = match refs { |