more reasonable tracking of open FDs

This commit is contained in:
Qyriad 2026-03-19 19:45:09 +01:00
parent 398fccc5d0
commit aee8dcb31a
6 changed files with 163 additions and 77 deletions

38
src/daemon_tokfd.rs Normal file
View file

@ -0,0 +1,38 @@
use std::os::fd::RawFd;
use iddqd::BiHashItem;
use mio::Token;
#[derive(Copy)]
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct TokenFd {
pub token: Token,
pub fd: RawFd,
}
impl BiHashItem for TokenFd {
type K1<'a> = Token;
type K2<'a> = RawFd;
fn key1(&self) -> Token {
self.token
}
fn key2(&self) -> RawFd {
self.fd
}
iddqd::bi_upcast!();
}
impl From<TokenFd> for (Token, RawFd) {
fn from(TokenFd { token, fd }: TokenFd) -> (Token, RawFd) {
(token, fd)
}
}
impl From<(Token, RawFd)> for TokenFd {
fn from((token, fd): (Token, RawFd)) -> TokenFd {
TokenFd { token, fd }
}
}