From 6935b7c73b0368f4c2e9252019ecd7a9f6223c04 Mon Sep 17 00:00:00 2001 From: Piotr Caban Date: Tue, 18 Sep 2012 14:43:44 +0200 Subject: [PATCH] wininet: Unlock urlcache entries that were locked for over a day. --- dlls/wininet/urlcache.c | 43 +++++++++++++++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/dlls/wininet/urlcache.c b/dlls/wininet/urlcache.c index 1b62fdae6d3..e1d189e30ca 100644 --- a/dlls/wininet/urlcache.c +++ b/dlls/wininet/urlcache.c @@ -1552,6 +1552,38 @@ static BOOL URLCache_DeleteCacheDirectory(LPCWSTR lpszPath) return !(ret || shfos.fAnyOperationsAborted); } +/*********************************************************************** + * URLCache_IsLocked (Internal) + * + * Checks if entry is locked. Unlocks it if possible. + */ +static BOOL URLCache_IsLocked(struct _HASH_ENTRY *hash_entry, URL_CACHEFILE_ENTRY *url_entry) +{ + FILETIME cur_time; + ULARGE_INTEGER acc_time, time; + + if ((hash_entry->dwHashKey & ((1<LastAccessTime.dwLowDateTime; + acc_time.u.HighPart = url_entry->LastAccessTime.dwHighDateTime; + + time.QuadPart -= acc_time.QuadPart; + + /* check if entry was locked for at least a day */ + if(time.QuadPart > (ULONGLONG)24*60*60*10000000) { + URLCache_HashEntrySetFlags(hash_entry, HASHTABLE_URL); + url_entry->dwUseCount = 0; + return FALSE; + } + + return TRUE; +} + /*********************************************************************** * FreeUrlCacheSpaceW (WININET.@) * @@ -2193,9 +2225,8 @@ static BOOL DeleteUrlCacheEntryInternal(const URLCACHECONTAINER * pContainer, } pUrlEntry = (URL_CACHEFILE_ENTRY *)pEntry; - if ((pHashEntry->dwHashKey & ((1<CacheEntryType |= PENDING_DELETE_CACHE_ENTRY; SetLastError(ERROR_SHARING_VIOLATION); @@ -2736,11 +2767,11 @@ static BOOL CommitUrlCacheEntryInternal( if (URLCache_FindHash(pHeader, lpszUrlNameA, &pHashEntry)) { - if ((pHashEntry->dwHashKey & ((1<dwOffsetEntry); + if (URLCache_IsLocked(pHashEntry, pUrlEntry)) { - /* FIXME: implement timeout object unlocking */ - FIXME("Trying to overwrite locked entry\n"); - SetLastError(ERROR_SHARING_VIOLATION); + TRACE("Trying to overwrite locked entry\n"); + error = ERROR_SHARING_VIOLATION; goto cleanup; }