fn hdl_close(hdl: u32) {
        if hdl == INVALID_HANDLE {
            return;
        }
        let wakeup = match HANDLES.lock().remove(hdl as usize) {
            FidlHandle::LeftChannel(cs, peer) => {
                let st = &mut *cs.lock();
                let wakeup = match st {
                    ChannelState::Closed => false,
                    ChannelState::Open(_, st) => st.need_read,
                };
                *st = ChannelState::Closed;
                if wakeup {
                    peer
                } else {
                    INVALID_HANDLE
                }
            }
            FidlHandle::RightChannel(cs, peer) => {
                let st = &mut *cs.lock();
                let wakeup = match st {
                    ChannelState::Closed => false,
                    ChannelState::Open(st, _) => st.need_read,
                };
                *st = ChannelState::Closed;
                if wakeup {
                    peer
                } else {
                    INVALID_HANDLE
                }
            }
            FidlHandle::LeftStreamSocket(cs, peer) => {
                let st = &mut *cs.lock();
                let wakeup = match st {
                    StreamSocketState { open: false, .. } => false,
                    StreamSocketState { right: st, .. } => st.need_read,
                };
                st.open = false;
                if wakeup {
                    peer
                } else {
                    INVALID_HANDLE
                }
            }
            FidlHandle::RightStreamSocket(cs, peer) => {
                let st = &mut *cs.lock();
                let wakeup = match st {
                    StreamSocketState { open: false, .. } => false,
                    StreamSocketState { left: st, .. } => st.need_read,
                };
                st.open = false;
                if wakeup {
                    peer
                } else {
                    INVALID_HANDLE
                }
            }
            FidlHandle::LeftDatagramSocket(cs, peer) => {
                let st = &mut *cs.lock();
                let wakeup = match st {
                    DatagramSocketState { open: false, .. } => false,
                    DatagramSocketState { right: st, .. } => st.need_read,
                };
                st.open = false;
                if wakeup {
                    peer
                } else {
                    INVALID_HANDLE
                }
            }
            FidlHandle::RightDatagramSocket(cs, peer) => {
                let st = &mut *cs.lock();
                let wakeup = match st {
                    DatagramSocketState { open: false, .. } => false,
                    DatagramSocketState { left: st, .. } => st.need_read,
                };
                st.open = false;
                if wakeup {
                    peer
                } else {
                    INVALID_HANDLE
                }
            }
        };
        if wakeup != INVALID_HANDLE {
            hdl_awaken(wakeup);
        }
    }
/// Close the handle: no action if hdl==INVALID_HANDLE
Close the handle: no action if hdl==INVALID_HANDLE
Close the handle : no action if hdl == INVALID_HANDLE
fn hdl_close(hdl: u32) {
        if hdl == INVALID_HANDLE {
            return;
        }
        let wakeup = match HANDLES.lock().remove(hdl as usize) {
            FidlHandle::LeftChannel(cs, peer) => {
                let st = &mut *cs.lock();
                let wakeup = match st {
                    ChannelState::Closed => false,
                    ChannelState::Open(_, st) => st.need_read,
                };
                *st = ChannelState::Closed;
                if wakeup {
                    peer
                } else {
                    INVALID_HANDLE
                }
            }
            FidlHandle::RightChannel(cs, peer) => {
                let st = &mut *cs.lock();
                let wakeup = match st {
                    ChannelState::Closed => false,
                    ChannelState::Open(st, _) => st.need_read,
                };
                *st = ChannelState::Closed;
                if wakeup {
                    peer
                } else {
                    INVALID_HANDLE
                }
            }
            FidlHandle::LeftStreamSocket(cs, peer) => {
                let st = &mut *cs.lock();
                let wakeup = match st {
                    StreamSocketState { open: false, .. } => false,
                    StreamSocketState { right: st, .. } => st.need_read,
                };
                st.open = false;
                if wakeup {
                    peer
                } else {
                    INVALID_HANDLE
                }
            }
            FidlHandle::RightStreamSocket(cs, peer) => {
                let st = &mut *cs.lock();
                let wakeup = match st {
                    StreamSocketState { open: false, .. } => false,
                    StreamSocketState { left: st, .. } => st.need_read,
                };
                st.open = false;
                if wakeup {
                    peer
                } else {
                    INVALID_HANDLE
                }
            }
            FidlHandle::LeftDatagramSocket(cs, peer) => {
                let st = &mut *cs.lock();
                let wakeup = match st {
                    DatagramSocketState { open: false, .. } => false,
                    DatagramSocketState { right: st, .. } => st.need_read,
                };
                st.open = false;
                if wakeup {
                    peer
                } else {
                    INVALID_HANDLE
                }
            }
            FidlHandle::RightDatagramSocket(cs, peer) => {
                let st = &mut *cs.lock();
                let wakeup = match st {
                    DatagramSocketState { open: false, .. } => false,
                    DatagramSocketState { left: st, .. } => st.need_read,
                };
                st.open = false;
                if wakeup {
                    peer
                } else {
                    INVALID_HANDLE
                }
            }
        };
        if wakeup != INVALID_HANDLE {
            hdl_awaken(wakeup);
        }
    }
fn hdl_close ( hdl : u32 ) { if hdl == INVALID_HANDLE { return ; } let wakeup = match HANDLES . lock ( ) . remove ( hdl as usize ) { FidlHandle :: LeftChannel ( cs , peer ) => { let st = & mut * cs . lock ( ) ; let wakeup = match st { ChannelState :: Closed => false , ChannelState :: Open ( _ , st ) => st . need_read , } ; * st = ChannelState :: Closed ; if wakeup { peer } else { INVALID_HANDLE } } FidlHandle :: RightChannel ( cs , peer ) => { let st = & mut * cs . lock ( ) ; let wakeup = match st { ChannelState :: Closed => false , ChannelState :: Open ( st , _ ) => st . need_read , } ; * st = ChannelState :: Closed ; if wakeup { peer } else { INVALID_HANDLE } } FidlHandle :: LeftStreamSocket ( cs , peer ) => { let st = & mut * cs . lock ( ) ; let wakeup = match st { StreamSocketState { open : false , .. } => false , StreamSocketState { right : st , .. } => st . need_read , } ; st . open = false ; if wakeup { peer } else { INVALID_HANDLE } } FidlHandle :: RightStreamSocket ( cs , peer ) => { let st = & mut * cs . lock ( ) ; let wakeup = match st { StreamSocketState { open : false , .. } => false , StreamSocketState { left : st , .. } => st . need_read , } ; st . open = false ; if wakeup { peer } else { INVALID_HANDLE } } FidlHandle :: LeftDatagramSocket ( cs , peer ) => { let st = & mut * cs . lock ( ) ; let wakeup = match st { DatagramSocketState { open : false , .. } => false , DatagramSocketState { right : st , .. } => st . need_read , } ; st . open = false ; if wakeup { peer } else { INVALID_HANDLE } } FidlHandle :: RightDatagramSocket ( cs , peer ) => { let st = & mut * cs . lock ( ) ; let wakeup = match st { DatagramSocketState { open : false , .. } => false , DatagramSocketState { left : st , .. } => st . need_read , } ; st . open = false ; if wakeup { peer } else { INVALID_HANDLE } } } ; if wakeup != INVALID_HANDLE { hdl_awaken ( wakeup ) ; } }
Close the handle: no action if hdl==INVALID_HANDLE
Close the handle : no action if hdl == INVALID_HANDLE
hdl
u32
hdl
u32