unit: rework a bit how we keep the service fdstore from being destroyed during servic...
authorLennart Poettering <lennart@poettering.net>
Mon, 13 Nov 2017 14:08:49 +0000 (15:08 +0100)
committerLennart Poettering <lennart@poettering.net>
Thu, 16 Nov 2017 13:37:33 +0000 (14:37 +0100)
commit7eb2a8a1259043e107ebec94e30ed160a93f40a7
treea730dd22e8221f69bf55bf45e39b706e8cbbf646
parent6af6a50a0ba856319e4aa04813967cd0860e484c
unit: rework a bit how we keep the service fdstore from being destroyed during service restart

When preparing for a restart we quickly go through the DEAD/INACTIVE
service state before entering AUTO_RESTART. When doing this, we need to
make sure we don't destroy the FD store. Previously this was done by
checking the failure state of the unit, and keeping the FD store around
when the unit failed, under the assumption that the restart logic will
then get into action.

This is not entirely correct howver, as there might be failure states
that will no result in restarts.

With this commit we slightly alter the logic: a ref counter for the fd
store is added, that is increased right before we handle the restart
logic, and decreased again right-after.

This should ensure that the fdstore lives exactly as long as it needs.

Follow-up for f0bfbfac43b7faa68ef1bb2ad659c191b9ec85d2.
src/core/service.c
src/core/service.h
src/core/unit.c
src/core/unit.h