diff options
| author | fusion32 <marcopuzziello@gmail.com> | 2025-10-07 18:50:02 -0300 |
|---|---|---|
| committer | fusion32 <marcopuzziello@gmail.com> | 2025-10-07 18:50:02 -0300 |
| commit | aa31732158d3e457dfe630f3b2e56f53de89e2b1 (patch) | |
| tree | 685b2fe7cecb53a659e5f7b48581c6736318ea7e /src/hostcache.cc | |
| parent | f3c2d53f1837a7bd8e9e1517579b7354af91ef8c (diff) | |
| download | querymanager-aa31732158d3e457dfe630f3b2e56f53de89e2b1.tar.gz querymanager-aa31732158d3e457dfe630f3b2e56f53de89e2b1.zip | |
make connections properly handle async queries
This moves queries from `src/connections.cc` to `src/query.cc` and
adds a few missing details. The only thing left is to review query
processing and tie database operations to the `TDatabase` struct.
Diffstat (limited to 'src/hostcache.cc')
| -rw-r--r-- | src/hostcache.cc | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/hostcache.cc b/src/hostcache.cc index 5d5d46a..55c8663 100644 --- a/src/hostcache.cc +++ b/src/hostcache.cc @@ -18,10 +18,10 @@ static THostCacheEntry *g_CachedHostNames; bool InitHostCache(void){ ASSERT(g_CachedHostNames == NULL); - LOG("Max cached host names: %d", g_MaxCachedHostNames); - LOG("Host name expire time: %dms", g_HostNameExpireTime); + LOG("Max cached host names: %d", g_Config.MaxCachedHostNames); + LOG("Host name expire time: %dms", g_Config.HostNameExpireTime); g_CachedHostNames = (THostCacheEntry*)calloc( - g_MaxCachedHostNames, sizeof(THostCacheEntry)); + g_Config.MaxCachedHostNames, sizeof(THostCacheEntry)); return true; } @@ -64,10 +64,10 @@ bool ResolveHostName(const char *HostName, int *OutAddr){ THostCacheEntry *Entry = NULL; int LeastRecentlyUsedIndex = 0; int LeastRecentlyUsedTime = g_CachedHostNames[0].ResolveTime; - for(int i = 0; i < g_MaxCachedHostNames; i += 1){ + for(int i = 0; i < g_Config.MaxCachedHostNames; i += 1){ THostCacheEntry *Current = &g_CachedHostNames[i]; - if((g_MonotonicTimeMS - Current->ResolveTime) >= g_HostNameExpireTime){ + if((g_MonotonicTimeMS - Current->ResolveTime) >= g_Config.HostNameExpireTime){ memset(Current, 0, sizeof(THostCacheEntry)); } @@ -85,7 +85,7 @@ bool ResolveHostName(const char *HostName, int *OutAddr){ if(Entry == NULL){ // NOTE(fusion): We also cache failures. Entry = &g_CachedHostNames[LeastRecentlyUsedIndex]; - if(!StringCopy(Entry->HostName, sizeof(Entry->HostName), HostName)){ + if(!StringBufCopy(Entry->HostName, HostName)){ LOG_WARN("Hostname \"%s\" was improperly cached because it was" " too long (Length: %d, MaxLength: %d)", HostName, (int)strlen(HostName), (int)sizeof(Entry->HostName)); |
