- struct queued_packet *qp;
- if (hc->pq_bytes + len > MAX_BACKLOG) {
- http_shutdown_client(hc, "packet queue overrun");
- return -E_QUEUE;
- }
- qp = para_malloc(sizeof(struct queued_packet));
- hc->pq_bytes += len;
- qp->packet = para_malloc(len);
- memcpy(qp->packet, buf, len);
- qp->len = len;
- list_add_tail(&qp->node, &hc->packet_queue);
- PARA_INFO_LOG("%lu bytes queued for fd %d\n", hc->pq_bytes, hc->fd);
- return 1;
-}
-
-static int send_queued_packets(struct http_client *hc)
-{
- int ret;
- struct queued_packet *qp, *tmp;
-
- if (list_empty(&hc->packet_queue))
- return 1;
- list_for_each_entry_safe(qp, tmp, &hc->packet_queue, node) {
- ret = write_ok(hc->fd);
+ struct queued_chunk *qc;
+ while ((qc = cq_peek(hc->cq))) {
+ char *buf;
+ size_t len;
+ int ret = write_ok(hc->fd);