summaryrefslogtreecommitdiffstats
path: root/stream
diff options
context:
space:
mode:
Diffstat (limited to 'stream')
-rw-r--r--stream/stream.c2
-rw-r--r--stream/stream_ffmpeg.c1
-rw-r--r--stream/stream_file.c12
-rw-r--r--stream/stream_smb.c12
4 files changed, 23 insertions, 4 deletions
diff --git a/stream/stream.c b/stream/stream.c
index 6f35252e3d..34b6bc81f9 100644
--- a/stream/stream.c
+++ b/stream/stream.c
@@ -28,6 +28,7 @@
#endif
#include <fcntl.h>
#include <strings.h>
+#include <assert.h>
#include "config.h"
@@ -326,6 +327,7 @@ int stream_write_buffer(stream_t *s, unsigned char *buf, int len) {
if(rd < 0)
return -1;
s->pos += rd;
+ assert(rd == len && "stream_write_buffer(): unexpected short write");
return rd;
}
diff --git a/stream/stream_ffmpeg.c b/stream/stream_ffmpeg.c
index e6705883fc..343381afb0 100644
--- a/stream/stream_ffmpeg.c
+++ b/stream/stream_ffmpeg.c
@@ -34,6 +34,7 @@ static int fill_buffer(stream_t *s, char *buffer, int max_len)
static int write_buffer(stream_t *s, char *buffer, int len)
{
+ /* url_write retries internally on short writes and EAGAIN */
int r = url_write(s->priv, buffer, len);
return (r <= 0) ? -1 : r;
}
diff --git a/stream/stream_file.c b/stream/stream_file.c
index 22be803fba..6d436cf6f5 100644
--- a/stream/stream_file.c
+++ b/stream/stream_file.c
@@ -56,8 +56,16 @@ static int fill_buffer(stream_t *s, char* buffer, int max_len){
}
static int write_buffer(stream_t *s, char* buffer, int len) {
- int r = write(s->fd,buffer,len);
- return (r <= 0) ? -1 : r;
+ int r;
+ int wr = 0;
+ while (wr < len) {
+ r = write(s->fd,buffer,len);
+ if (r <= 0)
+ return -1;
+ wr += r;
+ buffer += r;
+ }
+ return len;
}
static int seek(stream_t *s,off_t newpos) {
diff --git a/stream/stream_smb.c b/stream/stream_smb.c
index 684940749f..714e80fe79 100644
--- a/stream/stream_smb.c
+++ b/stream/stream_smb.c
@@ -100,8 +100,16 @@ static int fill_buffer(stream_t *s, char* buffer, int max_len){
}
static int write_buffer(stream_t *s, char* buffer, int len) {
- int r = smbc_write(s->fd,buffer,len);
- return (r <= 0) ? -1 : r;
+ int r;
+ int wr = 0;
+ while (wr < len) {
+ r = smbc_write(s->fd,buffer,len);
+ if (r <= 0)
+ return -1;
+ wr += r;
+ buffer += r;
+ }
+ return len;
}
static void close_f(stream_t *s){