Skip to main content

patch_seq_udp_close

Function patch_seq_udp_close 

Source
#[unsafe(no_mangle)]
pub unsafe extern "C" fn patch_seq_udp_close(stack: Stack) -> Stack
Expand description

Close a UDP socket and free its handle.

Stack effect: ( socket – Bool )

Returns true if the handle was open (the registry slot held a socket), false if it was already invalid (never allocated, or previously closed). Idempotent across redundant calls on the same id.

Concurrent I/O is safe: any strand mid-send_to / recv_from holds its own Arc<UdpSocket> clone, so closing the registry slot from another strand only drops the registry’s reference. The in-flight syscall completes; the OS-level close fires when the last Arc is dropped. The id is recycled to the free list as soon as close returns, regardless of any in-flight strand.

§Safety

Stack must have an Int (socket) on top.