Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 768030 - net-misc/minidlna leaks sockets, becomes unresponsive
Summary: net-misc/minidlna leaks sockets, becomes unresponsive
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Michał Górny
Depends on:
Reported: 2021-01-30 20:44 UTC by peteru
Modified: 2022-03-05 18:09 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---

Fixes leaked sockets by correctly initialising the ev struct (fix-leaked-sockets.patch,1.15 KB, patch)
2021-01-30 20:46 UTC, peteru
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description peteru 2021-01-30 20:44:02 UTC
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.

Reproducible: Always

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.
Comment 1 peteru 2021-01-30 20:46:33 UTC
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.
Comment 3 Larry the Git Cow gentoo-dev 2021-01-31 09:18:57 UTC
The bug has been closed via the following commit(s):

commit 2fe2484bb7f9de72413eb25deb02e4212d81c8d0
Author:     Michał Górny <>
AuthorDate: 2021-01-31 09:14:14 +0000
Commit:     Michał Górny <>
CommitDate: 2021-01-31 09:16:28 +0000

    net-misc/minidlna: Fix socket leak
    Signed-off-by: Michał Górny <>

 .../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(-)