listen: Make one of the closure into a function
This make it a bit easier to debug any problems with it.
This commit is contained in:
parent
907008df66
commit
f61df0da1b
|
@ -236,14 +236,7 @@ impl FileDescriptor {
|
|||
.collect::<Vec<_>>())
|
||||
}
|
||||
|
||||
fn from_fds(
|
||||
num_fds: usize,
|
||||
) -> Result<impl IntoIterator<Item = Result<Self, DupError>>, GetFdsError> {
|
||||
if SD_LISTEN_FDS_START.checked_add(num_fds as RawFd).is_none() {
|
||||
return Err(GetFdsError::TooManyFDs(num_fds));
|
||||
}
|
||||
|
||||
let ret = (0..num_fds).map(|fd_offset| {
|
||||
fn from_fd_offset(fd_offset: usize) -> Result<Self, DupError> {
|
||||
SD_LISTEN_FDS_START
|
||||
.checked_add(fd_offset as RawFd)
|
||||
.map(|fd| {
|
||||
|
@ -253,7 +246,16 @@ impl FileDescriptor {
|
|||
})
|
||||
.expect("Already checked against overflow.")
|
||||
.map(Self::from_fd)
|
||||
});
|
||||
}
|
||||
|
||||
fn from_fds(
|
||||
num_fds: usize,
|
||||
) -> Result<impl IntoIterator<Item = Result<Self, DupError>>, GetFdsError> {
|
||||
if SD_LISTEN_FDS_START.checked_add(num_fds as RawFd).is_none() {
|
||||
return Err(GetFdsError::TooManyFDs(num_fds));
|
||||
}
|
||||
|
||||
let ret = (0..num_fds).map(Self::from_fd_offset);
|
||||
Ok(ret)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue