diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/youtube/YoutubeMediaProxy.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/plugins/youtube/YoutubeMediaProxy.cpp b/src/plugins/youtube/YoutubeMediaProxy.cpp index 4d84674..e51e3d9 100644 --- a/src/plugins/youtube/YoutubeMediaProxy.cpp +++ b/src/plugins/youtube/YoutubeMediaProxy.cpp @@ -30,6 +30,20 @@ static ssize_t read_eintr(int fd, void *buffer, size_t size) { } } +static ssize_t write_all(int fd, const void *buffer, size_t size) { + ssize_t bytes_written = 0; + while((size_t)bytes_written < size) { + ssize_t written = write(fd, (char*)buffer + bytes_written, size - bytes_written); + if(written == -1) { + if(errno != EINTR) + return -1; + } else { + bytes_written += written; + } + } + return bytes_written; +} + static ssize_t write_all_blocking(int fd, const void *buffer, size_t size) { ssize_t bytes_written = 0; while((size_t)bytes_written < size) { @@ -433,7 +447,7 @@ namespace QuickMedia { return Error::OK; } - const ssize_t num_bytes_written = write_all_blocking(client_fd, buffer_start + buffer_offset, num_bytes_to_write); + const ssize_t num_bytes_written = write_all(client_fd, buffer_start + buffer_offset, num_bytes_to_write); if(num_bytes_written == -1) { const int err = errno; if(err == EAGAIN || err == EWOULDBLOCK) { |