]> git.sesse.net Git - cubemap/blobdiff - server.cpp
Create $(libdir) on make install.
[cubemap] / server.cpp
index 4773b479b92047b0be10f87095e14605799e4db1..8025fd1b4cb257ee71aa6a280a98c1913e007e73 100644 (file)
@@ -60,7 +60,7 @@ inline bool is_earlier(timespec a, timespec b)
 
 Server::Server()
 {
-       epoll_fd = epoll_create(1024);  // Size argument is ignored.
+       epoll_fd = epoll_create1(EPOLL_CLOEXEC);
        if (epoll_fd == -1) {
                log_perror("epoll_fd");
                exit(1);
@@ -70,6 +70,11 @@ Server::Server()
 Server::~Server()
 {
        safe_close(epoll_fd);
+
+       // We're going to die soon anyway, but clean this up to keep leak checking happy.
+       for (const auto &acceptor_and_context : tls_server_contexts) {
+               tls_destroy_context(acceptor_and_context.second);
+       }
 }
 
 vector<ClientStats> Server::get_client_stats() const
@@ -460,6 +465,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 +1120,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.
                }