From a9dc7c25db7f58243d4b3a4c1968ac81e7327a3d Mon Sep 17 00:00:00 2001 From: Ian Gulliver Date: Thu, 25 Feb 2016 16:33:47 -0800 Subject: [PATCH] Switch back to write(), since we have non-sockets. --- adsbus/send.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/adsbus/send.c b/adsbus/send.c index 7034d09..f4a50ac 100644 --- a/adsbus/send.c +++ b/adsbus/send.c @@ -1,5 +1,6 @@ #include #include +#include #include #include #include @@ -89,13 +90,14 @@ static bool send_hello(int fd, struct serializer *serializer) { if (buf.length == 0) { return true; } - if (send(fd, buf_at(&buf, 0), buf.length, MSG_NOSIGNAL) != buf.length) { + if (write(fd, buf_at(&buf, 0), buf.length) != buf.length) { return false; } return true; } void send_init() { + assert(signal(SIGPIPE, SIG_IGN) != SIG_ERR); } void send_cleanup() { @@ -160,13 +162,13 @@ void send_write(struct packet *packet) { if (buf.length == 0) { continue; } - struct send *send_obj = serializer->send_head; - while (send_obj) { - if (send(send_obj->peer.fd, buf_at(&buf, 0), buf.length, MSG_NOSIGNAL) != buf.length) { + struct send *send = serializer->send_head; + while (send) { + if (write(send->peer.fd, buf_at(&buf, 0), buf.length) != buf.length) { // peer_loop() will see this shutdown and call send_del - shutdown(send_obj->peer.fd, SHUT_RD | SHUT_WR); + shutdown(send->peer.fd, SHUT_RD | SHUT_WR); } - send_obj = send_obj->next; + send = send->next; } } }