diff options
author | Leah Neukirchen <leah@vuxu.org> | 2020-05-15 19:27:42 +0200 |
---|---|---|
committer | Leah Neukirchen <leah@vuxu.org> | 2020-05-15 19:27:42 +0200 |
commit | 2363d60f2e46d5621898b925c1750cddb202a4a2 (patch) | |
tree | 4da521d9a4a5e54d5c33e3be6b1252e8d107f300 | |
parent | d14d97f1a0f3155540548c4b0e37af3f7eb54c0d (diff) | |
download | hittpd-2363d60f2e46d5621898b925c1750cddb202a4a2.tar.gz hittpd-2363d60f2e46d5621898b925c1750cddb202a4a2.tar.xz hittpd-2363d60f2e46d5621898b925c1750cddb202a4a2.zip |
detect file truncation
We have to close the connection here to notify the client.
-rw-r--r-- | hittpd.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/hittpd.c b/hittpd.c index 270f81b..6b295ee 100644 --- a/hittpd.c +++ b/hittpd.c @@ -804,14 +804,18 @@ write_client(int i) w = write(sockfd, buf, n); if (w > 0) data->off += w; - if (w == 0 || data->off == data->last) + if (data->off == data->last) finish_response(i); + else if (w == 0) + close_connection(i); // file was truncated! } #else w = sendfile(sockfd, data->stream_fd, &(data->off), data->last - data->off); - if (w == 0 || data->off == data->last) + if (data->off == data->last) finish_response(i); + else if (w == 0) + close_connection(i); // file was truncated! #endif } else if (data->buf) { if (data->off == data->last) { |