From b70f34b696c75dee9af1387d2e1536cd9edffa4b Mon Sep 17 00:00:00 2001 From: Shauren Date: Sun, 27 Jun 2021 20:20:51 +0200 Subject: Dep/CascLib: Update to ladislav-zezula/CascLib@37a948bdb5f493b6a0959489baa07e1636002c3b --- dep/CascLib/src/CascOpenStorage.cpp | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) (limited to 'dep/CascLib/src/CascOpenStorage.cpp') diff --git a/dep/CascLib/src/CascOpenStorage.cpp b/dep/CascLib/src/CascOpenStorage.cpp index 00b3797eb68..584b79a38a1 100644 --- a/dep/CascLib/src/CascOpenStorage.cpp +++ b/dep/CascLib/src/CascOpenStorage.cpp @@ -135,6 +135,11 @@ TCascStorage * TCascStorage::Release() // Need this to be atomic to make multi-threaded file opens work if(CascInterlockedDecrement(&dwRefCount) == 0) { + // Release all references in the socket cache + if(dwFeatures & CASC_FEATURE_ONLINE) + sockets_set_caching(false); + + // Delete the object and return NULL delete this; return NULL; } @@ -162,16 +167,16 @@ void * ProbeOutputBuffer(void * pvBuffer, size_t cbLength, size_t cbMinLength, s static LPTSTR CheckForIndexDirectory(TCascStorage * hs, LPCTSTR szSubDir) { - LPTSTR szIndexPath; + TCHAR szIndexPath[MAX_PATH]; // Combine the index path - szIndexPath = CombinePath(hs->szDataPath, szSubDir); - if (!DirectoryExists(szIndexPath)) - { - CASC_FREE(szIndexPath); - } + CombinePath(szIndexPath, _countof(szIndexPath), hs->szDataPath, szSubDir, NULL); - return szIndexPath; + // Check whether the path exists + if(!DirectoryExists(szIndexPath)) + return NULL; + + return CascNewStr(szIndexPath); } // Inserts an entry from the text build file @@ -1168,9 +1173,14 @@ static DWORD LoadCascStorage(TCascStorage * hs, PCASC_OPEN_STORAGE_ARGS pArgs) if(ExtractVersionedArgument(pArgs, FIELD_OFFSET(CASC_OPEN_STORAGE_ARGS, szBuildKey), &szBuildKey) && szBuildKey != NULL) hs->szBuildKey = CascNewStrT2A(szBuildKey); - // For online storages, we need to load CDN servers - if ((dwErrCode == ERROR_SUCCESS) && (hs->dwFeatures & CASC_FEATURE_ONLINE)) + // Special handling to online storages + if(hs->dwFeatures & CASC_FEATURE_ONLINE) { + // Enable caching of the sockets. This will add references + // to all existing and all future sockets + sockets_set_caching(true); + + // For online storages, we need to load CDN servers dwErrCode = LoadCdnsFile(hs); } -- cgit v1.2.3