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/querymanager.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/querymanager.cc')
| -rw-r--r-- | src/querymanager.cc | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/querymanager.cc b/src/querymanager.cc index 350b708..4f68d5e 100644 --- a/src/querymanager.cc +++ b/src/querymanager.cc @@ -101,8 +101,8 @@ int64 GetClockMonotonicMS(void){ #endif } -int GetMonotonicUptimeMS(void){ - return (int)(GetClockMonotonicMS() - g_StartTimeMS); +int GetMonotonicUptime(void){ + return (int)((GetClockMonotonicMS() - g_StartTimeMS) / 1000); } void SleepMS(int DurationMS){ @@ -342,11 +342,11 @@ bool ParseDuration(int *Dest, const char *String){ } if(Suffix[0] == 'S' || Suffix[0] == 's'){ - *Dest *= (1000); + *Dest *= (1); }else if(Suffix[0] == 'M' || Suffix[0] == 'm'){ - *Dest *= (60 * 1000); + *Dest *= (60); }else if(Suffix[0] == 'H' || Suffix[0] == 'h'){ - *Dest *= (60 * 60 * 1000); + *Dest *= (60 * 60); } return true; @@ -592,7 +592,7 @@ int main(int argc, const char **argv){ // HostCache Config g_Config.MaxCachedHostNames = 100; - g_Config.HostNameExpireTime = 30 * 60 * 1000; // milliseconds + g_Config.HostNameExpireTime = 60 * 30; // seconds // Database Config #if DATABASE_SQLITE @@ -627,7 +627,7 @@ int main(int argc, const char **argv){ g_Config.QueryBufferSize = (int)MB(1); g_Config.QueryMaxAttempts = 3; g_Config.MaxConnections = 25; - g_Config.MaxConnectionIdleTime = 60 * 1000; // milliseconds + g_Config.MaxConnectionIdleTime = 60 * 5; // seconds LOG("Tibia Query Manager v0.2 (%s)", DATABASE_SYSTEM_NAME); if(!ReadConfig("config.cfg", &g_Config)){ @@ -636,7 +636,7 @@ int main(int argc, const char **argv){ // NOTE(fusion): Print config values for debugging purposes. LOG("Max cached host names: %d", g_Config.MaxCachedHostNames); - LOG("Host name expire time: %dms", g_Config.HostNameExpireTime); + LOG("Host name expire time: %ds", g_Config.HostNameExpireTime); #if DATABASE_SQLITE LOG("SQLite file: \"%s\"", g_Config.SQLite.File); LOG("SQLite max cached statements: %d", g_Config.SQLite.MaxCachedStatements); @@ -664,7 +664,7 @@ int main(int argc, const char **argv){ LOG("Query buffer size: %dB", g_Config.QueryBufferSize); LOG("Query max attempts: %d", g_Config.QueryMaxAttempts); LOG("Max connections: %d", g_Config.MaxConnections); - LOG("Max connection idle time: %dms", g_Config.MaxConnectionIdleTime); + LOG("Max connection idle time: %ds", g_Config.MaxConnectionIdleTime); if(!CheckSHA256()){ return EXIT_FAILURE; |
