LCOV - differential code coverage report
Current view: top level - libs/utils/src - nonblock.rs (source / functions) Coverage Total Hit CBC
Current: f6946e90941b557c917ac98cd5a7e9506d180f3e.info Lines: 100.0 % 8 8 8
Current Date: 2023-10-19 02:04:12 Functions: 100.0 % 1 1 1
Baseline: c8637f37369098875162f194f92736355783b050.info
Baseline Date: 2023-10-18 20:25:20

           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        1158 : pub fn set_nonblock(fd: RawFd) -> Result<(), std::io::Error> {
       6            1158 :     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            1158 :     let mut flags = unsafe { OFlag::from_bits_unchecked(bits) };
      12            1158 :     flags |= OFlag::O_NONBLOCK;
      13            1158 : 
      14            1158 :     fcntl(fd, F_SETFL(flags))?;
      15                 : 
      16            1158 :     Ok(())
      17            1158 : }
        

Generated by: LCOV version 2.1-beta