cfc0b19418ea14d458e9e4502e0ed9d34b76f836
shutdown() only sets shutDown=true and expects the fifo to drain normally before eventReceived()'s keepAlive check (!shutDown || (fifo.size() > 0 && !readHangup)) lets the connection close - correct for a graceful QUIT/LOGOUT reply that just needs a few more successful writes to flush, but exactly backwards for the give-up path: the whole reason that path was reached is that the front of the fifo can never be sent. Leaving it queued meant keepAlive stayed true forever, resetSocket() kept re-arming EPOLLWRNORM because fifo wasn't empty, the very next write attempt hit the identical stall immediately, and shutdown() got called again - forever, at whatever rate the kernel could fire EPOLLWRNORM. Confirmed live on a real internet-facing server (Zephora's game server, an ordinary port-scanner connection was enough to trigger it): one socket logged "consecutive writes made zero progress - giving up and shutting down" 2.4 million+ times in under 4 milliseconds, pegging a worker thread at 100% CPU indefinitely. The give-up path now clears the undeliverable fifo entry before calling shutdown(), so keepAlive correctly evaluates to just !shutDown (now false) on the next cycle and the connection actually tears down.
Description
This repository provides core functionality for TCP and UDP servers using the epoll linux function.
184 MiB
0 Stars
1 Watchers
0 Forks
Languages
C++
99.6%
Shell
0.4%