diff --git a/src/connection.cpp b/src/connection.cpp index 720a313..b9b8fe1 100644 --- a/src/connection.cpp +++ b/src/connection.cpp @@ -134,7 +134,11 @@ bool Connection::writeBytes() { ssize_t w; for (;;) { - w = writev(fd_, iov, iov_count); + struct msghdr msg = {}; + msg.msg_iov = iov; + msg.msg_iovlen = iov_count; + + w = sendmsg(fd_, &msg, MSG_NOSIGNAL); if (w == -1) { if (errno == EINTR) { continue; // Standard practice: retry on signal interruption @@ -148,7 +152,7 @@ bool Connection::writeBytes() { } return false; } - perror("writev"); + perror("sendmsg"); return true; } break; diff --git a/src/main.cpp b/src/main.cpp index 31ecd48..34ca057 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -264,7 +264,6 @@ int main(int argc, char *argv[]) { g_server = server.get(); // Setup signal handling - std::signal(SIGPIPE, SIG_IGN); std::signal(SIGTERM, signal_handler); std::signal(SIGINT, signal_handler); diff --git a/tools/load_tester.cpp b/tools/load_tester.cpp index 18a12ae..5df9210 100644 --- a/tools/load_tester.cpp +++ b/tools/load_tester.cpp @@ -300,7 +300,7 @@ struct Connection { bool writeBytes() { for (;;) { assert(!request.empty()); - int w = write(fd, request.data(), request.size()); + int w = send(fd, request.data(), request.size(), MSG_NOSIGNAL); if (w == -1) { if (errno == EINTR) { continue; @@ -610,7 +610,6 @@ int main(int argc, char *argv[]) { } printf("\n"); - signal(SIGPIPE, SIG_IGN); signal(SIGTERM, signal_handler); signal(SIGINT, signal_handler);