Browse Source

[multiple] avoid empty chunks in chunkqueue

(This might render some calls to chunkqueue_remove_finished_chunks()
 no longer necessary)
Glenn Strauss 1 month ago
parent
commit
b0a5ebc6f7
  1. 7
      src/chunk.c
  2. 7
      src/mod_dirlisting.c
  3. 15
      src/mod_ssi.c

7
src/chunk.c

@ -554,6 +554,8 @@ void chunkqueue_update_file(chunkqueue * const restrict cq, chunk *c, off_t len)
/*assert(c->type == FILE_CHUNK);*/
c->file.length += len;
cq->bytes_in += len;
if (0 == chunk_remaining_length(c))
chunkqueue_remove_empty_chunks(cq);
}
void chunkqueue_set_tempdirs_default (const array *tempdirs, off_t upload_temp_file_size) {
@ -764,6 +766,11 @@ int chunkqueue_append_mem_to_tempfile(chunkqueue * const restrict dest, const ch
}
do {
/*(aside: arg len is permitted to be 0 and creates tempfile as a
* side effect. This is used by mod_ssi for ssi exec, as the func
* chunkqueue_get_append_tempfile() is not public. The result is
* an empty chunk at the end of the chunkqueue, which typically
* should be avoided)*/
dst_c = chunkqueue_get_append_tempfile(dest, errh);
if (NULL == dst_c)
return -1;

7
src/mod_dirlisting.c

@ -1185,9 +1185,10 @@ static void http_list_directory(request_st * const r, handler_ctx * const hctx)
}
if (out == tb) {
if (0 != chunkqueue_append_mem_to_tempfile(cq,
BUF_PTR_LEN(out),
r->conf.errh)) {
if (!buffer_is_blank(out)
&& 0 != chunkqueue_append_mem_to_tempfile(cq,
BUF_PTR_LEN(out),
r->conf.errh)) {
/* ignore */
}
}

15
src/mod_ssi.c

@ -802,33 +802,30 @@ static int process_ssi_stmt(request_st * const r, handler_ctx * const p, const c
*(const char **)&args[2] = cmd;
args[3] = NULL;
int status = 0;
struct stat stb;
stb.st_size = 0;
/*(expects STDIN_FILENO open to /dev/null)*/
int serrh_fd = r->conf.serrh ? r->conf.serrh->fd : -1;
pid = fdevent_fork_execve(args[0], args, NULL, -1, c->file.fd, serrh_fd, -1);
if (-1 == pid) {
log_perror(errh, __FILE__, __LINE__, "spawning exec failed: %s", cmd);
} else if (fdevent_waitpid(pid, &status, 0) < 0) {
log_perror(errh, __FILE__, __LINE__, "waitpid failed");
} else {
struct stat stb;
int status = 0;
/* wait for the client to end */
/* NOTE: synchronous; blocks entire lighttpd server */
/*
* OpenBSD and Solaris send a EINTR on SIGCHILD even if we ignore it
*/
if (fdevent_waitpid(pid, &status, 0) < 0) {
log_perror(errh, __FILE__, __LINE__, "waitpid failed");
break;
}
if (!WIFEXITED(status)) {
log_error(errh, __FILE__, __LINE__, "process exited abnormally: %s", cmd);
}
if (0 == fstat(c->file.fd, &stb)) {
chunkqueue_update_file(cq, c, stb.st_size);
}
}
chunkqueue_update_file(cq, c, stb.st_size);
break;
}
case SSI_IF: {

Loading…
Cancel
Save