- if (listen_fd < 0)
- return;
- list_for_each_entry_safe(hc, tmp, &clients, node) {
- i++;
-// PARA_DEBUG_LOG("handling client %d: %s\n", i, remote_name(hc->fd));
- switch (hc->status) {
- case HTTP_STREAMING: /* nothing to do */
- case HTTP_READY_TO_STREAM:
- break;
- case HTTP_CONNECTED: /* need to recv get request */
- if (hc->check_r && FD_ISSET(hc->fd, rfds)) {
- if (recv_pattern(hc->fd, HTTP_GET_MSG, MAXLINE)
- < 0) {
- hc->status = HTTP_INVALID_GET_REQUEST;
- } else {
- hc->status = HTTP_GOT_GET_REQUEST;
- PARA_INFO_LOG("%s",
- "received get request\n");
- }
- }
- break;
- case HTTP_GOT_GET_REQUEST: /* need to send ok msg */
- if (hc->check_w && FD_ISSET(hc->fd, wfds)) {
- hc->status = HTTP_SENT_OK_MSG;
- http_send_ok_msg(hc);
- }
- break;
- case HTTP_INVALID_GET_REQUEST: /* need to send err msg */
- if (hc->check_w && FD_ISSET(hc->fd, wfds)) {
- if (http_send_err_msg(hc) >= 0)
- http_shutdown_client(hc,
- "invalid get request");
- }
- break;
- case HTTP_SENT_OK_MSG: /* need to send header? */
- if (hc->check_w && FD_ISSET(hc->fd, wfds))
- hc->status = HTTP_READY_TO_STREAM;
- break;
- }
- }
- if (!FD_ISSET(listen_fd, rfds))
- return;
- hc = para_calloc(sizeof(struct http_client));
- err_msg = "accept error";
- hc->fd = para_accept(listen_fd, NULL, 0);
- if (hc->fd <= 0)
- goto err_out;
- hc->name = make_message("%s", remote_name(hc->fd));
- PARA_NOTICE_LOG("connection from %s (fd %d)\n", hc->name, hc->fd);
- if (conf.http_max_clients_arg > 0 && numclients >=
- conf.http_max_clients_arg) {
- err_msg = "server full";
- goto err_out;
- }
- match = acl_lookup(hc->fd, &http_acl);
- PARA_DEBUG_LOG("acl lookup returned %d\n", match);
- if ((match && !conf.http_default_deny_given) ||
- (!match && conf.http_default_deny_given)) {
- err_msg = "permission denied";
- goto err_out;
+ 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);