Fix fd leak when restarting external validator
This MR fixes an fd leak that occurs when the external validator is automatically restarted by the node. The communication socket of the former (crashed) validator was left open and discarded. We now close it properly.
Manually testing the MR
Run a sandbox node. Activate alpha.
- Use
lsof -p NODE_PID | wc -lto count the number of fds opened by the node.lsof -a -p NODE_PIDcan also be useful to see that multiple "validator-socket" as kept open. - kill the
octez-validatorusingkill -9 VALIDATOR_PID(the pid is given in the node's logs) octez-client bake for --minimal-timestamp- notice a fd bump of 2: - 1 is the validator fd that is not close; - 1 is another fd leak spotted by this investigation that will be tackled later.
With the patch, the number of fds is increased by 1 only (because of the other fd leak.)
Checklist
-
Document the interface of any function added or modified (see the coding guidelines) -
Document any change to the user interface, including configuration parameters (see node configuration) -
Provide automatic testing (see the testing guide). -
For new features and bug fixes, add an item in the appropriate changelog ( docs/protocols/alpha.rstfor the protocol and the environment,CHANGES.rstat the root of the repository for everything else). -
Select suitable reviewers using the Reviewersfield below. -
Select as Assigneethe next person who should take action on that MR