'NamedPipe' should be more robust #2201
Labels
bug
Something isn't working
good first issue
Good for newcomers
refactoring
Refactor code without adding features
Brief description
When the server side of a
NamedPipe
destructs it's endpoint, it can lead to a termination of the process using the client side.It should behave more like a
UnixDomainSocket
where the server side can close a socket but the client side can still try to access it. In the worst case this will lead to a runtime error which can be handled gracefully.Detailed information
On destruction, the server side
NamedPipe
destroys theNamedPipeData
which will lead to the client side user of theNamedPipe
accessing an invalid object. Instead of destruction theNamedPipeData
unconditionally, it could be marked for destruction. This could be done with an atomic (compare) exchange on a state variable, e.g.On construction the state variable will be set to
READY
.When a client opens the
NamedPipe
, the state will be set toIN_USE
by a compare and swap operation withREADY
being the expected state.On destruction two scenarios need to be taken care of
NamedPipe
DESTRUCTION
READY
, it can be destructedIN_USE
, the client need to destroy theNamedPipe
NamedPipe
READY
as new stateIN_USE
DESTRUCTION
, the client needs to destroy theNamedPipeData
The text was updated successfully, but these errors were encountered: