File tree Expand file tree Collapse file tree 1 file changed +13
-6
lines changed
compio-driver/src/iocp/cp Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,10 @@ impl GlobalPort {
3838 receiver
3939 }
4040
41+ pub fn deregister ( & self , driver : usize ) {
42+ self . drivers . remove ( & driver) ;
43+ }
44+
4145 pub fn attach ( & self , fd : RawFd ) -> io:: Result < ( ) > {
4246 self . port . attach ( fd)
4347 }
@@ -51,12 +55,9 @@ impl GlobalPort {
5155 }
5256
5357 pub fn push ( & self , driver : usize , entry : Entry ) {
54- self . drivers
55- . get ( & driver)
56- . expect ( "driver should register first" )
57- . value ( )
58- . send ( entry)
59- . ok ( ) ; // It's OK if the driver has been dropped.
58+ if let Some ( e) = self . drivers . get ( & driver) {
59+ e. value ( ) . send ( entry) . ok ( ) ; // It's OK if the driver has been dropped.
60+ }
6061 }
6162}
6263
@@ -146,6 +147,12 @@ impl Port {
146147 }
147148}
148149
150+ impl Drop for Port {
151+ fn drop ( & mut self ) {
152+ self . port . deregister ( self . id ) ;
153+ }
154+ }
155+
149156pub struct PortHandle {
150157 port : & ' static GlobalPort ,
151158}
You can’t perform that action at this time.
0 commit comments