mirror of
https://github.com/corda/corda.git
synced 2025-01-19 11:16:54 +00:00
set SO_NOSIGPIPE socket option when available
This ensures we avoid SIGPIPE on socket disconnect on Darwin.
This commit is contained in:
parent
a648787e11
commit
d873f096a1
@ -262,18 +262,32 @@ setTcpNoDelay(JNIEnv* e, int d, bool on)
|
||||
void
|
||||
doBind(JNIEnv* e, int s, sockaddr_in* address)
|
||||
{
|
||||
int opt = 1;
|
||||
int r = ::setsockopt(s, SOL_SOCKET, SO_REUSEADDR,
|
||||
reinterpret_cast<char*>(&opt), sizeof(int));
|
||||
if (r != 0) {
|
||||
throwIOException(e);
|
||||
return;
|
||||
{ int opt = 1;
|
||||
int r = ::setsockopt(s, SOL_SOCKET, SO_REUSEADDR,
|
||||
reinterpret_cast<char*>(&opt), sizeof(int));
|
||||
if (r != 0) {
|
||||
throwIOException(e);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
r = ::bind(s, reinterpret_cast<sockaddr*>(address), sizeof(sockaddr_in));
|
||||
if (r != 0) {
|
||||
throwIOException(e);
|
||||
return;
|
||||
#ifdef SO_NOSIGPIPE
|
||||
{ int opt = 1;
|
||||
int r = ::setsockopt(s, SOL_SOCKET, SO_NOSIGPIPE,
|
||||
reinterpret_cast<char*>(&opt), sizeof(int));
|
||||
if (r != 0) {
|
||||
throwIOException(e);
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
{ int r = ::bind
|
||||
(s, reinterpret_cast<sockaddr*>(address), sizeof(sockaddr_in));
|
||||
if (r != 0) {
|
||||
throwIOException(e);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user