Fix a crash when trying to get HLS fragments from a disconnected strema.
[cubemap] / server.cpp
index 4773b479b92047b0be10f87095e14605799e4db1..35cb9d6bce869b354f73b96f1824e004cf1835ec 100644 (file)
@@ -460,6 +460,13 @@ void Server::set_header(int stream_index, const string &http_header, const strin
        assert(stream_index >= 0 && stream_index < ssize_t(streams.size()));
        streams[stream_index]->set_header(http_header, stream_header);
 }
+
+void Server::set_unavailable(int stream_index)
+{
+       lock_guard<mutex> lock(mu);
+       assert(stream_index >= 0 && stream_index < ssize_t(streams.size()));
+       streams[stream_index]->set_unavailable();
+}
        
 void Server::set_pacing_rate(int stream_index, uint32_t pacing_rate)
 {
@@ -1108,7 +1115,7 @@ int Server::parse_request(Client *client)
        }
 
        if (client->stream_pos_end == Client::STREAM_POS_NO_END) {
-               if (stream->http_header.empty()) {
+               if (stream->unavailable) {
                        return 503;  // Service unavailable.
                }