diff --git a/src/LibAmqp/Buffer/BufferWrite.c b/src/LibAmqp/Buffer/BufferWrite.c index 3090b8c..6186abd 100644 --- a/src/LibAmqp/Buffer/BufferWrite.c +++ b/src/LibAmqp/Buffer/BufferWrite.c @@ -16,21 +16,35 @@ #include #include -#include -#include + +#include +#include #include "Buffer/Buffer.h" #include "Buffer/BufferInternal.h" #include "Memory/Memory.h" #include "Misc/Bits.h" - #include "Context/Context.h" #include "debug_helper.h" +#ifndef MSG_NOSIGNAL +#define MSG_NOSIGNAL 0 +#endif + int amqp_buffer_write(int fd, amqp_buffer_t *buffer) { int iov_count; struct iovec *io_vec = amqp_buffer_read_io_vec(buffer, &iov_count); - return writev(fd, io_vec, iov_count); + struct msghdr header = { + .msg_name = 0, + .msg_namelen = 0, + .msg_iov = io_vec, + .msg_iovlen = iov_count, + .msg_control = 0, + .msg_controllen = 0, + .msg_flags = 0 + }; + + return sendmsg(fd, &header, MSG_NOSIGNAL); } \ No newline at end of file diff --git a/src/LibAmqp/Transport/LowLevel/Socket.c b/src/LibAmqp/Transport/LowLevel/Socket.c index b4e4992..d1a59c0 100644 --- a/src/LibAmqp/Transport/LowLevel/Socket.c +++ b/src/LibAmqp/Transport/LowLevel/Socket.c @@ -115,8 +115,12 @@ int amqp_set_socket_to_ignore_sigpipe(amqp_socket_t fd) int value = 1; return amqp_set_socket_option(fd, SO_NOSIGPIPE, value); #else -#error "Ignore SIGPIPE" +#ifdef MSG_NOSIGNAL + return 0; +#else +#error "Neither SO_NOSIGPIPE nor MSG_NOSIGNAL is available. (Must ignore SIGPIPE)" return -1; -#endif -#endif +#endif /* MSG_NOSIGNAL */ +#endif /* SO_NOSIGPIPE */ +#endif /* AMQP_WINDOWS_PORT */ }