File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ extern crate mio;
2
2
extern crate futures;
3
3
4
4
use std:: collections:: HashMap ;
5
- use std:: io:: { self , Read , Write } ;
5
+ use std:: io:: { self , ErrorKind , Read , Write } ;
6
6
use std:: net:: SocketAddr ;
7
7
use std:: panic;
8
8
use std:: slice;
@@ -231,7 +231,20 @@ impl Loop {
231
231
232
232
fn _await ( & mut self , done : & mut FnMut ( ) -> bool ) {
233
233
while !done ( ) {
234
- let amt = self . io . poll ( None ) . unwrap ( ) ;
234
+ let amt;
235
+ // On Linux, Poll::poll is epoll_wait, which may return EINTR if a
236
+ // ptracer attaches. This retry loop prevents crashing when
237
+ // attaching strace, or similar.
238
+ loop {
239
+ match self . io . poll ( None ) {
240
+ Ok ( a) => {
241
+ amt = a;
242
+ break ;
243
+ }
244
+ Err ( ref e) if e. kind ( ) == ErrorKind :: Interrupted => { }
245
+ err@Err ( _) => { err. unwrap ( ) ; } ,
246
+ }
247
+ }
235
248
236
249
for i in 0 ..amt {
237
250
let event = self . io . events ( ) . get ( i) . unwrap ( ) ;
You can’t perform that action at this time.
0 commit comments