File tree Expand file tree Collapse file tree 2 files changed +23
-20
lines changed Expand file tree Collapse file tree 2 files changed +23
-20
lines changed Original file line number Diff line number Diff line change @@ -381,21 +381,6 @@ impl Socket {
381381 sys:: set_nonblocking ( self . as_raw ( ) , nonblocking)
382382 }
383383
384- /// Sets the busy polling timeout in microseconds for blocking socket operations.
385- ///
386- /// When there is no data available, the socket will busy poll for the specified
387- /// duration (in microseconds) before falling back to blocking behavior.
388- ///
389- /// # Notes
390- ///
391- /// - Requires `CAP_NET_ADMIN` capability to increase the value
392- /// - Default value is controlled by `/proc/sys/net/core/busy_read`
393- /// - Available since Linux 3.11
394- #[ cfg( target_os = "linux" ) ]
395- pub fn set_busy_poll ( & self , busy_poll : u16 ) -> io:: Result < ( ) > {
396- sys:: set_busy_poll ( self . as_raw ( ) , busy_poll)
397- }
398-
399384 /// Shuts down the read, write, or both halves of this connection.
400385 ///
401386 /// This function will cause all pending and future I/O on the specified
Original file line number Diff line number Diff line change @@ -993,11 +993,6 @@ pub(crate) fn set_nonblocking(fd: RawSocket, nonblocking: bool) -> io::Result<()
993993 }
994994}
995995
996- #[ cfg( target_os = "linux" ) ]
997- pub ( crate ) fn set_busy_poll ( fd : RawSocket , busy_poll : u16 ) -> io:: Result < ( ) > {
998- unsafe { setsockopt ( fd, libc:: SOL_SOCKET , libc:: SO_BUSY_POLL , busy_poll as c_int ) }
999- }
1000-
1001996pub ( crate ) fn shutdown ( fd : RawSocket , how : Shutdown ) -> io:: Result < ( ) > {
1002997 let how = match how {
1003998 Shutdown :: Write => libc:: SHUT_WR ,
@@ -2818,6 +2813,29 @@ impl crate::Socket {
28182813 )
28192814 }
28202815 }
2816+
2817+ /// Get the value for the `SO_BUSY_POLL` option on this socket.
2818+ ///
2819+ /// On Linux this function requires the `CAP_NET_ADMIN` capability.
2820+ #[ cfg( all( feature = "all" , target_os = "linux" ) ) ]
2821+ pub fn busy_poll ( & self ) -> io:: Result < u32 > {
2822+ unsafe { getsockopt ( self . as_raw ( ) , libc:: SOL_SOCKET , libc:: SO_BUSY_POLL ) }
2823+ }
2824+
2825+ /// Set the value for the `SO_BUSY_POLL` option on this socket.
2826+ ///
2827+ /// On Linux this function requires the `CAP_NET_ADMIN` capability.
2828+ #[ cfg( all( feature = "all" , target_os = "linux" ) ) ]
2829+ pub fn set_busy_poll ( & self , busy_poll : u32 ) -> io:: Result < ( ) > {
2830+ unsafe {
2831+ setsockopt (
2832+ self . as_raw ( ) ,
2833+ libc:: SOL_SOCKET ,
2834+ libc:: SO_BUSY_POLL ,
2835+ busy_poll as c_int ,
2836+ )
2837+ }
2838+ }
28212839}
28222840
28232841/// Berkeley Packet Filter (BPF).
You can’t perform that action at this time.
0 commit comments