- ret = send_queued_chunks(hc);
- if (ret < 0) {
- http_shutdown_client(hc, "queue send error");
- continue;
- }
- if (!len)
- continue;
- if (!ret || write_ok(hc->fd) <= 0) {
- queue_chunk_or_shutdown(hc, current_chunk, 0);
- continue;
- }
-// PARA_DEBUG_LOG("sending %d -> %s\n", len, remote_name(hc->fd));
- ret = write(hc->fd, buf, len);
-// PARA_DEBUG_LOG("ret: %d\n", ret);
- if (ret < 0) {
- http_shutdown_client(hc, "send error");
- continue;
- }
- if (ret != len)
- queue_chunk_or_shutdown(hc, current_chunk, ret);
+ }
+ sc->header_sent = 1;
+ ret = send_queued_chunks(sc->fd, sc->cq);
+ if (ret < 0) {
+ shutdown_client(sc, ss);
+ goto out;
+ }
+ if (!len)
+ goto out;
+ if (!ret) { /* still data left in the queue */
+ ret = queue_chunk_or_shutdown(sc, ss, buf, len);
+ goto out;
+ }
+ ret = xwrite(sc->fd, buf, len);
+ if (ret < 0) {
+ shutdown_client(sc, ss);
+ goto out;
+ }
+ if (ret != len)
+ ret = queue_chunk_or_shutdown(sc, ss, buf + ret, len - ret);
+out:
+ if (ret < 0)
+ PARA_NOTICE_LOG("%s\n", para_strerror(-ret));
+}
+
+static void http_send(long unsigned current_chunk,
+ __a_unused long unsigned chunks_sent, const char *buf, size_t len,
+ const char *header_buf, size_t header_len)
+{
+ struct sender_client *sc, *tmp;
+
+ list_for_each_entry_safe(sc, tmp, &hss->client_list, node) {
+ struct private_http_sender_data *phsd = sc->private_data;
+
+ if (phsd->status == HTTP_STREAMING)
+ http_send_chunk(sc, hss, current_chunk, buf, len,
+ header_buf, header_len);