From 8ae176933ef6baabc3b092c1cee34072c5455de6 Mon Sep 17 00:00:00 2001 From: Mike Brady Date: Mon, 23 May 2016 18:22:08 +0100 Subject: [PATCH] Check non-blocking write returns correctly, sheesh. --- rtsp.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/rtsp.c b/rtsp.c index ec4eb7c5..604b9989 100644 --- a/rtsp.c +++ b/rtsp.c @@ -1119,13 +1119,17 @@ void metadata_process(uint32_t type, uint32_t code, char *data, "%x%x%u", type, code, length); ret = non_blocking_write(fd, thestring, strlen(thestring)); - if (ret < 1) + if (ret < 0) { + debug(1,"metadata_process error %d exit 1",ret); return; + } if ((data != NULL) && (length > 0)) { snprintf(thestring, 1024, "\n\n"); ret = non_blocking_write(fd, thestring, strlen(thestring)); - if (ret < 1) // no reader + if (ret < 0) { + debug(1,"metadata_process error %d exit 2",ret); return; + } // here, we write the data in base64 form using our nice base64 encoder // but, we break it into lines of 76 output characters, except for the last // one. @@ -1146,20 +1150,26 @@ void metadata_process(uint32_t type, uint32_t code, char *data, // debug(1,"Remaining count: %d ret: %d, outbuf_size: // %d.",remaining_count,ret,outbuf_size); ret = non_blocking_write(fd, outbuf, outbuf_size); - if (ret < 0) + if (ret < 0) { + debug(1,"metadata_process error %d exit 3",ret); return; + } remaining_data += towrite_count; remaining_count -= towrite_count; } snprintf(thestring, 1024, ""); ret = non_blocking_write(fd, thestring, strlen(thestring)); - if (ret < 1) // no reader + if (ret < 0) { + debug(1,"metadata_process error %d exit 4",ret); return; + } } snprintf(thestring, 1024, "\n"); ret = non_blocking_write(fd, thestring, strlen(thestring)); - if (ret < 1) // no reader + if (ret < 0) { + debug(1,"metadata_process error %d exit 5",ret); return; + } } void *metadata_thread_function(void *ignore) {