Jeck - Stricter cache limits.
This commit is contained in:
@@ -9,10 +9,10 @@
|
|||||||
#include <list>
|
#include <list>
|
||||||
|
|
||||||
//Soft limits.
|
//Soft limits.
|
||||||
//For values higher than ~8000000, we run the danger of hitting our reserved space in deck editor.
|
//For values higher than ~6000000, we run the danger of hitting our reserved space in deck editor.
|
||||||
#define HUGE_CACHE_LIMIT 8000000
|
#define HUGE_CACHE_LIMIT 6000000
|
||||||
#define LARGE_CACHE_LIMIT 6000000
|
#define LARGE_CACHE_LIMIT 4000000
|
||||||
#define SMALL_CACHE_LIMIT 3000000
|
#define SMALL_CACHE_LIMIT 2000000
|
||||||
|
|
||||||
#define HUGE_CACHE_ITEMS 200
|
#define HUGE_CACHE_ITEMS 200
|
||||||
#define LARGE_CACHE_ITEMS 150
|
#define LARGE_CACHE_ITEMS 150
|
||||||
|
|||||||
@@ -1020,36 +1020,6 @@ bool WCache<cacheItem, cacheActual>::AttemptNew(cacheItem* item, int submode){
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Keep a bit of memory in reserve.
|
|
||||||
if(CACHE_SPACE_RESERVED > 0){
|
|
||||||
char * test = (char*)malloc(CACHE_SPACE_RESERVED);;
|
|
||||||
int tries = 0;
|
|
||||||
while(!test && tries++ < MAX_CACHE_ATTEMPTS){
|
|
||||||
if(!RemoveOldest())
|
|
||||||
break;
|
|
||||||
|
|
||||||
test = (char*)malloc(CACHE_SPACE_RESERVED);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(test){
|
|
||||||
free(test);
|
|
||||||
test = NULL;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
resources.ClearUnlocked();
|
|
||||||
test = (char*)malloc(CACHE_SPACE_RESERVED);
|
|
||||||
|
|
||||||
if(test){
|
|
||||||
free(test);
|
|
||||||
test = NULL;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
mError = CACHE_ERROR_BAD_ALLOC;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
string filename = makeFilename(item->id,submode);
|
string filename = makeFilename(item->id,submode);
|
||||||
|
|
||||||
if(!item->Attempt(filename,submode,mError)){
|
if(!item->Attempt(filename,submode,mError)){
|
||||||
@@ -1064,7 +1034,7 @@ bool WCache<cacheItem, cacheActual>::AttemptNew(cacheItem* item, int submode){
|
|||||||
if(!RemoveOldest())
|
if(!RemoveOldest())
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if(item->Attempt(filename,submode,mError))
|
if(item->Attempt(filename,submode,mError) && item->isGood())
|
||||||
break;
|
break;
|
||||||
|
|
||||||
//Failed attempt. Trash this.
|
//Failed attempt. Trash this.
|
||||||
@@ -1072,18 +1042,20 @@ bool WCache<cacheItem, cacheActual>::AttemptNew(cacheItem* item, int submode){
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!item->isGood()){
|
if(!item->isGood()){
|
||||||
|
item->Trash();
|
||||||
Cleanup();
|
Cleanup();
|
||||||
item->Attempt(filename,submode,mError);
|
item->Attempt(filename,submode,mError);
|
||||||
}
|
}
|
||||||
//Still no result, so clear cache entirely, then try again.
|
//Still no result, so clear cache entirely, then try again.
|
||||||
if(!item->isGood()){
|
if(!item->isGood()){
|
||||||
|
item->Trash();
|
||||||
ClearUnlocked();
|
ClearUnlocked();
|
||||||
item->Attempt(filename,submode,mError);
|
item->Attempt(filename,submode,mError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Final failure. Trash it.
|
//Final failure. Trash it.
|
||||||
if(!item->isGood()){
|
if(item && !item->isGood()){
|
||||||
item->Trash();
|
item->Trash();
|
||||||
mError = CACHE_ERROR_BAD;
|
mError = CACHE_ERROR_BAD;
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user