33//! The Linux kernel configuration option `CONFIG_USB_CONFIGFS_F_FS` must be enabled.
44
55use bytes:: { Bytes , BytesMut } ;
6- use nix:: poll:: { poll, PollFd , PollFlags } ;
6+ use nix:: poll:: { poll, PollFd , PollFlags , PollTimeout } ;
77use proc_mounts:: MountIter ;
88use std:: {
99 collections:: { hash_map:: Entry , HashMap , HashSet } ,
@@ -12,7 +12,7 @@ use std::{
1212 fs:: File ,
1313 hash:: Hash ,
1414 io:: { Error , ErrorKind , Read , Result , Write } ,
15- os:: fd:: { AsRawFd , RawFd } ,
15+ os:: fd:: { AsFd , AsRawFd , RawFd } ,
1616 path:: { Path , PathBuf } ,
1717 sync:: {
1818 atomic:: { AtomicBool , Ordering } ,
@@ -978,15 +978,14 @@ impl Custom {
978978 fn wait_event_sync ( & mut self , timeout : Option < Duration > ) -> Result < bool > {
979979 let ep0 = self . ep0 ( ) ?;
980980
981- let mut fds = [ PollFd :: new ( & ep0, PollFlags :: POLLIN ) ] ;
982- poll ( & mut fds, timeout. map ( |d| d. as_millis ( ) . try_into ( ) . unwrap ( ) ) . unwrap_or ( - 1 ) ) ?;
981+ let mut fds = [ PollFd :: new ( ep0. as_fd ( ) , PollFlags :: POLLIN ) ] ;
982+ poll ( & mut fds, timeout. map ( |d| d. as_millis ( ) . try_into ( ) . unwrap ( ) ) . unwrap_or ( PollTimeout :: NONE ) ) ?;
983983 Ok ( fds[ 0 ] . revents ( ) . map ( |e| e. contains ( PollFlags :: POLLIN ) ) . unwrap_or_default ( ) )
984984 }
985985
986986 /// Asynchronously wait for an event to be available.
987987 #[ cfg( feature = "tokio" ) ]
988988 pub async fn wait_event ( & mut self ) -> Result < ( ) > {
989- use std:: os:: fd:: AsFd ;
990989 use tokio:: io:: { unix:: AsyncFd , Interest } ;
991990
992991 let ep0 = self . ep0 ( ) ?;
0 commit comments