Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
communications: make control socket writes recover from interruption
Both send_message() and receive_message() use writes: the former to send to the latter, and then a reply is sent back from the latter to the former. Both of them expected a single write to work unconditionally without being able to tolerate any transient issues. This commit factors out the writes into a common function called send_unix() which serves as the companion to the recently added recv_unix(). The send call is modified to handle both partial writes and interrupted writes. Especially the latter is not that unlikely: it can happen when we're in the middle of writing a message and then we get interrupted by a SIGCHLD. This is not a difficult thing to happen during the ordinary course of operations because the native 'exec' is asynchronous. It was observed to happen during testing. Partial writes might also be possible if some of the buffer was sent and then got interrupted by a signal, but this probably can't happen at the small BUFSZ we use. Nonetheless it will make the code more robust to support the possibility of partial writes. Any error besides EINTR is considered a fatal error for send_message() because this is only called by a "client" invocation, ie "sdorfehs -c". The "server" (ie receve_message()) only issues a warning and then aborts processing the signal. Otherwise, it would die. This matches the existing use of err() and warn() that was used after a mismatch in written and wrote buffer sizes in the respective writers, prior to this patch.
- Loading branch information