LCOV - differential code coverage report
Current view: top level - libs/utils/src - nonblock.rs (source / functions) Coverage Total Hit CBC
Current: cd44433dd675caa99df17a61b18949c8387e2242.info Lines: 100.0 % 8 8 8
Current Date: 2024-01-09 02:06:09 Functions: 100.0 % 1 1 1
Baseline: 66c52a629a0f4a503e193045e0df4c77139e344b.info
Baseline Date: 2024-01-08 15:34:46

           TLA  Line data    Source code
       1                 : use nix::fcntl::{fcntl, OFlag, F_GETFL, F_SETFL};
       2                 : use std::os::unix::io::RawFd;
       3                 : 
       4                 : /// Put a file descriptor into non-blocking mode
       5 CBC        1088 : pub fn set_nonblock(fd: RawFd) -> Result<(), std::io::Error> {
       6            1088 :     let bits = fcntl(fd, F_GETFL)?;
       7                 : 
       8                 :     // Safety: If F_GETFL returns some unknown bits, they should be valid
       9                 :     // for passing back to F_SETFL, too. If we left them out, the F_SETFL
      10                 :     // would effectively clear them, which is not what we want.
      11            1088 :     let mut flags = unsafe { OFlag::from_bits_unchecked(bits) };
      12            1088 :     flags |= OFlag::O_NONBLOCK;
      13            1088 : 
      14            1088 :     fcntl(fd, F_SETFL(flags))?;
      15                 : 
      16            1088 :     Ok(())
      17            1088 : }
        

Generated by: LCOV version 2.1-beta