OK seriously, how dumb can i be?

This commit is contained in:
Siana Gearz
2011-10-13 18:55:16 +02:00
parent af74766ead
commit 41a305f52b
2 changed files with 7 additions and 22 deletions

View File

@@ -376,7 +376,7 @@ S32 LLImageJ2C::calcDataSizeJ2C(S32 w, S32 h, S32 comp, S32 discard_level, F32 r
discard_level--;
}
S32 bytes = (S32)((F32)(w*h*comp)*rate);
bytes = llmax(bytes, calcHeaderSizeJ2C());
//bytes = llmax(bytes, calcHeaderSizeJ2C());
return bytes;
}
@@ -396,9 +396,11 @@ S32 LLImageJ2C::calcDataSize(S32 discard_level)
static const LLCachedControl<S32> offset("SianaJ2CSizeOffset", 0);
S32 size = calcDataSizeJ2C(getWidth(), getHeight(), getComponents(), discard_level, mRate);
S32 size_d0 = calcDataSizeJ2C(getWidth(), getHeight(), getComponents(), discard_level, mRate);
return pow(size/size_d0, exponent)*size_d0 + offset;
S32 size_d0 = calcDataSizeJ2C(getWidth(), getHeight(), getComponents(), 0, mRate);
llassert_always(size_d0);
S32 bytes = pow(size/size_d0, exponent)*size_d0 + offset;
bytes = llmax(bytes, calcHeaderSizeJ2C());
return bytes;
}
discard_level = llclamp(discard_level, 0, MAX_DISCARD_LEVEL);
@@ -412,6 +414,7 @@ S32 LLImageJ2C::calcDataSize(S32 discard_level)
while ( level >= 0 )
{
mDataSizes[level] = calcDataSizeJ2C(getWidth(), getHeight(), getComponents(), level, mRate);
mDataSizes[level] = llmax(mDataSizes[level], calcHeaderSizeJ2C());
level--;
}

View File

@@ -400,7 +400,6 @@ class SGHostBlackList{
int errorCount;
};
static LLMutex* sMutex;
typedef std::vector<BlackListEntry> blacklist_t;
//Why is it a vector? because using std::map for just 1-2 values is insane-ish.
typedef blacklist_t::iterator iter;
@@ -423,22 +422,10 @@ class SGHostBlackList{
return blacklist.end();
}
static void lock() {
if (!sMutex)
sMutex = new LLMutex;
sMutex->lock();
}
static void unlock() {
sMutex->unlock();
}
public:
static bool isBlacklisted(std::string url) {
lock();
iter found = find(url);
bool r = (found != blacklist.end()) && (found->errorCount > MAX_ERRORCOUNT);
unlock();
return r;
}
@@ -450,7 +437,6 @@ public:
entry.timeUntil = LLTimer::getTotalTime() + timeout*1000;
entry.reason = reason;
entry.errorCount = 0;
lock();
iter found = find(entry.host);
if(found != blacklist.end()) {
entry.errorCount = found->errorCount + 1;
@@ -465,18 +451,14 @@ public:
}
}
else blacklist.push_back(entry);
unlock();
}
};
LLMutex* SGHostBlackList::sMutex = 0;
SGHostBlackList::blacklist_t SGHostBlackList::blacklist;
//call every time a connection is opened
//return true if connecting allowed
static bool sgConnectionThrottle() {
static LLMutex mutex;
LLMutexLock lock(&mutex);
const U32 THROTTLE_TIMESTEPS_PER_SECOND = 10;
static const LLCachedControl<U32> max_connections_per_second("HTTPRequestRate", 30);
U32 max_connections = max_connections_per_second/THROTTLE_TIMESTEPS_PER_SECOND;