@@ -60,7 +60,7 @@ impl<'de> Deserialize<'de> for NoParams {
60
60
}
61
61
62
62
pub trait Response {
63
- fn send < O : Output > ( & self , id : usize , out : O ) ;
63
+ fn send < O : Output > ( & self , id : usize , out : O ) ;
64
64
}
65
65
66
66
impl Response for NoResponse {
@@ -311,7 +311,7 @@ impl<O: Output> LsService<O> {
311
311
} ;
312
312
313
313
let method = method. as_str ( ) . ok_or_else ( || jsonrpc:: Error :: invalid_request ( ) ) ?. to_owned ( ) ;
314
-
314
+
315
315
// Representing internally a missing parameter as Null instead of None,
316
316
// (Null being unused value of param by the JSON-RPC 2.0 spec)
317
317
// to unify the type handling – now the parameter type implements Deserialize.
@@ -402,17 +402,6 @@ impl<O: Output> LsService<O> {
402
402
403
403
trace ! ( "Read message `{}`" , msg_string) ;
404
404
405
- {
406
- let shut_down = self . state . shut_down . load ( Ordering :: SeqCst ) ;
407
- if shut_down {
408
- if msg_string != ExitNotification :: METHOD {
409
- // We're shutdown, ignore any messages other than 'exit'. This is not actually
410
- // in the spec, I'm not sure we should do this, but it kinda makes sense.
411
- return ServerStateChange :: Continue ;
412
- }
413
- }
414
- }
415
-
416
405
let raw_message = match self . parse_message ( & msg_string) {
417
406
Ok ( Some ( rm) ) => rm,
418
407
Ok ( None ) => return ServerStateChange :: Continue ,
@@ -422,9 +411,20 @@ impl<O: Output> LsService<O> {
422
411
return ServerStateChange :: Break ;
423
412
}
424
413
} ;
425
-
414
+
426
415
trace ! ( "Parsed message `{:?}`" , raw_message) ;
427
416
417
+ // If we're in shutdown mode, ignore any messages other than 'exit'.
418
+ // This is not actually in the spec, I'm not sure we should do this,
419
+ // but it kinda makes sense.
420
+ {
421
+ let shut_down = self . state . shut_down . load ( Ordering :: SeqCst ) ;
422
+ if shut_down && raw_message. method != ExitNotification :: METHOD {
423
+ trace ! ( "In shutdown mode, ignoring {:?}!" , raw_message) ;
424
+ return ServerStateChange :: Continue ;
425
+ }
426
+ }
427
+
428
428
if let Err ( e) = self . dispatch_message ( & raw_message) {
429
429
debug ! ( "dispatch error, {:?}" , e) ;
430
430
self . output . failure ( raw_message. id . unwrap_or ( Id :: Null ) , e) ;
0 commit comments