V2 llmessage merge, incl. llcommon requisites.

Excluded llareslistener, as that appears to only be present for unit-testing
Excluded new SSL methods because, well, they don't work right reliably in v2 for me
This commit is contained in:
Shyotl
2011-02-25 19:30:59 -06:00
parent 58edba5129
commit f9937d7f8a
53 changed files with 630 additions and 276 deletions

View File

@@ -343,3 +343,41 @@ bool LLAssetType::lookupIsLinkType(EType asset_type)
{
return (asset_type == AT_LINK || asset_type == AT_LINK_FOLDER);
}
// static
bool LLAssetType::lookupIsAssetFetchByIDAllowed(EType asset_type)
{
// *FIX: Make this list smaller.
switch(asset_type)
{
case LLAssetType::AT_SOUND:
case LLAssetType::AT_LANDMARK:
case LLAssetType::AT_CLOTHING:
case LLAssetType::AT_BODYPART:
case LLAssetType::AT_ANIMATION:
case LLAssetType::AT_GESTURE:
return true;
}
return false;
}
// static
bool LLAssetType::lookupIsAssetIDKnowable(EType asset_type)
{
switch(asset_type)
{
case LLAssetType::AT_TEXTURE:
case LLAssetType::AT_SOUND:
case LLAssetType::AT_LANDMARK:
case LLAssetType::AT_CLOTHING:
case LLAssetType::AT_NOTECARD:
case LLAssetType::AT_BODYPART:
case LLAssetType::AT_ANIMATION:
case LLAssetType::AT_GESTURE:
case LLAssetType::AT_LINK:
case LLAssetType::AT_LINK_FOLDER:
return true;
}
return false;
}

View File

@@ -30,8 +30,8 @@
* $/LicenseInfo$
*/
#ifndef LL_LLASSETTYPE
#define LL_LLASSETTYPE
#ifndef LL_LLASSETTYPE_H
#define LL_LLASSETTYPE_H
#include <string>
@@ -179,9 +179,12 @@ public:
static EType getType(const std::string& sin);
static std::string getDesc(EType type);
static bool lookupCanLink(EType asset_type);
static bool lookupIsLinkType(EType asset_type);
static bool lookupCanLink(EType asset_type);
static bool lookupIsLinkType(EType asset_type);
static bool lookupIsAssetFetchByIDAllowed(EType asset_type); // the asset allows direct download
static bool lookupIsAssetIDKnowable(EType asset_type); // asset data can be known by the viewer
private:
// don't instantiate or derive one of these objects
LLAssetType( void ) {}

View File

@@ -52,10 +52,10 @@ const U32 AVATAR_TRANSACTED = 0x1 << 3; // whether avatar has actively used p
const U32 AVATAR_ONLINE = 0x1 << 4; // the online status of this avatar, if known.
const U32 AVATAR_AGEVERIFIED = 0x1 << 5; // whether avatar has been age-verified
static const std::string VISIBILITY_DEFAULT("default");
static const std::string VISIBILITY_HIDDEN("hidden");
static const std::string VISIBILITY_VISIBLE("visible");
static const std::string VISIBILITY_INVISIBLE("invisible");
char const* const VISIBILITY_DEFAULT = "default";
char const* const VISIBILITY_HIDDEN = "hidden";
char const* const VISIBILITY_VISIBLE = "visible";
char const* const VISIBILITY_INVISIBLE = "invisible";
#endif

View File

@@ -290,7 +290,7 @@ namespace
public:
static LogControlFile& fromDirectory(const std::string& dir);
virtual void loadFile();
virtual bool loadFile();
private:
LogControlFile(const std::string &filename)
@@ -318,7 +318,7 @@ namespace
// NB: This instance is never freed
}
void LogControlFile::loadFile()
bool LogControlFile::loadFile()
{
LLSD configuration;
@@ -334,12 +334,13 @@ namespace
llwarns << filename() << " missing, ill-formed,"
" or simply undefined; not changing configuration"
<< llendl;
return;
return false;
}
}
LLError::configure(configuration);
llinfos << "logging reconfigured from " << filename() << llendl;
return true;
}
@@ -601,12 +602,18 @@ namespace LLError
s.printLocation = print;
}
void setFatalFunction(FatalFunction f)
void setFatalFunction(const FatalFunction& f)
{
Settings& s = Settings::get();
s.crashFunction = f;
}
FatalFunction getFatalFunction()
{
Settings& s = Settings::get();
return s.crashFunction;
}
void setTimeFunction(TimeFunction f)
{
Settings& s = Settings::get();
@@ -1211,14 +1218,17 @@ namespace LLError
void crashAndLoop(const std::string& message)
{
// Now, we go kaboom!
int* crash = NULL;
int* make_me_crash = NULL;
*crash = 0;
*make_me_crash = 0;
while(true)
{
// Loop forever, in case the crash didn't work?
}
// this is an attempt to let Coverity and other semantic scanners know that this function won't be returning ever.
exit(EXIT_FAILURE);
}
#if LL_WINDOWS
#pragma optimize("", on)

View File

@@ -242,7 +242,7 @@ typedef LLError::NoClassInfo _LL_CLASS_TO_LOG;
do { \
static LLError::CallSite _site( \
level, __FILE__, __LINE__, typeid(_LL_CLASS_TO_LOG), __FUNCTION__, broadTag, narrowTag, once);\
if (_site.shouldLog()) \
if (LL_UNLIKELY(_site.shouldLog())) \
{ \
std::ostringstream* _out = LLError::Log::out(); \
(*_out)

View File

@@ -35,7 +35,7 @@
#define LL_LLERRORCONTROL_H
#include "llerror.h"
#include "boost/function.hpp"
#include <string>
class LLSD;
@@ -95,16 +95,37 @@ namespace LLError
Control functions.
*/
typedef void(*FatalFunction)(const std::string& message);
typedef boost::function<void(const std::string&)> FatalFunction;
LL_COMMON_API void crashAndLoop(const std::string& message);
// Default fatal funtion: access null pointer and loops forever
// Default fatal function: access null pointer and loops forever
LL_COMMON_API void setFatalFunction(FatalFunction);
LL_COMMON_API void setFatalFunction(const FatalFunction&);
// The fatal function will be called when an message of LEVEL_ERROR
// is logged. Note: supressing a LEVEL_ERROR message from being logged
// (by, for example, setting a class level to LEVEL_NONE), will keep
// the that message from causing the fatal funciton to be invoked.
LL_COMMON_API FatalFunction getFatalFunction();
// Retrieve the previously-set FatalFunction
/// temporarily override the FatalFunction for the duration of a
/// particular scope, e.g. for unit tests
class LL_COMMON_API OverrideFatalFunction
{
public:
OverrideFatalFunction(const FatalFunction& func):
mPrev(getFatalFunction())
{
setFatalFunction(func);
}
~OverrideFatalFunction()
{
setFatalFunction(mPrev);
}
private:
FatalFunction mPrev;
};
typedef std::string (*TimeFunction)();
LL_COMMON_API std::string utcTime();

View File

@@ -45,7 +45,7 @@ static const char indraConfigFileName[] = "indra.xml";
LLIndraConfigFile::LLIndraConfigFile()
: LLLiveFile(filename(), configFileRefreshRate),
: LLLiveFile(filename()),
mConfig(LLSD())
{
}
@@ -84,7 +84,7 @@ std::string LLIndraConfigFile::filename()
}
/* virtual */
void LLIndraConfigFile::loadFile()
bool LLIndraConfigFile::loadFile()
{
llinfos << "LLIndraConfigFile::loadFile: reading from "
<< filename() << llendl;
@@ -102,17 +102,18 @@ void LLIndraConfigFile::loadFile()
{
llinfos << "LLIndraConfigFile::loadFile: file missing, ill-formed,"
" or simply undefined; not changing the blacklist" << llendl;
return;
return false;
}
}
if (config.isMap())
{
mConfig = config;
return true;
}
else
{
llwarns << "LLIndraConfigFile: " << indraConfigFileName << " expects a map; wrong format" << llendl;
return;
return false;
}
}

View File

@@ -54,7 +54,7 @@ private:
static std::string filename();
protected:
/* virtual */ void loadFile();
/* virtual */ bool loadFile();
LLSD mConfig;
};

View File

@@ -48,7 +48,7 @@ LLLiveAppConfig::~LLLiveAppConfig()
{ }
// virtual
void LLLiveAppConfig::loadFile()
bool LLLiveAppConfig::loadFile()
{
llinfos << "LLLiveAppConfig::loadFile(): reading from "
<< filename() << llendl;
@@ -59,12 +59,25 @@ void LLLiveAppConfig::loadFile()
LLSDSerialize::fromXML(config, file);
if(!config.isMap())
{
llinfos << "LLDataserverConfig::loadFile(): not an map!"
llwarns << "Live app config not an map in " << filename()
<< " Ignoring the data." << llendl;
return;
return false;
}
file.close();
}
else
{
llinfos << "Live file " << filename() << " does not exit." << llendl;
}
// *NOTE: we do not handle the else case here because we would not
// have attempted to load the file unless LLLiveFile had
// determined there was a reason to load it. This only happens
// when either the file has been updated or it is either suddenly
// in existence or has passed out of existence. Therefore, we want
// to set the config to an empty config, and return that it
// changed.
mApp->setOptionData(
LLApp::PRIORITY_SPECIFIC_CONFIGURATION, config);
return true;
}

View File

@@ -48,7 +48,7 @@ public:
~LLLiveAppConfig();
protected:
/*virtual*/ void loadFile();
/*virtual*/ bool loadFile();
private:
LLApp* mApp;

View File

@@ -35,6 +35,8 @@
#include "llframetimer.h"
#include "lltimer.h"
const F32 DEFAULT_CONFIG_FILE_REFRESH = 5.0f;
class LLLiveFile::Impl
{
public:
@@ -42,7 +44,7 @@ public:
~Impl();
bool check();
void changed();
bool mForceCheck;
F32 mRefreshPeriod;
@@ -50,16 +52,19 @@ public:
std::string mFilename;
time_t mLastModTime;
time_t mLastStatTime;
bool mLastExists;
LLEventTimer* mEventTimer;
};
LLLiveFile::Impl::Impl(const std::string &filename, const F32 refresh_period)
: mForceCheck(true),
LLLiveFile::Impl::Impl(const std::string& filename, const F32 refresh_period)
:
mForceCheck(true),
mRefreshPeriod(refresh_period),
mFilename(filename),
mLastModTime(0),
mLastStatTime(0),
mLastExists(false),
mEventTimer(NULL)
{
@@ -121,17 +126,29 @@ bool LLLiveFile::Impl::check()
// We want to read the file. Update status info for the file.
mLastExists = true;
mLastModTime = stat_data.st_mtime;
mLastStatTime = stat_data.st_mtime;
return true;
}
void LLLiveFile::Impl::changed()
{
// we wanted to read this file, and we were successful.
mLastModTime = mLastStatTime;
}
bool LLLiveFile::checkAndReload()
{
bool changed = impl.check();
if (changed)
{
loadFile();
if(loadFile())
{
impl.changed();
this->changed();
}
else
{
changed = false;
}
}
return changed;
}
@@ -167,3 +184,11 @@ void LLLiveFile::addToEventTimer()
impl.mEventTimer = new LiveFileEventTimer(*this, impl.mRefreshPeriod);
}
void LLLiveFile::setRefreshPeriod(F32 seconds)
{
if (seconds < 0.f)
{
seconds = -seconds;
}
impl.mRefreshPeriod = seconds;
}

View File

@@ -33,27 +33,65 @@
#ifndef LL_LLLIVEFILE_H
#define LL_LLLIVEFILE_H
const F32 configFileRefreshRate = 5.0; // seconds
extern const F32 DEFAULT_CONFIG_FILE_REFRESH;
class LL_COMMON_API LLLiveFile
{
public:
LLLiveFile(const std::string &filename, const F32 refresh_period = 5.f);
LLLiveFile(const std::string& filename, const F32 refresh_period = DEFAULT_CONFIG_FILE_REFRESH);
virtual ~LLLiveFile();
/**
* @brief Check to see if this live file should reload.
*
* Call this before using anything that was read & cached
* from the file.
*
* This method calls the <code>loadFile()</code> method if
* any of:
* file has a new modify time since the last check
* file used to exist and now does not
* file used to not exist but now does
* @return Returns true if the file was reloaded.
*/
bool checkAndReload();
// Returns true if the file changed in any way
// Call this before using anything that was read & cached from the file
std::string filename() const;
/**
* @brief Add this live file to an automated recheck.
*
* Normally, just calling checkAndReload() is enough. In some
* cases though, you may need to let the live file periodically
* check itself.
*/
void addToEventTimer();
// Normally, just calling checkAndReload() is enough. In some cases
// though, you may need to let the live file periodically check itself.
void setRefreshPeriod(F32 seconds);
protected:
virtual void loadFile() = 0; // Implement this to load your file if it changed
/**
* @breif Implement this to load your file if it changed.
*
* This method is called automatically by <code>checkAndReload()</code>,
* so though you must implement this in derived classes, you do
* not need to call it manually.
* @return Returns true if the file was successfully loaded.
*/
virtual bool loadFile() = 0;
/**
* @brief Implement this method if you want to get a change callback.
*
* This virtual function will be called automatically at the end
* of <code>checkAndReload()</code> if a new configuration was
* loaded. This does not track differences between the current and
* newly loaded file, so any successful load event will trigger a
* <code>changed()</code> callback. Default is to do nothing.
*/
virtual void changed() {}
private:
class Impl;

View File

@@ -62,7 +62,7 @@ public:
static std::string filename();
protected:
/* virtual */ void loadFile();
/* virtual */ bool loadFile();
public:
void init(LLPerfStats* statsp);
@@ -94,12 +94,12 @@ LLStatsConfigFile& LLStatsConfigFile::instance()
/* virtual */
// Load and parse the stats configuration file
void LLStatsConfigFile::loadFile()
bool LLStatsConfigFile::loadFile()
{
if (!mStatsp)
{
llwarns << "Tries to load performance configure file without initializing LPerfStats" << llendl;
return;
return false;
}
mChanged = true;
@@ -113,7 +113,7 @@ void LLStatsConfigFile::loadFile()
{
llinfos << "Performance statistics configuration file ill-formed, not recording statistics" << llendl;
mStatsp->setReportPerformanceDuration( 0.f );
return;
return false;
}
}
else
@@ -123,7 +123,7 @@ void LLStatsConfigFile::loadFile()
llinfos << "Performance statistics configuration file deleted, not recording statistics" << llendl;
mStatsp->setReportPerformanceDuration( 0.f );
}
return;
return true;
}
}
@@ -159,6 +159,7 @@ void LLStatsConfigFile::loadFile()
{
llinfos << "Performance stats recording turned off" << llendl;
}
return true;
}
@@ -327,6 +328,7 @@ U64 LLStatAccum::sScaleTimes[NUM_SCALES] =
LLStatAccum::LLStatAccum(bool useFrameTimer)
: mUseFrameTimer(useFrameTimer),
mRunning(FALSE),
mLastTime(0),
mLastSampleValue(0.0),
mLastSampleValid(FALSE)
{
@@ -347,7 +349,7 @@ void LLStatAccum::reset(U64 when)
{
mBuckets[i].accum = 0.0;
mBuckets[i].endTime = when + sScaleTimes[i];
mBuckets[i].lastValid = FALSE;
mBuckets[i].lastValid = false;
}
}
@@ -395,7 +397,7 @@ void LLStatAccum::sum(F64 value, U64 when)
{
F64 valueLeft = value * timeLeft / timeSpan;
bucket.lastValid = TRUE;
bucket.lastValid = true;
bucket.lastAccum = bucket.accum + (value - valueLeft);
bucket.accum = valueLeft;
bucket.endTime += timeScale;
@@ -404,7 +406,7 @@ void LLStatAccum::sum(F64 value, U64 when)
{
U64 timeTail = timeLeft % timeScale;
bucket.lastValid = TRUE;
bucket.lastValid = true;
bucket.lastAccum = value * timeScale / timeSpan;
bucket.accum = value * timeTail / timeSpan;
bucket.endTime += (timeLeft - timeTail) + timeScale;
@@ -726,7 +728,6 @@ LLFrameTimer LLStat::sFrameTimer;
LLStat::LLStat(const U32 num_bins, const BOOL use_frame_timer)
{
llassert(num_bins > 0);
U32 i;
mUseFrameTimer = use_frame_timer;
mNumValues = 0;
mLastValue = 0.f;
@@ -738,7 +739,7 @@ LLStat::LLStat(const U32 num_bins, const BOOL use_frame_timer)
mBeginTime = new F64[mNumBins];
mTime = new F64[mNumBins];
mDT = new F32[mNumBins];
for (i = 0; i < mNumBins; i++)
for (U32 i = 0; i < mNumBins; i++)
{
mBins[i] = 0.f;
mBeginTime[i] = 0.0;

View File

@@ -96,11 +96,18 @@ public:
struct Bucket
{
F64 accum;
U64 endTime;
Bucket() :
accum(0.0),
endTime(0),
lastValid(false),
lastAccum(0.0)
{}
BOOL lastValid;
F64 lastAccum;
F64 accum;
U64 endTime;
bool lastValid;
F64 lastAccum;
};
Bucket mBuckets[NUM_SCALES];