wininet: Handle the cache being full better in CommitUrlCacheEntryInternal.
Move the freeing of allocation blocks for an entry into URLCache_DeleteEntry. Call URLCache_DeleteEntry to rollback from failure in CommitUrlCacheEntryInternal.
This commit is contained in:
parent
13f2ce26dd
commit
7b4b4b7930
|
@ -785,8 +785,17 @@ static BOOL URLCache_FindFirstFreeEntry(URLCACHE_HEADER * pHeader, DWORD dwBlock
|
||||||
* FALSE if it failed
|
* FALSE if it failed
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static BOOL URLCache_DeleteEntry(CACHEFILE_ENTRY * pEntry)
|
static BOOL URLCache_DeleteEntry(LPURLCACHE_HEADER pHeader, CACHEFILE_ENTRY * pEntry)
|
||||||
{
|
{
|
||||||
|
DWORD dwStartBlock;
|
||||||
|
DWORD dwBlock;
|
||||||
|
BYTE * AllocationTable = (LPBYTE)pHeader + ALLOCATION_TABLE_OFFSET;
|
||||||
|
|
||||||
|
/* update allocation table */
|
||||||
|
dwStartBlock = ((DWORD)((BYTE *)pEntry - (BYTE *)pHeader)) / BLOCKSIZE;
|
||||||
|
for (dwBlock = dwStartBlock; dwBlock < dwStartBlock + pEntry->dwBlocksUsed; dwBlock++)
|
||||||
|
URLCache_Allocation_BlockFree(AllocationTable, dwBlock);
|
||||||
|
|
||||||
ZeroMemory(pEntry, pEntry->dwBlocksUsed * BLOCKSIZE);
|
ZeroMemory(pEntry, pEntry->dwBlocksUsed * BLOCKSIZE);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -2199,6 +2208,7 @@ static BOOL WINAPI CommitUrlCacheEntryInternal(
|
||||||
|
|
||||||
if (!URLCache_AddEntryToHash(pHeader, achUrl, (DWORD)((LPBYTE)pUrlEntry - (LPBYTE)pHeader)))
|
if (!URLCache_AddEntryToHash(pHeader, achUrl, (DWORD)((LPBYTE)pUrlEntry - (LPBYTE)pHeader)))
|
||||||
{
|
{
|
||||||
|
URLCache_DeleteEntry(pHeader, &pUrlEntry->CacheFileEntry);
|
||||||
URLCacheContainer_UnlockIndex(pContainer, pHeader);
|
URLCacheContainer_UnlockIndex(pContainer, pHeader);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -2496,9 +2506,6 @@ BOOL WINAPI DeleteUrlCacheEntryA(LPCSTR lpszUrlName)
|
||||||
URLCACHECONTAINER * pContainer;
|
URLCACHECONTAINER * pContainer;
|
||||||
LPURLCACHE_HEADER pHeader;
|
LPURLCACHE_HEADER pHeader;
|
||||||
CACHEFILE_ENTRY * pEntry;
|
CACHEFILE_ENTRY * pEntry;
|
||||||
DWORD dwStartBlock;
|
|
||||||
DWORD dwBlock;
|
|
||||||
BYTE * AllocationTable;
|
|
||||||
|
|
||||||
TRACE("(%s)\n", debugstr_a(lpszUrlName));
|
TRACE("(%s)\n", debugstr_a(lpszUrlName));
|
||||||
|
|
||||||
|
@ -2519,14 +2526,7 @@ BOOL WINAPI DeleteUrlCacheEntryA(LPCSTR lpszUrlName)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
AllocationTable = (LPBYTE)pHeader + ALLOCATION_TABLE_OFFSET;
|
URLCache_DeleteEntry(pHeader, pEntry);
|
||||||
|
|
||||||
/* update allocation table */
|
|
||||||
dwStartBlock = ((DWORD)pEntry - (DWORD)pHeader) / BLOCKSIZE;
|
|
||||||
for (dwBlock = dwStartBlock; dwBlock < dwStartBlock + pEntry->dwBlocksUsed; dwBlock++)
|
|
||||||
URLCache_Allocation_BlockFree(AllocationTable, dwBlock);
|
|
||||||
|
|
||||||
URLCache_DeleteEntry(pEntry);
|
|
||||||
|
|
||||||
URLCache_DeleteEntryFromHash(pHeader, lpszUrlName);
|
URLCache_DeleteEntryFromHash(pHeader, lpszUrlName);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue