Issue #138: fixed MSG_NOSIGNAL on Mac OS.
This commit is contained in:
parent
87b052588b
commit
4d1a6ad2f2
@ -977,6 +977,9 @@ CHECK_FUNCTION_EXISTS(syscall VMIME_HAVE_SYSCALL)
|
||||
CHECK_SYMBOL_EXISTS(SYS_gettid sys/syscall.h VMIME_HAVE_SYSCALL_GETTID)
|
||||
|
||||
CHECK_SYMBOL_EXISTS(SO_KEEPALIVE sys/socket.h VMIME_HAVE_SO_KEEPALIVE)
|
||||
CHECK_SYMBOL_EXISTS(SO_NOSIGPIPE sys/socket.h VMIME_HAVE_SO_NOSIGPIPE)
|
||||
|
||||
CHECK_SYMBOL_EXISTS(MSG_NOSIGNAL sys/socket.h VMIME_HAVE_MSG_NOSIGNAL)
|
||||
|
||||
CHECK_SYMBOL_EXISTS(strerror_r string.h VMIME_HAVE_STRERROR_R)
|
||||
|
||||
|
@ -87,6 +87,8 @@ typedef unsigned @VMIME_64BIT_TYPE@ vmime_uint64;
|
||||
#cmakedefine01 VMIME_HAVE_STRERROR_R
|
||||
#cmakedefine01 VMIME_HAVE_MLANG
|
||||
#cmakedefine01 VMIME_HAVE_SO_KEEPALIVE
|
||||
#cmakedefine01 VMIME_HAVE_SO_NOSIGPIPE
|
||||
#cmakedefine01 VMIME_HAVE_MSG_NOSIGNAL
|
||||
#cmakedefine01 VMIME_SHARED_PTR_USE_CXX
|
||||
#cmakedefine01 VMIME_SHARED_PTR_USE_BOOST
|
||||
|
||||
|
@ -138,6 +138,17 @@ void posixSocket::connect(const vmime::string& address, const vmime::port_t port
|
||||
|
||||
#endif // VMIME_HAVE_SO_KEEPALIVE
|
||||
|
||||
#if VMIME_HAVE_SO_NOSIGPIPE
|
||||
|
||||
// Return EPIPE instead of generating SIGPIPE
|
||||
int nosigpipe_optval = 1;
|
||||
socklen_t nosigpipe_optlen = sizeof(nosigpipe_optval);
|
||||
|
||||
::setsockopt(sock, SOL_SOCKET, SO_NOSIGPIPE, &nosigpipe_optval, nosigpipe_optlen);
|
||||
|
||||
#endif // VMIME_HAVE_SO_NOSIGPIPE
|
||||
|
||||
|
||||
if (m_timeoutHandler != NULL)
|
||||
{
|
||||
::fcntl(sock, F_SETFL, ::fcntl(sock, F_GETFL) | O_NONBLOCK);
|
||||
@ -750,7 +761,12 @@ void posixSocket::sendRaw(const byte_t* buffer, const size_t count)
|
||||
|
||||
while (size > 0)
|
||||
{
|
||||
|
||||
#if VMIME_HAVE_MSG_NOSIGNAL
|
||||
const ssize_t ret = ::send(m_desc, buffer, size, MSG_NOSIGNAL);
|
||||
#else
|
||||
const ssize_t ret = ::send(m_desc, buffer, size, 0);
|
||||
#endif
|
||||
|
||||
if (ret <= 0)
|
||||
{
|
||||
@ -776,7 +792,11 @@ size_t posixSocket::sendRawNonBlocking(const byte_t* buffer, const size_t count)
|
||||
{
|
||||
m_status &= ~STATUS_WOULDBLOCK;
|
||||
|
||||
#if VMIME_HAVE_MSG_NOSIGNAL
|
||||
const ssize_t ret = ::send(m_desc, buffer, count, MSG_NOSIGNAL);
|
||||
#else
|
||||
const ssize_t ret = ::send(m_desc, buffer, count, 0);
|
||||
#endif
|
||||
|
||||
if (ret <= 0)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user