[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#55223: Shepherd 0.9.0 ‘make-inetd-constructor’ can leak file descrip
From: |
Ludovic Courtès |
Subject: |
bug#55223: Shepherd 0.9.0 ‘make-inetd-constructor’ can leak file descriptors |
Date: |
Mon, 02 May 2022 16:52:05 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) |
‘make-inetd-constructor’ creates a socket and then calls bind(2) on it.
--8<---------------cut here---------------start------------->8---
(lambda args
(let ((sock (non-blocking-port
(socket (sockaddr:fam address) socket-style 0)))
[…])
(setsockopt sock SOL_SOCKET SO_REUSEADDR 1)
[…]
(bind sock address)
--8<---------------cut here---------------end--------------->8---
If bind(2) fails, for instance with EADDRINUSE, the socket it created is
leaked; it will be closed “eventually”, when GC runs, but that could
happen much later.
Solution is to use some sort of ‘unwind-protect’ and close it upon
exception.
Ludo’.
- bug#55223: Shepherd 0.9.0 ‘make-inetd-constructor’ can leak file descriptors,
Ludovic Courtès <=