Disable SIGPIPE for sockets created on iOS.
This can occur (and by default, terminates the process) for apps that don't use the "voip" UIBackgroundMode. We're already doing a similar thing on Linux (using MSG_NOSIGNAL for every packet sent). BUG=webrtc:7686 Review-Url: https://codereview.webrtc.org/2903313002 Cr-Commit-Position: refs/heads/master@{#18277}
This commit is contained in:
parent
36ba4f483f
commit
eae4564cb7
@ -608,6 +608,15 @@ bool SocketDispatcher::Initialize() {
|
||||
ioctlsocket(s_, FIONBIO, &argp);
|
||||
#elif defined(WEBRTC_POSIX)
|
||||
fcntl(s_, F_SETFL, fcntl(s_, F_GETFL, 0) | O_NONBLOCK);
|
||||
#endif
|
||||
#if defined(WEBRTC_IOS)
|
||||
// iOS may kill sockets when the app is moved to the background
|
||||
// (specifically, if the app doesn't use the "voip" UIBackgroundMode). When
|
||||
// we attempt to write to such a socket, SIGPIPE will be raised, which by
|
||||
// default will terminate the process, which we don't want. By specifying
|
||||
// this socket option, SIGPIPE will be disabled for the socket.
|
||||
int value = 1;
|
||||
::setsockopt(s_, SOL_SOCKET, SO_NOSIGPIPE, &value, sizeof(value));
|
||||
#endif
|
||||
ss_->Add(this);
|
||||
return true;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user