chiark / gitweb /
sort out error handling for server rx slip frames
[hippotat.git] / src / bin / client.rs
index e89eeade2c8f67a0a73753be4f9084f639c61855..cfb632e8ce359ed2d89d643854e52aa2c0258fe2 100644 (file)
@@ -230,11 +230,11 @@ async fn run_client<C:HCC>(
           //eprintln!("data={:?}", DumpHex(&data));
 
           match check1(Slip2Mime, ic.mtu, &data, |header| {
-            let addr = ip_packet_addr::<false>(header)?;
-            if addr != ic.link.client.0 { throw!(PE::Src(addr)) }
+            let saddr = ip_packet_addr::<false>(header)?;
+            if saddr != ic.link.client.0 { throw!(PE::Src(saddr)) }
             Ok(())
           }) {
-            Ok(data) => tx_queue.push_back(TxQueued {
+            Ok((data, ())) => tx_queue.push_back(TxQueued {
               data,
               expires: Instant::now() + ic.max_queue_time
             }),
@@ -282,16 +282,20 @@ async fn run_client<C:HCC>(
               let addr = ip_packet_addr::<true>(header)?;
               if addr != ic.link.client.0 { throw!(PE::Dst(addr)) }
               Ok(())
-            }, |o| rx_queue.push(o),
-               |e| error!("{} #{}: rx discarding: {}", &ic, req_num, e))
+            },
+            |(o,())| Ok({ rx_queue.push(o); }),
+            |e| Ok::<_,SlipFramesError<Void>>( {
+              error!("{} #{}: rx discarding: {}", &ic, req_num, e);
+            }))
             {
               Ok(()) => reporter.lock().success(),
-              Err(ErrorOnlyBad) => {
+              Err(SlipFramesError::ErrorOnlyBad) => {
                 reqs.push(Box::pin(async {
                   tokio::time::sleep(ic.http_retry).await;
                   None
                 }));
               },
+              Err(SlipFramesError::Other(v)) => unreachable!(v),
             }
           }
         },