diff --git a/upnphttp.c b/upnphttp.c index 61a6cdb..4bc0c54 100644 --- a/upnphttp.c +++ b/upnphttp.c @@ -1323,6 +1323,10 @@ send_file(struct upnphttp * h, int sendfd, off_t offset, off_t end_offset) else if( errno != EAGAIN ) break; } + else if( ret == 0 ) + { + break; /* Premature end of file */ + } else { //DPRINTF(E_DEBUG, L_HTTP, "sent %lld bytes to %d. offset is now %lld.\n", ret, h->socket, offset); @@ -1343,6 +1347,10 @@ send_file(struct upnphttp * h, int sendfd, off_t offset, off_t end_offset) else break; } + else if( ret == 0 ) + { + break; /* premature end of file */ + } ret = write(h->ev.fd, buf, ret); if( ret == -1 ) { DPRINTF(E_DEBUG, L_HTTP, "write error :: error no. %d [%s]\n", errno, strerror(errno));