@@ -47,8 +47,8 @@ use crate::r#async::stream::{
47
47
use crate :: r#async:: utils;
48
48
use crate :: r#async:: { MethodHandler , StreamHandler , TtrpcContext } ;
49
49
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 ) ;
52
52
53
53
pub struct Service {
54
54
pub methods : HashMap < String , Box < dyn MethodHandler + Send + Sync > > ,
@@ -202,7 +202,7 @@ impl Server {
202
202
) . await ;
203
203
}
204
204
Err ( e) => {
205
- error!( "{:?}" , e)
205
+ error!( "incoming conn fail {:?}" , e)
206
206
}
207
207
}
208
208
@@ -381,14 +381,17 @@ impl ReaderDelegate for ServerReader {
381
381
async fn handle_msg ( & self , msg : GenMessage ) {
382
382
let handler_shutdown_waiter = self . handler_shutdown . subscribe ( ) ;
383
383
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
+ }
392
395
}
393
396
394
397
async fn handle_err ( & self , header : MessageHeader , e : Error ) {
0 commit comments