From: Ian Jackson Date: Tue, 3 Aug 2021 23:50:04 +0000 (+0100) Subject: Revert "prep for moving lock into reporter" X-Git-Tag: hippotat/1.0.0~360 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=25186f3428ca0e217dc772af6197adc1380b5d98;p=hippotat.git Revert "prep for moving lock into reporter" Actually, keep it out there This reverts commit 9c229f46f9d6c4b5b86c701cc4e7de61c603d1af. Signed-off-by: Ian Jackson --- diff --git a/src/bin/client.rs b/src/bin/client.rs index dda2c7c..95d4730 100644 --- a/src/bin/client.rs +++ b/src/bin/client.rs @@ -16,7 +16,7 @@ trait HCC: hyper::client::connect::Connect + Clone + Send + Sync + 'static { } struct ClientContext<'c,C> { ic: &'c InstanceConfig, hclient: &'c Arc>, - reporter: &'c Reporter<'c>, + reporter: &'c parking_lot::Mutex>, } #[throws(AE)] @@ -135,7 +135,7 @@ fn submit_request<'r, 'c:'r, C:HCC>( Ok::<_,AE>(resp) }).await? }.await; - let r = c.reporter.report(Some(req_num), r); + let r = c.reporter.lock().report(Some(req_num), r); if r.is_none() { tokio::time::sleep(c.ic.http_retry).await; @@ -155,7 +155,7 @@ async fn run_client( { debug!("{}: config: {:?}", &ic, &ic); - let reporter = Reporter::new(&ic); + let reporter = parking_lot::Mutex::new(Reporter::new(&ic)); let c = ClientContext { reporter: &reporter, @@ -239,7 +239,7 @@ async fn run_client( }, _ = async { }, - if reporter.report(None, { + if reporter.lock().report(None, { if rx_queue.remaining() < ic.max_batch_down.sat() * 3 /* xxx */ { // xxx make this separate option ? docs say server only Ok(()) diff --git a/src/reporter.rs b/src/reporter.rs index 17df050..04a8e49 100644 --- a/src/reporter.rs +++ b/src/reporter.rs @@ -13,7 +13,7 @@ impl<'r> Reporter<'r> { ic } } - pub fn report(&self, req_num: Option, r: Result) + pub fn report(&mut self, req_num: Option, r: Result) -> Option { match r { Ok(t) => {