Browse Source

[core] always lseek() with shared fd

always lseek() with shared fd; remove optim to skip with offset = 0
master
Glenn Strauss 7 months ago
parent
commit
1b74c50854
  1. 2
      src/chunk.c
  2. 2
      src/http_chunk.c

2
src/chunk.c

@ -882,7 +882,7 @@ chunkqueue_small_resp_optim (chunkqueue * const restrict cq)
const int fd = filec->file.fd;
if (fd < 0) return; /*(require that file already be open)*/
off_t offset = filec->offset;
if (0 != offset && -1 == lseek(fd, offset, SEEK_SET)) return;
if (-1 == lseek(fd, offset, SEEK_SET)) return;
/* Note: there should be no size change in chunkqueue,
* so cq->bytes_in and cq->bytes_out should not be modified */

2
src/http_chunk.c

@ -76,7 +76,7 @@ static int http_chunk_append_read_fd_range(request_st * const r, const buffer *
if (r->resp_send_chunked)
http_chunk_len_append(cq, (uintmax_t)len);
if (0 != offset && -1 == lseek(fd, offset, SEEK_SET)) return -1;
if (-1 == lseek(fd, offset, SEEK_SET)) return -1;
buffer * const b = chunkqueue_append_buffer_open_sz(cq, len+2+1);
ssize_t rd;
offset = 0;

Loading…
Cancel
Save