From: Mike Brady Date: Tue, 27 Nov 2018 22:53:27 +0000 (+0000) Subject: Add extra diagnostic to capture a meg_write_response error. X-Git-Tag: 3.3RC0~136 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4ab81ce0b76db062d4ce910515291e740e64edf3;p=thirdparty%2Fshairport-sync.git Add extra diagnostic to capture a meg_write_response error. --- diff --git a/rtsp.c b/rtsp.c index cb26c576..478f20e6 100644 --- a/rtsp.c +++ b/rtsp.c @@ -692,9 +692,17 @@ int msg_write_response(int fd, rtsp_message *resp) { debug(1, "Attempted to write overlong RTSP packet 3"); return -3; } - if (write(fd, pkt, p - pkt) != p - pkt) { - debug(1, "Error writing an RTSP packet -- requested bytes not fully written."); - return -4; + ssize_t reply = write(fd, pkt, p - pkt); + if (reply == -1) { + char errorstring[1024]; + strerror_r(errno, (char *)errorstring, sizeof(errorstring)); + debug(1, "msg_write_response error %d: \"%s\".", + errno, (char *)errorstring); + return -4; + } + if (reply != p - pkt) { + debug(1, "msg_write_response error -- requested bytes not fully written."); + return -5; } return 0; }