@@ -47,8 +47,8 @@ use crate::r#async::stream::{
4747use crate :: r#async:: utils;
4848use crate :: r#async:: { MethodHandler , StreamHandler , TtrpcContext } ;
4949
50- const DEFAULT_CONN_SHUTDOWN_TIMEOUT : Duration = Duration :: from_millis ( 5000 ) ;
51- const DEFAULT_SERVER_SHUTDOWN_TIMEOUT : Duration = Duration :: from_millis ( 10000 ) ;
50+ const DEFAULT_CONN_SHUTDOWN_TIMEOUT : Duration = Duration :: from_secs ( 5 ) ;
51+ const DEFAULT_SERVER_SHUTDOWN_TIMEOUT : Duration = Duration :: from_secs ( 10 ) ;
5252
5353pub struct Service {
5454 pub methods : HashMap < String , Box < dyn MethodHandler + Send + Sync > > ,
@@ -202,7 +202,7 @@ impl Server {
202202 ) . await ;
203203 }
204204 Err ( e) => {
205- error!( "{:?}" , e)
205+ error!( "incoming conn fail {:?}" , e)
206206 }
207207 }
208208
@@ -381,14 +381,17 @@ impl ReaderDelegate for ServerReader {
381381 async fn handle_msg ( & self , msg : GenMessage ) {
382382 let handler_shutdown_waiter = self . handler_shutdown . subscribe ( ) ;
383383 let context = self . context ( ) ;
384- let ( wait_tx, wait_rx) = tokio:: sync:: oneshot:: channel :: < ( ) > ( ) ;
385- spawn ( async move {
386- select ! {
387- _ = context. handle_msg( msg, wait_tx) => { }
388- _ = handler_shutdown_waiter. wait_shutdown( ) => { }
389- }
390- } ) ;
391- wait_rx. await . unwrap_or_default ( ) ;
384+ //Check if it is already shutdown no need select wait
385+ if !handler_shutdown_waiter. is_shutdown ( ) {
386+ let ( wait_tx, wait_rx) = tokio:: sync:: oneshot:: channel :: < ( ) > ( ) ;
387+ spawn ( async move {
388+ select ! {
389+ _ = context. handle_msg( msg, wait_tx) => { }
390+ _ = handler_shutdown_waiter. wait_shutdown( ) => { }
391+ }
392+ } ) ;
393+ wait_rx. await . unwrap_or_default ( ) ;
394+ }
392395 }
393396
394397 async fn handle_err ( & self , header : MessageHeader , e : Error ) {
0 commit comments