- list_for_each_entry_safe(hc, tmp, &clients, node) {
- if (hc->status != HTTP_STREAMING &&
- hc->status != HTTP_READY_TO_STREAM)
- continue;
- if (hc->status == HTTP_READY_TO_STREAM) {
- unsigned hlen;
- char *hbuf = vss_get_header(&hlen);
- if (hbuf && hlen > 0 && current_chunk) {
- /* need to send header */
- PARA_INFO_LOG("queueing header: %d\n", hlen);
- if (queue_packet(hc, hbuf, hlen) < 0)
- continue;
- } else
- PARA_INFO_LOG("%s", "no need to queue header\n");
- hc->status = HTTP_STREAMING;
- }
- ret = send_queued_packets(hc);
- if (ret < 0) {
- http_shutdown_client(hc, "send error");
- continue;
- }
- if (!len)
- continue;
- if (!ret || write_ok(hc->fd) <= 0) {
- PARA_INFO_LOG("fd %d not ready (%lu bytes queued),"
- " trying to queue packet\n", hc->fd,
- hc->pq_bytes);
- queue_packet(hc, buf, len);
- continue;
- }
-// PARA_DEBUG_LOG("sending %d -> %s\n", len, CLIENT_ADDR(hc));
- ret = write(hc->fd, buf, len);
- if (ret < 0) {
- http_shutdown_client(hc, "send error");
- continue;
- }
- if (ret != len)
- queue_packet(hc, buf + ret, len - ret);
- }
-}