TCP server spins at 100% CPU when accept() fails with EMFILE
@itsGiaan ci sta già lavorando.
Dal 17/11/2026.
Valutazione
Questa issue non è ancora stata valutata.
Descrizione
Description
When a TCP server runs out of file descriptors, accept() fails with EMFILE. The pending connection stays in the listen queue, so the listening socket remains readable. Every event wait then returns immediately, accept() fails again, and the server busy-loops at 100% CPU.
Because the server loop only runs scheduled timers when the event wait returns no events, timers (ping-restart, hand-window, etc.) stall for as long as the condition lasts. The same applies to the management listener.
The default --max-clients is 1024, the same as the usual default soft RLIMIT_NOFILE on Linux. Since each TCP client uses one descriptor, plus the tun device, listeners, log and management, a TCP server with default settings hits EMFILE before reaching --max-clients.
On Linux the issue is not specific to the userspace data channel: it reproduces with DCO as well, since accepting connections and the event loop stay in userspace.
Affected platforms
Linux: reproduced, with both epoll and poll. The default limits are enough.
FreeBSD 14.5: reproduced (poll backend). The kernel also leaves the pending connection in the queue after a failed accept(), on a stock system the default descriptor limit is much higher (kern.maxfilesperproc), so it needs a lowered limit or a --max-clients close to it.
macOS: not affected, because XNU drops the pending connection when accept() fails.
Windows: not affected.
How to reproduce
Start a server with tcp-server listener, on Linux the default limits are enough (about 1000 connections are needed); a low limit such as ulimit -n 64 makes it quicker to reproduce.
Open TCP connections to the server port, without completing the handshake, until accept() fails with Too many open files.
Watch the CPU usage of the server process: it stays at 100% and the log fills with TCP: accept(...) failed: Too many open files (errno=24).
Patches are ready and will be sent to Gerrit.
- Lingua principale
- C
- Stelle
- 14.8k
- Fork
- 3.4k
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di OpenVPN/openvpn
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 71/100
-
CVE-2026-11604 vs OpenVPN 2.7.x DocumentationForse di nuovo libera @lstipakov l’ha presa 35 giorni fa e non c’è nessuna pull request aperta. ApertaDCO website Windows
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
Document Real Address format change in management/status output (OpenVPN 2.7)Forse già presa Una pull request collegata a questa issue è aperta o già unita. Apertadocumentation enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
Since 2.7.9 "route-method exe" can't set routeForse già presa @d12fk l’ha presa 1 giorno fa. Apertaoutdated code Windows
-
enhancement feature
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
Tutte le issue di OpenVPN/openvpn
Issue simili
-
issue: bug report
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 2 giorni
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
I maintainer di solito rispondono entro 1 giorno
-
documentation
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
Stellarium/stellarium#5197 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
ChupathingyCE/chupathingyce#1550 ·
I maintainer di solito rispondono entro 1 giorno
-
[BUG] SWAPDB sends no invalidation to CLIENT TRACKING clientsForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
redis/redis#16302 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno