diff --git a/src/chunk.c b/src/chunk.c index 5500fa7d..78abdd68 100644 --- a/src/chunk.c +++ b/src/chunk.c @@ -486,9 +486,15 @@ static int chunkqueue_append_to_tempfile(server *srv, chunkqueue *dest, const ch if (dst_c->file.length >= (off_t)dest->upload_temp_file_size) { /* the chunk is too large now, close it */ - close(dst_c->file.fd); + int rc = close(dst_c->file.fd); dst_c->file.fd = -1; dst_c = NULL; + if (0 != rc) { + log_error_write(srv, __FILE__, __LINE__, "sbss", + "close() temp-file", dst_c->file.name, "failed:", + strerror(errno)); + return -1; + } } } else { dst_c = NULL; @@ -502,8 +508,7 @@ static int chunkqueue_append_to_tempfile(server *srv, chunkqueue *dest, const ch */ log_error_write(srv, __FILE__, __LINE__, "ss", - "denying upload as opening temp-file for upload failed:", - strerror(errno)); + "opening temp-file failed:", strerror(errno)); return -1; } @@ -529,16 +534,22 @@ static int chunkqueue_append_to_tempfile(server *srv, chunkqueue *dest, const ch int retry = (errno == ENOSPC && dest->tempdirs && ++dest->tempdir_idx < dest->tempdirs->used); if (!retry) { log_error_write(srv, __FILE__, __LINE__, "sbs", - "denying upload as writing to file failed:", - dst_c->file.name, strerror(errno)); + "write() temp-file", dst_c->file.name, "failed:", + strerror(errno)); } if (0 == chunk_remaining_length(dst_c)) { /*(remove empty chunk and unlink tempfile)*/ chunkqueue_remove_empty_chunks(dest); } else {/*(close tempfile; avoid later attempts to append)*/ - close(dst_c->file.fd); + int rc = close(dst_c->file.fd); dst_c->file.fd = -1; + if (0 != rc) { + log_error_write(srv, __FILE__, __LINE__, "sbss", + "close() temp-file", dst_c->file.name, "failed:", + strerror(errno)); + return -1; + } } if (!retry) return -1; diff --git a/src/mod_compress.c b/src/mod_compress.c index 8caa5061..f6d24cdc 100644 --- a/src/mod_compress.c +++ b/src/mod_compress.c @@ -594,10 +594,13 @@ static int deflate_file_to_file(server *srv, connection *con, plugin_data *p, bu #endif free(start); - close(ofd); close(ifd); - if (ret != 0) { + if (0 != close(ofd) || ret != 0) { + if (0 == ret) { + log_error_write(srv, __FILE__, __LINE__, "sbss", "writing cachefile", p->ofn, "failed:", strerror(errno)); + } + /* Remove the incomplete cache file, so that later hits aren't served from it */ if (-1 == unlink(p->ofn->ptr)) { log_error_write(srv, __FILE__, __LINE__, "sbss", "unlinking incomplete cachefile", p->ofn, "failed:", strerror(errno)); diff --git a/src/mod_webdav.c b/src/mod_webdav.c index 038ca874..a9fffd61 100644 --- a/src/mod_webdav.c +++ b/src/mod_webdav.c @@ -722,7 +722,11 @@ static int webdav_copy_file(server *srv, connection *con, plugin_data *p, physic free(data); close(ifd); - close(ofd); + if (0 != close(ofd)) { + if (0 == status) status = (errno == ENOSPC) ? 507 : 403; + log_error_write(srv, __FILE__, __LINE__, "sbss", + "close ", dst->path, "failed: ", strerror(errno)); + } #ifdef USE_PROPPATCH if (0 == status) { @@ -1848,7 +1852,11 @@ SUBREQUEST_FUNC(mod_webdav_subrequest_handler_huge) { break; } } - close(fd); + if (0 != close(fd)) { + log_error_write(srv, __FILE__, __LINE__, "sbss", + "close ", con->physical.path, "failed: ", strerror(errno)); + return HANDLER_ERROR; + } return HANDLER_FINISHED; }