assert(stream_index >= 0 && stream_index < ssize_t(streams.size()));
streams[stream_index]->http_header = http_header;
streams[stream_index]->stream_header = stream_header;
-
- // If there are clients we haven't sent anything to yet, we should give
- // them the header, so push back into the SENDING_HEADER state.
- for (map<int, Client>::iterator client_it = clients.begin();
- client_it != clients.end();
- ++client_it) {
- Client *client = &client_it->second;
- if (client->state == Client::WAITING_FOR_KEYFRAME ||
- (client->state == Client::SENDING_DATA &&
- client->stream_pos == 0)) {
- construct_header(client);
- }
- }
}
void Server::set_mark_pool(int stream_index, MarkPool *mark_pool)
void Server::skip_lost_data(Client *client)
{
Stream *stream = client->stream;
+ if (stream == NULL) {
+ return;
+ }
size_t bytes_to_send = stream->bytes_received - client->stream_pos;
if (bytes_to_send > stream->backlog_size) {
size_t bytes_lost = bytes_to_send - stream->backlog_size;
return 404; // Not found.
}
+ Stream *stream = streams[url_map_it->second];
+ if (stream->http_header.empty()) {
+ return 503; // Service unavailable.
+ }
+
client->url = request_tokens[1];
- client->stream = streams[url_map_it->second];
+ client->stream = stream;
if (client->stream->mark_pool != NULL) {
client->fwmark = client->stream->mark_pool->get_mark();
} else {