summaryrefslogtreecommitdiff
path: root/src/controller.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/controller.rs')
-rw-r--r--src/controller.rs70
1 files changed, 40 insertions, 30 deletions
diff --git a/src/controller.rs b/src/controller.rs
index 4686118..ea98a65 100644
--- a/src/controller.rs
+++ b/src/controller.rs
@@ -336,27 +336,32 @@ impl Controller {
"The diagnostic provider requested a pause; retry after its Retry-After delay"
);
}
- let probe = self
- .runtime
- .probe(
- entry.connection.as_ref().unwrap(),
- if speed {
- settings.maximum_duration_seconds
- } else {
- 5
- },
+ let result = async {
+ let probe = self
+ .runtime
+ .probe(
+ entry.connection.as_ref().unwrap(),
+ if speed {
+ settings.maximum_duration_seconds
+ } else {
+ 5
+ },
+ )
+ .await?;
+ let connection = probe.connection();
+ let measured = crate::diagnostics::measure(
+ &settings,
+ connection.proxy_url,
+ connection.certificate,
+ id.into(),
+ generation,
+ speed,
)
- .await?;
- let result = crate::diagnostics::measure(
- &settings,
- &probe.proxy,
- &probe.certificate,
- id.into(),
- generation,
- speed,
- )
+ .await;
+ probe.stop().await;
+ measured
+ }
.await;
- probe.stop().await;
match result {
Ok(observation) => {
if let Some(wait) = observation.retry_after_seconds {
@@ -383,19 +388,24 @@ impl Controller {
Ok(observation)
}
Err(error) => {
+ let observation = crate::diagnostics::Observation {
+ configuration_id: id.into(),
+ generation,
+ kind: if speed { "speed" } else { "ping" }.into(),
+ success: false,
+ elapsed_ms: 0,
+ bytes: 0,
+ bytes_per_second: None,
+ stop_reason: error.to_string(),
+ retry_after_seconds: None,
+ };
if !speed && Some(id) == selected.as_deref() {
- self.observation = Some(crate::diagnostics::Observation {
- configuration_id: id.into(),
- generation,
- kind: "ping".into(),
- success: false,
- elapsed_ms: 0,
- bytes: 0,
- bytes_per_second: None,
- stop_reason: error.to_string(),
- retry_after_seconds: None,
- });
+ self.observation = Some(observation.clone());
}
+ self.measurements.retain(|previous| {
+ previous.configuration_id != id || previous.kind != observation.kind
+ });
+ self.measurements.push(observation);
self.record(error.to_string());
Err(error)
}