From a490f2ebd9dbb4b0fb395a2b93f727c56afda218 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Tue, 12 Apr 2016 00:11:00 -0400 Subject: fix weird slow start issue --- src/multipart-replace.c | 22 ++++++++++++---------- 1 file 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); -- cgit v1.2.3