@@ -207,6 +207,7 @@ pub use self::kqueue::Waker;
207207 target_os = "redox" ,
208208) ) ]
209209mod pipe {
210+ use crate :: unix:: pipe:: new as new_pipe;
210211 use std:: fs:: File ;
211212 use std:: io:: { self , Read , Write } ;
212213 use std:: os:: unix:: io:: { AsRawFd , FromRawFd , RawFd } ;
@@ -223,9 +224,9 @@ mod pipe {
223224
224225 impl WakerInternal {
225226 pub fn new ( ) -> io:: Result < WakerInternal > {
226- let ( receiver , sender ) = Self :: pipe2 ( ) ?;
227- let receiver = unsafe { File :: from_raw_fd ( receiver ) } ;
228- let sender = unsafe { File :: from_raw_fd ( sender ) } ;
227+ let ( sender , receiver ) = new_pipe ( ) ?;
228+ let sender = unsafe { File :: from_raw_fd ( sender . as_raw_fd ( ) ) } ;
229+ let receiver = unsafe { File :: from_raw_fd ( receiver . as_raw_fd ( ) ) } ;
229230 Ok ( WakerInternal { sender, receiver } )
230231 }
231232
@@ -265,32 +266,6 @@ mod pipe {
265266 }
266267 }
267268 }
268-
269- #[ cfg( target_os = "aix" ) ]
270- fn pipe2 ( ) -> io:: Result < ( RawFd , RawFd ) > {
271- let mut fds = [ -1 ; 2 ] ;
272- syscall ! ( pipe( fds. as_mut_ptr( ) ) ) ?;
273- unsafe {
274- if libc:: fcntl ( fds[ 0 ] , libc:: F_SETFL , libc:: O_NONBLOCK ) != 0
275- || libc:: fcntl ( fds[ 0 ] , libc:: F_SETFD , libc:: O_CLOEXEC ) != 0
276- || libc:: fcntl ( fds[ 1 ] , libc:: F_SETFL , libc:: O_NONBLOCK ) != 0
277- || libc:: fcntl ( fds[ 1 ] , libc:: F_SETFD , libc:: O_CLOEXEC ) != 0
278- {
279- let err = io:: Error :: last_os_error ( ) ;
280- let _ = libc:: close ( fds[ 0 ] ) ;
281- let _ = libc:: close ( fds[ 1 ] ) ;
282- return Err ( err) ;
283- }
284- }
285- Ok ( ( fds[ 0 ] , fds[ 1 ] ) )
286- }
287-
288- #[ cfg( not( target_os = "aix" ) ) ]
289- fn pipe2 ( ) -> io:: Result < ( RawFd , RawFd ) > {
290- let mut fds = [ -1 ; 2 ] ;
291- syscall ! ( pipe2( fds. as_mut_ptr( ) , libc:: O_NONBLOCK | libc:: O_CLOEXEC ) ) ?;
292- Ok ( ( fds[ 0 ] , fds[ 1 ] ) )
293- }
294269 }
295270
296271 impl AsRawFd for WakerInternal {
0 commit comments