From 74fc637eeba387927907df40d8d22ecd2c5de2da Mon Sep 17 00:00:00 2001 From: Ronnie Sahlberg Date: Sun, 6 Dec 2015 12:12:49 -0800 Subject: [PATCH] Use MSG_NOSIGNAL with send() If the server closes the TCP connection before we call send() in iscsi_write_to_socket() we will get SIGPIPE unless we pass this argument to send. Signed-off-by: Ronnie Sahlberg --- lib/socket.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/socket.c b/lib/socket.c index a7b0a2f..db6344d 100644 --- a/lib/socket.c +++ b/lib/socket.c @@ -697,7 +697,7 @@ iscsi_write_to_socket(struct iscsi_context *iscsi) count = send(iscsi->fd, pdu->outdata.data + pdu->outdata_written, pdu->outdata.size - pdu->outdata_written, - 0); + MSG_NOSIGNAL); if (count == -1) { if (errno == EAGAIN || errno == EWOULDBLOCK) { return 0; @@ -746,7 +746,7 @@ iscsi_write_to_socket(struct iscsi_context *iscsi) /* Write padding */ if (pdu->payload_written < total) { - count = send(iscsi->fd, padding_buf, total - pdu->payload_written, 0); + count = send(iscsi->fd, padding_buf, total - pdu->payload_written, MSG_NOSIGNAL); if (count == -1) { if (errno == EAGAIN || errno == EWOULDBLOCK) { return 0;