Merge branch 'master' of https://bitbucket.org/Lirusaito/singularityviewer
This commit is contained in:
@@ -67,6 +67,7 @@ U32 ll_thread_local local_thread_ID = 0;
|
||||
#endif
|
||||
|
||||
U32 LLThread::sIDIter = 0;
|
||||
LLAtomicS32 LLThread::sCount = 0;
|
||||
|
||||
LL_COMMON_API void assert_main_thread()
|
||||
{
|
||||
@@ -125,6 +126,8 @@ LLThread::LLThread(std::string const& name) :
|
||||
mThreadLocalData(NULL)
|
||||
{
|
||||
mID = ++sIDIter;
|
||||
sCount++;
|
||||
llassert(sCount <= 50);
|
||||
mRunCondition = new LLCondition;
|
||||
}
|
||||
|
||||
@@ -175,7 +178,7 @@ void LLThread::shutdown()
|
||||
}
|
||||
mAPRThreadp = NULL;
|
||||
}
|
||||
|
||||
sCount--;
|
||||
delete mRunCondition;
|
||||
mRunCondition = 0;
|
||||
}
|
||||
|
||||
@@ -73,6 +73,7 @@ class LL_COMMON_API LLThread
|
||||
{
|
||||
private:
|
||||
static U32 sIDIter;
|
||||
static LLAtomicS32 sCount;
|
||||
|
||||
public:
|
||||
typedef enum e_thread_status
|
||||
@@ -90,6 +91,7 @@ public:
|
||||
bool isStopped() const { return (STOPPED == mStatus); }
|
||||
|
||||
static U32 currentID(); // Return ID of current thread
|
||||
static S32 getCount() { return sCount; }
|
||||
static void yield(); // Static because it can be called by the main thread, which doesn't have an LLThread data structure.
|
||||
|
||||
public:
|
||||
@@ -129,7 +131,7 @@ protected:
|
||||
apr_thread_t *mAPRThreadp;
|
||||
volatile EThreadStatus mStatus;
|
||||
U32 mID;
|
||||
|
||||
|
||||
friend void LLThreadLocalData::create(LLThread* threadp);
|
||||
LLThreadLocalData* mThreadLocalData;
|
||||
|
||||
|
||||
@@ -99,7 +99,6 @@ set(viewer_SOURCE_FILES
|
||||
ascentprefsvan.cpp
|
||||
dhparam.cpp
|
||||
dsaparam.cpp
|
||||
emerald.cpp
|
||||
emeraldboobutils.cpp
|
||||
dofloaterhex.cpp
|
||||
dohexeditor.cpp
|
||||
@@ -584,7 +583,6 @@ set(viewer_HEADER_FILES
|
||||
ascentprefschat.h
|
||||
ascentprefssys.h
|
||||
ascentprefsvan.h
|
||||
emerald.h
|
||||
emeraldboobutils.h
|
||||
dofloaterhex.h
|
||||
dohexeditor.h
|
||||
|
||||
@@ -8156,7 +8156,7 @@
|
||||
<key>Type</key>
|
||||
<string>F32</string>
|
||||
<key>Value</key>
|
||||
<real>600.0</real>
|
||||
<real>30.0</real>
|
||||
</map>
|
||||
<key>MemoryPrivatePoolEnabled</key>
|
||||
<map>
|
||||
|
||||
@@ -1,593 +0,0 @@
|
||||
// Copyright (c)2009 Thomas Shikami
|
||||
//
|
||||
// Permission to use, copy, modify, and/or distribute this software for any
|
||||
// purpose with or without fee is hereby granted, provided that the above
|
||||
// copyright notice and this permission notice appear in all copies.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
#include "llviewerprecompiledheaders.h"
|
||||
#include "emerald.h"
|
||||
#include <sstream>
|
||||
#include <cstring>
|
||||
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/dh.h>
|
||||
#include <openssl/dsa.h>
|
||||
|
||||
//-- Ascii85 encoder and decoder
|
||||
|
||||
typedef unsigned int U32;
|
||||
|
||||
static void encodeU32(unsigned int in, char *out)
|
||||
{
|
||||
out[4] = char(in % 85) + char(33);
|
||||
in /= 85;
|
||||
out[3] = char(in % 85) + char(33);
|
||||
in /= 85;
|
||||
out[2] = char(in % 85) + char(33);
|
||||
in /= 85;
|
||||
out[1] = char(in % 85) + char(33);
|
||||
in /= 85;
|
||||
out[0] = char(in % 85) + char(33);
|
||||
}
|
||||
|
||||
static unsigned int decodeU32(const char *in)
|
||||
{
|
||||
U32 out;
|
||||
|
||||
out = U32(in[0] - 33);
|
||||
out *= 85;
|
||||
out += U32(in[1] - 33);
|
||||
out *= 85;
|
||||
out += U32(in[2] - 33);
|
||||
out *= 85;
|
||||
out += U32(in[3] - 33);
|
||||
out *= 85;
|
||||
out += U32(in[4] - 33);
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
// static
|
||||
std::string EAscii85::encode(const std::vector<unsigned char> &in)
|
||||
{
|
||||
std::ostringstream out;
|
||||
U32 tuple;
|
||||
int count;
|
||||
char block[6];
|
||||
block[5] = '\0';
|
||||
|
||||
out << "<~";
|
||||
|
||||
count = 0;
|
||||
tuple = 0;
|
||||
for(size_t i = 0; i < in.size(); i++)
|
||||
{
|
||||
tuple <<= 8;
|
||||
tuple += in[i];
|
||||
if(++count == 4)
|
||||
{
|
||||
if(tuple == 0)
|
||||
{
|
||||
out << "z";
|
||||
}
|
||||
else
|
||||
{
|
||||
encodeU32(tuple, block);
|
||||
out << block;
|
||||
}
|
||||
count = 0;
|
||||
}
|
||||
}
|
||||
|
||||
switch(count)
|
||||
{
|
||||
case 1:
|
||||
tuple <<= 8;
|
||||
tuple += 255;
|
||||
// pass through
|
||||
case 2:
|
||||
tuple <<= 8;
|
||||
tuple += 255;
|
||||
// pass through
|
||||
case 3:
|
||||
tuple <<= 8;
|
||||
tuple += 255;
|
||||
}
|
||||
|
||||
encodeU32(tuple, block);
|
||||
|
||||
switch(count)
|
||||
{
|
||||
case 1:
|
||||
block[2] = '\0';
|
||||
break;
|
||||
case 2:
|
||||
block[3] = '\0';
|
||||
break;
|
||||
case 3:
|
||||
block[4] = '\0';
|
||||
break;
|
||||
}
|
||||
|
||||
if(count > 0)
|
||||
out << block;
|
||||
|
||||
out << "~>";
|
||||
|
||||
return out.str();
|
||||
}
|
||||
|
||||
// static
|
||||
std::vector<unsigned char> EAscii85::decode(const std::string &in)
|
||||
{
|
||||
std::vector<unsigned char> out;
|
||||
size_t len;
|
||||
int count = 0;
|
||||
char block[6];
|
||||
block[5] = '\0';
|
||||
U32 tuple;
|
||||
|
||||
// approximate length
|
||||
len = in.length() / 5 * 4;
|
||||
|
||||
out.clear();
|
||||
|
||||
if(in.length() < 4) return out;
|
||||
|
||||
std::string::const_iterator i = in.begin();
|
||||
|
||||
if(*i != '<') return out;
|
||||
i++;
|
||||
if(*i != '~') return out;
|
||||
i++;
|
||||
|
||||
out.reserve(len);
|
||||
|
||||
for(; i != in.end(); i++)
|
||||
{
|
||||
char c = *i;
|
||||
|
||||
if(c >= '!' && c < 'v')
|
||||
{
|
||||
block[count++] = c;
|
||||
}
|
||||
|
||||
switch(c)
|
||||
{
|
||||
case 'z':
|
||||
if(count == 1)
|
||||
{
|
||||
for(count = 0; count < 4; count++)
|
||||
out.push_back(0);
|
||||
count = 0;
|
||||
}
|
||||
break;
|
||||
case '~':
|
||||
if(count > 1)
|
||||
{
|
||||
switch(count)
|
||||
{
|
||||
case 2:
|
||||
block[2] = 'u';
|
||||
case 3:
|
||||
block[3] = 'u';
|
||||
case 4:
|
||||
block[4] = 'u';
|
||||
}
|
||||
tuple = decodeU32(block);
|
||||
for(;count > 1; count--)
|
||||
{
|
||||
out.push_back(char(tuple >> 24));
|
||||
tuple <<= 8;
|
||||
}
|
||||
count = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if(count == 5)
|
||||
{
|
||||
tuple = decodeU32(block);
|
||||
for(count = 0; count < 4; count++)
|
||||
{
|
||||
out.push_back(char(tuple >> 24));
|
||||
tuple <<= 8;
|
||||
}
|
||||
count = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
//-- AES wrapper
|
||||
|
||||
class EAESEncrypt::EncryptImpl {
|
||||
public:
|
||||
EncryptImpl(const unsigned char *key, const unsigned char *iv);
|
||||
~EncryptImpl();
|
||||
|
||||
std::vector<unsigned char> encrypt(const std::string &in);
|
||||
|
||||
EVP_CIPHER_CTX ctx;
|
||||
};
|
||||
|
||||
EAESEncrypt::EAESEncrypt(const unsigned char *key, const unsigned char *iv)
|
||||
{
|
||||
mEncryptImpl = new EAESEncrypt::EncryptImpl(key, iv);
|
||||
}
|
||||
|
||||
EAESEncrypt::EAESEncrypt(const std::vector<unsigned char> &key, const std::vector<unsigned char> &iv)
|
||||
{
|
||||
mEncryptImpl = new EAESEncrypt::EncryptImpl(&key[0], &iv[0]);
|
||||
}
|
||||
|
||||
EAESEncrypt::~EAESEncrypt()
|
||||
{
|
||||
delete mEncryptImpl;
|
||||
}
|
||||
|
||||
std::vector<unsigned char> EAESEncrypt::encrypt(const std::string &in)
|
||||
{
|
||||
return mEncryptImpl->encrypt(in);
|
||||
}
|
||||
|
||||
EAESEncrypt::EncryptImpl::EncryptImpl(const unsigned char *key, const unsigned char *iv)
|
||||
{
|
||||
EVP_CIPHER_CTX_init(&ctx);
|
||||
EVP_EncryptInit_ex(&ctx, EVP_aes_128_cbc(), NULL, key, iv);
|
||||
}
|
||||
|
||||
EAESEncrypt::EncryptImpl::~EncryptImpl()
|
||||
{
|
||||
EVP_CIPHER_CTX_cleanup(&ctx);
|
||||
}
|
||||
|
||||
std::vector<unsigned char> EAESEncrypt::EncryptImpl::encrypt(const std::string &in)
|
||||
{
|
||||
std::vector<unsigned char> out;
|
||||
int outlen;
|
||||
int tmplen;
|
||||
|
||||
out.resize(in.length() + 32);
|
||||
|
||||
EVP_EncryptUpdate(&ctx, &out[0], &outlen, reinterpret_cast<const unsigned char *>(in.c_str()), in.length());
|
||||
EVP_EncryptFinal_ex(&ctx, &out[outlen], &tmplen);
|
||||
|
||||
out.resize(outlen + tmplen);
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
class EAESDecrypt::DecryptImpl {
|
||||
public:
|
||||
DecryptImpl(const unsigned char *key, const unsigned char *iv);
|
||||
~DecryptImpl();
|
||||
|
||||
std::string decrypt(const std::vector<unsigned char> &in);
|
||||
|
||||
EVP_CIPHER_CTX ctx;
|
||||
};
|
||||
|
||||
EAESDecrypt::EAESDecrypt(const unsigned char *key, const unsigned char *iv)
|
||||
{
|
||||
mDecryptImpl = new EAESDecrypt::DecryptImpl(key, iv);
|
||||
}
|
||||
|
||||
EAESDecrypt::EAESDecrypt(const std::vector<unsigned char> &key, const std::vector<unsigned char> &iv)
|
||||
{
|
||||
mDecryptImpl = new EAESDecrypt::DecryptImpl(&key[0], &iv[0]);
|
||||
}
|
||||
|
||||
EAESDecrypt::~EAESDecrypt()
|
||||
{
|
||||
delete mDecryptImpl;
|
||||
}
|
||||
|
||||
EAESDecrypt::DecryptImpl::DecryptImpl(const unsigned char *key, const unsigned char *iv)
|
||||
{
|
||||
EVP_CIPHER_CTX_init(&ctx);
|
||||
EVP_DecryptInit_ex(&ctx, EVP_aes_128_cbc(), NULL, key, iv);
|
||||
}
|
||||
|
||||
EAESDecrypt::DecryptImpl::~DecryptImpl()
|
||||
{
|
||||
EVP_CIPHER_CTX_cleanup(&ctx);
|
||||
}
|
||||
|
||||
std::string EAESDecrypt::decrypt(const std::vector<unsigned char> &in)
|
||||
{
|
||||
return mDecryptImpl->decrypt(in);
|
||||
}
|
||||
|
||||
std::string EAESDecrypt::DecryptImpl::decrypt(const std::vector<unsigned char> &in)
|
||||
{
|
||||
std::vector<unsigned char> out;
|
||||
int outlen;
|
||||
int tmplen;
|
||||
|
||||
if(in.size() == 0) return "";
|
||||
|
||||
out.resize(in.size() + 32);
|
||||
|
||||
EVP_DecryptUpdate(&ctx, &out[0], &outlen, &in[0], in.size());
|
||||
EVP_DecryptFinal_ex(&ctx, &out[outlen], &tmplen);
|
||||
|
||||
out.resize(outlen + tmplen);
|
||||
|
||||
if(out.empty())
|
||||
return "";
|
||||
|
||||
return std::string(reinterpret_cast<const char *>(&out[0]), out.size());
|
||||
}
|
||||
|
||||
EGenKey::EGenKey(const std::string &password, const unsigned char *salt)
|
||||
{
|
||||
EVP_BytesToKey(EVP_aes_128_cbc(), EVP_sha1(), salt,
|
||||
reinterpret_cast<const unsigned char *>(password.c_str()), password.length(),
|
||||
1000, mKey, mIv);
|
||||
}
|
||||
|
||||
EGenKey::~EGenKey()
|
||||
{
|
||||
memset(mKey, 0, 16);
|
||||
memset(mIv, 0, 16);
|
||||
}
|
||||
|
||||
DH *get_dh2048();
|
||||
|
||||
class BigNum
|
||||
{
|
||||
public:
|
||||
BigNum(const std::vector<unsigned char> &bin)
|
||||
{
|
||||
mBN = BN_bin2bn(&(bin[0]), bin.size(), NULL);
|
||||
}
|
||||
|
||||
BigNum()
|
||||
{
|
||||
mBN = BN_new();
|
||||
}
|
||||
|
||||
BigNum(const BigNum &other)
|
||||
{
|
||||
mBN = BN_dup(*other);
|
||||
}
|
||||
|
||||
BigNum(BIGNUM *bn)
|
||||
{
|
||||
mBN = BN_dup(bn);
|
||||
}
|
||||
|
||||
~BigNum()
|
||||
{
|
||||
BN_clear_free(mBN);
|
||||
mBN = NULL;
|
||||
}
|
||||
|
||||
friend BIGNUM* operator*(const BigNum&);
|
||||
|
||||
BigNum& operator=(const std::vector<unsigned char> &bin)
|
||||
{
|
||||
mBN = BN_bin2bn(&(bin[0]), bin.size(), mBN);
|
||||
return *this;
|
||||
}
|
||||
|
||||
BigNum& operator=(const BigNum& other)
|
||||
{
|
||||
BN_copy(mBN, *other);
|
||||
return *this;
|
||||
}
|
||||
|
||||
void to(std::vector<unsigned char> &dest)
|
||||
{
|
||||
dest.resize(BN_num_bytes(mBN));
|
||||
BN_bn2bin(mBN, &(dest[0]));
|
||||
}
|
||||
|
||||
BIGNUM* to(BIGNUM *ret)
|
||||
{
|
||||
return BN_copy(ret, mBN);
|
||||
}
|
||||
|
||||
BIGNUM* dup()
|
||||
{
|
||||
return BN_dup(mBN);
|
||||
}
|
||||
|
||||
static BIGNUM* dup(const std::vector<unsigned char> &bin)
|
||||
{
|
||||
return BN_bin2bn(&(bin[0]), bin.size(), NULL);
|
||||
}
|
||||
|
||||
private:
|
||||
BIGNUM *mBN;
|
||||
};
|
||||
|
||||
BIGNUM* operator*(const BigNum& o) { return o.mBN; }
|
||||
|
||||
class EDH::DHImpl
|
||||
{
|
||||
public:
|
||||
DH *mDH;
|
||||
};
|
||||
|
||||
EDH::EDH(const std::vector<unsigned char> &priv_key)
|
||||
{
|
||||
mDHImpl = new DHImpl();
|
||||
|
||||
mDHImpl->mDH = get_dh2048();
|
||||
mDHImpl->mDH->priv_key = BigNum::dup(priv_key);
|
||||
|
||||
DH_generate_key(mDHImpl->mDH);
|
||||
}
|
||||
|
||||
EDH::EDH()
|
||||
{
|
||||
mDHImpl = new DHImpl();
|
||||
|
||||
mDHImpl->mDH = get_dh2048();
|
||||
|
||||
DH_generate_key(mDHImpl->mDH);
|
||||
}
|
||||
|
||||
EDH::~EDH()
|
||||
{
|
||||
if(mDHImpl)
|
||||
{
|
||||
if(mDHImpl->mDH)
|
||||
{
|
||||
mDHImpl->mDH->priv_key = NULL;
|
||||
mDHImpl->mDH->pub_key = NULL;
|
||||
DH_free(mDHImpl->mDH);
|
||||
mDHImpl->mDH = NULL;
|
||||
}
|
||||
delete mDHImpl;
|
||||
mDHImpl = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void EDH::secretTo(std::vector<unsigned char> &secret)
|
||||
{
|
||||
BigNum(mDHImpl->mDH->priv_key).to(secret);
|
||||
}
|
||||
|
||||
void EDH::publicTo(std::vector<unsigned char> &pub)
|
||||
{
|
||||
BigNum(mDHImpl->mDH->pub_key).to(pub);
|
||||
}
|
||||
|
||||
std::vector<unsigned char> EDH::computeKey(const std::vector<unsigned char> &other_pub)
|
||||
{
|
||||
std::vector<unsigned char> temp;
|
||||
BigNum pub(other_pub);
|
||||
temp.resize(DH_size(mDHImpl->mDH));
|
||||
|
||||
DH_compute_key(&(temp[0]), *pub, mDHImpl->mDH);
|
||||
|
||||
return temp;
|
||||
}
|
||||
|
||||
DSA *get_dsa2048();
|
||||
|
||||
class EDSA::DSAImpl
|
||||
{
|
||||
public:
|
||||
DSA *mDSA;
|
||||
};
|
||||
|
||||
EDSA::EDSA()
|
||||
{
|
||||
mDSAImpl = new DSAImpl();
|
||||
mDSAImpl->mDSA = get_dsa2048();
|
||||
}
|
||||
|
||||
EDSA::EDSA(const std::vector<unsigned char> &secret)
|
||||
{
|
||||
mDSAImpl = new DSAImpl();
|
||||
|
||||
const unsigned char *buf = &(secret[0]);
|
||||
|
||||
mDSAImpl->mDSA = d2i_DSAPrivateKey(NULL, &buf, secret.size());
|
||||
}
|
||||
|
||||
std::vector<unsigned char> EDSA::generateSecret()
|
||||
{
|
||||
DSA_generate_key(mDSAImpl->mDSA);
|
||||
|
||||
std::vector<unsigned char> temp;
|
||||
|
||||
int size = i2d_DSAPrivateKey(mDSAImpl->mDSA, NULL);
|
||||
|
||||
temp.resize(size);
|
||||
|
||||
unsigned char *buf = &(temp[0]);
|
||||
|
||||
i2d_DSAPrivateKey(mDSAImpl->mDSA, &buf);
|
||||
|
||||
return temp;
|
||||
}
|
||||
|
||||
std::vector<unsigned char> EDSA::getPublic()
|
||||
{
|
||||
std::vector<unsigned char> temp;
|
||||
|
||||
mDSAImpl->mDSA->write_params = 0;
|
||||
|
||||
int size = i2d_DSAPublicKey(mDSAImpl->mDSA, NULL);
|
||||
|
||||
temp.resize(size);
|
||||
|
||||
unsigned char *buf = &(temp[0]);
|
||||
|
||||
i2d_DSAPublicKey(mDSAImpl->mDSA, &buf);
|
||||
|
||||
return temp;
|
||||
}
|
||||
|
||||
void EDSA::setPublic(const std::vector<unsigned char> &pub)
|
||||
{
|
||||
const unsigned char *buf = &(pub[0]);
|
||||
|
||||
d2i_DSAPublicKey(&mDSAImpl->mDSA, &buf, pub.size());
|
||||
}
|
||||
|
||||
bool EDSA::verify(const std::vector<unsigned char> &dgst, const std::vector<unsigned char> &sig)
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
if(DSA_verify(0, &(dgst[0]), dgst.size(), &(sig[0]), sig.size(), mDSAImpl->mDSA) == 1)
|
||||
{
|
||||
result = true;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// static
|
||||
bool EDSA::verify(const std::vector<unsigned char> &dgst, const std::vector<unsigned char> &sig, const std::vector <unsigned char> &pub)
|
||||
{
|
||||
const unsigned char *buf = &(pub[0]);
|
||||
DSA *dsa;
|
||||
bool result = false;
|
||||
|
||||
dsa = get_dsa2048();
|
||||
|
||||
d2i_DSAPublicKey(&dsa, &buf, pub.size());
|
||||
|
||||
if(DSA_verify(0, &(dgst[0]), dgst.size(), &(sig[0]), sig.size(), dsa) == 1)
|
||||
{
|
||||
result = true;
|
||||
}
|
||||
|
||||
DSA_free(dsa);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
std::vector<unsigned char> EDSA::sign(const std::vector<unsigned char> &dgst)
|
||||
{
|
||||
std::vector<unsigned char> sig;
|
||||
unsigned int size = DSA_size(mDSAImpl->mDSA);
|
||||
|
||||
sig.resize(size);
|
||||
|
||||
DSA_sign(0, &(dgst[0]), dgst.size(), &(sig[0]), &size, mDSAImpl->mDSA);
|
||||
|
||||
sig.resize(size);
|
||||
|
||||
return sig;
|
||||
}
|
||||
|
||||
EDSA::~EDSA()
|
||||
{
|
||||
delete mDSAImpl;
|
||||
mDSAImpl = NULL;
|
||||
}
|
||||
@@ -1,107 +0,0 @@
|
||||
// Copyright (c)2009 Thomas Shikami
|
||||
//
|
||||
// Permission to use, copy, modify, and/or distribute this software for any
|
||||
// purpose with or without fee is hereby granted, provided that the above
|
||||
// copyright notice and this permission notice appear in all copies.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class EAscii85 {
|
||||
private:
|
||||
EAscii85() { }
|
||||
public:
|
||||
static std::string encode(const std::vector<unsigned char> &in);
|
||||
static std::vector<unsigned char> decode(const std::string &in);
|
||||
};
|
||||
|
||||
class EAESEncrypt {
|
||||
public:
|
||||
EAESEncrypt(const unsigned char *key, const unsigned char *iv);
|
||||
EAESEncrypt(const std::vector<unsigned char> &key, const std::vector<unsigned char> &iv);
|
||||
~EAESEncrypt();
|
||||
|
||||
std::vector<unsigned char> encrypt(const std::string &in);
|
||||
|
||||
private:
|
||||
EAESEncrypt(const EAESEncrypt&) {}
|
||||
|
||||
class EncryptImpl;
|
||||
|
||||
EncryptImpl *mEncryptImpl;
|
||||
};
|
||||
|
||||
class EAESDecrypt {
|
||||
public:
|
||||
EAESDecrypt(const unsigned char *key, const unsigned char *iv);
|
||||
EAESDecrypt(const std::vector<unsigned char> &key, const std::vector<unsigned char> &iv);
|
||||
~EAESDecrypt();
|
||||
|
||||
std::string decrypt(const std::vector<unsigned char> &in);
|
||||
|
||||
private:
|
||||
EAESDecrypt(const EAESDecrypt&) {}
|
||||
class DecryptImpl;
|
||||
|
||||
DecryptImpl *mDecryptImpl;
|
||||
};
|
||||
|
||||
class EGenKey {
|
||||
public:
|
||||
EGenKey(const std::string &password, const unsigned char *salt = 0);
|
||||
~EGenKey();
|
||||
|
||||
const unsigned char *key() const { return mKey; }
|
||||
const unsigned char *iv() const { return mIv; }
|
||||
|
||||
private:
|
||||
unsigned char mKey[16];
|
||||
unsigned char mIv[16];
|
||||
};
|
||||
|
||||
class EDH {
|
||||
public:
|
||||
EDH(const std::vector<unsigned char> &secret);
|
||||
EDH();
|
||||
~EDH();
|
||||
|
||||
void secretTo(std::vector<unsigned char> &secret);
|
||||
void publicTo(std::vector<unsigned char> &pub);
|
||||
std::vector<unsigned char> computeKey(const std::vector<unsigned char> &other_pub);
|
||||
|
||||
private:
|
||||
EDH(const EDH&) {}
|
||||
|
||||
class DHImpl;
|
||||
|
||||
DHImpl *mDHImpl;
|
||||
};
|
||||
|
||||
class EDSA {
|
||||
public:
|
||||
EDSA(const std::vector<unsigned char> &secret);
|
||||
EDSA();
|
||||
~EDSA();
|
||||
|
||||
std::vector<unsigned char> getPublic();
|
||||
void setPublic(const std::vector<unsigned char> &pub);
|
||||
std::vector<unsigned char> generateSecret();
|
||||
static bool verify(const std::vector<unsigned char> &dgst, const std::vector<unsigned char> &sig, const std::vector <unsigned char> &pub);
|
||||
bool verify(const std::vector<unsigned char> &dgst, const std::vector<unsigned char> &sig);
|
||||
std::vector<unsigned char> sign(const std::vector<unsigned char> &dgst);
|
||||
|
||||
private:
|
||||
EDSA(const EDSA&) {}
|
||||
|
||||
class DSAImpl;
|
||||
|
||||
DSAImpl *mDSAImpl;
|
||||
};
|
||||
@@ -105,9 +105,9 @@ void LLFloaterStats::buildStats()
|
||||
stat_barp = stat_viewp->addStat("Allocated memory", &(LLViewerStats::getInstance()->mMallocStat), "DebugStatModeMalloc");
|
||||
stat_barp->setUnitLabel(" MB");
|
||||
stat_barp->mMinBar = 0.f;
|
||||
stat_barp->mMaxBar = 4000.f;
|
||||
stat_barp->mTickSpacing = 100.f;
|
||||
stat_barp->mLabelSpacing = 200.f;
|
||||
stat_barp->mMaxBar = 2048.f;
|
||||
stat_barp->mTickSpacing = 128.f;
|
||||
stat_barp->mLabelSpacing = 512.f;
|
||||
stat_barp->mPerSec = FALSE;
|
||||
stat_barp->mDisplayMean = FALSE;
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ LLIconDictionary::LLIconDictionary()
|
||||
addEntry(LLInventoryIcon::ICONNAME_LINKFOLDER, new IconEntry("inv_link_folder.tga"));
|
||||
addEntry(LLInventoryIcon::ICONNAME_MESH, new IconEntry("inv_item_mesh.tga"));
|
||||
|
||||
addEntry(LLInventoryIcon::ICONNAME_INVALID, new IconEntry("Inv_Invalid.png"));
|
||||
addEntry(LLInventoryIcon::ICONNAME_INVALID, new IconEntry("inv_invalid.png"));
|
||||
|
||||
addEntry(LLInventoryIcon::ICONNAME_NONE, new IconEntry("NONE"));
|
||||
}
|
||||
|
||||
@@ -2,31 +2,25 @@
|
||||
* @file lltexturecache.cpp
|
||||
* @brief Object which handles local texture caching
|
||||
*
|
||||
* $LicenseInfo:firstyear=2000&license=viewergpl$
|
||||
*
|
||||
* Copyright (c) 2000-2009, Linden Research, Inc.
|
||||
*
|
||||
* $LicenseInfo:firstyear=2000&license=viewerlgpl$
|
||||
* Second Life Viewer Source Code
|
||||
* The source code in this file ("Source Code") is provided by Linden Lab
|
||||
* to you under the terms of the GNU General Public License, version 2.0
|
||||
* ("GPL"), unless you have obtained a separate licensing agreement
|
||||
* ("Other License"), formally executed by you and Linden Lab. Terms of
|
||||
* the GPL can be found in doc/GPL-license.txt in this distribution, or
|
||||
* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
|
||||
* Copyright (C) 2010, Linden Research, Inc.
|
||||
*
|
||||
* There are special exceptions to the terms and conditions of the GPL as
|
||||
* it is applied to this Source Code. View the full text of the exception
|
||||
* in the file doc/FLOSS-exception.txt in this software distribution, or
|
||||
* online at
|
||||
* http://secondlifegrid.net/programs/open_source/licensing/flossexception
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation;
|
||||
* version 2.1 of the License only.
|
||||
*
|
||||
* By copying, modifying or distributing this software, you acknowledge
|
||||
* that you have read and understood your obligations described above,
|
||||
* and agree to abide by those obligations.
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
|
||||
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
|
||||
* COMPLETENESS OR PERFORMANCE.
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
@@ -251,9 +245,9 @@ bool LLTextureCacheLocalFileWorker::doRead()
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (!mDataSize || mDataSize > local_size/* - mOffset*/)
|
||||
if (!mDataSize || mDataSize > local_size - mOffset)
|
||||
{
|
||||
mDataSize = local_size/* - mOffset*/;
|
||||
mDataSize = local_size - mOffset;
|
||||
}
|
||||
mReadData = (U8*)ALLOCATE_MEM(LLImageBase::getPrivatePool(), mDataSize);
|
||||
|
||||
@@ -333,6 +327,7 @@ bool LLTextureCacheRemoteWorker::doRead()
|
||||
// First state / stage : find out if the file is local
|
||||
if (mState == INIT)
|
||||
{
|
||||
#if 0
|
||||
std::string filename = mCache->getLocalFileName(mID);
|
||||
// Is it a JPEG2000 file?
|
||||
{
|
||||
@@ -367,20 +362,24 @@ bool LLTextureCacheRemoteWorker::doRead()
|
||||
}
|
||||
// Determine the next stage: if we found a file, then LOCAL else CACHE
|
||||
mState = (local_size > 0 ? LOCAL : CACHE);
|
||||
|
||||
llassert_always(mState == CACHE) ;
|
||||
#else
|
||||
mState = CACHE;
|
||||
#endif
|
||||
}
|
||||
|
||||
// Second state / stage : if the file is local, load it and leave
|
||||
if (!done && (mState == LOCAL))
|
||||
{
|
||||
llassert(local_size != 0); // we're assuming there is a non empty local file here...
|
||||
if (!mDataSize || mDataSize > local_size/* - mOffset*/)
|
||||
if (!mDataSize || mDataSize > local_size - mOffset)
|
||||
{
|
||||
mDataSize = local_size/* - mOffset*/;
|
||||
mDataSize = local_size - mOffset;
|
||||
}
|
||||
// Allocate read buffer
|
||||
mReadData = (U8*)ALLOCATE_MEM(LLImageBase::getPrivatePool(), mDataSize);
|
||||
S32 bytes_read = LLAPRFile::readEx(local_filename,
|
||||
mReadData, mOffset, mDataSize);
|
||||
S32 bytes_read = LLAPRFile::readEx(local_filename, mReadData, mOffset, mDataSize);
|
||||
if (bytes_read != mDataSize)
|
||||
{
|
||||
llwarns << "Error reading file from local cache: " << local_filename
|
||||
@@ -513,19 +512,9 @@ bool LLTextureCacheRemoteWorker::doRead()
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mImageSize > TEXTURE_CACHE_ENTRY_SIZE)
|
||||
{
|
||||
LL_DEBUGS("TextureCache") << "LLTextureCacheWorker: no body for texture: " << mID << LL_ENDL;
|
||||
FREE_MEM(LLImageBase::getPrivatePool(), mReadData);
|
||||
mReadData = NULL;
|
||||
mDataSize = -1; // failed
|
||||
done = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// No body, we're done.
|
||||
mDataSize = llmax(TEXTURE_CACHE_ENTRY_SIZE - mOffset, 0);
|
||||
}
|
||||
lldebugs << "No body file for: " << filename << llendl;
|
||||
}
|
||||
// Nothing else to do at that point...
|
||||
done = true;
|
||||
@@ -759,7 +748,6 @@ LLTextureCache::~LLTextureCache()
|
||||
{
|
||||
clearDeleteList();
|
||||
writeUpdatedEntries();
|
||||
purgeTextureFilesTimeSliced(true); // VWR-3878 - NB - force-flush all pending file deletes
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
@@ -1427,21 +1415,22 @@ void LLTextureCache::readHeaderCache()
|
||||
}
|
||||
}
|
||||
}
|
||||
if (num_entries - empty_entries > sCacheMaxEntries)
|
||||
if (num_entries > sCacheMaxEntries)
|
||||
{
|
||||
// Special case: cache size was reduced, need to remove entries
|
||||
// Note: After we prune entries, we will call this again and create the LRU
|
||||
U32 entries_to_purge = (num_entries - empty_entries) - sCacheMaxEntries;
|
||||
llinfos << "Texture Cache Entries: " << num_entries << " Max: " << sCacheMaxEntries << " Empty: " << empty_entries << " Purging: " << entries_to_purge << llendl;
|
||||
// We can exit the following loop with the given condition, since if we'd reach the end of the lru set we'd have:
|
||||
// purge_list.size() = lru.size() = num_entries - empty_entries = entries_to_purge + sCacheMaxEntries >= entries_to_purge
|
||||
// So, it's certain that iter will never reach lru.end() first.
|
||||
std::set<lru_data_t>::iterator iter = lru.begin();
|
||||
while (purge_list.size() < entries_to_purge)
|
||||
if (entries_to_purge > 0)
|
||||
{
|
||||
for (std::set<lru_data_t>::iterator iter = lru.begin(); iter != lru.end(); ++iter)
|
||||
{
|
||||
purge_list.insert(iter->second);
|
||||
++iter;
|
||||
if (purge_list.size() >= entries_to_purge)
|
||||
break;
|
||||
}
|
||||
}
|
||||
llassert_always(purge_list.size() >= entries_to_purge);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1555,18 +1544,11 @@ void LLTextureCache::purgeAllTextures(bool purge_directories)
|
||||
|
||||
void LLTextureCache::purgeTextures(bool validate)
|
||||
{
|
||||
mDoPurge = FALSE;
|
||||
|
||||
if (mReadOnly)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!validate && mTexturesSizeTotal <= sCacheMaxTexturesSize)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mThreaded)
|
||||
{
|
||||
// *FIX:Mani - watchdog off.
|
||||
@@ -1582,15 +1564,12 @@ void LLTextureCache::purgeTextures(bool validate)
|
||||
U32 num_entries = openAndReadEntries(entries);
|
||||
if (!num_entries)
|
||||
{
|
||||
LLAppViewer::instance()->resumeMainloopTimeout();
|
||||
return; // nothing to purge
|
||||
}
|
||||
|
||||
LL_INFOS("TextureCache") << "TEXTURE CACHE: Purging." << LL_ENDL;
|
||||
|
||||
// Use mTexturesSizeMap to collect UUIDs of textures with bodies
|
||||
typedef std::set<std::pair<U32,S32> > time_idx_set_t;
|
||||
time_idx_set_t time_idx_set;
|
||||
std::set<std::pair<U32,S32> > time_idx_set;
|
||||
for (size_map_t::iterator iter1 = mTexturesSizeMap.begin();
|
||||
iter1 != mTexturesSizeMap.end(); ++iter1)
|
||||
{
|
||||
@@ -1606,9 +1585,6 @@ void LLTextureCache::purgeTextures(bool validate)
|
||||
else
|
||||
{
|
||||
llerrs << "mTexturesSizeMap / mHeaderIDMap corrupted." << llendl ;
|
||||
//clearCorruptedCache();
|
||||
//LLAppViewer::instance()->resumeMainloopTimeout();
|
||||
//return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1661,8 +1637,7 @@ void LLTextureCache::purgeTextures(bool validate)
|
||||
{
|
||||
purge_count++;
|
||||
LL_DEBUGS("TextureCache") << "PURGING: " << filename << LL_ENDL;
|
||||
mFilesToDelete.insert(std::make_pair(entries[idx].mID, filename));
|
||||
removeEntry(idx, entries[idx], filename, false); // remove the entry but not the file
|
||||
removeEntry(idx, entries[idx], filename) ;
|
||||
cache_size -= entries[idx].mBodySize;
|
||||
}
|
||||
}
|
||||
@@ -1674,80 +1649,11 @@ void LLTextureCache::purgeTextures(bool validate)
|
||||
// *FIX:Mani - watchdog back on.
|
||||
LLAppViewer::instance()->resumeMainloopTimeout();
|
||||
|
||||
mSlicedPurgeTimer.reset();
|
||||
|
||||
LL_INFOS("TextureCache") << "TEXTURE CACHE:"
|
||||
<< " PURGED: " << purge_count
|
||||
<< " ENTRIES: " << num_entries
|
||||
<< " CACHE SIZE: " << mTexturesSizeTotal / (1024 * 1024) << " MB"
|
||||
<< " CACHE SIZE: " << mTexturesSizeTotal / 1024*1024 << " MB"
|
||||
<< llendl;
|
||||
|
||||
}
|
||||
|
||||
void LLTextureCache::purgeTextureFilesTimeSliced(bool force)
|
||||
{
|
||||
const F32 delay_between_passes = 2.0f; // seconds
|
||||
const F32 max_time_per_pass = 0.1f; // seconds
|
||||
|
||||
if (!force && mSlicedPurgeTimer.getElapsedTimeF32() <= delay_between_passes)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mFilesToDelete.empty())
|
||||
{
|
||||
LL_INFOS("TextureCache") << "time sliced purging with " << mFilesToDelete.size()
|
||||
<< " files scheduled for deletion" << LL_ENDL;
|
||||
|
||||
LLMutexLock lock(&mHeaderMutex);
|
||||
mSlicedPurgeTimer.reset();
|
||||
U32 purged = 0;
|
||||
std::string filename;
|
||||
|
||||
for (LLTextureCache::purge_map_t::iterator iter = mFilesToDelete.begin(); iter != mFilesToDelete.end(); )
|
||||
{
|
||||
LLTextureCache::purge_map_t::iterator curiter = iter++;
|
||||
// Only remove files for textures that have not been cached again
|
||||
// since we selected them for removal !
|
||||
if (mHeaderIDMap.find(curiter->first) == mHeaderIDMap.end())
|
||||
{
|
||||
filename = curiter->second;
|
||||
if(LLAPRFile::isExist(filename))
|
||||
LLAPRFile::remove(filename);
|
||||
}
|
||||
else
|
||||
{
|
||||
LL_DEBUGS("TextureCache") << curiter->second
|
||||
<< " selected for removal, but texture cached again since !"
|
||||
<< LL_ENDL;
|
||||
}
|
||||
mFilesToDelete.erase(curiter);
|
||||
purged++;
|
||||
|
||||
if (!force && mSlicedPurgeTimer.getElapsedTimeF32() > max_time_per_pass)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (mFilesToDelete.empty())
|
||||
{
|
||||
LL_INFOS("TextureCache") << "time sliced purge finished with " << purged
|
||||
<< " files deleted in "
|
||||
<< mSlicedPurgeTimer.getElapsedTimeF32()
|
||||
<< "s" << LL_ENDL;
|
||||
}
|
||||
else
|
||||
{
|
||||
LL_INFOS("TextureCache") << "time sliced purge: " << purged
|
||||
<< " files deleted in "
|
||||
<< mSlicedPurgeTimer.getElapsedTimeF32()
|
||||
<< "s (" << mFilesToDelete.size()
|
||||
<< " files left for next pass)" << LL_ENDL;
|
||||
}
|
||||
|
||||
mSlicedPurgeTimer.reset();
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
@@ -1888,11 +1794,12 @@ LLTextureCache::handle_t LLTextureCache::writeToCache(const LLUUID& id, U32 prio
|
||||
}
|
||||
if (mDoPurge)
|
||||
{
|
||||
// NOTE: This may cause an occasional hiccup,
|
||||
// but it really needs to be done on the control thread
|
||||
// (i.e. here)
|
||||
purgeTextures(false);
|
||||
mDoPurge = FALSE;
|
||||
}
|
||||
|
||||
purgeTextureFilesTimeSliced(); // VWR-3878 - NB - purge textures from cache in a non-hiccup-way
|
||||
|
||||
LLMutexLock lock(&mWorkersMutex);
|
||||
LLTextureCacheWorker* worker = new LLTextureCacheRemoteWorker(this, priority, id,
|
||||
data, datasize, 0,
|
||||
@@ -1951,7 +1858,7 @@ void LLTextureCache::removeCachedTexture(const LLUUID& id)
|
||||
}
|
||||
|
||||
//called after mHeaderMutex is locked.
|
||||
void LLTextureCache::removeEntry(S32 idx, Entry& entry, std::string& filename, bool remove_file)
|
||||
void LLTextureCache::removeEntry(S32 idx, Entry& entry, std::string& filename)
|
||||
{
|
||||
bool file_maybe_exists = true; // Always attempt to remove when idx is invalid.
|
||||
|
||||
@@ -1969,16 +1876,16 @@ void LLTextureCache::removeEntry(S32 idx, Entry& entry, std::string& filename, b
|
||||
}
|
||||
}
|
||||
|
||||
mTexturesSizeTotal -= entry.mBodySize;
|
||||
entry.mImageSize = -1;
|
||||
entry.mBodySize = 0;
|
||||
mHeaderIDMap.erase(entry.mID);
|
||||
mTexturesSizeMap.erase(entry.mID);
|
||||
|
||||
mTexturesSizeTotal -= entry.mBodySize;
|
||||
mFreeList.insert(idx);
|
||||
}
|
||||
|
||||
if (remove_file && file_maybe_exists)
|
||||
if (file_maybe_exists)
|
||||
{
|
||||
LLAPRFile::remove(filename);
|
||||
}
|
||||
|
||||
@@ -2,31 +2,25 @@
|
||||
* @file lltexturecache.h
|
||||
* @brief Object for managing texture cachees.
|
||||
*
|
||||
* $LicenseInfo:firstyear=2000&license=viewergpl$
|
||||
*
|
||||
* Copyright (c) 2000-2009, Linden Research, Inc.
|
||||
*
|
||||
* $LicenseInfo:firstyear=2000&license=viewerlgpl$
|
||||
* Second Life Viewer Source Code
|
||||
* The source code in this file ("Source Code") is provided by Linden Lab
|
||||
* to you under the terms of the GNU General Public License, version 2.0
|
||||
* ("GPL"), unless you have obtained a separate licensing agreement
|
||||
* ("Other License"), formally executed by you and Linden Lab. Terms of
|
||||
* the GPL can be found in doc/GPL-license.txt in this distribution, or
|
||||
* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
|
||||
* Copyright (C) 2010, Linden Research, Inc.
|
||||
*
|
||||
* There are special exceptions to the terms and conditions of the GPL as
|
||||
* it is applied to this Source Code. View the full text of the exception
|
||||
* in the file doc/FLOSS-exception.txt in this software distribution, or
|
||||
* online at
|
||||
* http://secondlifegrid.net/programs/open_source/licensing/flossexception
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation;
|
||||
* version 2.1 of the License only.
|
||||
*
|
||||
* By copying, modifying or distributing this software, you acknowledge
|
||||
* that you have read and understood your obligations described above,
|
||||
* and agree to abide by those obligations.
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
|
||||
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
|
||||
* COMPLETENESS OR PERFORMANCE.
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
@@ -154,7 +148,6 @@ private:
|
||||
void clearCorruptedCache();
|
||||
void purgeAllTextures(bool purge_directories);
|
||||
void purgeTextures(bool validate);
|
||||
void purgeTextureFilesTimeSliced(bool force = false);
|
||||
LLAPRFile* openHeaderEntriesFile(bool readonly, S32 offset);
|
||||
void closeHeaderEntriesFile();
|
||||
void readEntriesHeader();
|
||||
@@ -166,7 +159,7 @@ private:
|
||||
void writeEntriesAndClose(const std::vector<Entry>& entries);
|
||||
void readEntryFromHeaderImmediately(S32& idx, Entry& entry) ;
|
||||
void writeEntryToHeaderImmediately(S32& idx, Entry& entry, bool write_header = false) ;
|
||||
void removeEntry(S32 idx, Entry& entry, std::string& filename, bool remove_file = true);
|
||||
void removeEntry(S32 idx, Entry& entry, std::string& filename);
|
||||
void removeCachedTexture(const LLUUID& id) ;
|
||||
S32 getHeaderCacheEntry(const LLUUID& id, Entry& entry);
|
||||
S32 setHeaderCacheEntry(const LLUUID& id, Entry& entry, S32 imagesize, S32 datasize);
|
||||
@@ -192,10 +185,6 @@ private:
|
||||
typedef std::vector<std::pair<LLPointer<Responder>, bool> > responder_list_t;
|
||||
responder_list_t mCompletedList;
|
||||
|
||||
typedef std::map<LLUUID, std::string> purge_map_t;
|
||||
purge_map_t mFilesToDelete;
|
||||
LLTimer mSlicedPurgeTimer;
|
||||
|
||||
BOOL mReadOnly;
|
||||
|
||||
// HEADERS (Include first mip)
|
||||
|
||||
@@ -83,6 +83,7 @@
|
||||
#include "llwlparammanager.h"
|
||||
#include "llwaterparammanager.h"
|
||||
#include "llpostprocess.h"
|
||||
#include "sgmemstat.h"
|
||||
|
||||
// [RLVa:KB]
|
||||
#include "rlvhandler.h"
|
||||
@@ -228,6 +229,8 @@ void display_stats()
|
||||
gMemoryAllocated = LLMemory::getCurrentRSS();
|
||||
U32 memory = (U32)(gMemoryAllocated / (1024*1024));
|
||||
llinfos << llformat("MEMORY: %d MB", memory) << llendl;
|
||||
llinfos << "THREADS: "<< LLThread::getCount() << llendl;
|
||||
llinfos << "MALLOC: " << SGMemStat::getPrintableStat() <<llendl;
|
||||
LLMemory::logMemoryInfo(TRUE) ;
|
||||
gRecentMemoryTime.reset();
|
||||
}
|
||||
|
||||
@@ -61,6 +61,7 @@
|
||||
#include "llfeaturemanager.h"
|
||||
#include "llviewernetwork.h"
|
||||
#include "llmeshrepository.h" //for LLMeshRepository::sBytesReceived
|
||||
#include "sgmemstat.h"
|
||||
#if LL_LCD_COMPILE
|
||||
#include "lllcd.h"
|
||||
#endif
|
||||
@@ -689,6 +690,17 @@ void update_statistics(U32 frame_count)
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
static const F32 mem_stats_freq = 10.f;
|
||||
static LLFrameTimer mem_stats_timer;
|
||||
if (mem_stats_timer.getElapsedTimeF32() >= mem_stats_freq)
|
||||
{
|
||||
LLViewerStats::getInstance()->mMallocStat.addValue(SGMemStat::getMalloc()/1024.f/1024.f);
|
||||
mem_stats_timer.reset();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if LL_LCD_COMPILE
|
||||
bool LCDenabled = gLcdScreen->Enabled();
|
||||
LLViewerStats::getInstance()->setStat(LLViewerStats::ST_LOGITECH_LCD, LCDenabled);
|
||||
|
||||
@@ -1118,6 +1118,7 @@ LLVoiceClient::LLVoiceClient()
|
||||
mMuteMic = false;
|
||||
mSessionTerminateRequested = false;
|
||||
mRelogRequested = false;
|
||||
mConnected = false;
|
||||
mCommandCookie = 0;
|
||||
mCurrentParcelLocalID = 0;
|
||||
mLoginRetryCount = 0;
|
||||
|
||||
@@ -467,7 +467,7 @@ bool RlvUtil::sendChatReply(S32 nChannel, const std::string& strUTF8Text)
|
||||
gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
|
||||
gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
|
||||
gMessageSystem->nextBlockFast(_PREHASH_ChatData);
|
||||
gMessageSystem->addStringFast(_PREHASH_Message, strUTF8Text);
|
||||
gMessageSystem->addStringFast(_PREHASH_Message, utf8str_truncate(strUTF8Text, MAX_MSG_STR_LEN));
|
||||
gMessageSystem->addU8Fast(_PREHASH_Type, CHAT_TYPE_SHOUT);
|
||||
gMessageSystem->addS32("Channel", nChannel);
|
||||
gAgent.sendReliableMessage();
|
||||
|
||||
@@ -18,14 +18,80 @@
|
||||
#include "llviewerprecompiledheaders.h"
|
||||
#include "sgmemstat.h"
|
||||
|
||||
#if (!LL_WINDOWS && !LL_LINUX)
|
||||
bool SGMemStat::haveStat() {
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
F32 SGMemStat::getMalloc() {
|
||||
return 0.f;
|
||||
return 0.f;
|
||||
}
|
||||
|
||||
U32 SGMemStat::getNumObjects() {
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::string SGMemStat::getPrintableStat() {
|
||||
return std::string();
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
extern "C" {
|
||||
typedef void (*MallocExtension_GetStats_t)(char* buffer, int buffer_length);
|
||||
typedef int (*MallocExtension_GetNumericProperty_t)(const char* property, size_t* value);
|
||||
//typedef int (*MallocExtension_SetNumericProperty_t)(const char* property, size_t value);
|
||||
}
|
||||
|
||||
static MallocExtension_GetNumericProperty_t MallocExtension_GetNumericProperty = 0;
|
||||
static MallocExtension_GetStats_t MallocExtension_GetStats = 0;
|
||||
|
||||
static void initialize() {
|
||||
static bool initialized = false;
|
||||
if (!initialized) {
|
||||
apr_dso_handle_t* hprog = 0;
|
||||
LLAPRPool pool;
|
||||
pool.create();
|
||||
#if LL_WINDOWS
|
||||
apr_dso_load(&hprog, "libtcmalloc_minimal.dll", pool());
|
||||
#else
|
||||
apr_dso_load(&hprog, 0, pool());
|
||||
#endif
|
||||
apr_dso_sym((apr_dso_handle_sym_t*)&MallocExtension_GetNumericProperty,
|
||||
hprog, "MallocExtension_GetNumericProperty");
|
||||
apr_dso_sym((apr_dso_handle_sym_t*)&MallocExtension_GetStats,
|
||||
hprog, "MallocExtension_GetStats");
|
||||
initialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
bool SGMemStat::haveStat() {
|
||||
initialize();
|
||||
return MallocExtension_GetNumericProperty;
|
||||
}
|
||||
|
||||
F32 SGMemStat::getMalloc() {
|
||||
if(MallocExtension_GetNumericProperty) {
|
||||
size_t value;
|
||||
MallocExtension_GetNumericProperty("generic.current_allocated_bytes", &value);
|
||||
return value;
|
||||
}
|
||||
else return 0.0f;
|
||||
}
|
||||
|
||||
U32 SGMemStat::getNumObjects() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::string SGMemStat::getPrintableStat() {
|
||||
initialize();
|
||||
if (MallocExtension_GetStats) {
|
||||
char buffer[4096];
|
||||
buffer[4095] = 0;
|
||||
MallocExtension_GetStats(buffer, 4095);
|
||||
return std::string(buffer);
|
||||
}
|
||||
else return std::string();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -26,6 +26,8 @@ F32 getMalloc();
|
||||
|
||||
U32 getNumObjects();
|
||||
|
||||
std::string getPrintableStat();
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
Before Width: | Height: | Size: 460 B After Width: | Height: | Size: 460 B |
@@ -490,12 +490,12 @@
|
||||
<menu_item_separator bottom="-94" enabled="true" height="8" label="-----------" left="0"
|
||||
mouse_opaque="true" name="separator" width="185" />
|
||||
<menu_item_call bottom="-113" enabled="true" height="19" label="Create Landmark Here" left="0"
|
||||
mouse_opaque="true" name="Create Landmark Here" width="185">
|
||||
mouse_opaque="true" name="Create Landmark Here" shortcut="control|shift|D" width="185">
|
||||
<on_click function="World.CreateLandmark" userdata="" />
|
||||
<on_enable function="World.EnableCreateLandmark" userdata="" />
|
||||
</menu_item_call>
|
||||
<menu_item_call bottom="-132" enabled="true" height="19" label="Set Home to Here" left="0"
|
||||
mouse_opaque="true" name="Set Home to Here" shortcut="control|D" width="185">
|
||||
mouse_opaque="true" name="Set Home to Here" width="185">
|
||||
<on_click function="World.SetHomeLocation" userdata="" />
|
||||
<on_enable function="World.EnableSetHomeLocation" userdata="" />
|
||||
</menu_item_call>
|
||||
|
||||
@@ -14,6 +14,6 @@
|
||||
<button bottom_delta="0" control_name="MuteAmbient" follows="top" height="16" image_selected="icn_speaker-muted_dark.tga" image_unselected="icn_speaker_dark.tga" right="-28" label="" name="mute_wind" toggle="true" width="25"/>
|
||||
<slider control_name="AudioLevelUI" follows="top" height="15" increment="0.005" initial_val="0.5" label="UI" label_width="55" left="10" max_val="1" min_val="0" name="UI Volume" show_text="false" volume="true" width="181"/>
|
||||
<button bottom_delta="0" control_name="MuteUI" follows="top" height="16" image_selected="icn_speaker-muted_dark.tga" image_unselected="icn_speaker_dark.tga" right="-28" label="" name="mute_ui" toggle="true" width="25"/>
|
||||
<button bottom_delta="-18" follows="top" control_name="SinguMuteGestures" font="SansSerifSmall" height="16" label_selected="Unmute Gestures" label_unselected="Mute Gestures" image_selected="inv_item_gesture_muted.tga" image_unselected="inv_item_gesture.tga" right="-10" left="10" name="Mute gestures" toggle="true" tool_tip="When active, gesture sounds other than your own will not be played for you."/>
|
||||
<button bottom_delta="-18" follows="top" control_name="SinguMuteGestures" font="SansSerifSmall" height="16" label_selected="Unmute Gestures" label_unselected="Mute Gestures" image_selected="inv_item_gesture_muted.tga" image_unselected="inv_item_gesture.tga" scale_image="false" right="-10" left="10" name="Mute gestures" toggle="true" tool_tip="When active, gesture sounds other than your own will not be played for you."/>
|
||||
<button bottom_delta="0" follows="top" control_name="SinguMuteGestures" height="16" image_selected="icn_speaker-muted_dark.tga" image_unselected="icn_speaker_dark.tga" right="-28" label="" toggle="true" width="25"/>
|
||||
</panel>
|
||||
|
||||
Reference in New Issue
Block a user