pocoproject / poco

The POCO C++ Libraries are powerful cross-platform C++ libraries for building network- and internet-based applications that run on desktop, server, mobile, IoT, and embedded systems.
https://pocoproject.org
Other
8.04k stars 2.11k forks source link

PollSet::poll on Windows always returns immediately after first connection, due to bad event socket implementation #4594

Open obiltschnig opened 1 week ago

obiltschnig commented 1 week ago

PollSet uses and event fd to interrupt an ongoing poll() in wakeUp(). On POSIX platforms this uses eventfd() and works fine. On Windows, a ServerSocket is created (either as Unix domain socket or TCP socket) instead. The problem is that when that event fd is signaled, the implementation attempts to receive from it. Which is not going to work as it's a ServerSocket. So this eventfd stays signaled forever, causing high CPU load as poll() always returns immediately.

lanthora commented 4 days ago

The commit that fixes this problem should also solve the problem that the Poco::Net::ServiceNotFoundException exception is thrown when creating a PollSet with a Chinese username in Windows.

// TemporaryFile path contains Chinese characters
_pSockFile.reset(new TemporaryFile);
// SocketAddress throw ServiceNotFoundException
_pSocket.reset(new ServerSocket(SocketAddress(_pSockFile->path())));