chiark / gitweb /
Revert "prep for moving lock into reporter"
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 3 Aug 2021 23:50:04 +0000 (00:50 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 3 Aug 2021 23:55:19 +0000 (00:55 +0100)
Actually, keep it out there

This reverts commit 9c229f46f9d6c4b5b86c701cc4e7de61c603d1af.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/bin/client.rs
src/reporter.rs

index dda2c7caaeb16a4554168be1f87f0711c10c4204..95d473011bf638e0a13456227b37e52dda337039 100644 (file)
@@ -16,7 +16,7 @@ trait HCC: hyper::client::connect::Connect + Clone + Send + Sync + 'static { }
 struct ClientContext<'c,C> {
   ic: &'c InstanceConfig,
   hclient: &'c Arc<hyper::Client<C>>,
-  reporter: &'c Reporter<'c>,
+  reporter: &'c parking_lot::Mutex<Reporter<'c>>,
 }
 
 #[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<C:HCC>(
 {
   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<C:HCC>(
         },
 
         _ = 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(())
index 17df050055454adee0411dddf4926b4efa71a16a..04a8e49e2bd1b4df5e23df2b1b555b0a766df706 100644 (file)
@@ -13,7 +13,7 @@ impl<'r> Reporter<'r> {
     ic
   } }
   
-  pub fn report<T>(&self, req_num: Option<ReqNum>, r: Result<T,AE>)
+  pub fn report<T>(&mut self, req_num: Option<ReqNum>, r: Result<T,AE>)
                    -> Option<T> {
     match r {
       Ok(t) => {