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<_>>())
|
.collect::<Vec<_>>())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn from_fds(
|
fn from_fd_offset(fd_offset: usize) -> Result<Self, DupError> {
|
||||||
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| {
|
|
||||||
SD_LISTEN_FDS_START
|
SD_LISTEN_FDS_START
|
||||||
.checked_add(fd_offset as RawFd)
|
.checked_add(fd_offset as RawFd)
|
||||||
.map(|fd| {
|
.map(|fd| {
|
||||||
|
@ -253,7 +246,16 @@ impl FileDescriptor {
|
||||||
})
|
})
|
||||||
.expect("Already checked against overflow.")
|
.expect("Already checked against overflow.")
|
||||||
.map(Self::from_fd)
|
.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)
|
Ok(ret)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue