Re: POSIX semaphore fd collision on macOS

Michael Weiser <[email protected]> Mon, 19 Feb 2018 17:51:00 +0100
Newsgroups gmane.comp.archivers.amanda.devel
Message-ID <[email protected]>
Hi Jean-Louis,

On Mon, Feb 19, 2018 at 02:09:43PM +0000, Jean-Louis Martineau wrote:

> Thanks for the good bug report and the patch.
> Unfortunately, the patch is not correct.
> The problem is the fd is closed twice.
> It is first closed, then the semaphore use it and then the
> close(client_pipe[1]) close the semaphore instead f the pipe.  The
> proper fix is to remove the close, but this showed a bug in
> sendbackup.c which need a aclose(data_out);

> The patch also assign -1 to fd when we should no longer refer to them.

Yes, I also realized after sending that the actual cause is the fact
that client_pipe[1] is closed earlier via another reference. Sorry for
that. To be honest, I wouldn't have known how to fix it anyways because
the various hand-offs of the fds just left me with my brain in a knot.
;)

Your patch applies cleanly to amanda-3.5.1 and git master and solves the
problem in my testing and production setups with gnutar and gzip.
-- 
Thanks!
Micha