Use EventFD (one fd on Linux) in FutureConnection instead of WakeupFd

This commit is contained in:
Raúl Marín
2026-07-08 15:58:35 +02:00
parent 8c1b8555ad
commit 0c9cfaae37
2 changed files with 8 additions and 6 deletions
@@ -21,7 +21,7 @@ FutureConnection::FutureConnection()
int FutureConnection::getEventFd() const
{
return wake.fd();
return event_fd.fd;
}
bool FutureConnection::isReady() const
@@ -62,7 +62,7 @@ void FutureConnection::cancel(std::exception_ptr exception)
void FutureConnection::notifyWaiter() const
{
wake.notify();
event_fd.write();
}
}
@@ -3,8 +3,8 @@
#if defined(OS_LINUX) || defined(OS_DARWIN)
#include <Poco/Net/StreamSocket.h>
#include <Common/EventFD.h>
#include <Common/Logger.h>
#include <Common/WakeupFd.h>
#include <atomic>
#include <future>
@@ -13,7 +13,8 @@ namespace DB
/// Represents a connection that may not be established yet.
/// Provides a file descriptor that can be polled (epoll on Linux, kqueue on macOS) to wait
/// asynchronously for the connection, backed by a portable self-pipe (`WakeupFd`).
/// asynchronously for the connection, backed by `EventFD` (a native eventfd on Linux, a
/// self-pipe on macOS).
class FutureConnection
{
public:
@@ -48,8 +49,9 @@ private:
/// Guards the single allowed promise completion: setSocket and cancel race (the peer connecting
/// vs. query teardown), and the loser must be a no-op rather than throw "promise already set".
std::atomic<bool> satisfied{false};
/// Pollable self-pipe: its read end is registered with the poller, and completion writes to it.
WakeupFd wake;
/// Pollable wakeup fd: `event_fd.fd` is registered with the poller, and completion writes to it.
/// One kernel fd on Linux (eventfd), a self-pipe pair on macOS.
EventFD event_fd;
LoggerPtr log = getLogger("FutureConnection");
};