1- use std:: { io, ops :: ControlFlow , pin :: Pin } ;
1+ use std:: { io, pin :: Pin , task :: Poll } ;
22
33use polling:: Event ;
44
@@ -30,7 +30,7 @@ impl<T: IoBufMut> OpCode for ReadAt<T> {
3030 }
3131 }
3232
33- fn on_event ( mut self : Pin < & mut Self > , event : & Event ) -> std :: io:: Result < ControlFlow < usize > > {
33+ fn on_event ( mut self : Pin < & mut Self > , event : & Event ) -> Poll < io:: Result < usize > > {
3434 debug_assert ! ( event. readable) ;
3535
3636 let fd = self . fd ;
@@ -66,7 +66,7 @@ impl<T: IoBuf> OpCode for WriteAt<T> {
6666 }
6767 }
6868
69- fn on_event ( self : Pin < & mut Self > , event : & Event ) -> std :: io:: Result < ControlFlow < usize > > {
69+ fn on_event ( self : Pin < & mut Self > , event : & Event ) -> Poll < io:: Result < usize > > {
7070 debug_assert ! ( event. writable) ;
7171
7272 let slice = self . buffer . as_slice ( ) ;
@@ -87,7 +87,7 @@ impl OpCode for Sync {
8787 Ok ( Decision :: Completed ( syscall ! ( fsync( self . fd) ) ? as _ ) )
8888 }
8989
90- fn on_event ( self : Pin < & mut Self > , _: & Event ) -> std :: io:: Result < ControlFlow < usize > > {
90+ fn on_event ( self : Pin < & mut Self > , _: & Event ) -> Poll < io:: Result < usize > > {
9191 unreachable ! ( "Sync operation should not be submitted to polling" )
9292 }
9393}
@@ -103,18 +103,16 @@ impl OpCode for Accept {
103103 )
104104 }
105105
106- fn on_event ( mut self : Pin < & mut Self > , event : & Event ) -> std :: io:: Result < ControlFlow < usize > > {
106+ fn on_event ( mut self : Pin < & mut Self > , event : & Event ) -> Poll < io:: Result < usize > > {
107107 debug_assert ! ( event. readable) ;
108108
109- match syscall ! ( accept(
110- self . fd,
111- & mut self . buffer as * mut _ as * mut _,
112- & mut self . addr_len
113- ) ) {
114- Ok ( fd) => Ok ( ControlFlow :: Break ( fd as _ ) ) ,
115- Err ( e) if e. raw_os_error ( ) == Some ( libc:: EINPROGRESS ) => Ok ( ControlFlow :: Continue ( ( ) ) ) ,
116- Err ( e) => Err ( e) ,
117- }
109+ syscall ! (
110+ break accept(
111+ self . fd,
112+ & mut self . buffer as * mut _ as * mut _,
113+ & mut self . addr_len
114+ )
115+ )
118116 }
119117}
120118
@@ -125,7 +123,7 @@ impl OpCode for Connect {
125123 )
126124 }
127125
128- fn on_event ( self : Pin < & mut Self > , event : & Event ) -> std :: io:: Result < ControlFlow < usize > > {
126+ fn on_event ( self : Pin < & mut Self > , event : & Event ) -> Poll < io:: Result < usize > > {
129127 debug_assert ! ( event. writable) ;
130128
131129 let mut err: libc:: c_int = 0 ;
@@ -139,11 +137,12 @@ impl OpCode for Connect {
139137 & mut err_len
140138 ) ) ?;
141139
142- if err == 0 {
143- Ok ( ControlFlow :: Break ( 0 ) )
140+ let res = if err == 0 {
141+ Ok ( 0 )
144142 } else {
145143 Err ( io:: Error :: from_raw_os_error ( err) )
146- }
144+ } ;
145+ Poll :: Ready ( res)
147146 }
148147}
149148
@@ -152,7 +151,7 @@ impl<T: AsIoSlicesMut + Unpin> OpCode for RecvImpl<T> {
152151 Ok ( Decision :: wait_readable ( self . fd ) )
153152 }
154153
155- fn on_event ( mut self : Pin < & mut Self > , event : & Event ) -> std :: io:: Result < ControlFlow < usize > > {
154+ fn on_event ( mut self : Pin < & mut Self > , event : & Event ) -> Poll < io:: Result < usize > > {
156155 debug_assert ! ( event. readable) ;
157156
158157 self . slices = unsafe { self . buffer . as_io_slices_mut ( ) } ;
@@ -165,7 +164,7 @@ impl<T: AsIoSlices + Unpin> OpCode for SendImpl<T> {
165164 Ok ( Decision :: wait_writable ( self . fd ) )
166165 }
167166
168- fn on_event ( mut self : Pin < & mut Self > , event : & Event ) -> std :: io:: Result < ControlFlow < usize > > {
167+ fn on_event ( mut self : Pin < & mut Self > , event : & Event ) -> Poll < io:: Result < usize > > {
169168 debug_assert ! ( event. writable) ;
170169
171170 self . slices = unsafe { self . buffer . as_io_slices ( ) } ;
@@ -179,7 +178,7 @@ impl<T: AsIoSlicesMut + Unpin> OpCode for RecvFromImpl<T> {
179178 syscall ! ( recvmsg( self . fd, & mut self . msg, 0 ) or wait_readable( self . fd) )
180179 }
181180
182- fn on_event ( mut self : Pin < & mut Self > , event : & Event ) -> std :: io:: Result < ControlFlow < usize > > {
181+ fn on_event ( mut self : Pin < & mut Self > , event : & Event ) -> Poll < io:: Result < usize > > {
183182 debug_assert ! ( event. readable) ;
184183
185184 syscall ! ( break recvmsg( self . fd, & mut self . msg, 0 ) )
@@ -192,7 +191,7 @@ impl<T: AsIoSlices + Unpin> OpCode for SendToImpl<T> {
192191 syscall ! ( sendmsg( self . fd, & self . msg, 0 ) or wait_writable( self . fd) )
193192 }
194193
195- fn on_event ( self : Pin < & mut Self > , event : & Event ) -> std :: io:: Result < ControlFlow < usize > > {
194+ fn on_event ( self : Pin < & mut Self > , event : & Event ) -> Poll < io:: Result < usize > > {
196195 debug_assert ! ( event. writable) ;
197196
198197 syscall ! ( break sendmsg( self . fd, & self . msg, 0 ) )
0 commit comments