]> git.sesse.net Git - cubemap/blobdiff - server.h
Fix timeout behavior with persistent connections.
[cubemap] / server.h
index da2076498f010785ae8d1a8954dc5d5920a7d83b..cfb6b2e13680409314ba444f68dc023666d8de31 100644 (file)
--- a/server.h
+++ b/server.h
@@ -6,11 +6,11 @@
 #include <sys/epoll.h>
 #include <sys/types.h>
 #include <time.h>
-#include <map>
 #include <memory>
 #include <mutex>
 #include <queue>
 #include <string>
+#include <unordered_map>
 #include <vector>
 
 #include "tlse.h"
@@ -106,13 +106,13 @@ private:
        std::vector<std::unique_ptr<Stream>> streams;
 
        // Map from URL to index into <streams>.
-       std::map<std::string, int> stream_url_map, stream_hls_url_map;
+       std::unordered_map<std::string, int> stream_url_map, stream_hls_url_map;
 
        // Map from URL to CORS Allow-Origin header (or empty string).
-       std::map<std::string, std::string> ping_url_map;
+       std::unordered_map<std::string, std::string> ping_url_map;
 
        // Map from file descriptor to client.
-       std::map<int, Client> clients;
+       std::unordered_map<int, Client> clients;
 
        // A list of all clients, ordered by the time they connected (first element),
        // and their file descriptor (second element). It is ordered by connection time
@@ -132,7 +132,7 @@ private:
        epoll_event events[EPOLL_MAX_EVENTS];
 
        // For each TLS-enabled acceptor, our private server context for its key pair.
-       std::map<const Acceptor *, TLSContext *> tls_server_contexts;
+       std::unordered_map<const Acceptor *, TLSContext *> tls_server_contexts;
 
        // The actual worker thread.
        virtual void do_work();
@@ -201,6 +201,10 @@ private:
        void skip_lost_data(Client *client);
 
        void add_client(int sock, Acceptor *acceptor);
+
+       // Mark that a client just went into READING_REQUEST state, so we should
+       // note the current time of day and then put it into <clients_ordered_by_connect_time>.
+       void start_client_timeout_timer(Client *client);
 };
 
 #endif  // !defined(_SERVER_H)