mirror of
https://github.com/pocoproject/poco.git
synced 2025-07-03 09:15:21 +02:00
Merge pull request #237 from syvex/hotfix/sigpipe
Fix for Sockets and SIGPIPE
This commit is contained in:
commit
4bac0a6333
@ -920,6 +920,15 @@ void SocketImpl::initSocket(int af, int type, int proto)
|
|||||||
_sockfd = ::socket(af, type, proto);
|
_sockfd = ::socket(af, type, proto);
|
||||||
if (_sockfd == POCO_INVALID_SOCKET)
|
if (_sockfd == POCO_INVALID_SOCKET)
|
||||||
error();
|
error();
|
||||||
|
|
||||||
|
#if defined(__MACH__) && defined(__APPLE__) || defined(__FreeBSD__)
|
||||||
|
// SIGPIPE sends a signal that if unhandled (which is the default)
|
||||||
|
// will crash the process. This only happens on UNIX, and not Linux.
|
||||||
|
//
|
||||||
|
// In order to have POCO sockets behave the same across platforms, it is
|
||||||
|
// best to just ignore SIGPIPE all together.
|
||||||
|
setOption(SOL_SOCKET, SO_NOSIGPIPE, 1);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1069,6 +1078,10 @@ void SocketImpl::error(int code, const std::string& arg)
|
|||||||
throw NetException("Host is down", arg, code);
|
throw NetException("Host is down", arg, code);
|
||||||
case POCO_EHOSTUNREACH:
|
case POCO_EHOSTUNREACH:
|
||||||
throw NetException("No route to host", arg, code);
|
throw NetException("No route to host", arg, code);
|
||||||
|
#if defined(POCO_OS_FAMILY_UNIX)
|
||||||
|
case EPIPE:
|
||||||
|
throw IOException("Broken pipe", code);
|
||||||
|
#endif
|
||||||
default:
|
default:
|
||||||
throw IOException(NumberFormatter::format(code), arg, code);
|
throw IOException(NumberFormatter::format(code), arg, code);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user