minidlna commit f9a78d598e48132a8c6cf9ce31b51163b6bd2f67 introduced a socket leak. When connect() is called on a socket set to non-blocking mode, the returned error code is EINPROGRESS. In that case, the code never initialises the ev structure and the socket reference is lost. Given enough time (on my network about a day and a half) this will eventually lead to a non-responsive server because the process runs out of fds. Netstat will show an excessive number of sockets stuck in CLOSE_WAIT state forever and ls /proc/<pid>/fd will confirm a lot of open sockets.
I am attaching a patch that fixes the problem and has been submitted upstream. In the meantime, patching the ebuild should fix this serious bug that makes minidlna unusable.
Steps to Reproduce:
1. Run minidlna 1.3.0 on a busy network with many DLNA servers and clients
2. Wait a day or two
3. Notice minidlna server becoming unresponsive, due to fd exhaustion and many sockets in CLOSE_WAIT state.
Created attachment 685224 [details, diff]
Fixes leaked sockets by correctly initialising the ev struct
Initialising the ev struct before a call to connect() ensures that the socket reference is not lost. Verifying with netstat, one can see the sockets in TIME_WAIT state for a brief period of time and /proc/<pid>/fd shows a reasonable number of sockets being open.
The bug has been closed via the following commit(s):
Author: Michał Górny <email@example.com>
AuthorDate: 2021-01-31 09:14:14 +0000
Commit: Michał Górny <firstname.lastname@example.org>
CommitDate: 2021-01-31 09:16:28 +0000
net-misc/minidlna: Fix socket leak
Signed-off-by: Michał Górny <email@example.com>
.../minidlna/files/minidlna-1.3.0-fd-leak.patch | 28 ++++++++++++++++++++++
...idlna-1.3.0.ebuild => minidlna-1.3.0-r1.ebuild} | 5 ++--
2 files changed, 31 insertions(+), 2 deletions(-)