diff options
author | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-04-12 00:11:00 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-04-12 00:11:00 -0400 |
commit | a490f2ebd9dbb4b0fb395a2b93f727c56afda218 (patch) | |
tree | b6115ed6b850ffb7da167c95f20ebabd089d5ce4 /src | |
parent | 24de3887e5e3bba2b8a4f60d1224ac927b98b1ed (diff) |
fix weird slow start issue
Diffstat (limited to 'src')
-rw-r--r-- | src/multipart-replace.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/multipart-replace.c b/src/multipart-replace.c index fa893f2..facca62 100644 --- a/src/multipart-replace.c +++ b/src/multipart-replace.c @@ -40,7 +40,7 @@ if (err != 0) { \ error(0, err, "%s", name); \ } else { \ - error(0, errno, "%s: umm... what? Not EOF, but also not error. Here's errno", name); \ + error(0, 0, "%s: panic: neither feof nor ferror", name); \ } \ ret = EXIT_FAILURE; \ } \ @@ -155,15 +155,17 @@ int multipart_replace_writer(struct multipart_replace_stream *s, int fd, const c pthread_rwlock_unlock(&s->frontlock); - /* send the frame to the client */ - if (fwrite(boundary, boundary_len, 1, stream) < 1) - stdioerror(stream, "dst <- boundary"); - if (fwrite(myframe.buf, myframe.len, 1, stream) < 1) - stdioerror(stream, "dst <- frame"); - /* send a blank line for pleasantness */ - if (fwrite("\r\n", 2, 1, stream) < 1) - stdioerror(stream, "dst <- nl"); - fflush(stream); + if (myframe.len != 0) { + /* send the frame to the client */ + if (fwrite(boundary, boundary_len, 1, stream) < 1) + stdioerror(stream, "dst <- boundary"); + if (fwrite(myframe.buf, myframe.len, 1, stream) < 1) + stdioerror(stream, "dst <- frame"); + /* send a blank line for pleasantness */ + if (fwrite("\r\n", 2, 1, stream) < 1) + stdioerror(stream, "dst <- nl"); + fflush(stream); + } /* poll until there's a new frame */ pthread_rwlock_rdlock(&s->frontlock); |