diff options
author | gumi <git@gumi.ca> | 2018-04-05 20:48:38 -0400 |
---|---|---|
committer | gumi <git@gumi.ca> | 2018-04-05 20:48:38 -0400 |
commit | e06b88411d56b76522f5796356a65c91f26da609 (patch) | |
tree | 7736ace21685d518237785d11421404e3209b7c6 /src/net/socket.hpp | |
parent | 1acf5016d8dc5cdc93e7cb3ed655dde5ff04ca33 (diff) | |
download | tmwa-e06b88411d56b76522f5796356a65c91f26da609.tar.gz tmwa-e06b88411d56b76522f5796356a65c91f26da609.tar.bz2 tmwa-e06b88411d56b76522f5796356a65c91f26da609.tar.xz tmwa-e06b88411d56b76522f5796356a65c91f26da609.zip |
make sessions expire after 5 minutes of being unreachable
Diffstat (limited to 'src/net/socket.hpp')
-rw-r--r-- | src/net/socket.hpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/net/socket.hpp b/src/net/socket.hpp index d6caefd..6115d70 100644 --- a/src/net/socket.hpp +++ b/src/net/socket.hpp @@ -78,12 +78,17 @@ struct Session /// Checks whether a newly-connected socket actually does anything TimeT created; bool connected; + TimeT last_tick; private: - /// Flag needed since structure must be freed in a server-dependent manner - bool eof; + struct { + unsigned char eof : 1; /// Flag needed since structure must be freed in a server-dependent manner + unsigned char server : 1; + } flag; + public: - void set_eof() { eof = true; } + void set_eof() { flag.eof = 1; } + void set_server() { flag.server = 1; } /// Currently used by clif_setwaitclose Timer timed_close; @@ -141,6 +146,9 @@ constexpr int SOFT_LIMIT = FD_SETSIZE - 50; // socket timeout to establish a full connection in seconds constexpr int CONNECT_TIMEOUT = 15; +// socket timeout (no activity at all) in seconds +// the server will try to contact the session halfway through +constexpr int STALL_TIMEOUT = 300; // 5 minutes void set_session(io::FD fd, std::unique_ptr<Session> sess); Session *get_session(io::FD fd); |