chunkqueue_append_chunkqueue()

(simpler than chunkqueue_steal() for transferring entire chunkqueue)
personal/stbuehler/mod-csrf-old
Glenn Strauss 7 years ago
parent 16a3f3b6fc
commit 1a18669d53
  1. 18
      src/chunk.c
  2. 1
      src/chunk.h
  3. 6
      src/mod_proxy.c
  4. 6
      src/mod_scgi.c

@ -281,6 +281,24 @@ void chunkqueue_append_mem(chunkqueue *cq, const char * mem, size_t len) {
chunkqueue_append_chunk(cq, c);
}
void chunkqueue_append_chunkqueue(chunkqueue *cq, chunkqueue *src) {
if (src == NULL || NULL == src->first) return;
if (NULL == cq->first) {
cq->first = src->first;
} else {
cq->last->next = src->first;
}
cq->last = src->last;
cq->bytes_in += (src->bytes_in - src->bytes_out);
src->first = NULL;
src->last = NULL;
src->bytes_out = src->bytes_in;
}
void chunkqueue_get_memory(chunkqueue *cq, char **mem, size_t *len, size_t min_size, size_t alloc_size) {
static const size_t REALLOC_MAX_SIZE = 256;
chunk *c;

@ -56,6 +56,7 @@ void chunkqueue_append_file_fd(chunkqueue *cq, buffer *fn, int fd, off_t offset,
void chunkqueue_append_mem(chunkqueue *cq, const char *mem, size_t len); /* copies memory */
void chunkqueue_append_buffer(chunkqueue *cq, buffer *mem); /* may reset "mem" */
void chunkqueue_prepend_buffer(chunkqueue *cq, buffer *mem); /* may reset "mem" */
void chunkqueue_append_chunkqueue(chunkqueue *cq, chunkqueue *src);
struct server; /*(declaration)*/
int chunkqueue_append_mem_to_tempfile(struct server *srv, chunkqueue *cq, const char *mem, size_t len);

@ -511,9 +511,7 @@ static int proxy_create_env(server *srv, handler_ctx *hctx) {
/* body */
if (con->request.content_length) {
chunkqueue *req_cq = con->request_content_queue;
chunkqueue_steal(hctx->wb, req_cq, req_cq->bytes_in); /*(0 == req_cq->bytes_out)*/
chunkqueue_append_chunkqueue(hctx->wb, con->request_content_queue);
hctx->wb_reqlen += con->request.content_length;/* (eventual) total request size */
}
@ -973,7 +971,7 @@ SUBREQUEST_FUNC(mod_proxy_handle_subrequest) {
handler_t r = connection_handle_read_post_state(srv, con);
chunkqueue *req_cq = con->request_content_queue;
if (0 != hctx->wb->bytes_in && !chunkqueue_is_empty(req_cq)) {
chunkqueue_steal(hctx->wb, req_cq, req_cq->bytes_in - req_cq->bytes_out);
chunkqueue_append_chunkqueue(hctx->wb, req_cq);
if (fdevent_event_get_interest(srv->ev, hctx->fd) & FDEVENT_OUT) {
return (r == HANDLER_GO_ON) ? HANDLER_WAIT_FOR_EVENT : r;
}

@ -1731,9 +1731,7 @@ static int scgi_create_env(server *srv, handler_ctx *hctx) {
buffer_free(b);
if (con->request.content_length) {
chunkqueue *req_cq = con->request_content_queue;
chunkqueue_steal(hctx->wb, req_cq, req_cq->bytes_in); /*(0 == req_cq->bytes_out)*/
chunkqueue_append_chunkqueue(hctx->wb, con->request_content_queue);
hctx->wb_reqlen += con->request.content_length;/* (eventual) total request size */
}
@ -2563,7 +2561,7 @@ SUBREQUEST_FUNC(mod_scgi_handle_subrequest) {
handler_t r = connection_handle_read_post_state(srv, con);
chunkqueue *req_cq = con->request_content_queue;
if (0 != hctx->wb->bytes_in && !chunkqueue_is_empty(req_cq)) {
chunkqueue_steal(hctx->wb, req_cq, req_cq->bytes_in - req_cq->bytes_out);
chunkqueue_append_chunkqueue(hctx->wb, req_cq);
if (fdevent_event_get_interest(srv->ev, hctx->fd) & FDEVENT_OUT) {
return (r == HANDLER_GO_ON) ? HANDLER_WAIT_FOR_EVENT : r;
}

Loading…
Cancel
Save