diff options
| author | fusion32 <marcopuzziello@gmail.com> | 2025-10-16 01:35:10 -0300 |
|---|---|---|
| committer | fusion32 <marcopuzziello@gmail.com> | 2025-10-16 01:46:10 -0300 |
| commit | 95022ca95b1d2792bae447d90694dcc0d67b9de2 (patch) | |
| tree | 3a23505d31c48188f537a6da95239215a6487297 /src/connections.cc | |
| parent | b49d7de51cf14632a5768f292b870e647cf39bf5 (diff) | |
| download | querymanager-95022ca95b1d2792bae447d90694dcc0d67b9de2.tar.gz querymanager-95022ca95b1d2792bae447d90694dcc0d67b9de2.zip | |
lower monotonic uptime resolution from MILLISECONDS to SECONDS
The monotonic uptime was used exclusively with caches and having
a resolution of SECONDS allows it to be stored as an int without
risk of wrapping (~68 years). Using MILLISECONDS meant that it
would wrap after ~25 days which is totally possible and EXPECTED.
Just as an example, the small test server I ran for about 1 month
had ZERO downtime on the QueryManager except for when I manually
restarted it. It was probably very close to wrapping when I took
it down.
Diffstat (limited to 'src/connections.cc')
| -rw-r--r-- | src/connections.cc | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/connections.cc b/src/connections.cc index 0760514..b851954 100644 --- a/src/connections.cc +++ b/src/connections.cc @@ -141,7 +141,7 @@ TConnection *AssignConnection(int Socket, uint32 Addr, uint16 Port){ Connection = &g_Connections[ConnectionIndex]; Connection->State = CONNECTION_READING; Connection->Socket = Socket; - Connection->LastActive = GetMonotonicUptimeMS(); + Connection->LastActive = GetMonotonicUptime(); snprintf(Connection->RemoteAddress, sizeof(Connection->RemoteAddress), "%d.%d.%d.%d:%d", @@ -215,7 +215,7 @@ void CheckConnectionInput(TConnection *Connection, int Events){ if(Connection->RWPosition >= ReadSize){ if(Connection->RWSize != 0){ Connection->State = CONNECTION_REQUEST; - Connection->LastActive = GetMonotonicUptimeMS(); + Connection->LastActive = GetMonotonicUptime(); Connection->Query->Request = TReadBuffer(Buffer, Connection->RWSize); break; }else if(Connection->RWPosition == 2){ @@ -510,8 +510,12 @@ void CheckConnection(TConnection *Connection, int Events){ CloseConnection(Connection); } + // NOTE(fusion): Idle connection could linger for more than expected because + // the polling thread now blocks on `poll`. It shouldn't be a problem tho, as + // it could only happen on periods of absolutely NO traffic, so there is ZERO + // load on the query manager outside of used memory (which is already limited). if(g_Config.MaxConnectionIdleTime > 0){ - int IdleTime = (GetMonotonicUptimeMS() - Connection->LastActive); + int IdleTime = (GetMonotonicUptime() - Connection->LastActive); if(IdleTime >= g_Config.MaxConnectionIdleTime){ LOG_WARN("Dropping connection %s due to inactivity", Connection->RemoteAddress); |
