Browse Source

[core] remove redundant checks for tempfile chunk

remove redundant checks for tempfile chunk reuse
c->file.is_temp is only set if c->type == FILE_CHUNK is also true

The test for (0 == c->offset) is historical.  Before the temporary files
were opened O_APPEND (or written to using pwrite()), the file offset may
have changed via lseek() if lighttpd had started reading the file to
send to the client.  To avoid this, the (0 == c->offset) check was used
as a quick check to avoid continuing to write to a temporary file that
lighttpd had begun to read.
master
Glenn Strauss 3 months ago
parent
commit
2e60c4e0b2
  1. 7
      src/chunk.c

7
src/chunk.c

@ -683,18 +683,13 @@ static chunk *chunkqueue_get_append_tempfile(chunkqueue * const restrict cq, log
/*
* if the last chunk is
* - smaller than cq->upload_temp_file_size
* - not read yet (offset == 0)
* -> append to it (and it then might exceed cq->upload_temp_file_size)
* otherwise
* -> create a new chunk
*/
chunk * const c = cq->last;
if (NULL != c
&& FILE_CHUNK == c->type
&& c->file.is_temp
&& c->file.fd >= 0
&& 0 == c->offset) {
if (NULL != c && c->file.is_temp && c->file.fd >= 0) {
if (c->file.length < (off_t)cq->upload_temp_file_size)
return c; /* ok, take the last chunk for our job */

Loading…
Cancel
Save