@@ -23,7 +23,6 @@ use std::os::windows::ffi::OsStrExt;
23
23
use std:: os:: windows:: fs:: OpenOptionsExt ;
24
24
use std:: os:: windows:: io:: { IntoRawHandle } ;
25
25
use std:: sync:: atomic:: { AtomicBool , Ordering } ;
26
- use std:: sync:: { Arc } ;
27
26
use std:: { io} ;
28
27
29
28
use windows_sys:: Win32 :: Foundation :: { CloseHandle , ERROR_IO_PENDING , ERROR_PIPE_CONNECTED , INVALID_HANDLE_VALUE } ;
@@ -75,14 +74,7 @@ impl PipeListener {
75
74
// accept returns:
76
75
// - Ok(Some(PipeConnection)) if a new connection is established
77
76
// - Err(io::Error) if there is an error and listener loop should be shutdown
78
- pub ( crate ) fn accept ( & self , quit_flag : & Arc < AtomicBool > ) -> std:: result:: Result < Option < PipeConnection > , io:: Error > {
79
- if quit_flag. load ( Ordering :: SeqCst ) {
80
- return Err ( io:: Error :: new (
81
- io:: ErrorKind :: Other ,
82
- "listener shutdown for quit flag" ,
83
- ) ) ;
84
- }
85
-
77
+ pub ( crate ) fn accept ( & self ) -> std:: result:: Result < Option < PipeConnection > , io:: Error > {
86
78
// Create a new pipe instance for every new client
87
79
let instance = self . new_instance ( ) ?;
88
80
let np = match PipeConnection :: new ( instance) {
@@ -376,6 +368,7 @@ fn handle_windows_error(e: io::Error) -> Error {
376
368
#[ cfg( test) ]
377
369
mod test {
378
370
use super :: * ;
371
+ use std:: sync:: Arc ;
379
372
use windows_sys:: Win32 :: Foundation :: ERROR_FILE_NOT_FOUND ;
380
373
381
374
#[ test]
@@ -398,8 +391,7 @@ mod test {
398
391
399
392
let listener_server = listener. clone ( ) ;
400
393
let thread = std:: thread:: spawn ( move || {
401
- let quit_flag = Arc :: new ( AtomicBool :: new ( false ) ) ;
402
- match listener_server. accept ( & quit_flag) {
394
+ match listener_server. accept ( ) {
403
395
Ok ( Some ( _) ) => {
404
396
// pipe is working
405
397
}
@@ -422,8 +414,7 @@ mod test {
422
414
423
415
let listener_server = listener. clone ( ) ;
424
416
let thread = std:: thread:: spawn ( move || {
425
- let quit_flag = Arc :: new ( AtomicBool :: new ( false ) ) ;
426
- match listener_server. accept ( & quit_flag) {
417
+ match listener_server. accept ( ) {
427
418
Ok ( _) => {
428
419
panic ! ( "should not get pipe on close" )
429
420
}
0 commit comments