‘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’.



Reply via email to