Explorar o código

fix: improve logs

Yujia Qiao %!s(int64=4) %!d(string=hai) anos
pai
achega
3430845749
Modificáronse 2 ficheiros con 10 adicións e 4 borrados
  1. 2 1
      src/client.rs
  2. 8 3
      src/server.rs

+ 2 - 1
src/client.rs

@@ -165,6 +165,7 @@ async fn do_data_channel_handshake<T: Transport>(
         ..Default::default()
     };
 
+    // FIXME: Respect control channel shutdown here
     // Connect to remote_addr
     let mut conn: T::Stream = backoff::future::retry_notify(
         backoff,
@@ -447,12 +448,12 @@ impl<T: 'static + Transport> ControlChannel<T> {
                     }
                 },
                 _ = &mut self.shutdown_rx => {
-                    info!( "Control channel shutting down...");
                     break;
                 }
             }
         }
 
+        info!("Control channel shutdown");
         Ok(())
     }
 }

+ 8 - 3
src/server.rs

@@ -187,6 +187,8 @@ impl<'a, T: 'static + Transport> Server<'a, T> {
             }
         }
 
+        info!("Shutdown");
+
         Ok(())
     }
 
@@ -468,7 +470,7 @@ impl<T: Transport> ControlChannel<T> {
             }
         }
 
-        info!("Control channel shuting down");
+        info!("Control channel shutdown");
 
         Ok(())
     }
@@ -527,10 +529,9 @@ fn tcp_listen_and_send(
                         }
                         Ok((incoming, addr)) => {
                             // For every visitor, request to create a data channel
-                            if let Err(e) = data_ch_req_tx.send(true).with_context(|| "Failed to send data chan create request") {
+                            if data_ch_req_tx.send(true).with_context(|| "Failed to send data chan create request").is_err() {
                                 // An error indicates the control channel is broken
                                 // So break the loop
-                                error!("{:?}", e);
                                 break;
                             }
 
@@ -548,6 +549,8 @@ fn tcp_listen_and_send(
                 }
             }
         }
+
+        info!("TCPListener shutdown");
     }.instrument(Span::current()));
 
     rx
@@ -573,6 +576,8 @@ async fn run_tcp_connection_pool<T: Transport>(
             break;
         }
     }
+
+    info!("Shutdown");
     Ok(())
 }