Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent sendmsg/write raising SIGPIPE the TCP socket is closed:
This is observed by @gchiu etc when testing the http server: the problem is that the web server writes to the client when the client has closed the connection this happens when the browser client does a refresh while not having received yet the full response so the server code keeps writing to a broken pipe which doesn't seem to matter in windows but gives this signal in osx so it's seen on multiple refreshes with a browser client on the web server we saw the problem too on android but it went away when we trapped the writes There are a few ways to prevent it crashing: 1. installing a signal handler for SIGPIPE 2. set SO_NOSIGPIPE option on the socket (only supported on some platforms) 3. set MSG_NO_SIGNAL flag on the sendto (only supported on Linux) This commit tries to do both 2 and/or 3 when supported. See: https://stackoverflow.com/questions/108183/how-to-prevent-sigpipes-or-handle-them-properly
- Loading branch information