Async: Move ownership of file descriptors out of poll_reactor

This commit is contained in:
Tony Wasserka committed 2025-02-06 22:35:29 +01:00
1 parent 6e9d5f00de
commit 43dcc84c07
5 files changed
+94 -60

No files matched your search

+9 -2
View File
@@ -210,14 +210,21 @@ bool InitializeServerSocket(bool abstract) {
}
int FD = Socket->FD;
Reactor.callbacks[FD] = [Socket = std::move(Socket).value()](fasio::error ec) mutable {
Reactor.bind_handler(
pollfd {
.fd = FD,
.events = POLLIN | POLLPRI | POLLRDHUP,
.revents = 0,
},
[Socket = std::move(Socket).value()](fasio::error ec) mutable {
if (ec != fasio::error::success) {
close(Socket.FD);
return fasio::post_callback::drop;
}
HandleSocketData(Socket);
// Wait for next data
return fasio::post_callback::repeat;
};
});
// Wait for next connection
return fasio::post_callback::repeat;