Fix streaming errors
Streaming a file (through mplayer for instance), the socket would block, because mplayer fills its buffer sequentially. We would've never gotten to a write(.., n) == n. Instead, do it like we read from files and accept the fact clients can accept data chunk-wise, too. The reason why this error went unnoticed is that I added a faulty printf-directive (%ls for ssize_t), which silently produced no output. Thanks to sin for fixing the %ls -> %zd error, as it made me look at the code again.
This commit is contained in:
parent
a0a2b864a6
commit
a1fa707eec
1 changed files with 5 additions and 4 deletions
9
quark.c
9
quark.c
|
@ -184,12 +184,13 @@ putresentry(int type, ...) {
|
|||
void
|
||||
responsefiledata(int fd, off_t size) {
|
||||
char buf[BUFSIZ];
|
||||
ssize_t n;
|
||||
ssize_t n, m, size_in;
|
||||
|
||||
for (; (n = read(fd, buf, MIN(size, sizeof buf))) > 0; size -= n)
|
||||
if (write(req.fd, buf, n) != n)
|
||||
logerrmsg("error writing to client %s at %ls: %s\n",
|
||||
host, n, strerror(errno));
|
||||
for(size_in = n; (m = write(req.fd, buf, size_in)) > 0; size_in -= m);
|
||||
|
||||
if (m == -1)
|
||||
logerrmsg("error writing to client %s: %s\n", host, strerror(errno));
|
||||
if (n == -1)
|
||||
logerrmsg("error reading from file: %s\n", strerror(errno));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue