Merge remote-tracking branch 'lirusato/Frosting'

This commit is contained in:
Latif Khalifa
2013-03-24 14:22:02 +01:00
2167 changed files with 11840 additions and 9984 deletions

View File

@@ -70,10 +70,6 @@ if(STANDALONE)
add_subdirectory(${LIBS_OPEN_PREFIX}llqtwebkit)
endif(STANDALONE)
if (EXISTS ${LIBS_CLOSED_DIR}llkdu AND NOT STANDALONE)
add_subdirectory(${LIBS_CLOSED_PREFIX}llkdu)
endif (EXISTS ${LIBS_CLOSED_DIR}llkdu AND NOT STANDALONE)
#add_subdirectory(${LIBS_OPEN_PREFIX}lscript)
if (WINDOWS AND EXISTS ${LIBS_CLOSED_DIR}copy_win_scripts)
@@ -81,73 +77,43 @@ if (WINDOWS AND EXISTS ${LIBS_CLOSED_DIR}copy_win_scripts)
endif (WINDOWS AND EXISTS ${LIBS_CLOSED_DIR}copy_win_scripts)
add_custom_target(viewer)
if (VIEWER)
add_subdirectory(${LIBS_OPEN_PREFIX}llcrashlogger)
add_subdirectory(${LIBS_OPEN_PREFIX}llplugin)
add_subdirectory(${LIBS_OPEN_PREFIX}llui)
add_subdirectory(${LIBS_OPEN_PREFIX}llcrashlogger)
add_subdirectory(${LIBS_OPEN_PREFIX}llplugin)
add_subdirectory(${LIBS_OPEN_PREFIX}llui)
# viewer plugins directory
add_subdirectory(${LIBS_OPEN_PREFIX}plugins)
# viewer plugins directory
add_subdirectory(${LIBS_OPEN_PREFIX}plugins)
# llplugin testbed code (is this the right way to include it?)
#if (NOT LINUX)
# add_subdirectory(${VIEWER_PREFIX}test_apps/llplugintest)
#endif (NOT LINUX)
# llplugin testbed code (is this the right way to include it?)
#if (NOT LINUX)
# add_subdirectory(${VIEWER_PREFIX}test_apps/llplugintest)
#endif (NOT LINUX)
if (LINUX)
add_subdirectory(${VIEWER_PREFIX}linux_crash_logger)
add_dependencies(viewer linux-crash-logger-strip-target)
elseif (DARWIN)
#add_subdirectory(${VIEWER_PREFIX}mac_crash_logger)
#add_subdirectory(${VIEWER_PREFIX}mac_updater)
add_dependencies(viewer mac-crash-logger)
#add_dependencies(viewer mac-updater)
elseif (WINDOWS)
add_subdirectory(${VIEWER_PREFIX}win_crash_logger)
# cmake EXISTS requires an absolute path, see indra/cmake/Variables.cmake
if (EXISTS ${VIEWER_DIR}win_setup)
add_subdirectory(${VIEWER_DIR}win_setup)
endif (EXISTS ${VIEWER_DIR}win_setup)
add_subdirectory(${VIEWER_PREFIX}win_updater)
add_dependencies(viewer windows-updater)
add_dependencies(viewer windows-crash-logger)
elseif (SOLARIS)
add_subdirectory(solaris_crash_logger)
add_dependencies(viewer solaris-crash-logger)
endif (LINUX)
add_subdirectory(${VIEWER_PREFIX}newview/statemachine)
add_subdirectory(${VIEWER_PREFIX}newview)
add_dependencies(viewer secondlife-bin)
endif (VIEWER)
# Linux builds the viewer and server in 2 separate projects
# In order for ./develop.py build server to work on linux,
# the viewer project needs a server target.
# This is not true for mac and windows.
if (LINUX)
add_custom_target(server)
if (LINUX)
add_subdirectory(${VIEWER_PREFIX}linux_crash_logger)
add_dependencies(viewer linux-crash-logger-strip-target)
elseif (DARWIN)
#add_subdirectory(${VIEWER_PREFIX}mac_crash_logger)
#add_subdirectory(${VIEWER_PREFIX}mac_updater)
add_dependencies(viewer mac-crash-logger)
#add_dependencies(viewer mac-updater)
elseif (WINDOWS)
add_subdirectory(${VIEWER_PREFIX}win_crash_logger)
# cmake EXISTS requires an absolute path, see indra/cmake/Variables.cmake
if (EXISTS ${VIEWER_DIR}win_setup)
add_subdirectory(${VIEWER_DIR}win_setup)
endif (EXISTS ${VIEWER_DIR}win_setup)
add_subdirectory(${VIEWER_PREFIX}win_updater)
add_dependencies(viewer windows-updater)
add_dependencies(viewer windows-crash-logger)
elseif (SOLARIS)
add_subdirectory(solaris_crash_logger)
add_dependencies(viewer solaris-crash-logger)
endif (LINUX)
if (SERVER)
if (NOT LINUX)
add_custom_target(server)
endif (NOT LINUX)
include(${SERVER_PREFIX}Server.cmake)
endif (SERVER)
# Windows builds include tools like VFS tool
if (SERVER)
if (WINDOWS)
add_subdirectory(${SERVER_PREFIX}tools)
endif (WINDOWS)
endif (SERVER)
# Configure prebuilt binary download. This must be done last so that
# all subdirectories have a chance to list the packages they need.
# We need scp for proprietary downloads.
if(INSTALL_PROPRIETARY)
include(FindSCP)
endif(INSTALL_PROPRIETARY)
add_subdirectory(${VIEWER_PREFIX}newview/statemachine)
add_subdirectory(${VIEWER_PREFIX}newview)
add_dependencies(viewer secondlife-bin)
# The use_prebuilt_binary macro in cmake/Prebuilt.cmake records
# packages in the PREBUILT property of the 'prepare' target.

File diff suppressed because it is too large Load Diff

View File

@@ -2,7 +2,7 @@
* @file aistatemachine.h
* @brief State machine base class
*
* Copyright (c) 2010, Aleric Inglewood.
* Copyright (c) 2010 - 2013, Aleric Inglewood.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -26,397 +26,290 @@
*
* 01/03/2010
* Initial version, written by Aleric Inglewood @ SL
*
* 28/02/2013
* Rewritten from scratch to fully support threading.
*/
#ifndef AISTATEMACHINE_H
#define AISTATEMACHINE_H
#include "aithreadsafe.h"
#include "lltimer.h"
#include <llpointer.h>
#include <list>
#include <boost/signals2.hpp>
//!
// A AIStateMachine is a base class that allows derived classes to
// go through asynchronous states, while the code still appears to
// be more or less sequential.
//
// These state machine objects can be reused to build more complex
// objects.
//
// It is important to note that each state has a duality: the object
// can have a state that will cause a corresponding function to be
// called; and often that function will end with changing the state
// again, to signal that it was handled. It is easy to confuse the
// function of a state with the state at the end of the function.
// For example, the state "initialize" could cause the member
// function 'init()' to be called, and at the end one would be
// inclined to set the state to "initialized". However, this is the
// wrong approach: the correct use of state names does reflect the
// functions that will be called, never the function that just was
// called.
//
// Each (derived) class goes through a series of states as follows:
//
// Creation
// |
// v
// (idle) <----. Idle until run() is called.
// | |
// Initialize | Calls initialize_impl().
// | |
// | (idle) | Idle until cont() or set_state() is called.
// | | ^ |
// v v | |
// .-------. | |
// | Run |_, | Call multiplex_impl() until idle(), abort() or finish() is called.
// '-------' |
// | | |
// v | |
// Abort | | Calls abort_impl().
// | | |
// v v |
// Finish | Calls finish_impl() (which may call kill()) or
// | | | the callback function passed to run(), if any,
// | v |
// | Callback | which may call kill() and/or run().
// | | | |
// | | `-----'
// v v
// Killed Delete the statemachine (all statemachines must be allocated with new).
//
// Each state causes corresponding code to be called.
// Finish cleans up whatever is done by Initialize.
// Abort should clean up additional things done by Run.
//
// The Run state is entered by calling run().
//
// While the base class is in the Run state, it is the derived class
// that goes through different states. The state variable of the derived
// class is only valid while the base class is in the state Run.
//
// A derived class can exit the Run state by calling one of two methods:
// abort() in case of failure, or finish() in case of success.
// Respectively these set the state to Abort and Finish.
//
// finish_impl may call kill() for a (default) destruction upon finish.
// Even in that case the callback (passed to run()) may call run() again,
// which overrides the request for a default kill. Or, if finish_impl
// doesn't call kill() the callback may call kill() to request the
// destruction of the state machine object.
//
// State machines are run from the "idle" part of the viewer main loop.
// Often a state machine has nothing to do however. In that case it can
// call the method idle(). This will stop the state machine until
// external code changes it's state (by calling set_state()), or calls
// cont() to continue with the last state.
//
// The methods of the derived class call set_state() to change their
// own state within the bs_run state, or by calling either abort()
// or finish().
//
// Restarting a finished state machine can also be done by calling run(),
// which will cause a re-initialize.
//
// Derived classes should implement the following constants:
//
// static state_type const min_state = first_state;
// static state_type const max_state = last_state + 1;
//
// Where first_state should be equal to BaseClass::max_state.
// These should represent the minimum and (one past) the maximum
// values of mRunState.
//
// virtual void initialize_impl(void)
//
// Initializes the derived class.
//
// virtual void multiplex_impl(void);
//
// This method should handle mRunState in a switch.
// For example:
//
// switch(mRunState)
// {
// case foo:
// handle_foo();
// break;
// case wait_state:
// if (still_waiting())
// {
// idle();
// break;
// }
// set_state(working);
// /*fall-through*/
// case working:
// do_work();
// if (failure())
// abort();
// break;
// case etc:
// etc();
// finish();
// break;
// }
//
// virtual void abort_impl(void);
//
// A call to this method should bring the object to a state
// where finish_impl() can be called.
//
// virtual void finish_impl(void);
//
// Should cleanup whatever init_impl() did, or any of the
// states of the object where multiplex_impl() calls finish().
// Call kill() from here to make that the default behavior
// (state machine is deleted unless the callback calls run()).
//
// virtual char const* state_str_impl(state_type run_state);
//
// Should return a stringified value of run_state.
//
class AIStateMachine {
//! The type of mState
class AIStateMachine;
class AIEngine
{
private:
struct QueueElementComp;
class QueueElement {
private:
LLPointer<AIStateMachine> mStateMachine;
public:
QueueElement(AIStateMachine* statemachine) : mStateMachine(statemachine) { }
friend bool operator==(QueueElement const& e1, QueueElement const& e2) { return e1.mStateMachine == e2.mStateMachine; }
friend bool operator!=(QueueElement const& e1, QueueElement const& e2) { return e1.mStateMachine != e2.mStateMachine; }
friend struct QueueElementComp;
AIStateMachine const& statemachine(void) const { return *mStateMachine; }
AIStateMachine& statemachine(void) { return *mStateMachine; }
};
struct QueueElementComp {
inline bool operator()(QueueElement const& e1, QueueElement const& e2) const;
};
public:
typedef std::list<QueueElement> queued_type;
struct engine_state_type {
queued_type list;
bool waiting;
engine_state_type(void) : waiting(false) { }
};
private:
AIThreadSafeSimpleDC<engine_state_type, LLCondition> mEngineState;
typedef AIAccessConst<engine_state_type, LLCondition> engine_state_type_crat;
typedef AIAccess<engine_state_type, LLCondition> engine_state_type_rat;
typedef AIAccess<engine_state_type, LLCondition> engine_state_type_wat;
char const* mName;
static U64 sMaxCount;
public:
AIEngine(char const* name) : mName(name) { }
void add(AIStateMachine* state_machine);
void mainloop(void);
void threadloop(void);
void wake_up(void);
void flush(void);
char const* name(void) const { return mName; }
static void setMaxCount(F32 StateMachineMaxTime);
};
extern AIEngine gMainThreadEngine;
extern AIEngine gStateMachineThreadEngine;
class AIStateMachine : public LLThreadSafeRefCount
{
public:
typedef U32 state_type; //!< The type of run_state
protected:
// The type of event that causes multiplex() to be called.
enum event_type {
initial_run,
schedule_run,
normal_run,
insert_abort
};
// The type of mState
enum base_state_type {
bs_initialize,
bs_run,
bs_reset, // Idle state before run() is called. Reference count is zero (except for a possible external LLPointer).
bs_initialize, // State after run() and before/during initialize_impl().
bs_multiplex, // State after initialize_impl() before finish() or abort().
bs_abort,
bs_finish,
bs_callback,
bs_killed
};
//! The type of mActive
enum active_type {
as_idle, // State machine is on neither list.
as_queued, // State machine is on continued_statemachines list.
as_active // State machine is on active_statemachines list.
};
//! Type of continued_statemachines.
typedef std::vector<AIStateMachine*> continued_statemachines_type;
//! Type of sContinuedStateMachinesAndMainloopEnabled.
struct csme_type
{
continued_statemachines_type continued_statemachines;
bool mainloop_enabled;
};
public:
typedef U32 state_type; //!< The type of mRunState
//! Integral value equal to the state with the lowest value.
static state_type const min_state = bs_initialize;
//! Integral value one more than the state with the highest value.
static state_type const max_state = bs_killed + 1;
protected:
struct multiplex_state_type {
base_state_type base_state;
AIEngine* current_engine; // Current engine.
multiplex_state_type(void) : base_state(bs_reset), current_engine(NULL) { }
};
struct sub_state_type {
state_type run_state;
state_type advance_state;
bool reset;
bool need_run;
bool idle;
bool skip_idle;
bool aborted;
bool finished;
};
private:
base_state_type mState; //!< State of the base class.
bool mIdle; //!< True if this state machine is not running.
bool mAborted; //!< True after calling abort() and before calling run().
active_type mActive; //!< Whether statemachine is idle, queued to be added to the active list, or already on the active list.
S64 mSleep; //!< Non-zero while the state machine is sleeping.
LLMutex mIdleActive; //!< Used for atomic operations on the pair mIdle / mActive.
#ifdef SHOW_ASSERT
AIThreadID mContThread; //!< Thread that last called locked_cont().
bool mCalledThreadUnsafeIdle; //!< Set to true when idle() is called.
#endif
// Base state.
AIThreadSafeSimpleDC<multiplex_state_type> mState;
typedef AIAccessConst<multiplex_state_type> multiplex_state_type_crat;
typedef AIAccess<multiplex_state_type> multiplex_state_type_rat;
typedef AIAccess<multiplex_state_type> multiplex_state_type_wat;
// Sub state.
AIThreadSafeSimpleDC<sub_state_type> mSubState;
typedef AIAccessConst<sub_state_type> sub_state_type_crat;
typedef AIAccess<sub_state_type> sub_state_type_rat;
typedef AIAccess<sub_state_type> sub_state_type_wat;
// Mutex protecting everything below and making sure only one thread runs the state machine at a time.
LLMutex mMultiplexMutex;
// Mutex that is locked while calling *_impl() functions and the call back.
LLMutex mRunMutex;
S64 mSleep; //!< Non-zero while the state machine is sleeping.
// Callback facilities.
// From within an other state machine:
AIStateMachine* mParent; //!< The parent object that started this state machine, or NULL if there isn't any.
state_type mNewParentState; //!< The state at which the parent should continue upon a successful finish.
bool mAbortParent; //!< If true, abort parent on abort(). Otherwise continue as normal.
bool mOnAbortSignalParent; //!< If true and mAbortParent is false, change state of parent even on abort.
LLPointer<AIStateMachine> mParent; // The parent object that started this state machine, or NULL if there isn't any.
state_type mNewParentState; // The state at which the parent should continue upon a successful finish.
bool mAbortParent; // If true, abort parent on abort(). Otherwise continue as normal.
bool mOnAbortSignalParent; // If true and mAbortParent is false, change state of parent even on abort.
// From outside a state machine:
struct callback_type {
typedef boost::signals2::signal<void (bool)> signal_type;
callback_type(signal_type::slot_type const& slot) { connection = signal.connect(slot); }
~callback_type() { connection.disconnect(); }
void callback(bool success) const { signal(success); }
private:
boost::signals2::connection connection;
signal_type signal;
typedef boost::signals2::signal<void (bool)> signal_type;
callback_type(signal_type::slot_type const& slot) { connection = signal.connect(slot); }
~callback_type() { connection.disconnect(); }
void callback(bool success) const { signal(success); }
private:
boost::signals2::connection connection;
signal_type signal;
};
callback_type* mCallback; //!< Pointer to signal/connection, or NULL when not connected.
callback_type* mCallback; // Pointer to signal/connection, or NULL when not connected.
static U64 sMaxCount; //!< Number of cpu clocks below which we start a new state machine within the same frame.
static AIThreadSafeDC<csme_type> sContinuedStateMachinesAndMainloopEnabled; //!< Read/write locked variable pair.
// Engine stuff.
AIEngine* mDefaultEngine; // Default engine.
AIEngine* mYieldEngine; // Requested engine.
protected:
LLMutex mSetStateLock; //!< For critical areas in set_state() and locked_cont().
//! State of the derived class. Only valid if mState == bs_run. Call set_state to change.
volatile state_type mRunState;
public:
//! Create a non-running state machine.
AIStateMachine(void) : mState(bs_initialize), mIdle(true), mAborted(true), mActive(as_idle), mSleep(0), mParent(NULL), mCallback(NULL)
#ifdef SHOW_ASSERT
, mContThread(AIThreadID::none), mCalledThreadUnsafeIdle(false)
// Debug stuff.
AIThreadID mThreadId; // The thread currently running multiplex().
base_state_type mDebugLastState; // The previous state that multiplex() had a normal run with.
bool mDebugShouldRun; // Set if we found evidence that we should indeed call multiplex_impl().
bool mDebugAborted; // True when abort() was called.
bool mDebugContPending; // True while cont() was called by not handled yet.
bool mDebugSetStatePending; // True while set_state() was called by not handled yet.
bool mDebugAdvanceStatePending; // True while advance_state() was called by not handled yet.
bool mDebugRefCalled; // True when ref() is called (or will be called within the critial area of mMultiplexMutex).
#endif
{ }
U64 mRuntime; // Total time spent running in the main thread (in clocks).
public:
AIStateMachine(void) : mCallback(NULL), mDefaultEngine(NULL), mYieldEngine(NULL),
#ifdef SHOW_ASSERT
mThreadId(AIThreadID::none), mDebugLastState(bs_killed), mDebugShouldRun(false), mDebugAborted(false), mDebugContPending(false),
mDebugSetStatePending(false), mDebugAdvanceStatePending(false), mDebugRefCalled(false),
#endif
mRuntime(0)
{ }
protected:
//! The user should call 'kill()', not delete a AIStateMachine (derived) directly.
virtual ~AIStateMachine() { llassert((mState == bs_killed && mActive == as_idle) || mState == bs_initialize); }
// The user should call finish() (or abort(), or kill() from the call back when finish_impl() calls run()), not delete a class derived from AIStateMachine directly.
virtual ~AIStateMachine() { llassert(multiplex_state_type_rat(mState)->base_state == bs_killed); }
public:
//! Halt the state machine until cont() is called (not thread-safe).
void idle(void);
// These functions may be called directly after creation, or from within finish_impl(), or from the call back function.
void run(LLPointer<AIStateMachine> parent, state_type new_parent_state, bool abort_parent = true, bool on_abort_signal_parent = true, AIEngine* default_engine = &gMainThreadEngine);
void run(callback_type::signal_type::slot_type const& slot, AIEngine* default_engine = &gMainThreadEngine);
void run(void) { run(NULL, 0, false, true, mDefaultEngine); }
//! Halt the state machine until cont() is called, provided it is still in 'current_run_state'.
void idle(state_type current_run_state);
//! Temporarily halt the state machine.
void yield_frame(unsigned int frames) { mSleep = -(S64)frames; }
//! Temporarily halt the state machine.
void yield_ms(unsigned int ms) { mSleep = get_clock_count() + calc_clock_frequency() * ms / 1000; }
//! Continue running after calling idle.
void cont(void)
{
mSetStateLock.lock();
// Ignore calls to cont() if the statemachine isn't idle. See comments in set_state().
// Calling cont() twice or after calling set_state(), without first calling idle(), is an error.
if (mState != bs_run || !mIdle) { llassert(mState != bs_run || !mContThread.equals_current_thread()); mSetStateLock.unlock(); return; }
locked_cont();
}
private:
void locked_cont(void);
public:
//---------------------------------------
// Changing the state.
//! Change state to <code>bs_run</code>. May only be called after creation or after returning from finish().
// If <code>parent</code> is non-NULL, change the parent state machine's state to <code>new_parent_state</code>
// upon finish, or in the case of an abort and when <code>abort_parent</code> is true, call parent->abort() instead.
void run(AIStateMachine* parent, state_type new_parent_state, bool abort_parent = true, bool on_abort_signal_parent = true);
//! Change state to 'bs_run'. May only be called after creation or after returning from finish().
// Does not cause a callback.
void run(void) { run(NULL, 0, false); }
//! The same as above, but pass the result of a boost::bind with _1.
//
// Here _1, if present, will be replaced with a bool indicating success.
//
// For example:
//
// <code>
// struct Foo { void callback(AIStateMachineDerived* ptr, bool success); };
// ...
// AIStateMachineDerived* magic = new AIStateMachineDerived; // Deleted by callback
// // Call foo_ptr->callback(magic, _1) on finish.
// state_machine->run(boost::bind(&Foo::callback, foo_ptr, magic, _1));
// </code>
//
// or
//
// <code>
// struct Foo { void callback(bool success, AIStateMachineDerived const& magic); };
// ...
// AIStateMachineDerived magic;
// // Call foo_ptr->callback(_1, magic) on finish.
// magic.run(boost::bind(&Foo::callback, foo_ptr, _1, magic));
// </code>
//
// or
//
// <code>
// static void callback(void* userdata);
// ...
// AIStateMachineDerived magic;
// // Call callback(userdata) on finish.
// magic.run(boost::bind(&callback, userdata));
// </code>
void run(callback_type::signal_type::slot_type const& slot);
//! Change state to 'bs_abort'. May only be called while in the bs_run state.
void abort(void);
//! Change state to 'bs_finish'. May only be called while in the bs_run state.
void finish(void);
//! Refine state while in the bs_run state. May only be called while in the bs_run state.
void set_state(state_type run_state);
//! Change state to 'bs_killed'. May only be called while in the bs_finish state.
// This function may only be called from the call back function (and cancels a call to run() from finish_impl()).
void kill(void);
//---------------------------------------
// Other.
//! Called whenever the StateMachineMaxTime setting is changed.
static void setMaxCount(F32 StateMachineMaxTime);
//---------------------------------------
// Accessors.
//! Return true if state machine was aborted (can be used in finish_impl).
bool aborted(void) const { return mAborted; }
//! Return true if the derived class is running (also when we are idle).
bool running(void) const { return mState == bs_run; }
//! Return true if it's safe to call abort.
bool abortable(void) const { return mState == bs_run || mState == bs_initialize; }
//! Return true if the derived class is running but idle.
bool waiting(void) const { return mState == bs_run && mIdle; }
// Use some safebool idiom (http://www.artima.com/cppsource/safebool.html) rather than operator bool.
typedef volatile state_type AIStateMachine::* const bool_type;
//! Return true if state machine successfully finished.
operator bool_type() const { return ((mState == bs_initialize || mState == bs_callback) && !mAborted) ? &AIStateMachine::mRunState : 0; }
//! Return a stringified state, for debugging purposes.
char const* state_str(state_type state);
private:
static void add_continued_statemachines(AIReadAccess<csme_type>& csme_r);
static void dowork(void);
void multiplex(U64 current_time);
protected:
// This function can be called from initialize_impl() and multiplex_impl() (both called from within multiplex()).
void set_state(state_type new_state); // Run this state the NEXT loop.
// These functions can only be called from within multiplex_impl().
void idle(void); // Go idle unless cont() or advance_state() were called since the start of the current loop, or until they are called.
void finish(void); // Mark that the state machine finished and schedule the call back.
void yield(void); // Yield to give CPU to other state machines, but do not go idle.
void yield(AIEngine* engine); // Yield to give CPU to other state machines, but do not go idle. Continue running from engine 'engine'.
void yield_frame(unsigned int frames); // Run from the main-thread engine after at least 'frames' frames have passed.
void yield_ms(unsigned int ms); // Run from the main-thread engine after roughly 'ms' miliseconds have passed.
public:
//! Call this once per frame to give the statemachines CPU cycles.
static void mainloop(void)
// This function can be called from multiplex_imp(), but also by a child state machine and
// therefore by any thread. The child state machine should use an LLPointer<AIStateMachine>
// to access this state machine.
void abort(void); // Abort the state machine (unsuccessful finish).
// These are the only two functions that can be called by any thread at any moment.
// Those threads should use an LLPointer<AIStateMachine> to access this state machine.
void cont(void); // Guarantee at least one full run of multiplex() after this function is called. Cancels the last call to idle().
void advance_state(state_type new_state); // Guarantee at least one full run of multiplex() after this function is called
// iff new_state is larger than the last state that was processed.
public:
// Accessors.
// Return true if the derived class is running (also when we are idle).
bool running(void) const { return multiplex_state_type_crat(mState)->base_state == bs_multiplex; }
// Return true if the derived class is running and idle.
bool waiting(void) const
{
{
AIReadAccess<csme_type> csme_r(sContinuedStateMachinesAndMainloopEnabled, true);
if (!csme_r->mainloop_enabled)
return;
if (!csme_r->continued_statemachines.empty())
add_continued_statemachines(csme_r);
}
dowork();
multiplex_state_type_crat state_r(mState);
return state_r->base_state == bs_multiplex && sub_state_type_crat(mSubState)->idle;
}
// Return true if the derived class is running and idle or already being aborted.
bool waiting_or_aborting(void) const
{
multiplex_state_type_crat state_r(mState);
return state_r->base_state == bs_abort || ( state_r->base_state == bs_multiplex && sub_state_type_crat(mSubState)->idle);
}
// Return true if are added to the engine.
bool active(AIEngine const* engine) const { return multiplex_state_type_crat(mState)->current_engine == engine; }
bool aborted(void) const { return sub_state_type_crat(mSubState)->aborted; }
// Use some safebool idiom (http://www.artima.com/cppsource/safebool.html) rather than operator bool.
typedef state_type AIStateMachine::* const bool_type;
// Return true if state machine successfully finished.
operator bool_type() const
{
sub_state_type_crat sub_state_r(mSubState);
return (sub_state_r->finished && !sub_state_r->aborted) ? &AIStateMachine::mNewParentState : 0;
}
//! Abort all running state machines and then run mainloop until all state machines are idle (called when application is exiting).
static void flush(void);
// Return stringified state, for debugging purposes.
char const* state_str(base_state_type state);
#ifdef CWDEBUG
char const* event_str(event_type event);
#endif
void add(U64 count) { mRuntime += count; }
U64 getRuntime(void) const { return mRuntime; }
protected:
//---------------------------------------
// Derived class implementations.
// Handle initializing the object.
virtual void initialize_impl(void) = 0;
// Handle mRunState.
virtual void multiplex_impl(void) = 0;
// Handle aborting from current bs_run state.
virtual void abort_impl(void) = 0;
// Handle cleaning up from initialization (or post abort) state.
virtual void finish_impl(void) = 0;
// Implemenation of state_str for run states.
virtual void multiplex_impl(state_type run_state) = 0;
virtual void abort_impl(void) { }
virtual void finish_impl(void) { }
virtual char const* state_str_impl(state_type run_state) const = 0;
private:
void reset(void); // Called from run() to (re)initialize a (re)start.
void multiplex(event_type event); // Called from AIEngine to step through the states (and from reset() to kick start the state machine).
state_type begin_loop(base_state_type base_state); // Called from multiplex() at the start of a loop.
void callback(void); // Called when the state machine finished.
bool sleep(U64 current_time) // Count frames if necessary and return true when the state machine is still sleeping.
{
if (mSleep == 0)
return false;
else if (mSleep < 0)
++mSleep;
else if ((U64)mSleep >= current_time)
mSleep = 0;
return mSleep != 0;
}
friend class AIEngine; // Calls multiplex().
};
// This case be used in state_str_impl.
bool AIEngine::QueueElementComp::operator()(QueueElement const& e1, QueueElement const& e2) const
{
return e1.mStateMachine->getRuntime() < e2.mStateMachine->getRuntime();
}
// This can be used in state_str_impl.
#define AI_CASE_RETURN(x) do { case x: return #x; } while(0)
#endif

View File

@@ -88,15 +88,15 @@ void AIStateMachineThreadBase::initialize_impl(void)
set_state(start_thread);
}
void AIStateMachineThreadBase::multiplex_impl(void)
void AIStateMachineThreadBase::multiplex_impl(state_type run_state)
{
switch(mRunState)
switch(run_state)
{
case start_thread:
mThread = Thread::allocate(mImpl);
// Set next state.
set_state(wait_stopped);
idle(wait_stopped); // Wait till the thread returns.
idle(); // Wait till the thread returns.
mThread->start();
break;
case wait_stopped:
@@ -179,12 +179,8 @@ bool AIThreadImpl::thread_done(bool result)
{
// If state_machine_thread is non-NULL then AIThreadImpl::abort_impl wasn't called,
// which means the state machine still exists. In fact, it should be in the waiting() state.
// It can also happen that the state machine is being aborted right now (but it will still exist).
// (Note that waiting() and running() aren't strictly thread-safe (we should really lock
// mSetStateLock here) but by first calling waiting() and then running(), and assuming that
// changing an int from the value 1 to the value 2 is atomic, this will work since the
// only possible transition is from waiting to not running).
llassert(state_machine_thread->waiting() || !state_machine_thread->running());
// It can also happen that the state machine is being aborted right now.
llassert(state_machine_thread->waiting_or_aborting());
state_machine_thread->schedule_abort(!result);
// Note that if the state machine is not running (being aborted, ie - hanging in abort_impl
// waiting for the lock on mStateMachineThread) then this is simply ignored.

View File

@@ -89,19 +89,8 @@ class HelloWorld : public AIStateMachine {
// Handle initializing the object.
/*virtual*/ void initialize_impl(void);
// Handle mRunState.
/*virtual*/ void multiplex_impl(void);
// Handle aborting from current bs_run state.
/*virtual*/ void abort_impl(void) { }
// Handle cleaning up from initialization (or post abort) state.
/*virtual*/ void finish_impl(void)
{
// Kill object by default.
// This can be overridden by calling run() from the callback function.
kill();
}
// Handle run_state.
/*virtual*/ void multiplex_impl(state_type run_state);
// Implemenation of state_str for run states.
/*virtual*/ char const* state_str_impl(state_type run_state) const
@@ -123,9 +112,9 @@ void HelloWorld::initialize_impl(void)
set_state(HelloWorld_start);
}
void HelloWorld::multiplex_impl(void)
void HelloWorld::multiplex_impl(state_type run_state)
{
switch (mRunState)
switch (run_state)
{
case HelloWorld_start:
{
@@ -177,28 +166,30 @@ class AIStateMachineThreadBase : public AIStateMachine {
// The actual thread (derived from LLThread).
class Thread;
protected:
typedef AIStateMachine direct_base_type;
// The states of this state machine.
enum thread_state_type {
start_thread = AIStateMachine::max_state, // Start the thread (if necessary create it first).
start_thread = direct_base_type::max_state, // Start the thread (if necessary create it first).
wait_stopped // Wait till the thread is stopped.
};
public:
static state_type const max_state = wait_stopped + 1;
protected:
AIStateMachineThreadBase(AIThreadImpl* impl) : mImpl(impl) { }
AIStateMachineThreadBase(AIThreadImpl* impl) : mImpl(impl) { ref(); /* Never call delete */ }
private:
// Handle initializing the object.
/*virtual*/ void initialize_impl(void);
// Handle mRunState.
/*virtual*/ void multiplex_impl(void);
/*virtual*/ void multiplex_impl(state_type run_state);
// Handle aborting from current bs_run state.
/*virtual*/ void abort_impl(void);
// Handle cleaning up from initialization (or post abort) state.
/*virtual*/ void finish_impl(void) { }
// Implemenation of state_str for run states.
/*virtual*/ char const* state_str_impl(state_type run_state) const;

View File

@@ -31,11 +31,6 @@
#include "linden_common.h"
#include "aitimer.h"
enum timer_state_type {
AITimer_start = AIStateMachine::max_state,
AITimer_expired
};
char const* AITimer::state_str_impl(state_type run_state) const
{
switch(run_state)
@@ -43,6 +38,7 @@ char const* AITimer::state_str_impl(state_type run_state) const
AI_CASE_RETURN(AITimer_start);
AI_CASE_RETURN(AITimer_expired);
}
llassert(false);
return "UNKNOWN STATE";
}
@@ -54,12 +50,12 @@ void AITimer::initialize_impl(void)
void AITimer::expired(void)
{
set_state(AITimer_expired);
advance_state(AITimer_expired);
}
void AITimer::multiplex_impl(void)
void AITimer::multiplex_impl(state_type run_state)
{
switch (mRunState)
switch (run_state)
{
case AITimer_start:
{
@@ -79,18 +75,3 @@ void AITimer::abort_impl(void)
{
mFrameTimer.cancel();
}
void AITimer::finish_impl(void)
{
// Kill object by default.
// This can be overridden by calling run() from the callback function.
kill();
}
void AIPersistentTimer::finish_impl(void)
{
// Don't kill object by default.
if (aborted())
kill();
// Callback function should always call kill() or run().
}

View File

@@ -59,6 +59,18 @@
// just reuse the old ones (call the same callback).
//
class AITimer : public AIStateMachine {
protected:
// The base class of this state machine.
typedef AIStateMachine direct_base_type;
// The different states of the state machine.
enum timer_state_type {
AITimer_start = direct_base_type::max_state,
AITimer_expired
};
public:
static state_type const max_state = AITimer_expired + 1;
private:
AIFrameTimer mFrameTimer; //!< The actual timer that this object wraps.
F64 mInterval; //!< Input variable: interval after which the event will be generated, in seconds.
@@ -90,14 +102,11 @@ class AITimer : public AIStateMachine {
/*virtual*/ void initialize_impl(void);
// Handle mRunState.
/*virtual*/ void multiplex_impl(void);
/*virtual*/ void multiplex_impl(state_type run_state);
// Handle aborting from current bs_run state.
/*virtual*/ void abort_impl(void);
// Handle cleaning up from initialization (or post abort) state.
/*virtual*/ void finish_impl(void);
// Implemenation of state_str for run states.
/*virtual*/ char const* state_str_impl(state_type run_state) const;
@@ -106,12 +115,4 @@ class AITimer : public AIStateMachine {
void expired(void);
};
// Same as above but does not delete itself automatically by default after use.
// Call kill() on it yourself (from the callback function) when you're done with it!
class AIPersistentTimer : public AITimer {
protected:
// Handle cleaning up from initialization (or post abort) state.
/*virtual*/ void finish_impl(void);
};
#endif

View File

@@ -2,6 +2,9 @@
#
# Compilation options shared by all Second Life components.
if(NOT DEFINED ${CMAKE_CURRENT_LIST_FILE}_INCLUDED)
set(${CMAKE_CURRENT_LIST_FILE}_INCLUDED "YES")
include(Variables)
@@ -309,8 +312,6 @@ else (STANDALONE)
endif (STANDALONE)
if(1 EQUAL 1)
add_definitions(-DOPENSIM_RULES=1)
add_definitions(-DMESH_ENABLED=1)
add_definitions(-DENABLE_CLASSIC_CLOUDS=1)
if (NOT "$ENV{SHY_MOD}" STREQUAL "")
add_definitions(-DSHY_MOD=1)
@@ -331,3 +332,5 @@ MARK_AS_ADVANCED(
CMAKE_EXE_LINKER_FLAGS_RELEASE
CMAKE_SHARED_LINKER_FLAGS_RELEASE
)
endif(NOT DEFINED ${CMAKE_CURRENT_LIST_FILE}_INCLUDED)

View File

@@ -21,8 +21,6 @@ else (STANDALONE)
debug ${ARCH_PREBUILT_DIRS_DEBUG}/libapriconv-1.lib
optimized ${ARCH_PREBUILT_DIRS_RELEASE}/libapriconv-1.lib
)
# Doesn't need to link with iconv.dll
set(APRICONV_LIBRARIES "")
set(APRUTIL_LIBRARIES
debug ${ARCH_PREBUILT_DIRS_DEBUG}/libaprutil-1.lib ${APRICONV_LIBRARIES}
optimized ${ARCH_PREBUILT_DIRS_RELEASE}/libaprutil-1.lib ${APRICONV_LIBRARIES}
@@ -44,7 +42,7 @@ else (STANDALONE)
endif (WINDOWS)
set(APR_INCLUDE_DIR ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include/apr-1)
if (LINUX AND VIEWER)
if (LINUX)
list(APPEND APRUTIL_LIBRARIES ${DB_LIBRARIES})
endif (LINUX AND VIEWER)
endif (LINUX)
endif (STANDALONE)

View File

@@ -15,20 +15,8 @@ else (STANDALONE)
if (WINDOWS)
set(BOOST_VERSION 1_45)
# SNOW-788
# 00-Common.cmake alreay sets MSVC_SUFFIX to be correct for the VS we are using eg VC71, VC80, VC90 etc
# The precompiled boost libs for VC71 use a different suffix to VS80 and VS90
# This code should ensure the cmake rules are valid for any VS being used in future as long as the approprate
# boost libs are avaiable - RC.
if (MSVC71)
set(BOOST_OPTIM_SUFFIX mt-s)
set(BOOST_DEBUG_SUFFIX mt-sgd)
else (MSVC71)
set(BOOST_OPTIM_SUFFIX mt)
set(BOOST_DEBUG_SUFFIX mt-gd)
endif (MSVC71)
set(BOOST_OPTIM_SUFFIX mt)
set(BOOST_DEBUG_SUFFIX mt-gd)
set(Boost_PROGRAM_OPTIONS_LIBRARY
optimized libboost_program_options-vc${MSVC_SUFFIX}-${BOOST_OPTIM_SUFFIX}-${BOOST_VERSION}

View File

@@ -8,79 +8,97 @@ set(cmake_SOURCE_FILES
CMakeLists.txt
00-Common.cmake
AIStateMachine.cmake
APR.cmake
Audio.cmake
BasicPluginBase.cmake
BerkeleyDB.cmake
Boost.cmake
BuildVersion.cmake
CARes.cmake
CURL.cmake
CMakeCopyIfDifferent.cmake
CURL.cmake
Colladadom.cmake
ConfigurePkgConfig.cmake
CopyBackToSource.cmake
CopyWinLibs.cmake
CSharpMacros.cmake
Cwdebug.cmake
DBusGlib.cmake
DirectX.cmake
DownloadPrebuilt.cmake.in
ELFIO.cmake
EXPAT.cmake
ExamplePlugin.cmake
FMOD.cmake
FMODEX.cmake
FindAPR.cmake
FindBerkeleyDB.cmake
FindCARes.cmake
FindColladadom.cmake
FindELFIO.cmake
FindGLOD.cmake
FindGooglePerfTools.cmake
FindHunSpell.cmake
FindMT.cmake
FindJsonCpp.cmake
FindLLQtWebkit.cmake
FindNDOF.cmake
FindOpenJPEG.cmake
FindTut.cmake
FindXmlRpcEpi.cmake
FMOD.cmake
FMODEX.cmake
FreeType.cmake
GLOD.cmake
GStreamer010Plugin.cmake
Glui.cmake
Glut.cmake
GooglePerfTools.cmake
Hunspell.cmake
JPEG.cmake
JsonCpp.cmake
LLAddBuildTest.cmake
LLAppearance.cmake
LLAudio.cmake
LLCharacter.cmake
LLCommon.cmake
LLCrashLogger.cmake
LLDatabase.cmake
LLImage.cmake
LLImageJ2COJ.cmake
LLInventory.cmake
LLKDU.cmake
LLMath.cmake
LLMessage.cmake
LLPhysicsExtensions.cmake
LLPlugin.cmake
LLPrimitive.cmake
LLPhysicsExtensions.cmake
LLQtWebkit.cmake
LLRender.cmake
LLScene.cmake
LLUI.cmake
LLVFS.cmake
LLWindow.cmake
LLXML.cmake
# LScript.cmake
LScript.cmake
Linking.cmake
MediaPluginBase.cmake
NDOF.cmake
OPENAL.cmake
OpenGL.cmake
OpenJPEG.cmake
OpenSSL.cmake
PNG.cmake
Python.cmake
PluginAPI.cmake
Prebuilt.cmake
PulseAudio.cmake
Python.cmake
Qt4.cmake
QuickTimePlugin.cmake
RunBuildTest.cmake
StateMachine.cmake
TemplateCheck.cmake
Tut.cmake
UI.cmake
UnixInstall.cmake
Variables.cmake
ViewerMiscLibs.cmake
WebKitLibPlugin.cmake
XmlRpcEpi.cmake
ZLIB.cmake
)
@@ -92,10 +110,6 @@ set(master_SOURCE_FILES
../develop.py
)
if (SERVER)
list(APPEND master_SOURCE_FILES ../Server.cmake)
endif (SERVER)
source_group("Master Rules" FILES ${master_SOURCE_FILES})
set_source_files_properties(${cmake_SOURCE_FILES} ${master_SOURCE_FILES}

View File

@@ -1,142 +0,0 @@
# - This is a support module for easy Mono/C# handling with CMake
# It defines the following macros:
#
# ADD_CS_LIBRARY (<target> <source>)
# ADD_CS_EXECUTABLE (<target> <source>)
# INSTALL_GAC (<target>)
#
# Note that the order of the arguments is important.
#
# You can optionally set the variable CS_FLAGS to tell the macros whether
# to pass additional flags to the compiler. This is particularly useful to
# set assembly references, unsafe code, etc... These flags are always reset
# after the target was added so you don't have to care about that.
#
# copyright (c) 2007 Arno Rehn arno@arnorehn.de
#
# Redistribution and use is allowed according to the terms of the GPL license.
# ----- support macros -----
MACRO(GET_CS_LIBRARY_TARGET_DIR)
IF (NOT LIBRARY_OUTPUT_PATH)
SET(CS_LIBRARY_TARGET_DIR ${CMAKE_CURRENT_BINARY_DIR})
ELSE (NOT LIBRARY_OUTPUT_PATH)
SET(CS_LIBRARY_TARGET_DIR ${LIBRARY_OUTPUT_PATH})
ENDIF (NOT LIBRARY_OUTPUT_PATH)
ENDMACRO(GET_CS_LIBRARY_TARGET_DIR)
MACRO(GET_CS_EXECUTABLE_TARGET_DIR)
IF (NOT EXECUTABLE_OUTPUT_PATH)
SET(CS_EXECUTABLE_TARGET_DIR ${CMAKE_CURRENT_BINARY_DIR})
ELSE (NOT EXECUTABLE_OUTPUT_PATH)
SET(CS_EXECUTABLE_TARGET_DIR ${EXECUTABLE_OUTPUT_PATH})
ENDIF (NOT EXECUTABLE_OUTPUT_PATH)
ENDMACRO(GET_CS_EXECUTABLE_TARGET_DIR)
MACRO(MAKE_PROPER_FILE_LIST)
FOREACH(file ${ARGN})
# first assume it's a relative path
FILE(GLOB globbed ${CMAKE_CURRENT_SOURCE_DIR}/${file})
IF(globbed)
FILE(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/${file} native)
ELSE(globbed)
FILE(TO_NATIVE_PATH ${file} native)
ENDIF(globbed)
SET(proper_file_list ${proper_file_list} ${native})
SET(native "")
ENDFOREACH(file)
ENDMACRO(MAKE_PROPER_FILE_LIST)
# ----- end support macros -----
MACRO(ADD_CS_LIBRARY target)
GET_CS_LIBRARY_TARGET_DIR()
SET(target_DLL "${CS_LIBRARY_TARGET_DIR}/${target}.dll")
MAKE_PROPER_FILE_LIST(${ARGN})
FILE(RELATIVE_PATH relative_path ${CMAKE_BINARY_DIR} ${target_DLL})
SET(target_KEY "${CMAKE_CURRENT_SOURCE_DIR}/${target}.key")
SET(target_CS_FLAGS "${CS_FLAGS}")
IF(${target}_CS_FLAGS)
LIST(APPEND target_CS_FLAGS ${${target}_CS_FLAGS})
ENDIF(${target}_CS_FLAGS)
IF(EXISTS ${target_KEY})
LIST(APPEND target_CS_FLAGS -keyfile:${target_KEY})
ENDIF(EXISTS ${target_KEY})
FOREACH(ref ${${target}_REFS})
SET(ref_DLL ${CMAKE_CURRENT_BINARY_DIR}/${ref}.dll)
IF(EXISTS ${ref_DLL})
LIST(APPEND target_CS_FLAGS -r:${ref_DLL})
ELSE(EXISTS ${ref_DLL})
LIST(APPEND target_CS_FLAGS -r:${ref})
ENDIF(EXISTS ${ref_DLL})
ENDFOREACH(ref ${${target}_REFS})
ADD_CUSTOM_COMMAND (OUTPUT ${target_DLL}
COMMAND ${MCS_EXECUTABLE} ${target_CS_FLAGS} -out:${target_DLL} -target:library ${proper_file_list}
MAIN_DEPENDENCY ${proper_file_list}
DEPENDS ${ARGN}
COMMENT "Building ${relative_path}")
ADD_CUSTOM_TARGET (${target} ALL DEPENDS ${target_DLL})
FOREACH(ref ${${target}_REFS})
GET_TARGET_PROPERTY(is_target ${ref} TYPE)
IF(is_target)
ADD_DEPENDENCIES(${target} ${ref})
ENDIF(is_target)
ENDFOREACH(ref ${${target}_REFS})
SET(relative_path "")
SET(proper_file_list "")
ENDMACRO(ADD_CS_LIBRARY)
MACRO(ADD_CS_EXECUTABLE target)
GET_CS_EXECUTABLE_TARGET_DIR()
# Seems like cmake doesn't like the ".exe" ending for custom commands.
# If we call it ${target}.exe, 'make' will later complain about a missing rule.
# Create a fake target instead.
SET(target_EXE "${CS_EXECUTABLE_TARGET_DIR}/${target}.exe")
SET(target_TOUCH "${CS_EXECUTABLE_TARGET_DIR}/${target}.exe-built")
GET_DIRECTORY_PROPERTY(clean ADDITIONAL_MAKE_CLEAN_FILES)
LIST(APPEND clean ${target}.exe)
SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${clean}")
MAKE_PROPER_FILE_LIST(${ARGN})
FILE(RELATIVE_PATH relative_path ${CMAKE_BINARY_DIR} ${target_EXE})
SET(target_CS_FLAGS "${CS_FLAGS}")
FOREACH(ref ${${target}_REFS})
SET(ref_DLL ${CMAKE_CURRENT_SOURCE_DIR}/${ref}.dll)
IF(EXISTS ${ref_DLL})
LIST(APPEND target_CS_FLAGS -r:${ref_DLL})
ELSE(EXISTS ${ref_DLL})
LIST(APPEND target_CS_FLAGS -r:${ref})
ENDIF(EXISTS ${ref_DLL})
ENDFOREACH(ref ${${target}_REFS})
ADD_CUSTOM_COMMAND (OUTPUT "${target_TOUCH}"
COMMAND ${MCS_EXECUTABLE} ${target_CS_FLAGS} -out:${target_EXE} ${proper_file_list}
COMMAND ${CMAKE_COMMAND} -E touch ${target_TOUCH}
MAIN_DEPENDENCY ${ARGN}
DEPENDS ${ARGN}
COMMENT "Building ${relative_path}")
ADD_CUSTOM_TARGET ("${target}" ALL DEPENDS "${target_TOUCH}")
FOREACH(ref ${${target}_REFS})
GET_TARGET_PROPERTY(is_target ${ref} TYPE)
IF(is_target)
ADD_DEPENDENCIES(${target} ${ref})
ENDIF(is_target)
ENDFOREACH(ref ${${target}_REFS})
SET(relative_path "")
SET(proper_file_list "")
ENDMACRO(ADD_CS_EXECUTABLE)
MACRO(INSTALL_GAC target)
GET_CS_LIBRARY_TARGET_DIR()
INSTALL(CODE "EXECUTE_PROCESS(COMMAND ${GACUTIL_EXECUTABLE} -i ${CS_LIBRARY_TARGET_DIR}/${target}.dll -package 2.0)")
ENDMACRO(INSTALL_GAC target)

View File

@@ -0,0 +1,74 @@
# -*- cmake -*-
SET(DEBUG_PKG_CONFIG "YES")
# Don't change this if manually set by user.
IF("$ENV{PKG_CONFIG_LIBDIR}" STREQUAL "")
# Guess at architecture-specific system library paths.
if (WORD_SIZE EQUAL 32)
SET(PKG_CONFIG_NO_MULTI_GUESS /usr/lib32 /usr/lib)
SET(PKG_CONFIG_NO_MULTI_LOCAL_GUESS /usr/local/lib32 /usr/local/lib)
SET(PKG_CONFIG_MULTI_GUESS /usr/lib/i386-linux-gnu)
SET(PKG_CONFIG_MULTI_LOCAL_GUESS /usr/local/lib/i386-linux-gnu)
else (WORD_SIZE EQUAL 32)
SET(PKG_CONFIG_NO_MULTI_GUESS /usr/lib64 /usr/lib)
SET(PKG_CONFIG_NO_MULTI_LOCAL_GUESS /usr/local/lib64 /usr/local/lib)
SET(PKG_CONFIG_MULTI_GUESS /usr/local/lib/x86_64-linux-gnu)
SET(PKG_CONFIG_MULTI_LOCAL_GUESS /usr/local/lib/x86_64-linux-gnu)
endif (WORD_SIZE EQUAL 32)
# Use DPKG architecture, if available.
IF (${DPKG_ARCH})
SET(PKG_CONFIG_MULTI_GUESS /usr/lib/${DPKG_ARCH})
SET(PKG_CONFIG_MULTI_LOCAL_GUESS /usrlocal/lib/${DPKG_ARCH})
ENDIF (${DPKG_ARCH})
# Explicitly include anything listed in PKG_CONFIG_PATH
string(REPLACE ":" ";" PKG_CONFIG_PATH_LIST "$ENV{PKG_CONFIG_PATH}")
FOREACH(PKG_CONFIG_DIR ${PKG_CONFIG_PATH_LIST})
SET(VALID_PKG_LIBDIRS "${VALID_PKG_LIBDIRS}:${PKG_CONFIG_DIR}/pkgconfig")
ENDFOREACH(PKG_CONFIG_DIR)
# Look for valid pkgconfig directories.
FIND_PATH(PKG_CONFIG_ENV pkgconfig ENV LD_LIBRARY_PATH)
FIND_PATH(PKG_CONFIG_MULTI pkgconfig HINT ${PKG_CONFIG_MULTI_GUESS})
FIND_PATH(PKG_CONFIG_MULTI_LOCAL pkgconfig HINT ${PKG_CONFIG_MULTI_LOCAL_GUESS})
FIND_PATH(PKG_CONFIG_NO_MULTI pkgconfig HINT ${PKG_CONFIG_NO_MULTI_GUESS})
FIND_PATH(PKG_CONFIG_NO_MULTI_LOCAL pkgconfig HINT ${PKG_CONFIG_NO_MULTI_LOCAL_GUESS})
# Add anything we found to our list.
IF(NOT PKG_CONFIG_ENV STREQUAL PKG_CONFIG_ENV-NOTFOUND)
SET(VALID_PKG_LIBDIRS "${VALID_PKG_LIBDIRS}:${PKG_CONFIG_ENV}/pkgconfig")
ENDIF(NOT PKG_CONFIG_ENV STREQUAL PKG_CONFIG_ENV-NOTFOUND)
IF(NOT PKG_CONFIG_MULTI STREQUAL PKG_CONFIG_MULTI-NOTFOUND)
SET(VALID_PKG_LIBDIRS "${VALID_PKG_LIBDIRS}:${PKG_CONFIG_MULTI}/pkgconfig")
ENDIF(NOT PKG_CONFIG_MULTI STREQUAL PKG_CONFIG_MULTI-NOTFOUND)
IF(NOT PKG_CONFIG_MULTI_LOCAL STREQUAL PKG_CONFIG_MULTI_LOCAL-NOTFOUND)
SET(VALID_PKG_LIBDIRS "${VALID_PKG_LIBDIRS}:${PKG_CONFIG_MULTI_LOCAL}/pkgconfig")
ENDIF(NOT PKG_CONFIG_MULTI_LOCAL STREQUAL PKG_CONFIG_MULTI_LOCAL-NOTFOUND)
IF(NOT PKG_CONFIG_NO_MULTI STREQUAL PKG_CONFIG_NO_MULTI-NOTFOUND)
SET(VALID_PKG_LIBDIRS "${VALID_PKG_LIBDIRS}:${PKG_CONFIG_NO_MULTI}/pkgconfig")
ENDIF(NOT PKG_CONFIG_NO_MULTI STREQUAL PKG_CONFIG_NO_MULTI-NOTFOUND)
IF(NOT PKG_CONFIG_NO_MULTI_LOCAL STREQUAL PKG_CONFIG_NO_MULTI_LOCAL-NOTFOUND)
SET(VALID_PKG_LIBDIRS "${VALID_PKG_LIBDIRS}:${PKG_CONFIG_NO_MULTI_LOCAL}/pkgconfig")
ENDIF(NOT PKG_CONFIG_NO_MULTI_LOCAL STREQUAL PKG_CONFIG_NO_MULTI_LOCAL-NOTFOUND)
# Also add some non-architecture specific package locations.
SET(VALID_PKG_LIBDIRS "${VALID_PKG_LIBDIRS}:/usr/share/pkgconfig:/usr/local/share/pkgconfig")
# Remove first unwanted ':'
string(SUBSTRING ${VALID_PKG_LIBDIRS} 1 -1 VALID_PKG_LIBDIRS)
# Set PKG_CONFIG_LIBDIR environment.
SET(ENV{PKG_CONFIG_LIBDIR} ${VALID_PKG_LIBDIRS})
ENDIF("$ENV{PKG_CONFIG_LIBDIR}" STREQUAL "")
IF(DEBUG_PKG_CONFIG)
MESSAGE(STATUS "Using PKG_CONFIG_LIBDIR=$ENV{PKG_CONFIG_LIBDIR}")
ENDIF(DEBUG_PKG_CONFIG)

View File

@@ -285,53 +285,6 @@ copy_if_different(
)
set(all_targets ${all_targets} ${out_targets})
set(internal_llkdu_path "${CMAKE_SOURCE_DIR}/llkdu")
if(EXISTS ${internal_llkdu_path})
set(internal_llkdu_src "${CMAKE_BINARY_DIR}/llkdu/${CMAKE_CFG_INTDIR}/llkdu.dll")
set(llkdu_dst "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/llkdu.dll")
ADD_CUSTOM_COMMAND(
OUTPUT ${llkdu_dst}
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${internal_llkdu_src} ${llkdu_dst}
DEPENDS ${internal_llkdu_src}
COMMENT "Copying llkdu.dll ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}"
)
set(all_targets ${all_targets} ${llkdu_dst})
else(EXISTS ${internal_llkdu_path})
if (EXISTS "${debug_src_dir}/llkdu.dll")
set(debug_llkdu_src "${debug_src_dir}/llkdu.dll")
set(debug_llkdu_dst "${CMAKE_CURRENT_BINARY_DIR}/Debug/llkdu.dll")
ADD_CUSTOM_COMMAND(
OUTPUT ${debug_llkdu_dst}
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${debug_llkdu_src} ${debug_llkdu_dst}
DEPENDS ${debug_llkdu_src}
COMMENT "Copying llkdu.dll ${CMAKE_CURRENT_BINARY_DIR}/Debug"
)
set(all_targets ${all_targets} ${debug_llkdu_dst})
endif (EXISTS "${debug_src_dir}/llkdu.dll")
if (EXISTS "${release_src_dir}/llkdu.dll")
set(release_llkdu_src "${release_src_dir}/llkdu.dll")
set(release_llkdu_dst "${CMAKE_CURRENT_BINARY_DIR}/Release/llkdu.dll")
ADD_CUSTOM_COMMAND(
OUTPUT ${release_llkdu_dst}
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${release_llkdu_src} ${release_llkdu_dst}
DEPENDS ${release_llkdu_src}
COMMENT "Copying llkdu.dll ${CMAKE_CURRENT_BINARY_DIR}/Release"
)
set(all_targets ${all_targets} ${release_llkdu_dst})
set(relwithdebinfo_llkdu_dst "${CMAKE_CURRENT_BINARY_DIR}/RelWithDebInfo/llkdu.dll")
ADD_CUSTOM_COMMAND(
OUTPUT ${relwithdebinfo_llkdu_dst}
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${release_llkdu_src} ${relwithdebinfo_llkdu_dst}
DEPENDS ${release_llkdu_src}
COMMENT "Copying llkdu.dll ${CMAKE_CURRENT_BINARY_DIR}/RelWithDebInfo"
)
set(all_targets ${all_targets} ${relwithdebinfo_llkdu_dst})
endif (EXISTS "${release_src_dir}/llkdu.dll")
endif (EXISTS ${internal_llkdu_path})
# Copy MS C runtime dlls, required for packaging.
# *TODO - Adapt this to support VC9
if (MSVC80)
@@ -440,6 +393,3 @@ add_custom_target(copy_win_libs ALL
)
add_dependencies(copy_win_libs prepare)
if(EXISTS ${internal_llkdu_path})
add_dependencies(copy_win_libs llkdu)
endif(EXISTS ${internal_llkdu_path})

View File

@@ -1,6 +1,6 @@
# -*- cmake -*-
if (VIEWER AND WINDOWS)
if (WINDOWS)
find_path(DIRECTX_INCLUDE_DIR dxdiag.h
"$ENV{DXSDK_DIR}/Include"
"$ENV{PROGRAMFILES}/Microsoft DirectX SDK (June 2010)/Include"
@@ -43,4 +43,4 @@ if (VIEWER AND WINDOWS)
message(FATAL_ERROR "Could not find DirectX SDK Libraries")
endif (DIRECTX_LIBRARY_DIR)
endif (VIEWER AND WINDOWS)
endif (WINDOWS)

View File

@@ -1,17 +0,0 @@
#Find the windows manifest tool.
if (MSVC80)
FIND_PROGRAM(HAVE_MANIFEST_TOOL NAMES mt
PATHS
"$ENV{PROGRAMFILES}/Microsoft Visual Studio 8/VC/bin"
"$ENV{PROGRAMFILES}/Microsoft Visual Studio 8/Common7/Tools/Bin"
"$ENV{PROGRAMFILES}/Microsoft Visual Studio 8/SDK/v2.0/Bin")
IF(HAVE_MANIFEST_TOOL)
MESSAGE(STATUS "Found Mainfest Tool. Embedding custom manifests.")
ELSE(HAVE_MANIFEST_TOOL)
MESSAGE(FATAL_ERROR "Manifest tool, mt.exe, can't be found.")
ENDIF(HAVE_MANIFEST_TOOL)
STRING(REPLACE "/MANIFEST " "/MANIFEST:NO" CMAKE_EXE_LINKER_FLAGS
${CMAKE_EXE_LINKER_FLAGS})
endif (MSVC80)

View File

@@ -18,5 +18,5 @@ else (STANDALONE)
elseif (LINUX)
set(JSONCPP_LIBRARIES jsoncpp)
endif (WINDOWS)
set(JSONCPP_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include/jsoncpp)
set(JSONCPP_INCLUDE_DIR ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include/jsoncpp)
endif (STANDALONE)

View File

@@ -1,10 +0,0 @@
# -*- cmake -*-
include(MySQL)
set(LLDATABASE_INCLUDE_DIRS
${LIBS_SERVER_DIR}/lldatabase
${MYSQL_INCLUDE_DIR}
)
set(LLDATABASE_LIBRARIES lldatabase)

View File

@@ -1,18 +0,0 @@
# -*- cmake -*-
include(Prebuilt)
if (NOT STANDALONE AND EXISTS ${LIBS_CLOSED_DIR}/llkdu)
use_prebuilt_binary(kdu)
if (WINDOWS)
set(KDU_LIBRARY debug kdu_cored optimized kdu_core)
else (WINDOWS)
set(KDU_LIBRARY kdu)
endif (WINDOWS)
set(KDU_INCLUDE_DIR ${LIBS_PREBUILT_DIR}/include)
set(LLKDU_LIBRARY llkdu)
set(LLKDU_STATIC_LIBRARY llkdu_static)
set(LLKDU_LIBRARIES ${LLKDU_LIBRARY})
set(LLKDU_STATIC_LIBRARIES ${LLKDU_STATIC_LIBRARY})
endif (NOT STANDALONE AND EXISTS ${LIBS_CLOSED_DIR}/llkdu)

View File

@@ -1,7 +1,7 @@
# -*- cmake -*-
set(LLPHYSICSEXTENSIONS_LIBRARIES nd_hacdConvexDecomposition hacd nd_Pathing )
set(LLPHYSICSEXTENSIONS_INCLUDE_DIRS ${LIBS_OPEN_DIR}/libndhacd )
set(LLPHYSICSEXTENSIONS_INCLUDE_DIRS ${LIBS_OPEN_DIR}/libndhacd ${LIBS_OPEN_DIR}/libpathing)

View File

@@ -6,27 +6,7 @@ set(LLRENDER_INCLUDE_DIRS
${LIBS_OPEN_DIR}/llrender
)
if (SERVER AND LINUX)
set(LLRENDER_LIBRARIES
llrenderheadless
)
else (SERVER AND LINUX)
set(LLRENDER_LIBRARIES
llrender
)
endif (SERVER AND LINUX)
# mapserver requires certain files to be copied so LL_MESA_HEADLESS can be set
# differently for different object files.
macro (copy_server_sources )
foreach (PREFIX ${ARGV})
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${PREFIX}_server.cpp
COMMAND ${CMAKE_COMMAND}
ARGS -E copy ${CMAKE_CURRENT_SOURCE_DIR}/${PREFIX}.cpp
${CMAKE_CURRENT_BINARY_DIR}/${PREFIX}_server.cpp
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${PREFIX}.cpp
)
list(APPEND server_SOURCE_FILES ${PREFIX}_server.cpp)
endforeach (PREFIX ${_copied_SOURCES})
endmacro (copy_server_sources _copied_SOURCES)

View File

@@ -1,7 +0,0 @@
# -*- cmake -*-
set(LLSCENE_INCLUDE_DIRS
${LIBS_SERVER_DIR}/llscene
)
set(LLSCENE_LIBRARIES llscene)

View File

@@ -36,17 +36,12 @@ set(LLWINDOW_INCLUDE_DIRS
${LIBS_OPEN_DIR}/llwindow
)
if (SERVER AND LINUX)
set(LLWINDOW_LIBRARIES
llwindowheadless
)
else (SERVER AND LINUX)
set(LLWINDOW_LIBRARIES
llwindow
)
if (WINDOWS)
list(APPEND LLWINDOW_LIBRARIES
comdlg32
)
endif (WINDOWS)
endif (SERVER AND LINUX)
set(LLWINDOW_LIBRARIES
llwindow
)
if (WINDOWS)
list(APPEND LLWINDOW_LIBRARIES
comdlg32
)
endif (WINDOWS)

View File

@@ -3,8 +3,5 @@ include(Prebuilt)
if (NOT (STANDALONE OR DARWIN))
use_prebuilt_binary(glext)
# possible glh_linear should have its own .cmake file instead
#use_prebuilt_binary(glh_linear)
# actually... not any longer, it's now in git -SG
set(GLEXT_INCLUDE_DIR ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include)
endif ()
endif (NOT (STANDALONE OR DARWIN))

View File

@@ -8,41 +8,32 @@
# DARWIN - Mac OS X
# LINUX - Linux
# WINDOWS - Windows
#
# What to build:
#
# VIEWER - viewer and other viewer-side components
# SERVER - simulator and other server-side bits
# Relative and absolute paths to subtrees.
if(NOT DEFINED ${CMAKE_CURRENT_LIST_FILE}_INCLUDED)
set(${CMAKE_CURRENT_LIST_FILE}_INCLUDED "YES")
if(NOT DEFINED COMMON_CMAKE_DIR)
set(COMMON_CMAKE_DIR "${CMAKE_SOURCE_DIR}/cmake")
endif(NOT DEFINED COMMON_CMAKE_DIR)
set(LIBS_CLOSED_PREFIX)
set(LIBS_OPEN_PREFIX)
set(LIBS_SERVER_PREFIX)
set(SCRIPTS_PREFIX ../scripts)
set(SERVER_PREFIX)
set(VIEWER_PREFIX)
set(LIBS_CLOSED_DIR ${CMAKE_SOURCE_DIR}/${LIBS_CLOSED_PREFIX})
set(LIBS_OPEN_DIR ${CMAKE_SOURCE_DIR}/${LIBS_OPEN_PREFIX})
set(LIBS_SERVER_DIR ${CMAKE_SOURCE_DIR}/${LIBS_SERVER_PREFIX})
set(SCRIPTS_DIR ${CMAKE_SOURCE_DIR}/${SCRIPTS_PREFIX})
set(SERVER_DIR ${CMAKE_SOURCE_DIR}/${SERVER_PREFIX})
set(VIEWER_DIR ${CMAKE_SOURCE_DIR}/${VIEWER_PREFIX})
set(DISABLE_TCMALLOC OFF CACHE BOOL "Disable linkage of TCMalloc. (64bit builds automatically disable TCMalloc)")
set(LL_TESTS OFF CACHE BOOL "Build and run unit and integration tests (disable for build timing runs to reduce variation)")
set(VISTA_ICON OFF CACHE BOOL "Allow vista icon with pre 2008 Visual Studio IDEs. (Assumes replacement old rcdll.dll with new rcdll.dll from win sdk 7.0 or later)")
set(LIBS_PREBUILT_DIR ${CMAKE_SOURCE_DIR}/../libraries CACHE PATH
"Location of prebuilt libraries.")
if (EXISTS ${CMAKE_SOURCE_DIR}/Server.cmake)
# We use this as a marker that you can try to use the proprietary libraries.
set(INSTALL_PROPRIETARY ON CACHE BOOL "Install proprietary binaries")
endif (EXISTS ${CMAKE_SOURCE_DIR}/Server.cmake)
if (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set(WINDOWS ON BOOL FORCE)
set(ARCH i686)
@@ -69,6 +60,26 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(WORD_SIZE 64)
endif(CMAKE_SIZEOF_VOID_P MATCHES 4)
endif (WORD_SIZE EQUAL 32)
if (WORD_SIZE EQUAL 32)
set(DEB_ARCHITECTURE i386)
set(FIND_LIBRARY_USE_LIB64_PATHS OFF)
set(CMAKE_SYSTEM_LIBRARY_PATH /usr/lib32 ${CMAKE_SYSTEM_LIBRARY_PATH})
else (WORD_SIZE EQUAL 32)
set(DEB_ARCHITECTURE amd64)
set(FIND_LIBRARY_USE_LIB64_PATHS ON)
endif (WORD_SIZE EQUAL 32)
execute_process(COMMAND dpkg-architecture -a${DEB_ARCHITECTURE} -qDEB_HOST_MULTIARCH
RESULT_VARIABLE DPKG_RESULT
OUTPUT_VARIABLE DPKG_ARCH
OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET)
#message (STATUS "DPKG_RESULT ${DPKG_RESULT}, DPKG_ARCH ${DPKG_ARCH}")
if (DPKG_RESULT EQUAL 0)
set(CMAKE_LIBRARY_ARCHITECTURE ${DPKG_ARCH})
set(CMAKE_SYSTEM_LIBRARY_PATH /usr/lib/${DPKG_ARCH} /usr/local/lib/${DPKG_ARCH} ${CMAKE_SYSTEM_LIBRARY_PATH})
endif (DPKG_RESULT EQUAL 0)
include(ConfigurePkgConfig)
set(LL_ARCH ${ARCH}_linux)
set(LL_ARCH_DIR ${ARCH}-linux)
@@ -77,39 +88,37 @@ endif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(DARWIN 1)
if(${CMAKE_GENERATOR} MATCHES Xcode)
#SDK Compiler and Deployment targets for XCode
if (${XCODE_VERSION} VERSION_LESS 4.0.0)
set(CMAKE_OSX_SYSROOT /Developer/SDKs/MacOSX10.5.sdk)
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.5)
set(CMAKE_XCODE_ATTIBUTE_GCC_VERSION "4.2")
else (${XCODE_VERSION} VERSION_LESS 4.0.0)
set(CMAKE_OSX_SYSROOT /Developer/SDKs/MacOSX10.6.sdk)
if(${CMAKE_GENERATOR} MATCHES Xcode)
execute_process(
COMMAND sh -c "xcodebuild -version | grep Xcode | cut -d ' ' -f2 | cut -d'.' -f1-2"
OUTPUT_VARIABLE XCODE_VERSION )
# To support a different SDK update these Xcode settings:
if (XCODE_VERSION GREATER 4.2)
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.6)
set(CMAKE_XCODE_ATTRIBUTE_GCC_VERSION "com.apple.compilers.llvmgcc42")
endif (${XCODE_VERSION} VERSION_LESS 4.0.0)
else()
set(CMAKE_OSX_SYSROOT /Developer/SDKs/MacOSX10.6.sdk)
else (XCODE_VERSION GREATER 4.2)
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.5)
endif (XCODE_VERSION GREATER 4.2)
else(${CMAKE_GENERATOR} MATCHES Xcode)
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.6)
set(CMAKE_XCODE_ATTRIBUTE_GCC_VERSION "com.apple.compilers.llvmgcc42")
endif(${CMAKE_GENERATOR} MATCHES Xcode)
## We currently support only 32-bit i386 builds, so use these:
set(CMAKE_OSX_ARCHITECTURES i386)
set(CMAKE_OSX_SYSROOT macosx10.6)
set(CMAKE_XCODE_ATTRIBUTE_GCC_VERSION "com.apple.compilers.llvmgcc42")
set(CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT dwarf-with-dsym)
# Build only for i386 by default, system default on MacOSX 10.6 is x86_64
if (NOT CMAKE_OSX_ARCHITECTURES)
set(CMAKE_OSX_ARCHITECTURES i386)
endif (NOT CMAKE_OSX_ARCHITECTURES)
set(ARCH i386)
set(WORD_SIZE 32)
## But if you want to compile for mixed 32/64 bit, try these:
# set(CMAKE_OSX_ARCHITECTURES i386;x86_64)
# set(ARCH universal)
# set(WORD_SIZE 64)
## Finally, set up the build output directories
set(LL_ARCH ${ARCH}_darwin)
set(LL_ARCH_DIR universal-darwin)
endif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
if (WINDOWS)
set(PREBUILT_TYPE windows)
elseif(DARWIN)
@@ -120,11 +129,9 @@ elseif(LINUX AND WORD_SIZE EQUAL 64)
set(PREBUILT_TYPE linux64)
endif(WINDOWS)
# Default deploy grid
set(GRID agni CACHE STRING "Target Grid")
set(VIEWER ON CACHE BOOL "Build Second Life viewer.")
set(VIEWER_CHANNEL "Singularity" CACHE STRING "Viewer Channel Name")
set(VIEWER_LOGIN_CHANNEL ${VIEWER_CHANNEL} CACHE STRING "Fake login channel for A/B Testing")
set(VIEWER_BRANDING_ID "singularity" CACHE STRING "Viewer branding id (currently secondlife|snowglobe)")
@@ -135,17 +142,6 @@ set(VIEWER_BRANDING_NAME_CAMELCASE "Singularity")
set(STANDALONE OFF CACHE BOOL "Do not use Linden-supplied prebuilt libraries.")
if (NOT STANDALONE AND EXISTS ${CMAKE_SOURCE_DIR}/llphysics)
set(SERVER ON CACHE BOOL "Build Second Life server software.")
endif (NOT STANDALONE AND EXISTS ${CMAKE_SOURCE_DIR}/llphysics)
if (LINUX AND SERVER AND VIEWER)
MESSAGE(FATAL_ERROR "
The indra source does not currently support building SERVER and VIEWER at the same time.
Please set one of these values to OFF in your CMake cache file.
(either by running ccmake or by editing CMakeCache.txt by hand)
For more information, please see JIRA DEV-14943 - Cmake Linux cannot build both VIEWER and SERVER in one build environment
")
endif (LINUX AND SERVER AND VIEWER)
source_group("CMake Rules" FILES CMakeLists.txt)
endif(NOT DEFINED ${CMAKE_CURRENT_LIST_FILE}_INCLUDED)

View File

@@ -81,7 +81,6 @@ class PlatformSetup(object):
distcc = True
cmake_opts = []
word_size = 32
opensim_rules = 'OFF' #whether or not to use rules fit for opensim
using_express = False
def __init__(self):
@@ -125,7 +124,6 @@ class PlatformSetup(object):
standalone=self.standalone,
unattended=self.unattended,
word_size=self.word_size,
opensim_rules=self.opensim_rules,
type=self.build_type.upper(),
)
#if simple:
@@ -134,7 +132,6 @@ class PlatformSetup(object):
'-DSTANDALONE:BOOL=%(standalone)s '
'-DUNATTENDED:BOOL=%(unattended)s '
'-DWORD_SIZE:STRING=%(word_size)s '
'-DOPENSIM_RULES:BOOL=%(opensim_rules)s '
'-G %(generator)r %(opts)s %(dir)r' % args)
def run_cmake(self, args=[]):
@@ -296,7 +293,6 @@ class LinuxSetup(UnixSetup):
type=self.build_type.upper(),
project_name=self.project_name,
word_size=self.word_size,
opensim_rules=self.opensim_rules,
)
if not self.is_internal_tree():
args.update({'cxx':'g++', 'server':'OFF', 'viewer':'ON'})
@@ -323,7 +319,6 @@ class LinuxSetup(UnixSetup):
'-DVIEWER:BOOL=%(viewer)s -DSTANDALONE:BOOL=%(standalone)s '
'-DUNATTENDED:BOOL=%(unattended)s '
'-DWORD_SIZE:STRING=%(word_size)s '
'-DOPENSIM_RULES:BOOL=%(opensim_rules)s '
'-DROOT_PROJECT_NAME:STRING=%(project_name)s '
'%(opts)s %(dir)r')
% args)
@@ -437,7 +432,6 @@ class DarwinSetup(UnixSetup):
unattended=self.unattended,
project_name=self.project_name,
universal=self.universal,
opensim_rules=self.opensim_rules,
type=self.build_type.upper(),
)
if self.universal == 'ON':
@@ -449,7 +443,6 @@ class DarwinSetup(UnixSetup):
'-DSTANDALONE:BOOL=%(standalone)s '
'-DUNATTENDED:BOOL=%(unattended)s '
'-DWORD_SIZE:STRING=%(word_size)s '
'-DOPENSIM_RULES:BOOL=%(opensim_rules)s '
'-DROOT_PROJECT_NAME:STRING=%(project_name)s '
'%(universal)s '
'%(opts)s %(dir)r' % args)
@@ -535,7 +528,6 @@ class WindowsSetup(PlatformSetup):
unattended=self.unattended,
project_name=self.project_name,
word_size=self.word_size,
opensim_rules=self.opensim_rules,
)
#if simple:
# return 'cmake %(opts)s "%(dir)s"' % args
@@ -543,7 +535,6 @@ class WindowsSetup(PlatformSetup):
'-DSTANDALONE:BOOL=%(standalone)s '
'-DUNATTENDED:BOOL=%(unattended)s '
'-DWORD_SIZE:STRING=%(word_size)s '
'-DOPENSIM_RULES:BOOL=%(opensim_rules)s '
'-DROOT_PROJECT_NAME:STRING=%(project_name)s '
'%(opts)s "%(dir)s"' % args)
@@ -719,7 +710,6 @@ class CygwinSetup(WindowsSetup):
unattended=self.unattended,
project_name=self.project_name,
word_size=self.word_size,
opensim_rules=self.opensim_rules,
)
#if simple:
# return 'cmake %(opts)s "%(dir)s"' % args
@@ -727,7 +717,6 @@ class CygwinSetup(WindowsSetup):
'-DUNATTENDED:BOOl=%(unattended)s '
'-DSTANDALONE:BOOL=%(standalone)s '
'-DWORD_SIZE:STRING=%(word_size)s '
'-DOPENSIM_RULES:BOOL=%(opensim_rules)s '
'-DROOT_PROJECT_NAME:STRING=%(project_name)s '
'%(opts)s "%(dir)s"' % args)
@@ -766,21 +755,15 @@ Commands:
Command-options for "configure":
We use cmake variables to change the build configuration.
-DSERVER:BOOL=OFF Don't configure simulator/dataserver/etc
-DVIEWER:BOOL=OFF Don't configure the viewer
-DPACKAGE:BOOL=ON Create "package" target to make installers
-DLOCALIZESETUP:BOOL=ON Create one win_setup target per supported language
-DLL_TESTS:BOOL=OFF Don't generate unit test projects
-DEXAMPLEPLUGIN:BOOL=OFF Don't generate example plugin project
-DDISABLE_TCMALLOC:BOOL=ON Disable linkage of TCMalloc. (64bit builds automatically disable TCMalloc)
-DVISTA_ICON:BOOL=ON Allow pre-2008 VS to use vista-optimized resource file. (Requires updated rcdll.dll!)
Examples:
Set up a viewer-only project for your system:
develop.py configure -DSERVER:BOOL=OFF
Set up a Visual Studio 2005 project with "package" target:
develop.py -G vc80 configure -DPACKAGE:BOOL=ON
Set up a Visual Studio 2010 project with "package" target:
develop.py -G vc100 configure -DPACKAGE:BOOL=ON
'''
def main(arguments):

View File

@@ -187,7 +187,7 @@ namespace HACD
m_nTriangles--;
}
}
long idEdge;
long idEdge = 0;
for(size_t itE = 0; itE < m_vertices[v2].m_edges.Size(); ++itE)
{
idEdge = m_vertices[v2].m_edges[itE];
@@ -529,7 +529,7 @@ namespace HACD
long a, b;
long idEdge1;
long idEdge2;
long idEdgeV1V2;
long idEdgeV1V2 = 0;
for(size_t itE1 = 0; itE1 < m_vertices[v1].m_edges.Size(); ++itE1)
{
idEdge1 = m_vertices[v1].m_edges[itE1];

View File

@@ -50,8 +50,9 @@
#include <pthread.h>
#endif
#if defined(_WIN32)
#pragma warning(disable:4100)
#endif
namespace HACD
{

View File

@@ -14,8 +14,8 @@ set(OPENJPEG_VERSION
set(openjpeg_SOURCE_FILES
bio.c
cio.c
cidx_manager.c
cio.c
dwt.c
event.c
image.c
@@ -26,8 +26,8 @@ set(openjpeg_SOURCE_FILES
mct.c
mqc.c
openjpeg.c
pi.c
phix_manager.c
pi.c
ppix_manager.c
raw.c
t1.c
@@ -40,8 +40,8 @@ set(openjpeg_SOURCE_FILES
set(openjpeg_HEADER_FILES
bio.h
cio.h
cidx_manager.h
cio.h
dwt.h
event.h
fix.h

View File

@@ -169,8 +169,6 @@ LLAvatarAppearance::LLAvatarAppearance(LLWearableData* wearable_data) :
mRoot(NULL),
mWearableData(wearable_data)
{
LLMemType mt(LLMemType::MTYPE_AVATAR);
llassert_always(mWearableData);
mBakedTextureDatas.resize(LLAvatarAppearanceDefines::BAKED_NUM_INDICES);
for (U32 i = 0; i < mBakedTextureDatas.size(); i++ )
@@ -496,8 +494,6 @@ void LLAvatarAppearance::computeBodySize()
//-----------------------------------------------------------------------------
BOOL LLAvatarAppearance::parseSkeletonFile(const std::string& filename)
{
LLMemType mt(LLMemType::MTYPE_AVATAR);
//-------------------------------------------------------------------------
// parse the file
//-------------------------------------------------------------------------
@@ -539,8 +535,6 @@ BOOL LLAvatarAppearance::parseSkeletonFile(const std::string& filename)
//-----------------------------------------------------------------------------
BOOL LLAvatarAppearance::setupBone(const LLAvatarBoneInfo* info, LLJoint* parent, S32 &volume_num, S32 &joint_num)
{
LLMemType mt(LLMemType::MTYPE_AVATAR);
LLJoint* joint = NULL;
if (info->mIsJoint)
@@ -628,9 +622,6 @@ BOOL LLAvatarAppearance::allocateCharacterJoints( U32 num )
//-----------------------------------------------------------------------------
BOOL LLAvatarAppearance::buildSkeleton(const LLAvatarSkeletonInfo *info)
{
LLMemType mt(LLMemType::MTYPE_AVATAR);
if (!info)
return FALSE;
//-------------------------------------------------------------------------
@@ -685,8 +676,6 @@ void LLAvatarAppearance::clearSkeleton()
//-----------------------------------------------------------------------------
void LLAvatarAppearance::buildCharacter()
{
LLMemType mt(LLMemType::MTYPE_AVATAR);
//-------------------------------------------------------------------------
// remove all references to our existing skeleton
// so we can rebuild it
@@ -1471,6 +1460,7 @@ LLColor4 LLAvatarAppearance::getClothesColor( ETextureIndex te )
}
return color;
}
// static
LLColor4 LLAvatarAppearance::getDummyColor()
{

View File

@@ -749,8 +749,6 @@ const LLVector2 &LLPolyMeshSharedData::getUVs(U32 index)
//-----------------------------------------------------------------------------
LLPolyMesh::LLPolyMesh(LLPolyMeshSharedData *shared_data, LLPolyMesh *reference_mesh)
{
LLMemType mt(LLMemType::MTYPE_AVATAR_MESH);
llassert(shared_data);
mSharedData = shared_data;

View File

@@ -40,9 +40,9 @@ include_directories(
)
set(llaudio_SOURCE_FILES
llaudiodecodemgr.cpp
llaudioengine.cpp
lllistener.cpp
llaudiodecodemgr.cpp
llvorbisdecode.cpp
llvorbisencode.cpp
)
@@ -50,9 +50,9 @@ set(llaudio_SOURCE_FILES
set(llaudio_HEADER_FILES
CMakeLists.txt
llaudiodecodemgr.h
llaudioengine.h
lllistener.h
llaudiodecodemgr.h
llvorbisdecode.h
llvorbisencode.h
llwindgen.h

View File

@@ -38,6 +38,8 @@
#include "lllistener_openal.h"
const float LLAudioEngine_OpenAL::WIND_BUFFER_SIZE_SEC = 0.05f;
LLAudioEngine_OpenAL::LLAudioEngine_OpenAL()
:
mWindGen(NULL),
@@ -185,6 +187,8 @@ LLAudioChannelOpenAL::~LLAudioChannelOpenAL()
void LLAudioChannelOpenAL::cleanup()
{
alSourceStop(mALSource);
alSourcei(mALSource, AL_BUFFER, AL_NONE);
mCurrentBufferp = NULL;
}
@@ -324,7 +328,14 @@ void LLAudioBufferOpenAL::cleanup()
{
if(mALBuffer != AL_NONE)
{
alGetError(); // clear error
alDeleteBuffers(1, &mALBuffer);
ALenum error = alutGetError();
if(ALC_NO_ERROR != error)
{
LL_WARNS("OpenAL") << "Error: " << alutGetErrorString( error ) << " when cleaning up a buffer" << LL_ENDL;
}
mALBuffer = AL_NONE;
}
}
@@ -441,6 +452,7 @@ void LLAudioEngine_OpenAL::updateWind(LLVector3 wind_vec, F32 camera_altitude)
F64 pitch;
F64 center_freq;
ALenum error;
ALuint *buffers = NULL;
if (!mEnableWind)
return;
@@ -484,58 +496,68 @@ void LLAudioEngine_OpenAL::updateWind(LLVector3 wind_vec, F32 camera_altitude)
mNumEmptyWindALBuffers = llmax(mNumEmptyWindALBuffers, 0);
//llinfos << "mNumEmptyWindALBuffers: " << mNumEmptyWindALBuffers <<" (" << unprocessed << ":" << processed << ")" << llendl;
while(processed--) // unqueue old buffers
//delete the old wind buffers
buffers = new ALuint[processed];
alGetError(); /* clear error */
alSourceUnqueueBuffers(mWindSource, processed, &buffers[0]);
error = alGetError();
if(error != AL_NO_ERROR)
{
ALuint buffer;
ALenum error;
alGetError(); /* clear error */
alSourceUnqueueBuffers(mWindSource, 1, &buffer);
error = alGetError();
if(error != AL_NO_ERROR)
{
llwarns << "LLAudioEngine_OpenAL::updateWind() error swapping (unqueuing) buffers" << llendl;
}
else
{
alDeleteBuffers(1, &buffer);
}
llwarns << "LLAudioEngine_OpenAL::updateWind() error swapping (unqueuing) buffers" << llendl;
}
else
{
alDeleteBuffers(processed, &buffers[0]);
}
// We dont need to keep track of the buffers' id now.
delete[] buffers;
buffers = NULL;
//create the buffers for the empty wind buffers
unprocessed += mNumEmptyWindALBuffers;
buffers = new ALuint[mNumEmptyWindALBuffers];
alGetError(); /* clear error */
alGenBuffers(mNumEmptyWindALBuffers,&buffers[0]);
if((error=alGetError()) != AL_NO_ERROR)
{
llwarns << "LLAudioEngine_OpenAL::updateWind() Error creating wind buffer: " << error << llendl;
//break;
}
unprocessed += mNumEmptyWindALBuffers;
while (mNumEmptyWindALBuffers > 0) // fill+queue new buffers
//fill the buffers with generated wind.
int errors = 0;
for(int i = 0; i < mNumEmptyWindALBuffers; i++)
{
ALuint buffer;
alGetError(); /* clear error */
alGenBuffers(1,&buffer);
if((error=alGetError()) != AL_NO_ERROR)
{
llwarns << "LLAudioEngine_OpenAL::updateWind() Error creating wind buffer: " << error << llendl;
break;
}
alBufferData(buffer,
AL_FORMAT_STEREO16,
mWindGen->windGenerate(mWindBuf,
mWindBufSamples),
mWindBufBytes,
mWindBufFreq);
alBufferData(buffers[i],
AL_FORMAT_STEREO16,
mWindGen->windGenerate(mWindBuf,
mWindBufSamples),
mWindBufBytes,
mWindBufFreq);
error = alGetError();
if(error != AL_NO_ERROR)
{
llwarns << "LLAudioEngine_OpenAL::updateWind() error swapping (bufferdata) buffers" << llendl;
errors++;
}
alSourceQueueBuffers(mWindSource, 1, &buffer);
error = alGetError();
if(error != AL_NO_ERROR)
{
llwarns << "LLAudioEngine_OpenAL::updateWind() error swapping (queuing) buffers" << llendl;
}
--mNumEmptyWindALBuffers;
}
//queue the buffers
alSourceQueueBuffers(mWindSource, mNumEmptyWindALBuffers, &buffers[0]);
error = alGetError();
if(error != AL_NO_ERROR)
{
llwarns << "LLAudioEngine_OpenAL::updateWind() error swapping (queuing) buffers" << llendl;
}
mNumEmptyWindALBuffers = errors;
// We dont need to keep track of the buffers' id now.
delete[] buffers;
buffers = NULL;
//restart playing if not playing
ALint playing;
alGetSourcei(mWindSource, AL_SOURCE_STATE, &playing);
if(playing != AL_PLAYING)

View File

@@ -72,8 +72,8 @@ class LLAudioEngine_OpenAL : public LLAudioEngine
ALuint mWindSource;
int mNumEmptyWindALBuffers;
static const int MAX_NUM_WIND_BUFFERS = 80;
static const float WIND_BUFFER_SIZE_SEC = 0.05f; // 1/20th sec
static const int MAX_NUM_WIND_BUFFERS = 80;
static const float WIND_BUFFER_SIZE_SEC; // 1/20th sec
};
class LLAudioChannelOpenAL : public LLAudioChannel

View File

@@ -32,8 +32,8 @@ set(llcharacter_SOURCE_FILES
llkeyframemotionparam.cpp
llkeyframestandmotion.cpp
llkeyframewalkmotion.cpp
llmotioncontroller.cpp
llmotion.cpp
llmotioncontroller.cpp
llmultigesture.cpp
llpose.cpp
llstatemachine.cpp
@@ -45,8 +45,8 @@ set(llcharacter_HEADER_FILES
CMakeLists.txt
llanimationstates.h
llbvhloader.h
llbvhconsts.h
llbvhloader.h
llcharacter.h
lleditingmotion.h
llgesture.h

View File

@@ -35,8 +35,6 @@
//-----------------------------------------------------------------------------
#include "linden_common.h"
#include "llmemtype.h"
#include "llmotioncontroller.h"
#include "llkeyframemotion.h"
#include "llmath.h"
@@ -342,7 +340,6 @@ void LLMotionController::removeMotionInstance(LLMotion* motionp)
//-----------------------------------------------------------------------------
LLMotion* LLMotionController::createMotion( const LLUUID &id )
{
LLMemType mt(LLMemType::MTYPE_ANIMATION);
// do we have an instance of this motion for this character?
LLMotion *motion = findMotion(id);

View File

@@ -19,6 +19,7 @@ set(llcommon_SOURCE_FILES
aithreadid.cpp
imageids.cpp
indra_constants.cpp
ll_template_cast.h
llallocator.cpp
llallocator_heap_profile.cpp
llapp.cpp
@@ -54,22 +55,21 @@ set(llcommon_SOURCE_FILES
llformat.cpp
llframetimer.cpp
llheartbeat.cpp
llindraconfigfile.cpp
llinitparam.cpp
llinstancetracker.cpp
llindraconfigfile.cpp
llliveappconfig.cpp
lllivefile.cpp
lllog.cpp
llmd5.cpp
llmemory.cpp
llmemorystream.cpp
llmemtype.cpp
llmetrics.cpp
llmortician.cpp
lloptioninterface.cpp
llptrto.cpp
llprocesslauncher.cpp
llprocessor.cpp
llptrto.cpp
llqueuedthread.cpp
llrand.cpp
llrefcount.cpp
@@ -81,8 +81,8 @@ set(llcommon_SOURCE_FILES
llsdutil.cpp
llsecondlifeurls.cpp
llsingleton.cpp
llstat.cpp
llstacktrace.cpp
llstat.cpp
llstreamtools.cpp
llstring.cpp
llstringtable.cpp
@@ -93,7 +93,6 @@ set(llcommon_SOURCE_FILES
lluri.cpp
lluuid.cpp
llworkerthread.cpp
ll_template_cast.h
metaclass.cpp
metaproperty.cpp
reflective.cpp
@@ -116,10 +115,9 @@ set(llcommon_HEADER_FILES
linden_common.h
linked_lists.h
llaccountingcost.h
llagentconstants.h
llallocator.h
llallocator_heap_profile.h
llagentconstants.h
llavatarname.h
llapp.h
llapr.h
llaprpool.h
@@ -127,6 +125,7 @@ set(llcommon_HEADER_FILES
llassoclist.h
llatomic.h
llavatarconstants.h
llavatarname.h
llbase32.h
llbase64.h
llboost.h
@@ -142,8 +141,8 @@ set(llcommon_HEADER_FILES
lldarrayptr.h
lldate.h
lldefs.h
lldependencies.h
lldeleteutils.h
lldependencies.h
lldepthstack.h
lldictionary.h
lldlinked.h
@@ -158,11 +157,11 @@ set(llcommon_HEADER_FILES
lleventapi.h
lleventcoro.h
lleventdispatcher.h
lleventemitter.h
lleventfilter.h
llevents.h
lleventemitter.h
llextendedstatus.h
lleventtimer.h
llextendedstatus.h
llfasttimer.h
llfasttimer_class.h
llfile.h
@@ -176,9 +175,9 @@ set(llcommon_HEADER_FILES
llheartbeat.h
llhttpstatuscodes.h
llindexedqueue.h
llindraconfigfile.h
llinitparam.h
llinstancetracker.h
llindraconfigfile.h
llkeythrottle.h
lllinkedqueue.h
llliveappconfig.h
@@ -190,7 +189,6 @@ set(llcommon_HEADER_FILES
llmd5.h
llmemory.h
llmemorystream.h
llmemtype.h
llmetrics.h
llmortician.h
llnametable.h
@@ -206,8 +204,8 @@ set(llcommon_HEADER_FILES
llqueuedthread.h
llrand.h
llrefcount.h
llrun.h
llrefcount.h
llrun.h
llsafehandle.h
llsd.h
llsdserialize.h

View File

@@ -51,6 +51,11 @@ void AIThreadID::set_current_thread_id(void)
}
#ifndef LL_DARWIN
void AIThreadID::clear(void)
{
mID = undefinedID;
}
void AIThreadID::reset(void)
{
mID = lCurrentThread;

View File

@@ -63,6 +63,7 @@ public:
static void set_main_thread_id(void); // Called once to set sMainThreadID.
static void set_current_thread_id(void); // Called once for every thread to set lCurrentThread.
#ifndef LL_DARWIN
LL_COMMON_API void clear(void);
LL_COMMON_API void reset(void);
LL_COMMON_API bool equals_current_thread(void) const;
LL_COMMON_API static bool in_main_thread(void);
@@ -74,6 +75,7 @@ public:
static apr_os_thread_t getCurrentThread_inline(void) { return lCurrentThread; }
#else
// Both variants are inline on OS X.
void clear(void) { mID = undefinedID; }
void reset(void) { mID = apr_os_thread_current(); }
void reset_inline(void) { mID = apr_os_thread_current(); }
bool equals_current_thread(void) const { return apr_os_thread_equal(mID, apr_os_thread_current()); }

View File

@@ -479,9 +479,6 @@ public:
// Only for use by AITHREADSAFESIMPLE, see below.
AIThreadSafeSimple(T* object) { llassert(object == AIThreadSafeBits<T>::ptr()); }
// If MUTEX is a LLCondition then this can be used to wake up the waiting thread.
void signal() { mMutex.signal(); }
#if LL_DEBUG
// Can only be locked when there still exists an AIAccess object that
// references this object and will access it upon destruction.
@@ -622,6 +619,8 @@ struct AIAccessConst
// If MUTEX is an LLCondition, then this can be used to wait for a signal.
void wait() { this->mWrapper.mMutex.wait(); }
// If MUTEX is a LLCondition then this can be used to wake up the waiting thread.
void signal() { this->mWrapper.mMutex.signal(); }
protected:
AIThreadSafeSimple<T, MUTEX>& mWrapper; //!< Reference to the object that we provide access to.

View File

@@ -90,6 +90,16 @@ const S32 HTTP_VERSION_NOT_SUPPORTED = 505;
// These status codes should not be sent over the wire
// and indicate something went wrong internally.
// If you get these they are not normal.
const S32 HTTP_INTERNAL_ERROR = 499;
// Note that these are only related to curl, not to webkit.
const S32 HTTP_INTERNAL_ERROR_LOW_SPEED = 494; // The transfer (receiving data) stalled or was too slow.
const S32 HTTP_INTERNAL_ERROR_CURL_LOCKUP = 495; // Curl never returned at all for 10 minutes!?!
const S32 HTTP_INTERNAL_ERROR_CURL_BADSOCKET = 496; // Curl was aborted because the socket went bad!?!
const S32 HTTP_INTERNAL_ERROR_CURL_TIMEOUT = 497; // Curl returned a timeout error.
const S32 HTTP_INTERNAL_ERROR_CURL_OTHER = 498; // Any other curl error.
const S32 HTTP_INTERNAL_ERROR_OTHER = 499; // Every other internal error.
// Return true if status is an internal error (not received from a server but generated internally).
bool inline is_internal_http_error(S32 status) { return status >= HTTP_INTERNAL_ERROR_LOW_SPEED && status <= HTTP_INTERNAL_ERROR_OTHER; }
bool inline is_internal_http_error_that_warrants_a_retry(S32 status) { return status >= HTTP_INTERNAL_ERROR_LOW_SPEED && status <= HTTP_INTERNAL_ERROR_CURL_OTHER; }
#endif

View File

@@ -26,6 +26,7 @@
#ifndef LLMEMORY_H
#define LLMEMORY_H
#include "linden_common.h"
#include <new>
#include <cstdlib>
@@ -33,7 +34,7 @@
#include <stdint.h> // uintptr_t
#endif
#include "llmemtype.h"
class LLMutex ;
#if LL_WINDOWS && LL_DEBUG
#define LL_CHECK_MEMORY llassert(_CrtCheckMemory());
@@ -173,8 +174,8 @@ private:
};
//----------------------------------------------------------------------------
class LLMutex ;
#if MEM_TRACK_MEM
class LLMutex ;
class LL_COMMON_API LLMemTracker
{
private:

View File

@@ -1,234 +0,0 @@
/**
* @file llmemtype.cpp
* @brief Simple memory allocation/deallocation tracking stuff here
*
* $LicenseInfo:firstyear=2002&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2010, Linden Research, Inc.
*
* 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.
*
* 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.
*
* 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$
*/
#include "llmemtype.h"
#include "llallocator.h"
#if MEM_TRACK_TYPE
std::vector<char const *> LLMemType::DeclareMemType::mNameList;
#endif
LLMemType::DeclareMemType LLMemType::MTYPE_INIT("Init");
LLMemType::DeclareMemType LLMemType::MTYPE_STARTUP("Startup");
LLMemType::DeclareMemType LLMemType::MTYPE_MAIN("Main");
LLMemType::DeclareMemType LLMemType::MTYPE_FRAME("Frame");
LLMemType::DeclareMemType LLMemType::MTYPE_GATHER_INPUT("GatherInput");
LLMemType::DeclareMemType LLMemType::MTYPE_JOY_KEY("JoyKey");
LLMemType::DeclareMemType LLMemType::MTYPE_IDLE("Idle");
LLMemType::DeclareMemType LLMemType::MTYPE_IDLE_PUMP("IdlePump");
LLMemType::DeclareMemType LLMemType::MTYPE_IDLE_NETWORK("IdleNetwork");
LLMemType::DeclareMemType LLMemType::MTYPE_IDLE_UPDATE_REGIONS("IdleUpdateRegions");
LLMemType::DeclareMemType LLMemType::MTYPE_IDLE_UPDATE_VIEWER_REGION("IdleUpdateViewerRegion");
LLMemType::DeclareMemType LLMemType::MTYPE_IDLE_UPDATE_SURFACE("IdleUpdateSurface");
LLMemType::DeclareMemType LLMemType::MTYPE_IDLE_UPDATE_PARCEL_OVERLAY("IdleUpdateParcelOverlay");
LLMemType::DeclareMemType LLMemType::MTYPE_IDLE_AUDIO("IdleAudio");
LLMemType::DeclareMemType LLMemType::MTYPE_CACHE_PROCESS_PENDING("CacheProcessPending");
LLMemType::DeclareMemType LLMemType::MTYPE_CACHE_PROCESS_PENDING_ASKS("CacheProcessPendingAsks");
LLMemType::DeclareMemType LLMemType::MTYPE_CACHE_PROCESS_PENDING_REPLIES("CacheProcessPendingReplies");
LLMemType::DeclareMemType LLMemType::MTYPE_MESSAGE_CHECK_ALL("MessageCheckAll");
LLMemType::DeclareMemType LLMemType::MTYPE_MESSAGE_PROCESS_ACKS("MessageProcessAcks");
LLMemType::DeclareMemType LLMemType::MTYPE_RENDER("Render");
LLMemType::DeclareMemType LLMemType::MTYPE_SLEEP("Sleep");
LLMemType::DeclareMemType LLMemType::MTYPE_NETWORK("Network");
LLMemType::DeclareMemType LLMemType::MTYPE_PHYSICS("Physics");
LLMemType::DeclareMemType LLMemType::MTYPE_INTERESTLIST("InterestList");
LLMemType::DeclareMemType LLMemType::MTYPE_IMAGEBASE("ImageBase");
LLMemType::DeclareMemType LLMemType::MTYPE_IMAGERAW("ImageRaw");
LLMemType::DeclareMemType LLMemType::MTYPE_IMAGEFORMATTED("ImageFormatted");
LLMemType::DeclareMemType LLMemType::MTYPE_APPFMTIMAGE("AppFmtImage");
LLMemType::DeclareMemType LLMemType::MTYPE_APPRAWIMAGE("AppRawImage");
LLMemType::DeclareMemType LLMemType::MTYPE_APPAUXRAWIMAGE("AppAuxRawImage");
LLMemType::DeclareMemType LLMemType::MTYPE_DRAWABLE("Drawable");
LLMemType::DeclareMemType LLMemType::MTYPE_OBJECT("Object");
LLMemType::DeclareMemType LLMemType::MTYPE_OBJECT_PROCESS_UPDATE("ObjectProcessUpdate");
LLMemType::DeclareMemType LLMemType::MTYPE_OBJECT_PROCESS_UPDATE_CORE("ObjectProcessUpdateCore");
LLMemType::DeclareMemType LLMemType::MTYPE_DISPLAY("Display");
LLMemType::DeclareMemType LLMemType::MTYPE_DISPLAY_UPDATE("DisplayUpdate");
LLMemType::DeclareMemType LLMemType::MTYPE_DISPLAY_UPDATE_CAMERA("DisplayUpdateCam");
LLMemType::DeclareMemType LLMemType::MTYPE_DISPLAY_UPDATE_GEOM("DisplayUpdateGeom");
LLMemType::DeclareMemType LLMemType::MTYPE_DISPLAY_SWAP("DisplaySwap");
LLMemType::DeclareMemType LLMemType::MTYPE_DISPLAY_UPDATE_HUD("DisplayUpdateHud");
LLMemType::DeclareMemType LLMemType::MTYPE_DISPLAY_GEN_REFLECTION("DisplayGenRefl");
LLMemType::DeclareMemType LLMemType::MTYPE_DISPLAY_IMAGE_UPDATE("DisplayImageUpdate");
LLMemType::DeclareMemType LLMemType::MTYPE_DISPLAY_STATE_SORT("DisplayStateSort");
LLMemType::DeclareMemType LLMemType::MTYPE_DISPLAY_SKY("DisplaySky");
LLMemType::DeclareMemType LLMemType::MTYPE_DISPLAY_RENDER_GEOM("DisplayRenderGeom");
LLMemType::DeclareMemType LLMemType::MTYPE_DISPLAY_RENDER_FLUSH("DisplayRenderFlush");
LLMemType::DeclareMemType LLMemType::MTYPE_DISPLAY_RENDER_UI("DisplayRenderUI");
LLMemType::DeclareMemType LLMemType::MTYPE_DISPLAY_RENDER_ATTACHMENTS("DisplayRenderAttach");
LLMemType::DeclareMemType LLMemType::MTYPE_VERTEX_DATA("VertexData");
LLMemType::DeclareMemType LLMemType::MTYPE_VERTEX_CONSTRUCTOR("VertexConstr");
LLMemType::DeclareMemType LLMemType::MTYPE_VERTEX_DESTRUCTOR("VertexDestr");
LLMemType::DeclareMemType LLMemType::MTYPE_VERTEX_CREATE_VERTICES("VertexCreateVerts");
LLMemType::DeclareMemType LLMemType::MTYPE_VERTEX_CREATE_INDICES("VertexCreateIndices");
LLMemType::DeclareMemType LLMemType::MTYPE_VERTEX_DESTROY_BUFFER("VertexDestroyBuff");
LLMemType::DeclareMemType LLMemType::MTYPE_VERTEX_DESTROY_INDICES("VertexDestroyIndices");
LLMemType::DeclareMemType LLMemType::MTYPE_VERTEX_UPDATE_VERTS("VertexUpdateVerts");
LLMemType::DeclareMemType LLMemType::MTYPE_VERTEX_UPDATE_INDICES("VertexUpdateIndices");
LLMemType::DeclareMemType LLMemType::MTYPE_VERTEX_ALLOCATE_BUFFER("VertexAllocateBuffer");
LLMemType::DeclareMemType LLMemType::MTYPE_VERTEX_RESIZE_BUFFER("VertexResizeBuffer");
LLMemType::DeclareMemType LLMemType::MTYPE_VERTEX_MAP_BUFFER("VertexMapBuffer");
LLMemType::DeclareMemType LLMemType::MTYPE_VERTEX_MAP_BUFFER_VERTICES("VertexMapBufferVerts");
LLMemType::DeclareMemType LLMemType::MTYPE_VERTEX_MAP_BUFFER_INDICES("VertexMapBufferIndices");
LLMemType::DeclareMemType LLMemType::MTYPE_VERTEX_UNMAP_BUFFER("VertexUnmapBuffer");
LLMemType::DeclareMemType LLMemType::MTYPE_VERTEX_SET_STRIDE("VertexSetStride");
LLMemType::DeclareMemType LLMemType::MTYPE_VERTEX_SET_BUFFER("VertexSetBuffer");
LLMemType::DeclareMemType LLMemType::MTYPE_VERTEX_SETUP_VERTEX_BUFFER("VertexSetupVertBuff");
LLMemType::DeclareMemType LLMemType::MTYPE_VERTEX_CLEANUP_CLASS("VertexCleanupClass");
LLMemType::DeclareMemType LLMemType::MTYPE_SPACE_PARTITION("SpacePartition");
LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE("Pipeline");
LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_INIT("PipelineInit");
LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_CREATE_BUFFERS("PipelineCreateBuffs");
LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_RESTORE_GL("PipelineRestroGL");
LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_UNLOAD_SHADERS("PipelineUnloadShaders");
LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_LIGHTING_DETAIL("PipelineLightingDetail");
LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_GET_POOL_TYPE("PipelineGetPoolType");
LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_ADD_POOL("PipelineAddPool");
LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_ALLOCATE_DRAWABLE("PipelineAllocDrawable");
LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_ADD_OBJECT("PipelineAddObj");
LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_CREATE_OBJECTS("PipelineCreateObjs");
LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_UPDATE_MOVE("PipelineUpdateMove");
LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_UPDATE_GEOM("PipelineUpdateGeom");
LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_MARK_VISIBLE("PipelineMarkVisible");
LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_MARK_MOVED("PipelineMarkMoved");
LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_MARK_SHIFT("PipelineMarkShift");
LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_SHIFT_OBJECTS("PipelineShiftObjs");
LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_MARK_TEXTURED("PipelineMarkTextured");
LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_MARK_REBUILD("PipelineMarkRebuild");
LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_UPDATE_CULL("PipelineUpdateCull");
LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_STATE_SORT("PipelineStateSort");
LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_POST_SORT("PipelinePostSort");
LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_RENDER_HUD_ELS("PipelineHudEls");
LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_RENDER_HL("PipelineRenderHL");
LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_RENDER_GEOM("PipelineRenderGeom");
LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_RENDER_GEOM_DEFFERRED("PipelineRenderGeomDef");
LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_RENDER_GEOM_POST_DEF("PipelineRenderGeomPostDef");
LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_RENDER_GEOM_SHADOW("PipelineRenderGeomShadow");
LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_RENDER_SELECT("PipelineRenderSelect");
LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_REBUILD_POOLS("PipelineRebuildPools");
LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_QUICK_LOOKUP("PipelineQuickLookup");
LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_RENDER_OBJECTS("PipelineRenderObjs");
LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_GENERATE_IMPOSTOR("PipelineGenImpostors");
LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_RENDER_BLOOM("PipelineRenderBloom");
LLMemType::DeclareMemType LLMemType::MTYPE_UPKEEP_POOLS("UpkeepPools");
LLMemType::DeclareMemType LLMemType::MTYPE_AVATAR("Avatar");
LLMemType::DeclareMemType LLMemType::MTYPE_AVATAR_MESH("AvatarMesh");
LLMemType::DeclareMemType LLMemType::MTYPE_PARTICLES("Particles");
LLMemType::DeclareMemType LLMemType::MTYPE_REGIONS("Regions");
LLMemType::DeclareMemType LLMemType::MTYPE_INVENTORY("Inventory");
LLMemType::DeclareMemType LLMemType::MTYPE_INVENTORY_DRAW("InventoryDraw");
LLMemType::DeclareMemType LLMemType::MTYPE_INVENTORY_BUILD_NEW_VIEWS("InventoryBuildNewViews");
LLMemType::DeclareMemType LLMemType::MTYPE_INVENTORY_DO_FOLDER("InventoryDoFolder");
LLMemType::DeclareMemType LLMemType::MTYPE_INVENTORY_POST_BUILD("InventoryPostBuild");
LLMemType::DeclareMemType LLMemType::MTYPE_INVENTORY_FROM_XML("InventoryFromXML");
LLMemType::DeclareMemType LLMemType::MTYPE_INVENTORY_CREATE_NEW_ITEM("InventoryCreateNewItem");
LLMemType::DeclareMemType LLMemType::MTYPE_INVENTORY_VIEW_INIT("InventoryViewInit");
LLMemType::DeclareMemType LLMemType::MTYPE_INVENTORY_VIEW_SHOW("InventoryViewShow");
LLMemType::DeclareMemType LLMemType::MTYPE_INVENTORY_VIEW_TOGGLE("InventoryViewToggle");
LLMemType::DeclareMemType LLMemType::MTYPE_ANIMATION("Animation");
LLMemType::DeclareMemType LLMemType::MTYPE_VOLUME("Volume");
LLMemType::DeclareMemType LLMemType::MTYPE_PRIMITIVE("Primitive");
LLMemType::DeclareMemType LLMemType::MTYPE_SCRIPT("Script");
LLMemType::DeclareMemType LLMemType::MTYPE_SCRIPT_RUN("ScriptRun");
LLMemType::DeclareMemType LLMemType::MTYPE_SCRIPT_BYTECODE("ScriptByteCode");
LLMemType::DeclareMemType LLMemType::MTYPE_IO_PUMP("IoPump");
LLMemType::DeclareMemType LLMemType::MTYPE_IO_TCP("IoTCP");
LLMemType::DeclareMemType LLMemType::MTYPE_IO_BUFFER("IoBuffer");
LLMemType::DeclareMemType LLMemType::MTYPE_IO_HTTP_SERVER("IoHttpServer");
LLMemType::DeclareMemType LLMemType::MTYPE_IO_SD_SERVER("IoSDServer");
LLMemType::DeclareMemType LLMemType::MTYPE_IO_SD_CLIENT("IoSDClient");
LLMemType::DeclareMemType LLMemType::MTYPE_DIRECTX_INIT("DirectXInit");
LLMemType::DeclareMemType LLMemType::MTYPE_TEMP1("Temp1");
LLMemType::DeclareMemType LLMemType::MTYPE_TEMP2("Temp2");
LLMemType::DeclareMemType LLMemType::MTYPE_TEMP3("Temp3");
LLMemType::DeclareMemType LLMemType::MTYPE_TEMP4("Temp4");
LLMemType::DeclareMemType LLMemType::MTYPE_TEMP5("Temp5");
LLMemType::DeclareMemType LLMemType::MTYPE_TEMP6("Temp6");
LLMemType::DeclareMemType LLMemType::MTYPE_TEMP7("Temp7");
LLMemType::DeclareMemType LLMemType::MTYPE_TEMP8("Temp8");
LLMemType::DeclareMemType LLMemType::MTYPE_TEMP9("Temp9");
LLMemType::DeclareMemType LLMemType::MTYPE_OTHER("Other");
#if MEM_TRACK_TYPE
LLMemType::DeclareMemType::DeclareMemType(char const * st)
{
mID = (S32)mNameList.size();
mName = st;
mNameList.push_back(mName);
}
LLMemType::DeclareMemType::~DeclareMemType()
{
}
LLMemType::LLMemType(LLMemType::DeclareMemType& dt)
{
mTypeIndex = dt.mID;
LLAllocator::pushMemType(dt.mID);
}
LLMemType::~LLMemType()
{
LLAllocator::popMemType();
}
char const * LLMemType::getNameFromID(S32 id)
{
if (id < 0 || id >= (S32)DeclareMemType::mNameList.size())
{
return "INVALID";
}
return DeclareMemType::mNameList[id];
}
//--------------------------------------------------------------------------------------------------
#endif //MEM_TRACK_TYPE

View File

@@ -1,251 +0,0 @@
/**
* @file llmemtype.h
* @brief Runtime memory usage debugging utilities.
*
* $LicenseInfo:firstyear=2005&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2010, Linden Research, Inc.
*
* 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.
*
* 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.
*
* 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$
*/
#ifndef LL_MEMTYPE_H
#define LL_MEMTYPE_H
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
#include "linden_common.h"
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// WARNING: Never commit with MEM_TRACK_MEM == 1
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#define MEM_TRACK_MEM (0 && LL_WINDOWS)
#include <vector>
class LL_COMMON_API LLMemType
{
public:
// class we'll initialize all instances of as
// static members of MemType. Then use
// to construct any new mem type.
class LL_COMMON_API DeclareMemType
{
public:
#if !MEM_TRACK_TYPE
DeclareMemType(char const * st) {}; //Do nothing
#else
DeclareMemType(char const * st);
~DeclareMemType();
S32 mID;
char const * mName;
// array so we can map an index ID to Name
static std::vector<char const *> mNameList;
#endif
};
#if !MEM_TRACK_TYPE
LLMemType(DeclareMemType& dt){} //Do nothing
#else
LLMemType(DeclareMemType& dt);
~LLMemType();
static char const * getNameFromID(S32 id);
#endif
static DeclareMemType MTYPE_INIT;
static DeclareMemType MTYPE_STARTUP;
static DeclareMemType MTYPE_MAIN;
static DeclareMemType MTYPE_FRAME;
static DeclareMemType MTYPE_GATHER_INPUT;
static DeclareMemType MTYPE_JOY_KEY;
static DeclareMemType MTYPE_IDLE;
static DeclareMemType MTYPE_IDLE_PUMP;
static DeclareMemType MTYPE_IDLE_NETWORK;
static DeclareMemType MTYPE_IDLE_UPDATE_REGIONS;
static DeclareMemType MTYPE_IDLE_UPDATE_VIEWER_REGION;
static DeclareMemType MTYPE_IDLE_UPDATE_SURFACE;
static DeclareMemType MTYPE_IDLE_UPDATE_PARCEL_OVERLAY;
static DeclareMemType MTYPE_IDLE_AUDIO;
static DeclareMemType MTYPE_CACHE_PROCESS_PENDING;
static DeclareMemType MTYPE_CACHE_PROCESS_PENDING_ASKS;
static DeclareMemType MTYPE_CACHE_PROCESS_PENDING_REPLIES;
static DeclareMemType MTYPE_MESSAGE_CHECK_ALL;
static DeclareMemType MTYPE_MESSAGE_PROCESS_ACKS;
static DeclareMemType MTYPE_RENDER;
static DeclareMemType MTYPE_SLEEP;
static DeclareMemType MTYPE_NETWORK;
static DeclareMemType MTYPE_PHYSICS;
static DeclareMemType MTYPE_INTERESTLIST;
static DeclareMemType MTYPE_IMAGEBASE;
static DeclareMemType MTYPE_IMAGERAW;
static DeclareMemType MTYPE_IMAGEFORMATTED;
static DeclareMemType MTYPE_APPFMTIMAGE;
static DeclareMemType MTYPE_APPRAWIMAGE;
static DeclareMemType MTYPE_APPAUXRAWIMAGE;
static DeclareMemType MTYPE_DRAWABLE;
static DeclareMemType MTYPE_OBJECT;
static DeclareMemType MTYPE_OBJECT_PROCESS_UPDATE;
static DeclareMemType MTYPE_OBJECT_PROCESS_UPDATE_CORE;
static DeclareMemType MTYPE_DISPLAY;
static DeclareMemType MTYPE_DISPLAY_UPDATE;
static DeclareMemType MTYPE_DISPLAY_UPDATE_CAMERA;
static DeclareMemType MTYPE_DISPLAY_UPDATE_GEOM;
static DeclareMemType MTYPE_DISPLAY_SWAP;
static DeclareMemType MTYPE_DISPLAY_UPDATE_HUD;
static DeclareMemType MTYPE_DISPLAY_GEN_REFLECTION;
static DeclareMemType MTYPE_DISPLAY_IMAGE_UPDATE;
static DeclareMemType MTYPE_DISPLAY_STATE_SORT;
static DeclareMemType MTYPE_DISPLAY_SKY;
static DeclareMemType MTYPE_DISPLAY_RENDER_GEOM;
static DeclareMemType MTYPE_DISPLAY_RENDER_FLUSH;
static DeclareMemType MTYPE_DISPLAY_RENDER_UI;
static DeclareMemType MTYPE_DISPLAY_RENDER_ATTACHMENTS;
static DeclareMemType MTYPE_VERTEX_DATA;
static DeclareMemType MTYPE_VERTEX_CONSTRUCTOR;
static DeclareMemType MTYPE_VERTEX_DESTRUCTOR;
static DeclareMemType MTYPE_VERTEX_CREATE_VERTICES;
static DeclareMemType MTYPE_VERTEX_CREATE_INDICES;
static DeclareMemType MTYPE_VERTEX_DESTROY_BUFFER;
static DeclareMemType MTYPE_VERTEX_DESTROY_INDICES;
static DeclareMemType MTYPE_VERTEX_UPDATE_VERTS;
static DeclareMemType MTYPE_VERTEX_UPDATE_INDICES;
static DeclareMemType MTYPE_VERTEX_ALLOCATE_BUFFER;
static DeclareMemType MTYPE_VERTEX_RESIZE_BUFFER;
static DeclareMemType MTYPE_VERTEX_MAP_BUFFER;
static DeclareMemType MTYPE_VERTEX_MAP_BUFFER_VERTICES;
static DeclareMemType MTYPE_VERTEX_MAP_BUFFER_INDICES;
static DeclareMemType MTYPE_VERTEX_UNMAP_BUFFER;
static DeclareMemType MTYPE_VERTEX_SET_STRIDE;
static DeclareMemType MTYPE_VERTEX_SET_BUFFER;
static DeclareMemType MTYPE_VERTEX_SETUP_VERTEX_BUFFER;
static DeclareMemType MTYPE_VERTEX_CLEANUP_CLASS;
static DeclareMemType MTYPE_SPACE_PARTITION;
static DeclareMemType MTYPE_PIPELINE;
static DeclareMemType MTYPE_PIPELINE_INIT;
static DeclareMemType MTYPE_PIPELINE_CREATE_BUFFERS;
static DeclareMemType MTYPE_PIPELINE_RESTORE_GL;
static DeclareMemType MTYPE_PIPELINE_UNLOAD_SHADERS;
static DeclareMemType MTYPE_PIPELINE_LIGHTING_DETAIL;
static DeclareMemType MTYPE_PIPELINE_GET_POOL_TYPE;
static DeclareMemType MTYPE_PIPELINE_ADD_POOL;
static DeclareMemType MTYPE_PIPELINE_ALLOCATE_DRAWABLE;
static DeclareMemType MTYPE_PIPELINE_ADD_OBJECT;
static DeclareMemType MTYPE_PIPELINE_CREATE_OBJECTS;
static DeclareMemType MTYPE_PIPELINE_UPDATE_MOVE;
static DeclareMemType MTYPE_PIPELINE_UPDATE_GEOM;
static DeclareMemType MTYPE_PIPELINE_MARK_VISIBLE;
static DeclareMemType MTYPE_PIPELINE_MARK_MOVED;
static DeclareMemType MTYPE_PIPELINE_MARK_SHIFT;
static DeclareMemType MTYPE_PIPELINE_SHIFT_OBJECTS;
static DeclareMemType MTYPE_PIPELINE_MARK_TEXTURED;
static DeclareMemType MTYPE_PIPELINE_MARK_REBUILD;
static DeclareMemType MTYPE_PIPELINE_UPDATE_CULL;
static DeclareMemType MTYPE_PIPELINE_STATE_SORT;
static DeclareMemType MTYPE_PIPELINE_POST_SORT;
static DeclareMemType MTYPE_PIPELINE_RENDER_HUD_ELS;
static DeclareMemType MTYPE_PIPELINE_RENDER_HL;
static DeclareMemType MTYPE_PIPELINE_RENDER_GEOM;
static DeclareMemType MTYPE_PIPELINE_RENDER_GEOM_DEFFERRED;
static DeclareMemType MTYPE_PIPELINE_RENDER_GEOM_POST_DEF;
static DeclareMemType MTYPE_PIPELINE_RENDER_GEOM_SHADOW;
static DeclareMemType MTYPE_PIPELINE_RENDER_SELECT;
static DeclareMemType MTYPE_PIPELINE_REBUILD_POOLS;
static DeclareMemType MTYPE_PIPELINE_QUICK_LOOKUP;
static DeclareMemType MTYPE_PIPELINE_RENDER_OBJECTS;
static DeclareMemType MTYPE_PIPELINE_GENERATE_IMPOSTOR;
static DeclareMemType MTYPE_PIPELINE_RENDER_BLOOM;
static DeclareMemType MTYPE_UPKEEP_POOLS;
static DeclareMemType MTYPE_AVATAR;
static DeclareMemType MTYPE_AVATAR_MESH;
static DeclareMemType MTYPE_PARTICLES;
static DeclareMemType MTYPE_REGIONS;
static DeclareMemType MTYPE_INVENTORY;
static DeclareMemType MTYPE_INVENTORY_DRAW;
static DeclareMemType MTYPE_INVENTORY_BUILD_NEW_VIEWS;
static DeclareMemType MTYPE_INVENTORY_DO_FOLDER;
static DeclareMemType MTYPE_INVENTORY_POST_BUILD;
static DeclareMemType MTYPE_INVENTORY_FROM_XML;
static DeclareMemType MTYPE_INVENTORY_CREATE_NEW_ITEM;
static DeclareMemType MTYPE_INVENTORY_VIEW_INIT;
static DeclareMemType MTYPE_INVENTORY_VIEW_SHOW;
static DeclareMemType MTYPE_INVENTORY_VIEW_TOGGLE;
static DeclareMemType MTYPE_ANIMATION;
static DeclareMemType MTYPE_VOLUME;
static DeclareMemType MTYPE_PRIMITIVE;
static DeclareMemType MTYPE_SCRIPT;
static DeclareMemType MTYPE_SCRIPT_RUN;
static DeclareMemType MTYPE_SCRIPT_BYTECODE;
static DeclareMemType MTYPE_IO_PUMP;
static DeclareMemType MTYPE_IO_TCP;
static DeclareMemType MTYPE_IO_BUFFER;
static DeclareMemType MTYPE_IO_HTTP_SERVER;
static DeclareMemType MTYPE_IO_SD_SERVER;
static DeclareMemType MTYPE_IO_SD_CLIENT;
static DeclareMemType MTYPE_DIRECTX_INIT;
static DeclareMemType MTYPE_TEMP1;
static DeclareMemType MTYPE_TEMP2;
static DeclareMemType MTYPE_TEMP3;
static DeclareMemType MTYPE_TEMP4;
static DeclareMemType MTYPE_TEMP5;
static DeclareMemType MTYPE_TEMP6;
static DeclareMemType MTYPE_TEMP7;
static DeclareMemType MTYPE_TEMP8;
static DeclareMemType MTYPE_TEMP9;
static DeclareMemType MTYPE_OTHER; // Special; used by display code
#if MEM_TRACK_TYPE
S32 mTypeIndex;
#endif
};
//----------------------------------------------------------------------------
#endif

View File

@@ -226,7 +226,7 @@ void LLSingleton<DERIVED_TYPE>::createInstance(SingletonInstanceData& data)
if (data.mInitState == INITIALIZING)
{
lldebugs << "Tried to access singleton " << typeid(DERIVED_TYPE).name() << " from initSingleton(), using half-initialized object" << llendl;
llerrs << "Tried to access singleton " << typeid(DERIVED_TYPE).name() << " from initSingleton(), using half-initialized object" << llendl;
return;
}

View File

@@ -470,6 +470,7 @@ public:
void unref()
{
llassert(mRef > 0);
if (!--mRef) delete this;
}
S32 getNumRefs() const

View File

@@ -48,7 +48,7 @@
// Locally used constants
//
const U32 SEC_PER_DAY = 86400;
const F64 SEC_TO_MICROSEC = 1000000.f;
const F64 SEC_TO_MICROSEC = 1000000.0;
const U64 SEC_TO_MICROSEC_U64 = 1000000;
const F64 USEC_TO_SEC_F64 = 0.000001;

View File

@@ -49,6 +49,7 @@
#include "llhttpclient.h"
#include "llsdserialize.h"
#include "llcurl.h"
#include "aistatemachine.h"
LLPumpIO* gServicePump;
BOOL gBreak = false;
@@ -56,6 +57,7 @@ BOOL gSent = false;
class AIHTTPTimeoutPolicy;
extern AIHTTPTimeoutPolicy crashLoggerResponder_timeout;
extern void startEngineThread(void);
class LLCrashLoggerResponder : public LLHTTPClient::ResponderWithResult
{
@@ -374,7 +376,7 @@ void LLCrashLogger::updateApplication(const std::string& message)
{
gServicePump->pump();
gServicePump->callback();
//FIXME: AIStateMachine::mainloop(); needs CPU cycles. Can't call it from here though, because it uses gSavedSettings which is part of newview.
gMainThreadEngine.mainloop();
}
bool LLCrashLogger::init()
@@ -382,6 +384,17 @@ bool LLCrashLogger::init()
// Initialize curl
AICurlInterface::initCurl();
// Initialize state machine engines.
AIEngine::setMaxCount(100); // StateMachineMaxTime
// Start state machine thread.
startEngineThread();
// Start curl thread.
AICurlInterface::startCurlThread(64, // CurlMaxTotalConcurrentConnections
8, // CurlConcurrentConnectionsPerHost
true); // NoVerifySSLCert
// We assume that all the logs we're looking for reside on the current drive
gDirUtilp->initAppDirs("SecondLife");

View File

@@ -22,8 +22,8 @@ include_directories(
)
set(llimage_SOURCE_FILES
llimagebmp.cpp
llimage.cpp
llimagebmp.cpp
llimagedxt.cpp
llimagej2c.cpp
llimagejpeg.cpp
@@ -35,6 +35,7 @@ set(llimage_SOURCE_FILES
set(llimage_HEADER_FILES
CMakeLists.txt
llimage.h
llimagebmp.h
llimagedxt.h

View File

@@ -30,7 +30,6 @@
#include "llmath.h"
#include "v4coloru.h"
#include "llmemtype.h"
#include "llimagebmp.h"
#include "llimagetga.h"
@@ -93,8 +92,7 @@ LLImageBase::LLImageBase()
mHeight(0),
mComponents(0),
mBadBufferAllocation(false),
mAllowOverSize(false),
mMemType(LLMemType::MTYPE_IMAGEBASE)
mAllowOverSize(false)
{
}
@@ -164,8 +162,6 @@ void LLImageBase::deleteData()
// virtual
U8* LLImageBase::allocateData(S32 size)
{
LLMemType mt1(mMemType);
if (size < 0)
{
size = mWidth * mHeight * mComponents;
@@ -226,7 +222,6 @@ U8* LLImageBase::reallocateData(S32 size)
if(mData && (mDataSize == size))
return mData;
LLMemType mt1(mMemType);
U8 *new_datap = (U8*)ALLOCATE_MEM(sPrivatePoolp, size);
if (!new_datap)
{
@@ -293,14 +288,12 @@ S32 LLImageRaw::sRawImageCachedCount = 0;
LLImageRaw::LLImageRaw()
: LLImageBase(), mCacheEntries(0)
{
mMemType = LLMemType::MTYPE_IMAGERAW;
++sRawImageCount;
}
LLImageRaw::LLImageRaw(U16 width, U16 height, S8 components)
: LLImageBase(), mCacheEntries(0)
{
mMemType = LLMemType::MTYPE_IMAGERAW;
llassert( S32(width) * S32(height) * S32(components) <= MAX_IMAGE_DATA_SIZE );
allocateDataSize(width, height, components);
++sRawImageCount;
@@ -309,7 +302,6 @@ LLImageRaw::LLImageRaw(U16 width, U16 height, S8 components)
LLImageRaw::LLImageRaw(U8 *data, U16 width, U16 height, S8 components)
: LLImageBase(), mCacheEntries(0)
{
mMemType = LLMemType::MTYPE_IMAGERAW;
if(allocateDataSize(width, height, components) && data)
{
memcpy(getData(), data, width*height*components);
@@ -319,7 +311,6 @@ LLImageRaw::LLImageRaw(U8 *data, U16 width, U16 height, S8 components)
LLImageRaw::LLImageRaw(LLImageRaw const* src, U16 width, U16 height, U16 crop_offset, bool crop_vertically) : mCacheEntries(0)
{
mMemType = LLMemType::MTYPE_IMAGERAW;
llassert_always(src);
S8 const components = src->getComponents();
U8 const* const data = src->getData();
@@ -343,11 +334,11 @@ LLImageRaw::LLImageRaw(LLImageRaw const* src, U16 width, U16 height, U16 crop_of
++sRawImageCount;
}
/*LLImageRaw::LLImageRaw(const std::string& filename, bool j2c_lowest_mip_only)
: LLImageBase(), mCacheEntries(0)
{
createFromFile(filename, j2c_lowest_mip_only);
}*/
//LLImageRaw::LLImageRaw(const std::string& filename, bool j2c_lowest_mip_only)
// : LLImageBase(), mCacheEntries(0)
//{
// createFromFile(filename, j2c_lowest_mip_only);
//}
LLImageRaw::~LLImageRaw()
{
@@ -416,7 +407,6 @@ BOOL LLImageRaw::resize(U16 width, U16 height, S8 components)
#if 0
U8 * LLImageRaw::getSubImage(U32 x_pos, U32 y_pos, U32 width, U32 height) const
{
LLMemType mt1(mMemType);
U8 *data = new U8[width*height*getComponents()];
// Should do some simple bounds checking
@@ -500,7 +490,6 @@ void LLImageRaw::clear(U8 r, U8 g, U8 b, U8 a)
// Reverses the order of the rows in the image
void LLImageRaw::verticalFlip()
{
LLMemType mt1(mMemType);
S32 row_bytes = getWidth() * getComponents();
llassert(row_bytes > 0);
try
@@ -640,7 +629,6 @@ void LLImageRaw::composite( LLImageRaw* src )
// Src and dst can be any size. Src has 4 components. Dst has 3 components.
void LLImageRaw::compositeScaled4onto3(LLImageRaw* src)
{
LLMemType mt1(mMemType);
llinfos << "compositeScaled4onto3" << llendl;
LLImageRaw* dst = this; // Just for clarity.
@@ -915,7 +903,6 @@ void LLImageRaw::copyUnscaled3onto4( LLImageRaw* src )
// Src and dst can be any size. Src and dst have same number of components.
void LLImageRaw::copyScaled( LLImageRaw* src )
{
LLMemType mt1(mMemType);
LLImageRaw* dst = this; // Just for clarity.
llassert_always( (1 == src->getComponents()) || (3 == src->getComponents()) || (4 == src->getComponents()) );
@@ -956,8 +943,6 @@ void LLImageRaw::copyScaled( LLImageRaw* src )
//scale down image by not blending a pixel with its neighbors.
BOOL LLImageRaw::scaleDownWithoutBlending( S32 new_width, S32 new_height)
{
LLMemType mt1(mMemType);
S8 c = getComponents() ;
llassert((1 == c) || (3 == c) || (4 == c) );
@@ -1002,7 +987,6 @@ BOOL LLImageRaw::scaleDownWithoutBlending( S32 new_width, S32 new_height)
BOOL LLImageRaw::scale( S32 new_width, S32 new_height, BOOL scale_image_data )
{
LLMemType mt1(mMemType);
llassert((1 == getComponents()) || (3 == getComponents()) || (4 == getComponents()) );
S32 old_width = getWidth();
@@ -1439,7 +1423,6 @@ LLImageFormatted::LLImageFormatted(S8 codec)
mDecoded(0),
mDiscardLevel(-1)
{
mMemType = LLMemType::MTYPE_IMAGEFORMATTED;
}
// virtual

View File

@@ -36,7 +36,6 @@
#include "lluuid.h"
#include "llstring.h"
#include "llthread.h"
#include "llmemtype.h"
#include "aithreadsafe.h"
const S32 MIN_IMAGE_MIP = 2; // 4x4, only used for expand/contract power of 2
@@ -163,8 +162,6 @@ private:
bool mAllowOverSize ;
static LLPrivateMemoryPool* sPrivatePoolp ;
public:
LLMemType::DeclareMemType& mMemType; // debug
};
// Raw representation of an image (used for textures, and other uncompressed formats

View File

@@ -35,7 +35,6 @@
#include "lldir.h"
#include "../llxml/llcontrol.h"
#include "llimagej2c.h"
#include "llmemtype.h"
typedef LLImageJ2CImpl* (*CreateLLImageJ2CFunction)();
typedef void (*DestroyLLImageJ2CFunction)(LLImageJ2CImpl*);
@@ -291,8 +290,6 @@ BOOL LLImageJ2C::decode(LLImageRaw *raw_imagep, F32 decode_time)
// Returns TRUE to mean done, whether successful or not.
BOOL LLImageJ2C::decodeChannels(LLImageRaw *raw_imagep, F32 decode_time, S32 first_channel, S32 max_channel_count )
{
LLMemType mt1(mMemType);
BOOL res = TRUE;
resetLastError();
@@ -341,7 +338,6 @@ BOOL LLImageJ2C::encode(const LLImageRaw *raw_imagep, F32 encode_time)
BOOL LLImageJ2C::encode(const LLImageRaw *raw_imagep, const char* comment_text, F32 encode_time)
{
LLMemType mt1(mMemType);
resetLastError();
BOOL res = mImpl->encodeImpl(*this, *raw_imagep, comment_text, encode_time, mReversible);
if (!mLastError.empty())
@@ -518,8 +514,6 @@ BOOL LLImageJ2C::loadAndValidate(const std::string &filename)
BOOL LLImageJ2C::validate(U8 *data, U32 file_size)
{
LLMemType mt1(mMemType);
resetLastError();
setData(data, file_size);

View File

@@ -30,7 +30,6 @@
#include "lldarray.h"
#include "llfoldertype.h"
#include "llinventorytype.h"
#include "llmemtype.h"
#include "llpermissions.h"
#include "llrefcount.h"
#include "llsaleinfo.h"

View File

@@ -21,12 +21,12 @@ set(llmath_SOURCE_FILES
llperlin.cpp
llquaternion.cpp
llrect.cpp
llsdutil_math.cpp
llsphere.cpp
llvector4a.cpp
llvolume.cpp
llvolumemgr.cpp
llvolumeoctree.cpp
llsdutil_math.cpp
m3math.cpp
m4math.cpp
raytrace.cpp
@@ -66,6 +66,7 @@ set(llmath_HEADER_FILES
llquaternion2.h
llquaternion2.inl
llrect.h
llsdutil_math.h
llsimdmath.h
llsimdtypes.h
llsimdtypes.inl
@@ -77,7 +78,6 @@ set(llmath_HEADER_FILES
llvolume.h
llvolumemgr.h
llvolumeoctree.h
llsdutil_math.h
m3math.h
m4math.h
raytrace.h

View File

@@ -1,46 +0,0 @@
/*
* LLCalcParser.cpp
* SecondLife
*
* Created by Aimee Walton on 28/09/2008.
* Copyright 2008 Aimee Walton.
*
*/
#include "linden_common.h"
#include "llcalcparser.h"
using namespace boost::spirit::classic;
F32 LLCalcParser::lookup(const std::string::iterator& start, const std::string::iterator& end) const
{
LLCalc::calc_map_t::iterator iter;
std::string name(start, end);
if (mConstants)
{
iter = mConstants->find(name);
if (iter != mConstants->end())
{
return (*iter).second;
}
}
else
{
// This should never happen!
throw_(end, std::string("Missing constants table"));
}
if (mVariables)
{
iter = mVariables->find(name);
if (iter != mVariables->end())
{
return (*iter).second;
}
}
throw_(end, std::string("Unknown symbol " + name));
return 0.f;
}

View File

@@ -507,7 +507,7 @@ public:
//is it here?
if (isInside(data->getPositionGroup()))
{
if ((getElementCount() < gOctreeMaxCapacity && contains(data->getBinRadius()) ||
if (((getElementCount() < gOctreeMaxCapacity && contains(data->getBinRadius())) ||
(data->getBinRadius() > getSize()[0] && parent && parent->getElementCount() >= gOctreeMaxCapacity)))
{ //it belongs here
/*mElementCount++;

View File

@@ -35,7 +35,6 @@
#include <cmath>
#include "llerror.h"
#include "llmemtype.h"
#include "llvolumemgr.h"
#include "v2math.h"
@@ -378,8 +377,6 @@ public:
LLProfile::Face* LLProfile::addCap(S16 faceID)
{
LLMemType m1(LLMemType::MTYPE_VOLUME);
Face *face = vector_append(mFaces, 1);
face->mIndex = 0;
@@ -392,8 +389,6 @@ LLProfile::Face* LLProfile::addCap(S16 faceID)
LLProfile::Face* LLProfile::addFace(S32 i, S32 count, F32 scaleU, S16 faceID, BOOL flat)
{
LLMemType m1(LLMemType::MTYPE_VOLUME);
Face *face = vector_append(mFaces, 1);
face->mIndex = i;
@@ -409,7 +404,6 @@ LLProfile::Face* LLProfile::addFace(S32 i, S32 count, F32 scaleU, S16 faceID, BO
//static
S32 LLProfile::getNumNGonPoints(const LLProfileParams& params, S32 sides, F32 offset, F32 bevel, F32 ang_scale, S32 split)
{ // this is basically LLProfile::genNGon stripped down to only the operations that influence the number of points
LLMemType m1(LLMemType::MTYPE_VOLUME);
S32 np = 0;
// Generate an n-sided "circular" path.
@@ -475,8 +469,6 @@ S32 LLProfile::getNumNGonPoints(const LLProfileParams& params, S32 sides, F32 of
// filleted and chamfered corners
void LLProfile::genNGon(const LLProfileParams& params, S32 sides, F32 offset, F32 bevel, F32 ang_scale, S32 split)
{
LLMemType m1(LLMemType::MTYPE_VOLUME);
// Generate an n-sided "circular" path.
// 0 is (1,0), and we go counter-clockwise along a circular path from there.
const F32 tableScale[] = { 1, 1, 1, 0.5f, 0.707107f, 0.53f, 0.525f, 0.5f };
@@ -730,8 +722,6 @@ LLProfile::Face* LLProfile::addHole(const LLProfileParams& params, BOOL flat, F3
S32 LLProfile::getNumPoints(const LLProfileParams& params, BOOL path_open,F32 detail, S32 split,
BOOL is_sculpted, S32 sculpt_size)
{ // this is basically LLProfile::generate stripped down to only operations that influence the number of points
LLMemType m1(LLMemType::MTYPE_VOLUME);
if (detail < MIN_LOD)
{
detail = MIN_LOD;
@@ -842,8 +832,6 @@ S32 LLProfile::getNumPoints(const LLProfileParams& params, BOOL path_open,F32 de
BOOL LLProfile::generate(const LLProfileParams& params, BOOL path_open,F32 detail, S32 split,
BOOL is_sculpted, S32 sculpt_size)
{
LLMemType m1(LLMemType::MTYPE_VOLUME);
if ((!mDirty) && (!is_sculpted))
{
return FALSE;
@@ -1116,8 +1104,6 @@ BOOL LLProfile::generate(const LLProfileParams& params, BOOL path_open,F32 detai
BOOL LLProfileParams::importFile(LLFILE *fp)
{
LLMemType m1(LLMemType::MTYPE_VOLUME);
const S32 BUFSIZE = 16384;
char buffer[BUFSIZE]; /* Flawfinder: ignore */
// *NOTE: changing the size or type of these buffers will require
@@ -1193,8 +1179,6 @@ BOOL LLProfileParams::exportFile(LLFILE *fp) const
BOOL LLProfileParams::importLegacyStream(std::istream& input_stream)
{
LLMemType m1(LLMemType::MTYPE_VOLUME);
const S32 BUFSIZE = 16384;
char buffer[BUFSIZE]; /* Flawfinder: ignore */
// *NOTE: changing the size or type of these buffers will require
@@ -1286,7 +1270,6 @@ bool LLProfileParams::fromLLSD(LLSD& sd)
void LLProfileParams::copyParams(const LLProfileParams &params)
{
LLMemType m1(LLMemType::MTYPE_VOLUME);
setCurveType(params.getCurveType());
setBegin(params.getBegin());
setEnd(params.getEnd());
@@ -1503,8 +1486,6 @@ const LLVector2 LLPathParams::getEndScale() const
S32 LLPath::getNumPoints(const LLPathParams& params, F32 detail)
{ // this is basically LLPath::generate stripped down to only the operations that influence the number of points
LLMemType m1(LLMemType::MTYPE_VOLUME);
if (detail < MIN_LOD)
{
detail = MIN_LOD;
@@ -1554,8 +1535,6 @@ S32 LLPath::getNumPoints(const LLPathParams& params, F32 detail)
BOOL LLPath::generate(const LLPathParams& params, F32 detail, S32 split,
BOOL is_sculpted, S32 sculpt_size)
{
LLMemType m1(LLMemType::MTYPE_VOLUME);
if ((!mDirty) && (!is_sculpted))
{
return FALSE;
@@ -1683,8 +1662,6 @@ BOOL LLPath::generate(const LLPathParams& params, F32 detail, S32 split,
BOOL LLDynamicPath::generate(const LLPathParams& params, F32 detail, S32 split,
BOOL is_sculpted, S32 sculpt_size)
{
LLMemType m1(LLMemType::MTYPE_VOLUME);
mOpen = TRUE; // Draw end caps
if (getPathLength() == 0)
{
@@ -1706,8 +1683,6 @@ BOOL LLDynamicPath::generate(const LLPathParams& params, F32 detail, S32 split,
BOOL LLPathParams::importFile(LLFILE *fp)
{
LLMemType m1(LLMemType::MTYPE_VOLUME);
const S32 BUFSIZE = 16384;
char buffer[BUFSIZE]; /* Flawfinder: ignore */
// *NOTE: changing the size or type of these buffers will require
@@ -1852,8 +1827,6 @@ BOOL LLPathParams::exportFile(LLFILE *fp) const
BOOL LLPathParams::importLegacyStream(std::istream& input_stream)
{
LLMemType m1(LLMemType::MTYPE_VOLUME);
const S32 BUFSIZE = 16384;
char buffer[BUFSIZE]; /* Flawfinder: ignore */
// *NOTE: changing the size or type of these buffers will require
@@ -2061,8 +2034,6 @@ S32 LLVolume::sNumMeshPoints = 0;
LLVolume::LLVolume(const LLVolumeParams &params, const F32 detail, const BOOL generate_single_face, const BOOL is_unique)
: mParams(params)
{
LLMemType m1(LLMemType::MTYPE_VOLUME);
mUnique = is_unique;
mFaceMask = 0x0;
mDetail = detail;
@@ -2134,7 +2105,6 @@ LLVolume::~LLVolume()
BOOL LLVolume::generate()
{
LLMemType m1(LLMemType::MTYPE_VOLUME);
llassert_always(mProfilep);
//Added 10.03.05 Dave Parks
@@ -2171,7 +2141,7 @@ BOOL LLVolume::generate()
mLODScaleBias.setVec(0.6f, 0.6f, 0.6f);
}
// ********************************************************************
//********************************************************************
//debug info, to be removed
if((U32)(mPathp->mPath.size() * mProfilep->mProfile.size()) > (1u << 20))
{
@@ -2183,7 +2153,7 @@ BOOL LLVolume::generate()
llerrs << "LLVolume corrupted!" << llendl ;
}
// ********************************************************************
//********************************************************************
BOOL regenPath = mPathp->generate(mParams.getPathParams(), path_detail, split);
BOOL regenProf = mProfilep->generate(mParams.getProfileParams(), mPathp->isOpen(),profile_detail, split);
@@ -2193,7 +2163,7 @@ BOOL LLVolume::generate()
S32 sizeS = mPathp->mPath.size();
S32 sizeT = mProfilep->mProfile.size();
// ********************************************************************
//********************************************************************
//debug info, to be removed
if((U32)(sizeS * sizeT) > (1u << 20))
{
@@ -2206,7 +2176,7 @@ BOOL LLVolume::generate()
llerrs << "LLVolume corrupted!" << llendl ;
}
// ********************************************************************
//********************************************************************
sNumMeshPoints -= mMesh.size();
mMesh.resize(sizeT * sizeS);
@@ -2730,8 +2700,6 @@ S32 LLVolume::getNumFaces() const
void LLVolume::createVolumeFaces()
{
LLMemType m1(LLMemType::MTYPE_VOLUME);
if (mGenerateSingleFace)
{
// do nothing
@@ -2903,8 +2871,6 @@ F32 LLVolume::sculptGetSurfaceArea()
// create placeholder shape
void LLVolume::sculptGeneratePlaceholder()
{
LLMemType m1(LLMemType::MTYPE_VOLUME);
S32 sizeS = mPathp->mPath.size();
S32 sizeT = mProfilep->mProfile.size();
@@ -2940,10 +2906,7 @@ void LLVolume::sculptGenerateMapVertices(U16 sculpt_width, U16 sculpt_height, S8
BOOL sculpt_invert = sculpt_type & LL_SCULPT_FLAG_INVERT;
BOOL sculpt_mirror = sculpt_type & LL_SCULPT_FLAG_MIRROR;
BOOL reverse_horizontal = (sculpt_invert ? !sculpt_mirror : sculpt_mirror); // XOR
LLMemType m1(LLMemType::MTYPE_VOLUME);
S32 sizeS = mPathp->mPath.size();
S32 sizeT = mProfilep->mProfile.size();
@@ -3117,7 +3080,6 @@ bool sculpt_calc_mesh_resolution(U16 width, U16 height, U8 type, F32 detail, S32
// sculpt replaces generate() for sculpted surfaces
void LLVolume::sculpt(U16 sculpt_width, U16 sculpt_height, S8 sculpt_components, const U8* sculpt_data, S32 sculpt_level)
{
LLMemType m1(LLMemType::MTYPE_VOLUME);
U8 sculpt_type = mParams.getSculptType();
BOOL data_is_empty = FALSE;
@@ -3268,7 +3230,6 @@ bool LLVolumeParams::operator<(const LLVolumeParams &params) const
void LLVolumeParams::copyParams(const LLVolumeParams &params)
{
LLMemType m1(LLMemType::MTYPE_VOLUME);
mProfileParams.copyParams(params.mProfileParams);
mPathParams.copyParams(params.mPathParams);
mSculptID = params.getSculptID();
@@ -3640,8 +3601,6 @@ bool LLVolumeParams::validate(U8 prof_curve, F32 prof_begin, F32 prof_end, F32 h
S32 *LLVolume::getTriangleIndices(U32 &num_indices) const
{
LLMemType m1(LLMemType::MTYPE_VOLUME);
S32 expected_num_triangle_indices = getNumTriangleIndices();
if (expected_num_triangle_indices > MAX_VOLUME_TRIANGLE_INDICES)
{
@@ -4369,8 +4328,6 @@ void LLVolume::generateSilhouetteVertices(std::vector<LLVector3> &vertices,
const LLMatrix3& norm_mat_in,
S32 face_mask)
{
LLMemType m1(LLMemType::MTYPE_VOLUME);
LLMatrix4a mat;
mat.loadu(mat_in);
@@ -4832,8 +4789,6 @@ BOOL equalTriangle(const S32 *a, const S32 *b)
BOOL LLVolumeParams::importFile(LLFILE *fp)
{
LLMemType m1(LLMemType::MTYPE_VOLUME);
//llinfos << "importing volume" << llendl;
const S32 BUFSIZE = 16384;
char buffer[BUFSIZE]; /* Flawfinder: ignore */
@@ -4888,8 +4843,6 @@ BOOL LLVolumeParams::exportFile(LLFILE *fp) const
BOOL LLVolumeParams::importLegacyStream(std::istream& input_stream)
{
LLMemType m1(LLMemType::MTYPE_VOLUME);
//llinfos << "importing volume" << llendl;
const S32 BUFSIZE = 16384;
// *NOTE: changing the size or type of this buffer will require
@@ -4929,8 +4882,6 @@ BOOL LLVolumeParams::importLegacyStream(std::istream& input_stream)
BOOL LLVolumeParams::exportLegacyStream(std::ostream& output_stream) const
{
LLMemType m1(LLMemType::MTYPE_VOLUME);
output_stream <<"\tshape 0\n";
output_stream <<"\t{\n";
mPathParams.exportLegacyStream(output_stream);
@@ -6146,8 +6097,6 @@ void LerpPlanarVertex(LLVolumeFace::VertexData& v0,
BOOL LLVolumeFace::createUnCutCubeCap(LLVolume* volume, BOOL partial_build)
{
LLMemType m1(LLMemType::MTYPE_VOLUME);
const std::vector<LLVolume::Point>& mesh = volume->getMesh();
const std::vector<LLVector3>& profile = volume->getProfile().mProfile;
S32 max_s = volume->getProfile().getTotal();
@@ -6293,8 +6242,6 @@ BOOL LLVolumeFace::createUnCutCubeCap(LLVolume* volume, BOOL partial_build)
BOOL LLVolumeFace::createCap(LLVolume* volume, BOOL partial_build)
{
LLMemType m1(LLMemType::MTYPE_VOLUME);
if (!(mTypeMask & HOLLOW_MASK) &&
!(mTypeMask & OPEN_MASK) &&
((volume->getParams().getPathParams().getBegin()==0.0f)&&
@@ -6681,8 +6628,6 @@ BOOL LLVolumeFace::createCap(LLVolume* volume, BOOL partial_build)
void LLVolumeFace::createBinormals()
{
LLMemType m1(LLMemType::MTYPE_VOLUME);
if (!mBinormals)
{
allocateBinormals(mNumVertices);
@@ -6954,8 +6899,6 @@ void LLVolumeFace::appendFace(const LLVolumeFace& face, LLMatrix4& mat_in, LLMat
BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build)
{
LLMemType m1(LLMemType::MTYPE_VOLUME);
BOOL flat = mTypeMask & FLAT_MASK;
U8 sculpt_type = volume->getParams().getSculptType();

View File

@@ -26,7 +26,6 @@
#include "linden_common.h"
#include "llvolumemgr.h"
#include "llmemtype.h"
#include "llvolume.h"
@@ -182,7 +181,6 @@ void LLVolumeMgr::insertGroup(LLVolumeLODGroup* volgroup)
// protected
LLVolumeLODGroup* LLVolumeMgr::createNewGroup(const LLVolumeParams& volume_params)
{
LLMemType m1(LLMemType::MTYPE_VOLUME);
LLVolumeLODGroup* volgroup = new LLVolumeLODGroup(volume_params);
insertGroup(volgroup);
return volgroup;
@@ -297,7 +295,6 @@ LLVolume* LLVolumeLODGroup::refLOD(const S32 detail)
mRefs++;
if (mVolumeLODs[detail].isNull())
{
LLMemType m1(LLMemType::MTYPE_VOLUME);
mVolumeLODs[detail] = new LLVolume(mVolumeParams, mDetailScales[detail]);
}
mLODRefs[detail]++;

View File

@@ -30,7 +30,6 @@ set(llmessage_SOURCE_FILES
aihttptimeout.cpp
aihttptimeoutpolicy.cpp
debug_libcurl.cpp
llhttpclient.cpp
llares.cpp
llareslistener.cpp
llassetstorage.cpp
@@ -46,6 +45,7 @@ set(llmessage_SOURCE_FILES
lldispatcher.cpp
llfiltersd2xmlrpc.cpp
llhost.cpp
llhttpclient.cpp
llhttpnode.cpp
llhttpsender.cpp
llinstantmessage.cpp
@@ -91,9 +91,9 @@ set(llmessage_SOURCE_FILES
lluseroperation.cpp
llxfer.cpp
llxfer_file.cpp
llxfermanager.cpp
llxfer_mem.cpp
llxfer_vfile.cpp
llxfermanager.cpp
llxorcipher.cpp
machine.cpp
message.cpp
@@ -111,8 +111,8 @@ set(llmessage_HEADER_FILES
aicurl.h
aicurleasyrequeststatemachine.h
aicurlprivate.h
aicurlperhost.h
aicurlprivate.h
aicurlthread.h
aihttpheaders.h
aihttptimeout.h
@@ -166,8 +166,8 @@ set(llmessage_HEADER_FILES
llpacketbuffer.h
llpacketring.h
llpartdata.h
llpumpio.h
llproxy.h
llpumpio.h
llqueryflags.h
llregionflags.h
llregionhandle.h
@@ -193,10 +193,10 @@ set(llmessage_HEADER_FILES
lluseroperation.h
llvehicleparams.h
llxfer.h
llxfermanager.h
llxfer_file.h
llxfer_mem.h
llxfer_vfile.h
llxfermanager.h
llxorcipher.h
machine.h
mean_collision_data.h

View File

@@ -418,7 +418,8 @@ void cleanupCurl(void)
stopCurlThread();
if (CurlMultiHandle::getTotalMultiHandles() != 0)
llwarns << "Not all CurlMultiHandle objects were destroyed!" << llendl;
AIStateMachine::flush();
gMainThreadEngine.flush(); // Not really related to curl, but why not.
gStateMachineThreadEngine.flush();
clearCommandQueue();
Stats::print();
ssl_cleanup();
@@ -770,6 +771,22 @@ void CurlEasyRequest::setoptString(CURLoption option, std::string const& value)
setopt(option, value.c_str());
}
void CurlEasyRequest::setPut(U32 size, bool keepalive)
{
DoutCurl("PUT size is " << size << " bytes.");
mContentLength = size;
// The server never replies with 100-continue, so suppress the "Expect: 100-continue" header that libcurl adds by default.
addHeader("Expect:");
if (size > 0 && keepalive)
{
addHeader("Connection: keep-alive");
addHeader("Keep-alive: 300");
}
setopt(CURLOPT_UPLOAD, 1);
setopt(CURLOPT_INFILESIZE, size);
}
void CurlEasyRequest::setPost(AIPostFieldPtr const& postdata, U32 size, bool keepalive)
{
llassert_always(postdata->data());
@@ -787,6 +804,7 @@ void CurlEasyRequest::setPost_raw(U32 size, char const* data, bool keepalive)
// data == NULL when we're going to read the data using CURLOPT_READFUNCTION.
DoutCurl("POST size is " << size << " bytes.");
}
mContentLength = size;
// The server never replies with 100-continue, so suppress the "Expect: 100-continue" header that libcurl adds by default.
addHeader("Expect:");
@@ -872,13 +890,13 @@ void CurlEasyRequest::setSSLCtxCallback(curl_ssl_ctx_callback callback, void* us
static size_t noHeaderCallback(char* ptr, size_t size, size_t nmemb, void* userdata)
{
llmaybewarns << "Calling noHeaderCallback(); curl session aborted." << llendl;
return 0; // Cause a CURL_WRITE_ERROR
return 0; // Cause a CURLE_WRITE_ERROR
}
static size_t noWriteCallback(char* ptr, size_t size, size_t nmemb, void* userdata)
{
llmaybewarns << "Calling noWriteCallback(); curl session aborted." << llendl;
return 0; // Cause a CURL_WRITE_ERROR
return 0; // Cause a CURLE_WRITE_ERROR
}
static size_t noReadCallback(char* ptr, size_t size, size_t nmemb, void* userdata)
@@ -1276,7 +1294,7 @@ static int const HTTP_REDIRECTS_DEFAULT = 10;
LLChannelDescriptors const BufferedCurlEasyRequest::sChannels;
BufferedCurlEasyRequest::BufferedCurlEasyRequest() : mRequestTransferedBytes(0), mResponseTransferedBytes(0), mBufferEventsTarget(NULL), mStatus(HTTP_INTERNAL_ERROR)
BufferedCurlEasyRequest::BufferedCurlEasyRequest() : mRequestTransferedBytes(0), mResponseTransferedBytes(0), mBufferEventsTarget(NULL), mStatus(HTTP_INTERNAL_ERROR_OTHER)
{
AICurlInterface::Stats::BufferedCurlEasyRequest_count++;
}
@@ -1311,7 +1329,7 @@ BufferedCurlEasyRequest::~BufferedCurlEasyRequest()
void BufferedCurlEasyRequest::timed_out(void)
{
mResponder->finished(CURLE_OK, HTTP_INTERNAL_ERROR, "Request timeout, aborted.", sChannels, mOutput);
mResponder->finished(CURLE_OK, HTTP_INTERNAL_ERROR_CURL_LOCKUP, "Request timeout, aborted.", sChannels, mOutput);
if (mResponder->needsHeaders())
{
send_buffer_events_to(NULL); // Revoke buffer events: we send them to the responder.
@@ -1321,7 +1339,7 @@ void BufferedCurlEasyRequest::timed_out(void)
void BufferedCurlEasyRequest::bad_socket(void)
{
mResponder->finished(CURLE_OK, HTTP_INTERNAL_ERROR, "File descriptor went bad! Aborted.", sChannels, mOutput);
mResponder->finished(CURLE_OK, HTTP_INTERNAL_ERROR_CURL_BADSOCKET, "File descriptor went bad! Aborted.", sChannels, mOutput);
if (mResponder->needsHeaders())
{
send_buffer_events_to(NULL); // Revoke buffer events: we send them to the responder.
@@ -1342,7 +1360,7 @@ void BufferedCurlEasyRequest::resetState(void)
mRequestTransferedBytes = 0;
mResponseTransferedBytes = 0;
mBufferEventsTarget = NULL;
mStatus = HTTP_INTERNAL_ERROR;
mStatus = HTTP_INTERNAL_ERROR_OTHER;
}
void BufferedCurlEasyRequest::print_diagnostics(CURLcode code)

View File

@@ -52,8 +52,6 @@
#include "stdtypes.h" // U16, S32, U32, F64
#include "llatomic.h" // LLAtomicU32
#include "aithreadsafe.h"
#include "llhttpstatuscodes.h"
#include "llhttpclient.h"
// Debug Settings.
extern bool gNoVerifySSLCert;

View File

@@ -36,10 +36,8 @@
enum curleasyrequeststatemachine_state_type {
AICurlEasyRequestStateMachine_addRequest = AIStateMachine::max_state,
AICurlEasyRequestStateMachine_waitAdded,
AICurlEasyRequestStateMachine_added,
AICurlEasyRequestStateMachine_timedOut, // This must be smaller than the rest, so they always overrule.
AICurlEasyRequestStateMachine_finished,
AICurlEasyRequestStateMachine_removed, // The removed states must be largest two, so they are never ignored.
AICurlEasyRequestStateMachine_timedOut, // This must be smaller than the rest, so they always overrule.
AICurlEasyRequestStateMachine_removed, // The removed states must be largest two, so they are never ignored.
AICurlEasyRequestStateMachine_removed_after_finished,
AICurlEasyRequestStateMachine_bad_file_descriptor
};
@@ -50,9 +48,7 @@ char const* AICurlEasyRequestStateMachine::state_str_impl(state_type run_state)
{
AI_CASE_RETURN(AICurlEasyRequestStateMachine_addRequest);
AI_CASE_RETURN(AICurlEasyRequestStateMachine_waitAdded);
AI_CASE_RETURN(AICurlEasyRequestStateMachine_added);
AI_CASE_RETURN(AICurlEasyRequestStateMachine_timedOut);
AI_CASE_RETURN(AICurlEasyRequestStateMachine_finished);
AI_CASE_RETURN(AICurlEasyRequestStateMachine_removed);
AI_CASE_RETURN(AICurlEasyRequestStateMachine_removed_after_finished);
AI_CASE_RETURN(AICurlEasyRequestStateMachine_bad_file_descriptor);
@@ -77,14 +73,12 @@ void AICurlEasyRequestStateMachine::initialize_impl(void)
// CURL-THREAD
void AICurlEasyRequestStateMachine::added_to_multi_handle(AICurlEasyRequest_wat&)
{
set_state(AICurlEasyRequestStateMachine_added);
}
// CURL-THREAD
void AICurlEasyRequestStateMachine::finished(AICurlEasyRequest_wat&)
{
mFinished = true;
set_state(AICurlEasyRequestStateMachine_finished);
}
// CURL-THREAD
@@ -93,7 +87,7 @@ void AICurlEasyRequestStateMachine::removed_from_multi_handle(AICurlEasyRequest_
llassert(mFinished || mTimedOut); // If we neither finished nor timed out, then why is this being removed?
// Note that allowing this would cause an assertion later on for removing
// a BufferedCurlEasyRequest with a still active Responder.
set_state(mFinished ? AICurlEasyRequestStateMachine_removed_after_finished : AICurlEasyRequestStateMachine_removed);
advance_state(mFinished ? AICurlEasyRequestStateMachine_removed_after_finished : AICurlEasyRequestStateMachine_removed);
}
// CURL-THREAD
@@ -102,7 +96,7 @@ void AICurlEasyRequestStateMachine::bad_file_descriptor(AICurlEasyRequest_wat&)
if (!mFinished)
{
mFinished = true;
set_state(AICurlEasyRequestStateMachine_bad_file_descriptor);
advance_state(AICurlEasyRequestStateMachine_bad_file_descriptor);
}
}
@@ -114,59 +108,46 @@ void AICurlEasyRequestStateMachine::queued_for_removal(AICurlEasyRequest_wat&)
}
#endif
void AICurlEasyRequestStateMachine::multiplex_impl(void)
void AICurlEasyRequestStateMachine::multiplex_impl(state_type run_state)
{
mSetStateLock.lock();
state_type current_state = mRunState;
mSetStateLock.unlock();
switch (current_state)
switch (run_state)
{
case AICurlEasyRequestStateMachine_addRequest:
{
set_state(AICurlEasyRequestStateMachine_waitAdded);
idle(AICurlEasyRequestStateMachine_waitAdded); // Wait till AICurlEasyRequestStateMachine::added_to_multi_handle() is called.
idle(); // Wait till AICurlEasyRequestStateMachine::added_to_multi_handle() is called.
// Only AFTER going idle, add request to curl thread; this is needed because calls to set_state() are
// ignored when the statemachine is not idle, and theoretically the callbacks could be called
// immediately after this call.
mAdded = true;
mCurlEasyRequest.addRequest(); // This causes the state to be changed, now or later, to
// AICurlEasyRequestStateMachine_added, then
// AICurlEasyRequestStateMachine_finished and then
// AICurlEasyRequestStateMachine_removed_after_finished.
// The first two states might be skipped thus, and the state at this point is one of
// The state at this point is thus one of
// 1) AICurlEasyRequestStateMachine_waitAdded (idle)
// 2) AICurlEasyRequestStateMachine_added (running)
// 3) AICurlEasyRequestStateMachine_finished (running)
// 4) AICurlEasyRequestStateMachine_removed_after_finished (running)
// 2) AICurlEasyRequestStateMachine_removed_after_finished (running)
if (mTotalDelayTimeout > 0.f)
{
// Set an inactivity timer.
// This shouldn't really be necessary, except in the case of a bug
// in libcurl; but lets be sure and set a timer for inactivity.
mTimer = new AIPersistentTimer; // Do not delete timer upon expiration.
mTimer = new AITimer;
mTimer->setInterval(mTotalDelayTimeout);
mTimer->run(this, AICurlEasyRequestStateMachine_timedOut, false, false);
}
break;
}
case AICurlEasyRequestStateMachine_added:
case AICurlEasyRequestStateMachine_waitAdded:
{
// The request was added to the multi handle. This is a no-op, which is good cause
// this state might be skipped anyway ;).
idle(current_state); // Wait for the next event.
// The state at this point is one of
// 1) AICurlEasyRequestStateMachine_added (idle)
// 2) AICurlEasyRequestStateMachine_finished (running)
// 3) AICurlEasyRequestStateMachine_removed_after_finished (running)
// Nothing to do.
idle();
break;
}
case AICurlEasyRequestStateMachine_timedOut:
{
// It is possible that exactly at this point the state changes into
// AICurlEasyRequestStateMachine_finished, with as result that mTimedOut
// AICurlEasyRequestStateMachine_removed_after_finished, with as result that mTimedOut
// is set while we will continue with that state. Hence that mTimedOut
// is explicitly reset in that state.
@@ -176,10 +157,9 @@ void AICurlEasyRequestStateMachine::multiplex_impl(void)
llassert(mAdded);
mAdded = false;
mCurlEasyRequest.removeRequest();
idle(current_state); // Wait till AICurlEasyRequestStateMachine::removed_from_multi_handle() is called.
idle(); // Wait till AICurlEasyRequestStateMachine::removed_from_multi_handle() is called.
break;
}
case AICurlEasyRequestStateMachine_finished:
case AICurlEasyRequestStateMachine_removed_after_finished:
{
if (!mHandled)
@@ -199,12 +179,6 @@ void AICurlEasyRequestStateMachine::multiplex_impl(void)
easy_request_w->processOutput();
}
if (current_state == AICurlEasyRequestStateMachine_finished)
{
idle(current_state); // Wait till AICurlEasyRequestStateMachine::removed_from_multi_handle() is called.
break;
}
// See above.
mTimedOut = false;
/* Fall-Through */
@@ -261,17 +235,14 @@ void AICurlEasyRequestStateMachine::finish_impl(void)
}
if (mTimer)
{
// Note that even if the timer expired, it wasn't deleted because we used AIPersistentTimer; so mTimer is still valid.
// Stop the timer, if it's still running.
if (!mHandled)
mTimer->abort();
}
// Auto clean up ourselves.
kill();
}
AICurlEasyRequestStateMachine::AICurlEasyRequestStateMachine(void) :
mTimer(NULL), mTotalDelayTimeout(AIHTTPTimeoutPolicy::getDebugSettingsCurlTimeout().getTotalDelay())
mTotalDelayTimeout(AIHTTPTimeoutPolicy::getDebugSettingsCurlTimeout().getTotalDelay())
{
Dout(dc::statemachine, "Calling AICurlEasyRequestStateMachine(void) [" << (void*)this << "] [" << (void*)mCurlEasyRequest.get() << "]");
AICurlInterface::Stats::AICurlEasyRequestStateMachine_count++;

View File

@@ -62,7 +62,7 @@ class AICurlEasyRequestStateMachine : public AIStateMachine, public AICurlEasyHa
bool mTimedOut; // Set if the expiration timer timed out.
bool mFinished; // Set by the curl thread to signal it finished.
bool mHandled; // Set when we processed the received data.
AITimer* mTimer; // Expiration timer.
LLPointer<AITimer> mTimer; // Expiration timer.
F32 mTotalDelayTimeout; // The time out value for mTimer.
public:
@@ -99,7 +99,7 @@ class AICurlEasyRequestStateMachine : public AIStateMachine, public AICurlEasyHa
/*virtual*/ void initialize_impl(void);
// Handle mRunState.
/*virtual*/ void multiplex_impl(void);
/*virtual*/ void multiplex_impl(state_type run_state);
// Handle aborting from current bs_run state.
/*virtual*/ void abort_impl(void);

View File

@@ -36,9 +36,11 @@
#include "llrefcount.h"
#include "aicurlperhost.h"
#include "aihttptimeout.h"
#include "llhttpclient.h"
class AIHTTPHeaders;
class AICurlEasyRequestStateMachine;
struct AITransferInfo;
namespace AICurlPrivate {
@@ -212,6 +214,7 @@ class CurlEasyRequest : public CurlEasyHandle {
private:
void setPost_raw(U32 size, char const* data, bool keepalive);
public:
void setPut(U32 size, bool keepalive = true);
void setPost(U32 size, bool keepalive = true) { setPost_raw(size, NULL, keepalive); }
void setPost(AIPostFieldPtr const& postdata, U32 size, bool keepalive = true);
void setPost(char const* data, U32 size, bool keepalive = true) { setPost(new AIPostField(data), size, keepalive); }
@@ -297,6 +300,7 @@ class CurlEasyRequest : public CurlEasyHandle {
protected:
curl_slist* mHeaders;
AICurlEasyHandleEvents* mHandleEventsTarget;
U32 mContentLength; // Non-zero if known (only set for PUT and POST).
CURLcode mResult; //AIFIXME: this does not belong in the request object, but belongs in the response object.
AIHTTPTimeoutPolicy const* mTimeoutPolicy;
@@ -319,12 +323,12 @@ class CurlEasyRequest : public CurlEasyHandle {
// Accessor for mTimeout with optional creation of orphaned object (if lockobj != NULL).
LLPointer<curlthread::HTTPTimeout>& httptimeout(void) { if (!mTimeout) { create_timeout_object(); mTimeoutIsOrphan = true; } return mTimeout; }
// Return true if no data has been received on the latest socket (if any) for too long.
bool has_stalled(void) const { return mTimeout && mTimeout->has_stalled(); }
bool has_stalled(void) { return mTimeout && mTimeout->has_stalled(); }
protected:
// This class may only be created as base class of BufferedCurlEasyRequest.
// Throws AICurlNoEasyHandle.
CurlEasyRequest(void) : mHeaders(NULL), mHandleEventsTarget(NULL), mResult(CURLE_FAILED_INIT), mTimeoutPolicy(NULL), mTimeoutIsOrphan(false)
CurlEasyRequest(void) : mHeaders(NULL), mHandleEventsTarget(NULL), mContentLength(0), mResult(CURLE_FAILED_INIT), mTimeoutPolicy(NULL), mTimeoutIsOrphan(false)
#if defined(CWDEBUG) || defined(DEBUG_CURLIO)
, mDebugIsHeadOrGetMethod(false)
#endif
@@ -402,8 +406,8 @@ class BufferedCurlEasyRequest : public CurlEasyRequest {
//U32 mBodyLimit; // From the old LLURLRequestDetail::mBodyLimit, but never used.
U32 mStatus; // HTTP status, decoded from the first header line.
std::string mReason; // The "reason" from the same header line.
S32 mRequestTransferedBytes;
S32 mResponseTransferedBytes;
U32 mRequestTransferedBytes;
U32 mResponseTransferedBytes;
AIBufferedCurlEasyRequestEvents* mBufferEventsTarget;
public:
@@ -433,7 +437,7 @@ class BufferedCurlEasyRequest : public CurlEasyRequest {
ThreadSafeBufferedCurlEasyRequest const* get_lockobj(void) const;
// Return true when an error code was received that can occur before the upload finished.
// So far the only such error I've seen is HTTP_BAD_REQUEST.
bool upload_error_status(void) const { return mStatus == HTTP_BAD_REQUEST /*&& mStatus != HTTP_INTERNAL_ERROR*/; }
bool upload_error_status(void) const { return mStatus == HTTP_BAD_REQUEST; }
// Return true when prepRequest was already called and the object has not been
// invalidated as a result of calling timed_out().

View File

@@ -832,8 +832,9 @@ class AICurlThread : public LLThread
{
public:
static AICurlThread* sInstance;
LLMutex mWakeUpMutex;
bool mWakeUpFlag; // Protected by mWakeUpMutex.
LLMutex mWakeUpMutex; // Set while a thread is waking up the curl thread.
LLMutex mWakeUpFlagMutex; // Set when the curl thread is sleeping (in or about to enter select()).
bool mWakeUpFlag; // Protected by mWakeUpFlagMutex.
public:
// MAIN-THREAD
@@ -1067,11 +1068,10 @@ void AICurlThread::cleanup_wakeup_fds(void)
#endif
}
// MAIN-THREAD
// OTHER THREADS
void AICurlThread::wakeup_thread(bool stop_thread)
{
DoutEntering(dc::curl, "AICurlThread::wakeup_thread");
llassert(is_main_thread());
// If we are already exiting the viewer then return immediately.
if (!mRunning)
@@ -1079,12 +1079,29 @@ void AICurlThread::wakeup_thread(bool stop_thread)
// Last time we are run?
if (stop_thread)
mRunning = false;
mRunning = false; // Thread-safe because all other threads were already stopped.
// Note, we do not want this function to be blocking the calling thread; therefore we only use tryLock()s.
// Stop two threads running the following code concurrently.
if (!mWakeUpMutex.tryLock())
{
// If we failed to obtain mWakeUpMutex then another thread is (or was) in AICurlThread::wakeup_thread,
// or curl was holding the lock for a micro second at the start of process_commands.
// In the first case, curl might or might not yet have been woken up because of that, but if it was
// then it could not have started processing the commands yet, because it needs to obtain mWakeUpMutex
// between being woken up and processing the commands.
// Either way, the command that this thread called this function for was already in the queue (it's
// added before this function is called) but the command(s) that another thread called this function
// for were not processed yet. Hence, it's safe to exit here as our command(s) will be processed too.
return;
}
// Try if curl thread is still awake and if so, pass the new commands directly.
if (mWakeUpMutex.tryLock())
if (mWakeUpFlagMutex.tryLock())
{
mWakeUpFlag = true;
mWakeUpFlagMutex.unlock();
mWakeUpMutex.unlock();
return;
}
@@ -1111,7 +1128,10 @@ void AICurlThread::wakeup_thread(bool stop_thread)
{
len = write(mWakeUpFd_in, "!", 1);
if (len == -1 && errno == EAGAIN)
{
mWakeUpMutex.unlock();
return; // Unread characters are still in the pipe, so no need to add more.
}
}
while(len == -1 && errno == EINTR);
if (len == -1)
@@ -1120,6 +1140,12 @@ void AICurlThread::wakeup_thread(bool stop_thread)
}
llassert_always(len == 1);
#endif
// Release the lock here and not sooner, for the sole purpose of making sure
// that not two threads execute the above code concurrently. If the above code
// is thread-safe (maybe it is?) then we could release this lock arbitrarily
// sooner indeed - or even not lock it at all.
mWakeUpMutex.unlock();
}
apr_status_t AICurlThread::join_thread(void)
@@ -1239,6 +1265,16 @@ void AICurlThread::process_commands(AICurlMultiHandle_wat const& multi_handle_w)
{
DoutEntering(dc::curl, "AICurlThread::process_commands(void)");
// Block here until the thread that woke us up released mWakeUpMutex.
// This is necessary to make sure that a third thread added commands
// too then either it will signal us later, or we process those commands
// now, too.
mWakeUpMutex.lock();
// Note that if at THIS point another thread tries to obtain mWakeUpMutex in AICurlThread::wakeup_thread
// and fails, it is ok that it leaves that function without waking us up too: we're awake and
// about to process any commands!
mWakeUpMutex.unlock();
// If we get here then the main thread called wakeup_thread() recently.
for(;;)
{
@@ -1247,9 +1283,9 @@ void AICurlThread::process_commands(AICurlMultiHandle_wat const& multi_handle_w)
command_queue_wat command_queue_w(command_queue);
if (command_queue_w->empty())
{
mWakeUpMutex.lock();
mWakeUpFlagMutex.lock();
mWakeUpFlag = false;
mWakeUpMutex.unlock();
mWakeUpFlagMutex.unlock();
break;
}
// Move the next command from the queue into command_being_processed.
@@ -1312,10 +1348,10 @@ void AICurlThread::run(void)
// Process every command in command_queue before filling the fd_set passed to select().
for(;;)
{
mWakeUpMutex.lock();
mWakeUpFlagMutex.lock();
if (mWakeUpFlag)
{
mWakeUpMutex.unlock();
mWakeUpFlagMutex.unlock();
process_commands(multi_handle_w);
continue;
}
@@ -1324,7 +1360,7 @@ void AICurlThread::run(void)
// wakeup_thread() is also called after setting mRunning to false.
if (!mRunning)
{
mWakeUpMutex.unlock();
mWakeUpFlagMutex.unlock();
break;
}
@@ -1400,7 +1436,7 @@ void AICurlThread::run(void)
#endif
#endif
ready = select(nfds, read_fd_set, write_fd_set, NULL, &timeout);
mWakeUpMutex.unlock();
mWakeUpFlagMutex.unlock();
#ifdef CWDEBUG
#ifdef DEBUG_CURLIO
Dout(dc::finish|cond_error_cf(ready == -1), ready);
@@ -1901,7 +1937,7 @@ void BufferedCurlEasyRequest::setStatusAndReason(U32 status, std::string const&
// Sanity check. If the server replies with a redirect status then we better have that option turned on!
if ((status >= 300 && status < 400) && mResponder && !mResponder->redirect_status_ok())
{
llerrs << "Received " << status << " (" << reason << ") for responder \"" << mTimeoutPolicy->name() << "\" which has no followRedir()!" << llendl;
llerrs << "Received " << status << " (" << reason << ") for responder \"" << mResponder->getName() << "\" which has no followRedir()!" << llendl;
}
}
@@ -1913,7 +1949,7 @@ void BufferedCurlEasyRequest::processOutput(void)
CURLcode code;
AITransferInfo info;
getResult(&code, &info);
if (code == CURLE_OK && mStatus != HTTP_INTERNAL_ERROR)
if (code == CURLE_OK && !is_internal_http_error(mStatus))
{
getinfo(CURLINFO_RESPONSE_CODE, &responseCode);
// If getResult code is CURLE_OK then we should have decoded the first header line ourselves.
@@ -1925,8 +1961,30 @@ void BufferedCurlEasyRequest::processOutput(void)
}
else
{
responseCode = HTTP_INTERNAL_ERROR;
responseReason = (code == CURLE_OK) ? mReason : std::string(curl_easy_strerror(code));
switch (code)
{
case CURLE_FAILED_INIT:
responseCode = HTTP_INTERNAL_ERROR_OTHER;
break;
case CURLE_OPERATION_TIMEDOUT:
responseCode = HTTP_INTERNAL_ERROR_CURL_TIMEOUT;
break;
case CURLE_WRITE_ERROR:
responseCode = HTTP_INTERNAL_ERROR_LOW_SPEED;
break;
default:
responseCode = HTTP_INTERNAL_ERROR_CURL_OTHER;
break;
}
if (responseCode == HTTP_INTERNAL_ERROR_LOW_SPEED)
{
// Rewrite error to something understandable.
responseReason = llformat("Connection to \"%s\" stalled: download speed dropped below %u bytes/s for %u seconds (up till that point, %s received a total of %u bytes). "
"To change these values, go to Advanced --> Debug Settings and change CurlTimeoutLowSpeedLimit and CurlTimeoutLowSpeedTime respectively.",
mResponder->getURL().c_str(), mResponder->getHTTPTimeoutPolicy().getLowSpeedLimit(), mResponder->getHTTPTimeoutPolicy().getLowSpeedTime(),
mResponder->getName(), mResponseTransferedBytes);
}
setopt(CURLOPT_FRESH_CONNECT, TRUE);
}
@@ -2000,8 +2058,9 @@ size_t BufferedCurlEasyRequest::curlReadCallback(char* data, size_t size, size_t
S32 bytes = size * nmemb; // The maximum amount to read.
self_w->mLastRead = self_w->getInput()->readAfter(sChannels.out(), self_w->mLastRead, (U8*)data, bytes);
self_w->mRequestTransferedBytes += bytes; // Accumulate data sent to the server.
llassert(self_w->mRequestTransferedBytes <= self_w->mContentLength); // Content-Length should always be known, and we should never be sending more.
// Timeout administration.
if (self_w->httptimeout()->data_sent(bytes))
if (self_w->httptimeout()->data_sent(bytes, self_w->mRequestTransferedBytes >= self_w->mContentLength))
{
// Transfer timed out. Return CURL_READFUNC_ABORT which will abort with error CURLE_ABORTED_BY_CALLBACK.
return CURL_READFUNC_ABORT;
@@ -2063,7 +2122,7 @@ size_t BufferedCurlEasyRequest::curlHeaderCallback(char* data, size_t size, size
}
// Either way, this status value is not understood (or taken into account).
// Set it to internal error so that the rest of code treats it as an error.
status = HTTP_INTERNAL_ERROR;
status = HTTP_INTERNAL_ERROR_OTHER;
}
self_w->received_HTTP_header();
self_w->setStatusAndReason(status, reason);

View File

@@ -66,7 +66,7 @@ struct AIAccess {
struct AIHTTPTimeoutPolicy {
U16 getReplyDelay(void) const { return 60; }
U16 getLowSpeedTime(void) const { return 30; }
U32 getLowSpeedLimit(void) const { return 56000; }
U32 getLowSpeedLimit(void) const { return 7000; }
static bool connect_timed_out(std::string const&) { return false; }
};
@@ -84,6 +84,11 @@ public:
#include "aihttptimeout.h"
// If this is set, treat dc::curlio as off in the assertion below.
#if defined(CWDEBUG) || defined(DEBUG_CURLIO)
bool gCurlIo;
#endif
namespace AICurlPrivate {
namespace curlthread {
@@ -100,7 +105,7 @@ U64 HTTPTimeout::sClockCount; // Clock count, set once per select() exi
// queued--><--DNS lookup + connect + send headers-->[<--send body (if any)-->]<--replydelay--><--receive headers + body--><--done
// ^ ^ ^ ^ ^ ^
// | | | | | |
bool HTTPTimeout::data_sent(size_t n)
bool HTTPTimeout::data_sent(size_t n, bool finished)
{
// Generate events.
if (!mLowSpeedOn)
@@ -109,7 +114,7 @@ bool HTTPTimeout::data_sent(size_t n)
reset_lowspeed();
}
// Detect low speed.
return lowspeed(n);
return lowspeed(n, finished);
}
// CURL-THREAD
@@ -122,6 +127,7 @@ void HTTPTimeout::reset_lowspeed(void)
{
mLowSpeedClock = sClockCount;
mLowSpeedOn = true;
mLastBytesSent = false; // We're just starting!
mLastSecond = -1; // This causes lowspeed to initialize the rest.
mStalled = (U64)-1; // Stop reply delay timer.
DoutCurl("reset_lowspeed: mLowSpeedClock = " << mLowSpeedClock << "; mStalled = -1");
@@ -169,7 +175,7 @@ bool HTTPTimeout::data_received(size_t n/*,*/
// using CURLOPT_DEBUGFUNCTION. Note that mDebugIsHeadOrGetMethod is only valid when the debug channel 'curlio' is on,
// because it is set in the debug callback function.
// This is also normal if we received a HTTP header with an error status, since that can interrupt our upload.
Debug(llassert(upload_error_status || AICurlEasyRequest_wat(*mLockObj)->mDebugIsHeadOrGetMethod || !dc::curlio.is_on()));
Debug(llassert(upload_error_status || AICurlEasyRequest_wat(*mLockObj)->mDebugIsHeadOrGetMethod || !dc::curlio.is_on() || gCurlIo));
// 'Upload finished' detection failed, generate it now.
upload_finished();
}
@@ -193,9 +199,9 @@ bool HTTPTimeout::data_received(size_t n/*,*/
// queued--><--DNS lookup + connect + send headers-->[<--send body (if any)-->]<--replydelay--><--receive headers + body--><--done
// ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
// | | | | | | | | | | | | | |
bool HTTPTimeout::lowspeed(size_t bytes)
bool HTTPTimeout::lowspeed(size_t bytes, bool finished)
{
//DoutCurlEntering("HTTPTimeout::lowspeed(" << bytes << ")"); commented out... too spammy for normal use.
//DoutCurlEntering("HTTPTimeout::lowspeed(" << bytes << ", " << finished << ")"); commented out... too spammy for normal use.
// The algorithm to determine if we timed out if different from how libcurls CURLOPT_LOW_SPEED_TIME works.
//
@@ -219,6 +225,9 @@ bool HTTPTimeout::lowspeed(size_t bytes)
// and caused something so evil and hard to find that... NEVER AGAIN!
llassert(second >= 0);
// finished should be false until the very last call to this function.
mLastBytesSent = finished;
// If this is the same second as last time, just add the number of bytes to the current bucket.
if (second == mLastSecond)
{
@@ -274,21 +283,39 @@ bool HTTPTimeout::lowspeed(size_t bytes)
mBuckets[mBucket] = bytes;
// Check if we timed out.
U32 const low_speed_limit = mPolicy->getLowSpeedLimit();
U32 mintotalbytes = low_speed_limit * low_speed_time;
U32 const low_speed_limit = mPolicy->getLowSpeedLimit(); // In bytes/s
U32 mintotalbytes = low_speed_limit * low_speed_time; // In bytes.
DoutCurl("Transfered " << mTotalBytes << " bytes in " << llmin(second, (S32)low_speed_time) << " seconds after " << second << " second" << ((second == 1) ? "" : "s") << ".");
if (second >= low_speed_time)
{
DoutCurl("Average transfer rate is " << (mTotalBytes / low_speed_time) << " bytes/s (low speed limit is " << low_speed_limit << " bytes/s)");
if (mTotalBytes < mintotalbytes)
{
if (finished)
{
llwarns <<
#ifdef CWDEBUG
(void*)get_lockobj() << ": "
#endif
"Transfer rate timeout (average transfer rate below " << low_speed_limit <<
" bytes/s for more than " << low_speed_time << " second" << ((low_speed_time == 1) ? "" : "s") <<
") but we just sent the LAST bytes! Waiting an additional 4 seconds." << llendl;
// Lets hope these last bytes will make it and do not time out on transfer speed anymore.
// Just give these bytes 4 more seconds to be written to the socket (after which we'll
// assume that the 'upload finished' detection failed and we'll wait another ReplyDelay
// seconds before finally, actually timing out.
mStalled = sClockCount + 4 / sClockWidth;
DoutCurl("mStalled set to sClockCount (" << sClockCount << ") + " << (mStalled - sClockCount) << " (4 seconds)");
return false;
}
// The average transfer rate over the passed low_speed_time seconds is too low. Abort the transfer.
llwarns <<
#ifdef CWDEBUG
(void*)get_lockobj() << ": "
#endif
"aborting slow connection (average transfer rate below " << low_speed_limit <<
" for more than " << low_speed_time << " second" << ((low_speed_time == 1) ? "" : "s") << ")." << llendl;
" bytes/s for more than " << low_speed_time << " second" << ((low_speed_time == 1) ? "" : "s") << ")." << llendl;
// This causes curl to exit with CURLE_WRITE_ERROR.
return true;
}
}
@@ -327,7 +354,7 @@ bool HTTPTimeout::lowspeed(size_t bytes)
llassert_always(bucket < low_speed_time);
total_bytes -= mBuckets[bucket]; // Empty this bucket.
}
while(total_bytes >= 1); // Use 1 here instead of mintotalbytes, to test that total_bytes indeed always reaches zero.
while(total_bytes >= mintotalbytes);
}
// If this function isn't called again within max_stall_time seconds, we stalled.
mStalled = sClockCount + max_stall_time / sClockWidth;
@@ -377,6 +404,19 @@ void HTTPTimeout::done(AICurlEasyRequest_wat const& curlEasyRequest_w, CURLcode
DoutCurl("done: mStalled set to -1");
}
bool HTTPTimeout::maybe_upload_finished(void)
{
if (!mUploadFinished && mLastBytesSent)
{
// Assume that 'upload finished' detection failed and the server is slow with a reply.
// Switch to waiting for a reply.
upload_finished();
return true;
}
// The upload certainly finished or certainly did not finish.
return false;
}
// Libcurl uses GetTickCount on windows, with a resolution of 10 to 16 ms.
// As a result, we can not assume that namelookup_time == 0 has a special meaning.
#define LOWRESTIMER LL_WINDOWS
@@ -493,6 +533,10 @@ void HTTPTimeout::print_diagnostics(CurlEasyRequest const* curl_easy_request, ch
{
llinfos << "The request upload finished successfully." << llendl;
}
else if (mLastBytesSent)
{
llinfos << "All bytes where sent to libcurl for upload." << llendl;
}
if (mLastSecond > 0 && mLowSpeedOn)
{
llinfos << "The " << (mNothingReceivedYet ? "upload" : "download") << " did last " << mLastSecond << " second" << ((mLastSecond == 1) ? "" : "s") << ", before it timed out." << llendl;

View File

@@ -79,6 +79,7 @@ class HTTPTimeout : public LLRefCount {
U16 mBucket; // The bucket corresponding to mLastSecond.
bool mNothingReceivedYet; // Set when created, reset when the HTML reply header from the server is received.
bool mLowSpeedOn; // Set while uploading or downloading data.
bool mLastBytesSent; // Set when the last bytes were sent to libcurl to be uploaded.
bool mUploadFinished; // Used to keep track of whether upload_finished was called yet.
S32 mLastSecond; // The time at which lowspeed() was last called, in seconds since mLowSpeedClock.
S32 mOverwriteSecond; // The second at which the first bucket of this transfer will be overwritten.
@@ -94,7 +95,7 @@ class HTTPTimeout : public LLRefCount {
public:
HTTPTimeout(AIHTTPTimeoutPolicy const* policy, ThreadSafeBufferedCurlEasyRequest* lock_obj) :
mPolicy(policy), mNothingReceivedYet(true), mLowSpeedOn(false), mUploadFinished(false), mStalled((U64)-1)
mPolicy(policy), mNothingReceivedYet(true), mLowSpeedOn(false), mLastBytesSent(false), mUploadFinished(false), mStalled((U64)-1)
#if defined(CWDEBUG) || defined(DEBUG_CURLIO)
, mLockObj(lock_obj)
#endif
@@ -104,7 +105,7 @@ class HTTPTimeout : public LLRefCount {
void upload_finished(void);
// Called when data is sent. Returns true if transfer timed out.
bool data_sent(size_t n);
bool data_sent(size_t n, bool finished);
// Called when data is received. Returns true if transfer timed out.
bool data_received(size_t n/*,*/ ASSERT_ONLY_COMMA(bool upload_error_status = false));
@@ -112,8 +113,8 @@ class HTTPTimeout : public LLRefCount {
// Called immediately before done() after curl finished, with code.
void done(AICurlEasyRequest_wat const& curlEasyRequest_w, CURLcode code);
// Accessor.
bool has_stalled(void) const { return mStalled < sClockCount; }
// Returns true when we REALLY timed out. Might call upload_finished heuristically.
bool has_stalled(void) { return mStalled < sClockCount && !maybe_upload_finished(); }
// Called from BufferedCurlEasyRequest::processOutput if a timeout occurred.
void print_diagnostics(CurlEasyRequest const* curl_easy_request, char const* eff_url);
@@ -127,11 +128,19 @@ class HTTPTimeout : public LLRefCount {
void reset_lowspeed(void);
// Common low speed detection, Called from data_sent or data_received.
bool lowspeed(size_t bytes);
bool lowspeed(size_t bytes, bool finished = false);
// Return false when we timed out on reply delay, or didn't sent all bytes yet.
// Otherwise calls upload_finished() and return true;
bool maybe_upload_finished(void);
};
} // namespace curlthread
} // namespace AICurlPrivate
#if defined(CWDEBUG) || defined(DEBUG_CURLIO)
extern bool gCurlIo;
#endif
#endif

View File

@@ -88,7 +88,7 @@ U16 const AITP_default_DNS_lookup_grace = 60; // Allow for 60 seconds long DNS
U16 const AITP_default_maximum_connect_time = 10; // Allow the SSL/TLS connection through a proxy, including handshakes, to take up to 10 seconds.
U16 const AITP_default_maximum_reply_delay = 60; // Allow the server 60 seconds to do whatever it has to do before starting to send data.
U16 const AITP_default_low_speed_time = 30; // If a transfer speed drops below AITP_default_low_speed_limit bytes/s for 30 seconds, terminate the transfer.
U32 const AITP_default_low_speed_limit = 56000; // In bytes per second (use for CURLOPT_LOW_SPEED_LIMIT).
U32 const AITP_default_low_speed_limit = 7000; // In bytes per second (use for CURLOPT_LOW_SPEED_LIMIT).
U16 const AITP_default_maximum_curl_transaction = 300; // Allow large files to be transfered over slow connections.
U16 const AITP_default_maximum_total_delay = 600; // Avoid "leaking" by terminating anything that wasn't completed after 10 minutes.
@@ -105,6 +105,7 @@ AIHTTPTimeoutPolicy& AIHTTPTimeoutPolicy::operator=(AIHTTPTimeoutPolicy const& r
mLowSpeedLimit = rhs.mLowSpeedLimit;
mMaximumCurlTransaction = rhs.mMaximumCurlTransaction;
mMaximumTotalDelay = rhs.mMaximumTotalDelay;
changed();
return *this;
}
@@ -136,19 +137,27 @@ struct PolicyOp {
class AIHTTPTimeoutPolicyBase : public AIHTTPTimeoutPolicy {
private:
std::vector<AIHTTPTimeoutPolicy*> mDerived; // Policies derived from this one.
PolicyOp const* mOp; // Operator we applied to base to get ourselves.
public:
AIHTTPTimeoutPolicyBase(U16 dns_lookup_grace, U16 subsequent_connects, U16 reply_delay,
U16 low_speed_time, U32 low_speed_limit,
U16 curl_transaction, U16 total_delay) :
AIHTTPTimeoutPolicy(NULL, dns_lookup_grace, subsequent_connects, reply_delay, low_speed_time, low_speed_limit, curl_transaction, total_delay) { }
AIHTTPTimeoutPolicy(NULL, dns_lookup_grace, subsequent_connects, reply_delay, low_speed_time, low_speed_limit, curl_transaction, total_delay),
mOp(NULL) { }
// Derive base from base.
AIHTTPTimeoutPolicyBase(AIHTTPTimeoutPolicyBase& rhs, PolicyOp const& op) : AIHTTPTimeoutPolicy(rhs) { op.perform(this); }
AIHTTPTimeoutPolicyBase(AIHTTPTimeoutPolicyBase& rhs, PolicyOp& op) : AIHTTPTimeoutPolicy(rhs), mOp(&op) { rhs.derived(this); mOp->perform(this); }
// Called for every derived policy.
void derived(AIHTTPTimeoutPolicy* derived) { mDerived.push_back(derived); }
// Called when our base changed.
/*virtual*/ void base_changed(void);
// Called when we ourselves changed.
/*virtual*/ void changed(void);
// Provide public acces to sDebugSettingsCurlTimeout for this compilation unit.
static AIHTTPTimeoutPolicyBase& getDebugSettingsCurlTimeout(void) { return sDebugSettingsCurlTimeout; }
@@ -157,6 +166,27 @@ class AIHTTPTimeoutPolicyBase : public AIHTTPTimeoutPolicy {
AIHTTPTimeoutPolicyBase& operator=(AIHTTPTimeoutPolicy const& rhs);
};
void AIHTTPTimeoutPolicyBase::base_changed(void)
{
AIHTTPTimeoutPolicy::base_changed();
if (mOp)
mOp->perform(this);
changed();
}
void AIHTTPTimeoutPolicyBase::changed(void)
{
for (std::vector<AIHTTPTimeoutPolicy*>::iterator iter = mDerived.begin(); iter != mDerived.end(); ++iter)
(*iter)->base_changed();
}
void AIHTTPTimeoutPolicy::changed(void)
{
Dout(dc::notice, "Policy \"" << mName << "\" changed into: DNSLookup: " << mDNSLookupGrace << "; Connect: " << mMaximumConnectTime <<
"; ReplyDelay: " << mMaximumReplyDelay << "; LowSpeedTime: " << mLowSpeedTime << "; LowSpeedLimit: " << mLowSpeedLimit <<
"; MaxTransaction: " << mMaximumCurlTransaction << "; MaxTotalDelay:" << mMaximumTotalDelay);
}
AIHTTPTimeoutPolicy::AIHTTPTimeoutPolicy(AIHTTPTimeoutPolicy& base) :
mName(NULL),
mBase(static_cast<AIHTTPTimeoutPolicyBase*>(&base)),
@@ -192,6 +222,19 @@ AIHTTPTimeoutPolicy::AIHTTPTimeoutPolicy(char const* name, AIHTTPTimeoutPolicyBa
mBase->derived(this);
}
void AIHTTPTimeoutPolicy::base_changed(void)
{
// The same as *this = *mBase; but can't use operator= because of an assert that checks that mBase is not set.
mDNSLookupGrace = mBase->mDNSLookupGrace;
mMaximumConnectTime = mBase->mMaximumConnectTime;
mMaximumReplyDelay = mBase->mMaximumReplyDelay;
mLowSpeedTime = mBase->mLowSpeedTime;
mLowSpeedLimit = mBase->mLowSpeedLimit;
mMaximumCurlTransaction = mBase->mMaximumCurlTransaction;
mMaximumTotalDelay = mBase->mMaximumTotalDelay;
changed();
}
//static
void AIHTTPTimeoutPolicy::setDefaultCurlTimeout(AIHTTPTimeoutPolicy const& timeout)
{
@@ -621,7 +664,7 @@ AIHTTPTimeoutPolicyBase HTTPTimeoutPolicy_default(
AITP_default_maximum_curl_transaction,
AITP_default_maximum_total_delay);
//static. Initialized here, but shortly overwritten by Debug Settings.
//static. Initialized here, but shortly overwritten by Debug Settings (except for the crash logger, in which case these are the actual values).
AIHTTPTimeoutPolicyBase AIHTTPTimeoutPolicy::sDebugSettingsCurlTimeout(
AITP_default_DNS_lookup_grace,
AITP_default_maximum_connect_time,
@@ -631,8 +674,8 @@ AIHTTPTimeoutPolicyBase AIHTTPTimeoutPolicy::sDebugSettingsCurlTimeout(
AITP_default_maximum_curl_transaction,
AITP_default_maximum_total_delay);
// Note: Broken compiler doesn't allow as to use temporaries for the Operator ojects,
// so they are instantiated separately.
// Note: All operator objects (Transaction, Connect, etc) must be globals (not temporaries)!
// To enforce this they are passes as reference to non-const (but will never be changed).
// This used to be '5 seconds'.
Transaction transactionOp5s(5);

View File

@@ -89,6 +89,9 @@ class AIHTTPTimeoutPolicy {
U16 curl_transaction,
U16 total_delay);
// Destructor.
virtual ~AIHTTPTimeoutPolicy() { }
void sanity_checks(void) const;
// Accessors.
@@ -110,6 +113,12 @@ class AIHTTPTimeoutPolicy {
// Called when a connect to a hostname timed out.
static bool connect_timed_out(std::string const& hostname);
// Called when the base that this policy was based on changed.
virtual void base_changed(void);
// Called when we ourselves changed.
virtual void changed(void);
protected:
// Used by AIHTTPTimeoutPolicyBase::AIHTTPTimeoutPolicyBase(AIHTTPTimeoutPolicyBase&).
AIHTTPTimeoutPolicy(AIHTTPTimeoutPolicy&);

View File

@@ -30,7 +30,6 @@
#include "llbuffer.h"
#include "llmath.h"
#include "llmemtype.h"
#include "llstl.h"
#include "llthread.h"
@@ -44,7 +43,6 @@ LLSegment::LLSegment() :
mData(NULL),
mSize(0)
{
LLMemType m1(LLMemType::MTYPE_IO_BUFFER);
}
LLSegment::LLSegment(S32 channel, U8* data, S32 data_len) :
@@ -52,12 +50,10 @@ LLSegment::LLSegment(S32 channel, U8* data, S32 data_len) :
mData(data),
mSize(data_len)
{
LLMemType m1(LLMemType::MTYPE_IO_BUFFER);
}
LLSegment::~LLSegment()
{
LLMemType m1(LLMemType::MTYPE_IO_BUFFER);
}
bool LLSegment::isOnChannel(S32 channel) const
@@ -104,7 +100,6 @@ LLHeapBuffer::LLHeapBuffer() :
mNextFree(NULL),
mReclaimedBytes(0)
{
LLMemType m1(LLMemType::MTYPE_IO_BUFFER);
const S32 DEFAULT_HEAP_BUFFER_SIZE = 16384;
allocate(DEFAULT_HEAP_BUFFER_SIZE);
}
@@ -115,7 +110,6 @@ LLHeapBuffer::LLHeapBuffer(S32 size) :
mNextFree(NULL),
mReclaimedBytes(0)
{
LLMemType m1(LLMemType::MTYPE_IO_BUFFER);
allocate(size);
}
@@ -125,7 +119,6 @@ LLHeapBuffer::LLHeapBuffer(const U8* src, S32 len) :
mNextFree(NULL),
mReclaimedBytes(0)
{
LLMemType m1(LLMemType::MTYPE_IO_BUFFER);
if((len > 0) && src)
{
allocate(len);
@@ -139,7 +132,6 @@ LLHeapBuffer::LLHeapBuffer(const U8* src, S32 len) :
// virtual
LLHeapBuffer::~LLHeapBuffer()
{
LLMemType m1(LLMemType::MTYPE_IO_BUFFER);
delete[] mBuffer;
mBuffer = NULL;
mSize = 0;
@@ -157,7 +149,6 @@ bool LLHeapBuffer::createSegment(
S32 size,
LLSegment& segment)
{
LLMemType m1(LLMemType::MTYPE_IO_BUFFER);
// get actual size of the segment.
S32 actual_size = llmin(size, (mSize - S32(mNextFree - mBuffer)));
@@ -212,7 +203,6 @@ bool LLHeapBuffer::containsSegment(const LLSegment& segment) const
void LLHeapBuffer::allocate(S32 size)
{
LLMemType m1(LLMemType::MTYPE_IO_BUFFER);
mReclaimedBytes = 0;
mBuffer = new U8[size];
if(mBuffer)
@@ -230,12 +220,10 @@ LLBufferArray::LLBufferArray() :
mNextBaseChannel(0),
mMutexp(NULL)
{
LLMemType m1(LLMemType::MTYPE_IO_BUFFER);
}
LLBufferArray::~LLBufferArray()
{
LLMemType m1(LLMemType::MTYPE_IO_BUFFER);
std::for_each(mBuffers.begin(), mBuffers.end(), DeletePointer());
delete mMutexp;
@@ -314,7 +302,6 @@ bool LLBufferArray::append(S32 channel, const U8* src, S32 len)
{
LLMutexLock lock(mMutexp) ;
LLMemType m1(LLMemType::MTYPE_IO_BUFFER);
std::vector<LLSegment> segments;
if(copyIntoBuffers(channel, src, len, segments))
{
@@ -329,7 +316,6 @@ bool LLBufferArray::prepend(S32 channel, const U8* src, S32 len)
{
ASSERT_LLBUFFERARRAY_MUTEX_LOCKED
LLMemType m1(LLMemType::MTYPE_IO_BUFFER);
std::vector<LLSegment> segments;
if(copyIntoBuffers(channel, src, len, segments))
{
@@ -345,7 +331,6 @@ bool LLBufferArray::insertAfter(
const U8* src,
S32 len)
{
LLMemType m1(LLMemType::MTYPE_IO_BUFFER);
std::vector<LLSegment> segments;
LLMutexLock lock(mMutexp) ;
@@ -366,7 +351,6 @@ LLBufferArray::segment_iterator_t LLBufferArray::splitAfter(U8* address)
{
ASSERT_LLBUFFERARRAY_MUTEX_LOCKED
LLMemType m1(LLMemType::MTYPE_IO_BUFFER);
segment_iterator_t end = mSegments.end();
segment_iterator_t it = getSegment(address);
if(it == end)
@@ -428,7 +412,6 @@ LLBufferArray::segment_iterator_t LLBufferArray::constructSegmentAfter(
LLSegment& segment)
{
ASSERT_LLBUFFERARRAY_MUTEX_LOCKED
LLMemType m1(LLMemType::MTYPE_IO_BUFFER);
segment_iterator_t rv = mSegments.begin();
segment_iterator_t end = mSegments.end();
if(!address)
@@ -592,7 +575,6 @@ U8* LLBufferArray::readAfter(
U8* dest,
S32& len) const
{
LLMemType m1(LLMemType::MTYPE_IO_BUFFER);
U8* rv = start;
if(!dest || len <= 0)
{
@@ -652,7 +634,6 @@ U8* LLBufferArray::readAfter(
void LLBufferArray::writeChannelTo(std::ostream& ostr, S32 channel) const
{
LLMemType m1(LLMemType::MTYPE_IO_BUFFER);
LLMutexLock lock(mMutexp) ;
const_segment_iterator_t const end = mSegments.end();
for (const_segment_iterator_t it = mSegments.begin(); it != end; ++it)
@@ -670,7 +651,6 @@ U8* LLBufferArray::seek(
S32 delta) const
{
ASSERT_LLBUFFERARRAY_MUTEX_LOCKED
LLMemType m1(LLMemType::MTYPE_IO_BUFFER);
const_segment_iterator_t it;
const_segment_iterator_t end = mSegments.end();
U8* rv = start;
@@ -814,8 +794,6 @@ U8* LLBufferArray::seek(
//test use only
bool LLBufferArray::takeContents(LLBufferArray& source)
{
LLMemType m1(LLMemType::MTYPE_IO_BUFFER);
LLMutexLock lock(mMutexp);
source.lock();
@@ -841,7 +819,7 @@ LLBufferArray::segment_iterator_t LLBufferArray::makeSegment(
S32 len)
{
ASSERT_LLBUFFERARRAY_MUTEX_LOCKED
LLMemType m1(LLMemType::MTYPE_IO_BUFFER);
// start at the end of the buffers, because it is the most likely
// to have free space.
LLSegment segment;
@@ -880,7 +858,6 @@ LLBufferArray::segment_iterator_t LLBufferArray::makeSegment(
bool LLBufferArray::eraseSegment(const segment_iterator_t& erase_iter)
{
ASSERT_LLBUFFERARRAY_MUTEX_LOCKED
LLMemType m1(LLMemType::MTYPE_IO_BUFFER);
// Find out which buffer contains the segment, and if it is found,
// ask it to reclaim the memory.
@@ -913,7 +890,6 @@ bool LLBufferArray::copyIntoBuffers(
std::vector<LLSegment>& segments)
{
ASSERT_LLBUFFERARRAY_MUTEX_LOCKED
LLMemType m1(LLMemType::MTYPE_IO_BUFFER);
if(!src || !len) return false;
S32 copied = 0;
LLSegment segment;

View File

@@ -30,7 +30,6 @@
#include "llbufferstream.h"
#include "llbuffer.h"
#include "llmemtype.h"
#include "llthread.h"
static const S32 DEFAULT_OUTPUT_SEGMENT_SIZE = 1024 * 4;
@@ -44,19 +43,16 @@ LLBufferStreamBuf::LLBufferStreamBuf(
mChannels(channels),
mBuffer(buffer)
{
LLMemType m1(LLMemType::MTYPE_IO_BUFFER);
}
LLBufferStreamBuf::~LLBufferStreamBuf()
{
LLMemType m1(LLMemType::MTYPE_IO_BUFFER);
sync();
}
// virtual
int LLBufferStreamBuf::underflow()
{
LLMemType m1(LLMemType::MTYPE_IO_BUFFER);
//lldebugs << "LLBufferStreamBuf::underflow()" << llendl;
if(!mBuffer)
{
@@ -129,7 +125,6 @@ int LLBufferStreamBuf::underflow()
// virtual
int LLBufferStreamBuf::overflow(int c)
{
LLMemType m1(LLMemType::MTYPE_IO_BUFFER);
if(!mBuffer)
{
return EOF;
@@ -169,7 +164,6 @@ int LLBufferStreamBuf::overflow(int c)
// virtual
int LLBufferStreamBuf::sync()
{
LLMemType m1(LLMemType::MTYPE_IO_BUFFER);
int return_value = -1;
if(!mBuffer)
{
@@ -251,7 +245,6 @@ streampos LLBufferStreamBuf::seekoff(
std::ios::openmode which)
#endif
{
LLMemType m1(LLMemType::MTYPE_IO_BUFFER);
if(!mBuffer
|| ((way == std::ios::beg) && (off < 0))
|| ((way == std::ios::end) && (off > 0)))
@@ -343,10 +336,8 @@ LLBufferStream::LLBufferStream(
std::iostream(&mStreamBuf),
mStreamBuf(channels, buffer)
{
LLMemType m1(LLMemType::MTYPE_IO_BUFFER);
}
LLBufferStream::~LLBufferStream()
{
LLMemType m1(LLMemType::MTYPE_IO_BUFFER);
}

View File

@@ -36,7 +36,6 @@
#include "llsdserialize.h"
#include "lluuid.h"
#include "message.h"
#include "llmemtype.h"
#include <boost/regex.hpp>
@@ -692,7 +691,6 @@ bool LLCacheName::getIfThere(const LLUUID& id, std::string& fullname, BOOL& is_g
void LLCacheName::processPending()
{
LLMemType mt_pp(LLMemType::MTYPE_CACHE_PROCESS_PENDING);
const F32 SECS_BETWEEN_PROCESS = 0.1f;
if(!impl.mProcessTimer.checkExpirationAndReset(SECS_BETWEEN_PROCESS))
{
@@ -798,7 +796,6 @@ std::string LLCacheName::getDefaultLastName()
void LLCacheName::Impl::processPendingAsks()
{
LLMemType mt_ppa(LLMemType::MTYPE_CACHE_PROCESS_PENDING_ASKS);
sendRequest(_PREHASH_UUIDNameRequest, mAskNameQueue);
sendRequest(_PREHASH_UUIDGroupNameRequest, mAskGroupQueue);
mAskNameQueue.clear();
@@ -807,7 +804,6 @@ void LLCacheName::Impl::processPendingAsks()
void LLCacheName::Impl::processPendingReplies()
{
LLMemType mt_ppr(LLMemType::MTYPE_CACHE_PROCESS_PENDING_REPLIES);
// First call all the callbacks, because they might send messages.
for(ReplyQueue::iterator it = mReplyQueue.begin(); it != mReplyQueue.end(); ++it)
{

View File

@@ -195,18 +195,20 @@ public:
LLAssetType::EType mAssetType;
};
static void request(
const std::string& url,
//static
void LLHTTPClient::request(
std::string const& url,
LLURLRequest::ERequestAction method,
Injector* body_injector,
LLHTTPClient::ResponderPtr responder,
AIHTTPHeaders& headers/*,*/
DEBUG_CURLIO_PARAM(EDebugCurl debug),
EKeepAlive keepalive = keep_alive,
bool is_auth = false,
bool no_compression = false,
AIStateMachine* parent = NULL,
AIStateMachine::state_type new_parent_state = 0)
EKeepAlive keepalive,
EDoesAuthentication does_auth,
EAllowCompressedReply allow_compression,
AIStateMachine* parent,
AIStateMachine::state_type new_parent_state,
AIEngine* default_engine)
{
llassert(responder);
@@ -219,7 +221,7 @@ static void request(
LLURLRequest* req;
try
{
req = new LLURLRequest(method, url, body_injector, responder, headers, keepalive, is_auth, no_compression);
req = new LLURLRequest(method, url, body_injector, responder, headers, keepalive, does_auth, allow_compression);
#ifdef DEBUG_CURLIO
req->mCurlEasyRequest.debug(debug);
#endif
@@ -231,7 +233,7 @@ static void request(
return ;
}
req->run(parent, new_parent_state, parent != NULL);
req->run(parent, new_parent_state, parent != NULL, true, default_engine);
}
void LLHTTPClient::getByteRange(std::string const& url, S32 offset, S32 bytes, ResponderPtr responder, AIHTTPHeaders& headers/*,*/ DEBUG_CURLIO_PARAM(EDebugCurl debug))
@@ -240,22 +242,22 @@ void LLHTTPClient::getByteRange(std::string const& url, S32 offset, S32 bytes, R
{
headers.addHeader("Range", llformat("bytes=%d-%d", offset, offset + bytes - 1));
}
request(url, LLURLRequest::HTTP_GET, NULL, responder, headers/*,*/ DEBUG_CURLIO_PARAM(debug));
request(url, HTTP_GET, NULL, responder, headers/*,*/ DEBUG_CURLIO_PARAM(debug));
}
void LLHTTPClient::head(std::string const& url, ResponderHeadersOnly* responder, AIHTTPHeaders& headers/*,*/ DEBUG_CURLIO_PARAM(EDebugCurl debug))
{
request(url, LLURLRequest::HTTP_HEAD, NULL, responder, headers/*,*/ DEBUG_CURLIO_PARAM(debug));
request(url, HTTP_HEAD, NULL, responder, headers/*,*/ DEBUG_CURLIO_PARAM(debug));
}
void LLHTTPClient::get(std::string const& url, ResponderPtr responder, AIHTTPHeaders& headers/*,*/ DEBUG_CURLIO_PARAM(EDebugCurl debug))
{
request(url, LLURLRequest::HTTP_GET, NULL, responder, headers/*,*/ DEBUG_CURLIO_PARAM(debug));
request(url, HTTP_GET, NULL, responder, headers/*,*/ DEBUG_CURLIO_PARAM(debug));
}
void LLHTTPClient::getHeaderOnly(std::string const& url, ResponderHeadersOnly* responder, AIHTTPHeaders& headers/*,*/ DEBUG_CURLIO_PARAM(EDebugCurl debug))
{
request(url, LLURLRequest::HTTP_HEAD, NULL, responder, headers/*,*/ DEBUG_CURLIO_PARAM(debug));
request(url, HTTP_HEAD, NULL, responder, headers/*,*/ DEBUG_CURLIO_PARAM(debug));
}
void LLHTTPClient::get(std::string const& url, LLSD const& query, ResponderPtr responder, AIHTTPHeaders& headers/*,*/ DEBUG_CURLIO_PARAM(EDebugCurl debug))
@@ -302,7 +304,7 @@ AIHTTPTimeoutPolicy const& LLHTTPClient::ResponderBase::getHTTPTimeoutPolicy(voi
void LLHTTPClient::ResponderBase::decode_llsd_body(U32 status, std::string const& reason, LLChannelDescriptors const& channels, buffer_ptr_t const& buffer, LLSD& content)
{
AICurlInterface::Stats::llsd_body_count++;
if (status == HTTP_INTERNAL_ERROR)
if (is_internal_http_error(status))
{
// In case of an internal error (ie, a curl error), a description of the (curl) error is the best we can do.
// In any case, the body if anything was received at all, can not be relied upon.
@@ -353,7 +355,7 @@ void LLHTTPClient::ResponderBase::decode_llsd_body(U32 status, std::string const
void LLHTTPClient::ResponderBase::decode_raw_body(U32 status, std::string const& reason, LLChannelDescriptors const& channels, buffer_ptr_t const& buffer, std::string& content)
{
AICurlInterface::Stats::raw_body_count++;
if (status == HTTP_INTERNAL_ERROR)
if (is_internal_http_error(status))
{
// In case of an internal error (ie, a curl error), a description of the (curl) error is the best we can do.
// In any case, the body if anything was received at all, can not be relied upon.
@@ -487,7 +489,8 @@ void BlockingResponder::wait(void)
// We're the main thread, so we have to give AIStateMachine CPU cycles.
while (!mFinished)
{
AIStateMachine::mainloop();
// AIFIXME: this can probably be removed once curl is detached from the main thread.
gMainThreadEngine.mainloop();
ms_sleep(10);
}
}
@@ -609,11 +612,10 @@ static LLSD blocking_request(
responder->wait();
S32 http_status = HTTP_INTERNAL_ERROR;
LLSD response = LLSD::emptyMap();
CURLcode result = responder->result_code();
S32 http_status = responder->http_status();
http_status = responder->http_status();
bool http_success = http_status >= 200 && http_status < 300;
if (result == CURLE_OK && http_success)
{
@@ -685,17 +687,17 @@ U32 LLHTTPClient::blockingGetRaw(const std::string& url, std::string& body/*,*/
void LLHTTPClient::put(std::string const& url, LLSD const& body, ResponderPtr responder, AIHTTPHeaders& headers/*,*/ DEBUG_CURLIO_PARAM(EDebugCurl debug))
{
request(url, LLURLRequest::HTTP_PUT, new LLSDInjector(body), responder, headers/*,*/ DEBUG_CURLIO_PARAM(debug));
request(url, HTTP_PUT, new LLSDInjector(body), responder, headers/*,*/ DEBUG_CURLIO_PARAM(debug), no_keep_alive, no_does_authentication, no_allow_compressed_reply);
}
void LLHTTPClient::post(std::string const& url, LLSD const& body, ResponderPtr responder, AIHTTPHeaders& headers/*,*/ DEBUG_CURLIO_PARAM(EDebugCurl debug), EKeepAlive keepalive, AIStateMachine* parent, AIStateMachine::state_type new_parent_state)
{
request(url, LLURLRequest::HTTP_POST, new LLSDInjector(body), responder, headers/*,*/ DEBUG_CURLIO_PARAM(debug), keepalive, false, false, parent, new_parent_state);
request(url, HTTP_POST, new LLSDInjector(body), responder, headers/*,*/ DEBUG_CURLIO_PARAM(debug), keepalive, no_does_authentication, allow_compressed_reply, parent, new_parent_state);
}
void LLHTTPClient::postXMLRPC(std::string const& url, XMLRPC_REQUEST xmlrpc_request, ResponderPtr responder, AIHTTPHeaders& headers/*,*/ DEBUG_CURLIO_PARAM(EDebugCurl debug), EKeepAlive keepalive)
{
request(url, LLURLRequest::HTTP_POST, new XMLRPCInjector(xmlrpc_request), responder, headers/*,*/ DEBUG_CURLIO_PARAM(debug), keepalive, true, false); // Does use compression.
request(url, HTTP_POST, new XMLRPCInjector(xmlrpc_request), responder, headers/*,*/ DEBUG_CURLIO_PARAM(debug), keepalive, does_authentication, allow_compressed_reply);
}
void LLHTTPClient::postXMLRPC(std::string const& url, char const* method, XMLRPC_VALUE value, ResponderPtr responder, AIHTTPHeaders& headers/*,*/ DEBUG_CURLIO_PARAM(EDebugCurl debug), EKeepAlive keepalive)
@@ -706,33 +708,33 @@ void LLHTTPClient::postXMLRPC(std::string const& url, char const* method, XMLRPC
XMLRPC_RequestSetData(xmlrpc_request, value);
// XMLRPCInjector takes ownership of xmlrpc_request and will free it when done.
// LLURLRequest takes ownership of the XMLRPCInjector object and will free it when done.
request(url, LLURLRequest::HTTP_POST, new XMLRPCInjector(xmlrpc_request), responder, headers/*,*/ DEBUG_CURLIO_PARAM(debug), keepalive, true, true); // Does not use compression.
request(url, HTTP_POST, new XMLRPCInjector(xmlrpc_request), responder, headers/*,*/ DEBUG_CURLIO_PARAM(debug), keepalive, does_authentication, no_allow_compressed_reply);
}
void LLHTTPClient::postRaw(std::string const& url, char const* data, S32 size, ResponderPtr responder, AIHTTPHeaders& headers/*,*/ DEBUG_CURLIO_PARAM(EDebugCurl debug), EKeepAlive keepalive)
{
request(url, LLURLRequest::HTTP_POST, new RawInjector(data, size), responder, headers/*,*/ DEBUG_CURLIO_PARAM(debug), keepalive);
request(url, HTTP_POST, new RawInjector(data, size), responder, headers/*,*/ DEBUG_CURLIO_PARAM(debug), keepalive);
}
void LLHTTPClient::postFile(std::string const& url, std::string const& filename, ResponderPtr responder, AIHTTPHeaders& headers/*,*/ DEBUG_CURLIO_PARAM(EDebugCurl debug), EKeepAlive keepalive)
{
request(url, LLURLRequest::HTTP_POST, new FileInjector(filename), responder, headers/*,*/ DEBUG_CURLIO_PARAM(debug), keepalive);
request(url, HTTP_POST, new FileInjector(filename), responder, headers/*,*/ DEBUG_CURLIO_PARAM(debug), keepalive);
}
void LLHTTPClient::postFile(std::string const& url, LLUUID const& uuid, LLAssetType::EType asset_type, ResponderPtr responder, AIHTTPHeaders& headers/*,*/ DEBUG_CURLIO_PARAM(EDebugCurl debug), EKeepAlive keepalive)
{
request(url, LLURLRequest::HTTP_POST, new VFileInjector(uuid, asset_type), responder, headers/*,*/ DEBUG_CURLIO_PARAM(debug), keepalive);
request(url, HTTP_POST, new VFileInjector(uuid, asset_type), responder, headers/*,*/ DEBUG_CURLIO_PARAM(debug), keepalive);
}
// static
void LLHTTPClient::del(std::string const& url, ResponderPtr responder, AIHTTPHeaders& headers/*,*/ DEBUG_CURLIO_PARAM(EDebugCurl debug))
{
request(url, LLURLRequest::HTTP_DELETE, NULL, responder, headers/*,*/ DEBUG_CURLIO_PARAM(debug));
request(url, HTTP_DELETE, NULL, responder, headers/*,*/ DEBUG_CURLIO_PARAM(debug));
}
// static
void LLHTTPClient::move(std::string const& url, std::string const& destination, ResponderPtr responder, AIHTTPHeaders& headers/*,*/ DEBUG_CURLIO_PARAM(EDebugCurl debug))
{
headers.addHeader("Destination", destination);
request(url, LLURLRequest::HTTP_MOVE, NULL, responder, headers/*,*/ DEBUG_CURLIO_PARAM(debug));
request(url, HTTP_MOVE, NULL, responder, headers/*,*/ DEBUG_CURLIO_PARAM(debug));
}

View File

@@ -46,10 +46,13 @@ class AIHTTPTimeoutPolicy;
class LLBufferArray;
class LLChannelDescriptors;
class AIStateMachine;
class Injector;
class AIEngine;
extern AIHTTPTimeoutPolicy responderIgnore_timeout;
typedef struct _xmlrpc_request* XMLRPC_REQUEST;
typedef struct _xmlrpc_value* XMLRPC_VALUE;
extern AIEngine gMainThreadEngine;
// Output parameter of AICurlPrivate::CurlEasyRequest::getResult.
// Used in XMLRPCResponder.
@@ -72,6 +75,16 @@ enum EKeepAlive {
keep_alive
};
enum EDoesAuthentication {
no_does_authentication = 0,
does_authentication
};
enum EAllowCompressedReply {
no_allow_compressed_reply = 0,
allow_compressed_reply
};
#ifdef DEBUG_CURLIO
enum EDebugCurl {
debug_off = 0,
@@ -84,6 +97,20 @@ enum EDebugCurl {
class LLHTTPClient {
public:
/**
* @brief This enumeration is for specifying the type of request.
*/
enum ERequestAction
{
INVALID,
HTTP_HEAD,
HTTP_GET,
HTTP_PUT,
HTTP_POST,
HTTP_DELETE,
HTTP_MOVE, // Caller will need to set 'Destination' header
REQUEST_ACTION_COUNT
};
/** @name Responder base classes */
//@{
@@ -363,7 +390,7 @@ public:
}
public:
LegacyPolledResponder(void) : mStatus(HTTP_INTERNAL_ERROR) { }
LegacyPolledResponder(void) : mStatus(HTTP_INTERNAL_ERROR_OTHER) { }
// Accessors.
U32 http_status(void) const { return mStatus; }
@@ -393,6 +420,21 @@ public:
//@}
/** General API to request a transfer. */
static void request(
std::string const& url,
ERequestAction method,
Injector* body_injector,
ResponderPtr responder,
AIHTTPHeaders& headers/*,*/
DEBUG_CURLIO_PARAM(EDebugCurl debug),
EKeepAlive keepalive = keep_alive,
EDoesAuthentication does_auth = no_does_authentication,
EAllowCompressedReply allow_compression = allow_compressed_reply,
AIStateMachine* parent = NULL,
/*AIStateMachine::state_type*/ U32 new_parent_state = 0,
AIEngine* default_engine = &gMainThreadEngine);
/** @name non-blocking API */
//@{
static void head(std::string const& url, ResponderHeadersOnly* responder, AIHTTPHeaders& headers/*,*/ DEBUG_CURLIO_PARAM(EDebugCurl debug = debug_off));

View File

@@ -37,7 +37,6 @@
#include "lliopipe.h"
#include "lliosocket.h"
#include "llioutil.h"
#include "llmemtype.h"
#include "llmemorystream.h"
#include "llpumpio.h"
#include "llsd.h"
@@ -449,7 +448,6 @@ LLIOPipe::EStatus LLHTTPResponseHeader::process_impl(
{
LLFastTimer t(FTM_PROCESS_HTTP_HEADER);
PUMP_DEBUG;
LLMemType m1(LLMemType::MTYPE_IO_HTTP_SERVER);
if(eos)
{
PUMP_DEBUG;
@@ -593,13 +591,11 @@ LLHTTPResponder::LLHTTPResponder(const LLHTTPNode& tree, const LLSD& ctx) :
mContentLength(0),
mRootNode(tree)
{
LLMemType m1(LLMemType::MTYPE_IO_HTTP_SERVER);
}
// virtual
LLHTTPResponder::~LLHTTPResponder()
{
LLMemType m1(LLMemType::MTYPE_IO_HTTP_SERVER);
//lldebugs << "destroying LLHTTPResponder" << llendl;
}
@@ -609,7 +605,6 @@ bool LLHTTPResponder::readHeaderLine(
U8* dest,
S32& len)
{
LLMemType m1(LLMemType::MTYPE_IO_HTTP_SERVER);
--len;
U8* last = buffer->readAfter(channels.in(), mLastRead, dest, len);
dest[len] = '\0';
@@ -634,7 +629,6 @@ void LLHTTPResponder::markBad(
const LLChannelDescriptors& channels,
buffer_ptr_t buffer)
{
LLMemType m1(LLMemType::MTYPE_IO_HTTP_SERVER);
mState = STATE_SHORT_CIRCUIT;
LLBufferStream out(channels, buffer.get());
out << HTTP_VERSION_STR << " 400 Bad Request\r\n\r\n<html>\n"
@@ -654,7 +648,6 @@ LLIOPipe::EStatus LLHTTPResponder::process_impl(
{
LLFastTimer t(FTM_PROCESS_HTTP_RESPONDER);
PUMP_DEBUG;
LLMemType m1(LLMemType::MTYPE_IO_HTTP_SERVER);
LLIOPipe::EStatus status = STATUS_OK;
// parsing headers

View File

@@ -33,7 +33,6 @@
#include "llbuffer.h"
#include "llhost.h"
#include "llmemtype.h"
#include "llpumpio.h"
#include "llthread.h"
@@ -101,7 +100,6 @@ void ll_debug_socket(const char* msg, apr_socket_t* apr_sock)
// static
LLSocket::ptr_t LLSocket::create(EType type, U16 port)
{
LLMemType m1(LLMemType::MTYPE_IO_TCP);
apr_status_t status = APR_EGENERAL;
LLSocket::ptr_t rv(new LLSocket);
@@ -179,7 +177,6 @@ LLSocket::ptr_t LLSocket::create(EType type, U16 port)
// static
LLSocket::ptr_t LLSocket::create(apr_status_t& status, LLSocket::ptr_t& listen_socket)
{
LLMemType m1(LLMemType::MTYPE_IO_TCP);
if (!listen_socket->getSocket())
{
status = APR_ENOSOCKET;
@@ -232,7 +229,6 @@ LLSocket::LLSocket() :
LLSocket::~LLSocket()
{
LLMemType m1(LLMemType::MTYPE_IO_TCP);
// *FIX: clean up memory we are holding.
if(mSocket)
{
@@ -248,7 +244,6 @@ LLSocket::~LLSocket()
void LLSocket::setBlocking(S32 timeout)
{
LLMemType m1(LLMemType::MTYPE_IO_TCP);
// set up the socket options
ll_apr_warn_status(apr_socket_timeout_set(mSocket, timeout));
ll_apr_warn_status(apr_socket_opt_set(mSocket, APR_SO_NONBLOCK, 0));
@@ -259,7 +254,6 @@ void LLSocket::setBlocking(S32 timeout)
void LLSocket::setNonBlocking()
{
LLMemType m1(LLMemType::MTYPE_IO_TCP);
// set up the socket options
ll_apr_warn_status(apr_socket_timeout_set(mSocket, 0));
ll_apr_warn_status(apr_socket_opt_set(mSocket, APR_SO_NONBLOCK, 1));
@@ -276,12 +270,10 @@ LLIOSocketReader::LLIOSocketReader(LLSocket::ptr_t socket) :
mSource(socket),
mInitialized(false)
{
LLMemType m1(LLMemType::MTYPE_IO_TCP);
}
LLIOSocketReader::~LLIOSocketReader()
{
LLMemType m1(LLMemType::MTYPE_IO_TCP);
//lldebugs << "Destroying LLIOSocketReader" << llendl;
}
@@ -297,7 +289,6 @@ LLIOPipe::EStatus LLIOSocketReader::process_impl(
{
LLFastTimer t(FTM_PROCESS_SOCKET_READER);
PUMP_DEBUG;
LLMemType m1(LLMemType::MTYPE_IO_TCP);
if(!mSource) return STATUS_PRECONDITION_NOT_MET;
if(!mInitialized)
{
@@ -379,12 +370,10 @@ LLIOSocketWriter::LLIOSocketWriter(LLSocket::ptr_t socket) :
mLastWritten(NULL),
mInitialized(false)
{
LLMemType m1(LLMemType::MTYPE_IO_TCP);
}
LLIOSocketWriter::~LLIOSocketWriter()
{
LLMemType m1(LLMemType::MTYPE_IO_TCP);
//lldebugs << "Destroying LLIOSocketWriter" << llendl;
}
@@ -399,7 +388,6 @@ LLIOPipe::EStatus LLIOSocketWriter::process_impl(
{
LLFastTimer t(FTM_PROCESS_SOCKET_WRITER);
PUMP_DEBUG;
LLMemType m1(LLMemType::MTYPE_IO_TCP);
if(!mDestination) return STATUS_PRECONDITION_NOT_MET;
if(!mInitialized)
{
@@ -531,12 +519,10 @@ LLIOServerSocket::LLIOServerSocket(
mInitialized(false),
mResponseTimeout(DEFAULT_CHAIN_EXPIRY_SECS)
{
LLMemType m1(LLMemType::MTYPE_IO_TCP);
}
LLIOServerSocket::~LLIOServerSocket()
{
LLMemType m1(LLMemType::MTYPE_IO_TCP);
//lldebugs << "Destroying LLIOServerSocket" << llendl;
}
@@ -556,7 +542,6 @@ LLIOPipe::EStatus LLIOServerSocket::process_impl(
{
LLFastTimer t(FTM_PROCESS_SERVER_SOCKET);
PUMP_DEBUG;
LLMemType m1(LLMemType::MTYPE_IO_TCP);
if(!pump)
{
llwarns << "Need a pump for server socket." << llendl;

View File

@@ -35,7 +35,6 @@
#include "llapr.h"
#include "llfasttimer.h"
#include "llmemtype.h"
#include "llstl.h"
#include "llstat.h"
#include "llthread.h"
@@ -155,7 +154,6 @@ struct ll_delete_apr_pollset_fd_client_data
typedef std::pair<LLIOPipe::ptr_t, apr_pollfd_t> pipe_conditional_t;
void operator()(const pipe_conditional_t& conditional)
{
LLMemType m1(LLMemType::MTYPE_IO_PUMP);
S32* client_id = (S32*)conditional.second.client_data;
delete client_id;
}
@@ -177,13 +175,11 @@ LLPumpIO::LLPumpIO(void) :
{
mCurrentChain = mRunningChains.end();
LLMemType m1(LLMemType::MTYPE_IO_PUMP);
initialize();
}
LLPumpIO::~LLPumpIO()
{
LLMemType m1(LLMemType::MTYPE_IO_PUMP);
#if LL_THREADS_APR
if (mChainsMutex) apr_thread_mutex_destroy(mChainsMutex);
if (mCallbackMutex) apr_thread_mutex_destroy(mCallbackMutex);
@@ -200,8 +196,6 @@ LLPumpIO::~LLPumpIO()
bool LLPumpIO::addChain(chain_t const& chain, F32 timeout)
{
LLMemType m1(LLMemType::MTYPE_IO_PUMP);
chain_t::const_iterator it = chain.begin();
chain_t::const_iterator const end = chain.end();
if (it == end) return false;
@@ -237,8 +231,6 @@ bool LLPumpIO::addChain(
LLSD context,
F32 timeout)
{
LLMemType m1(LLMemType::MTYPE_IO_PUMP);
// remember that if the caller is providing a full link
// description, we need to have that description matched to a
// particular buffer.
@@ -325,7 +317,6 @@ static std::string events_2_string(apr_int16_t events)
bool LLPumpIO::setConditional(LLIOPipe* pipe, const apr_pollfd_t* poll)
{
LLMemType m1(LLMemType::MTYPE_IO_PUMP);
if(!pipe) return false;
ll_debug_poll_fd("Set conditional", poll);
@@ -436,7 +427,6 @@ bool LLPumpIO::sleepChain(F64 seconds)
bool LLPumpIO::copyCurrentLinkInfo(links_t& links) const
{
LLMemType m1(LLMemType::MTYPE_IO_PUMP);
if(mRunningChains.end() == mCurrentChain)
{
return false;
@@ -468,7 +458,6 @@ LLPumpIO::current_chain_t LLPumpIO::removeRunningChain(LLPumpIO::current_chain_t
//timeout is in microseconds
void LLPumpIO::pump(const S32& poll_timeout)
{
LLMemType m1(LLMemType::MTYPE_IO_PUMP);
LLFastTimer t1(FTM_PUMP_IO);
//llinfos << "LLPumpIO::pump()" << llendl;
@@ -761,7 +750,6 @@ void LLPumpIO::pump(const S32& poll_timeout)
bool LLPumpIO::respond(LLIOPipe* pipe)
{
LLMemType m1(LLMemType::MTYPE_IO_PUMP);
if(NULL == pipe) return false;
#if LL_THREADS_APR
@@ -780,7 +768,6 @@ bool LLPumpIO::respond(
LLIOPipe::buffer_ptr_t data,
LLSD context)
{
LLMemType m1(LLMemType::MTYPE_IO_PUMP);
// if the caller is providing a full link description, we need to
// have that description matched to a particular buffer.
if(!data) return false;
@@ -803,7 +790,6 @@ static LLFastTimer::DeclareTimer FTM_PUMP_CALLBACK_CHAIN("Chain");
void LLPumpIO::callback()
{
LLMemType m1(LLMemType::MTYPE_IO_PUMP);
//llinfos << "LLPumpIO::callback()" << llendl;
if(true)
{
@@ -854,7 +840,6 @@ void LLPumpIO::control(LLPumpIO::EControl op)
void LLPumpIO::initialize(void)
{
LLMemType m1(LLMemType::MTYPE_IO_PUMP);
mPool.create();
#if LL_THREADS_APR
// SJB: Windows defaults to NESTED and OSX defaults to UNNESTED, so use UNNESTED explicitly.
@@ -865,7 +850,6 @@ void LLPumpIO::initialize(void)
void LLPumpIO::rebuildPollset()
{
LLMemType m1(LLMemType::MTYPE_IO_PUMP);
// lldebugs << "LLPumpIO::rebuildPollset()" << llendl;
if(mPollset)
{
@@ -916,7 +900,6 @@ void LLPumpIO::rebuildPollset()
void LLPumpIO::processChain(LLChainInfo& chain)
{
PUMP_DEBUG;
LLMemType m1(LLMemType::MTYPE_IO_PUMP);
LLIOPipe::EStatus status = LLIOPipe::STATUS_OK;
links_t::iterator it = chain.mHead;
links_t::iterator end = chain.mChainLinks.end();
@@ -1120,7 +1103,6 @@ bool LLPumpIO::handleChainError(
{
DoutEntering(dc::notice, "LLPumpIO::handleChainError(" << (void*)&chain << ", " << LLIOPipe::lookupStatusString(error) << ")");
LLMemType m1(LLMemType::MTYPE_IO_PUMP);
links_t::reverse_iterator rit;
if(chain.mHead == chain.mChainLinks.end())
{
@@ -1185,13 +1167,11 @@ LLPumpIO::LLChainInfo::LLChainInfo() :
mHasExpiration(false),
mDescriptorsPool(new LLAPRPool(LLThread::tldata().mRootPool))
{
LLMemType m1(LLMemType::MTYPE_IO_PUMP);
mTimer.setTimerExpirySec(DEFAULT_CHAIN_EXPIRY_SECS);
}
void LLPumpIO::LLChainInfo::setTimeoutSeconds(F32 timeout)
{
LLMemType m1(LLMemType::MTYPE_IO_PUMP);
if(timeout > 0.0f)
{
mTimer.start(timeout);
@@ -1204,7 +1184,6 @@ void LLPumpIO::LLChainInfo::setTimeoutSeconds(F32 timeout)
void LLPumpIO::LLChainInfo::adjustTimeoutSeconds(F32 delta)
{
LLMemType m1(LLMemType::MTYPE_IO_PUMP);
if(mTimer.getStarted())
{
F64 expiry = mTimer.expiresAt();

View File

@@ -38,7 +38,6 @@
#include <openssl/ssl.h>
#include "aicurleasyrequeststatemachine.h"
#include "llioutil.h"
#include "llmemtype.h"
#include "llpumpio.h"
#include "llsd.h"
#include "llstring.h"
@@ -47,7 +46,6 @@
#include "llscopedvolatileaprpool.h"
#include "llfasttimer.h"
#include "message.h"
static const U32 HTTP_STATUS_PIPE_ERROR = 499;
/**
* String constants
@@ -61,7 +59,7 @@ const std::string CONTEXT_TRANSFERED_BYTES("transfered_bytes");
// static
std::string LLURLRequest::actionAsVerb(LLURLRequest::ERequestAction action)
{
static int const array_size = HTTP_MOVE + 1; // INVALID == 0
static int const array_size = LLHTTPClient::REQUEST_ACTION_COUNT; // INVALID == 0
static char const* const VERBS[array_size] =
{
"(invalid)",
@@ -72,14 +70,14 @@ std::string LLURLRequest::actionAsVerb(LLURLRequest::ERequestAction action)
"DELETE",
"MOVE"
};
return VERBS[action >= array_size ? INVALID : action];
return VERBS[action >= array_size ? LLHTTPClient::INVALID : action];
}
// This might throw AICurlNoEasyHandle.
LLURLRequest::LLURLRequest(LLURLRequest::ERequestAction action, std::string const& url, Injector* body,
LLHTTPClient::ResponderPtr responder, AIHTTPHeaders& headers, bool keepalive, bool is_auth, bool no_compression) :
mAction(action), mURL(url), mKeepAlive(keepalive), mIsAuth(is_auth), mNoCompression(no_compression),
mBody(body), mResponder(responder), mHeaders(headers)
LLHTTPClient::ResponderPtr responder, AIHTTPHeaders& headers, bool keepalive, bool is_auth, bool compression) :
mAction(action), mURL(url), mKeepAlive(keepalive), mIsAuth(is_auth), mNoCompression(!compression),
mBody(body), mResponder(responder), mHeaders(headers), mResponderNameCache(responder ? responder->getName() : "<uninitialized>")
{
}
@@ -94,13 +92,13 @@ void LLURLRequest::initialize_impl(void)
useProxy(false);
}
if (mAction == HTTP_PUT || mAction == HTTP_POST)
if (mAction == LLHTTPClient::HTTP_PUT || mAction == LLHTTPClient::HTTP_POST)
{
// If the Content-Type header was passed in we defer to the caller's wisdom,
// but if they did not specify a Content-Type, then ask the injector.
mHeaders.addHeader("Content-Type", mBody->contentType(), AIHTTPHeaders::keep_existing_header);
}
else if (mAction != HTTP_HEAD)
else if (mAction != LLHTTPClient::HTTP_HEAD)
{
// Check to see if we have already set Accept or not. If no one
// set it, set it to application/llsd+xml since that's what we
@@ -108,7 +106,7 @@ void LLURLRequest::initialize_impl(void)
mHeaders.addHeader("Accept", "application/llsd+xml", AIHTTPHeaders::keep_existing_header);
}
if (mAction == HTTP_POST && gMessageSystem)
if (mAction == LLHTTPClient::HTTP_POST && gMessageSystem)
{
mHeaders.addHeader("X-SecondLife-UDP-Listen-Port", llformat("%d", gMessageSystem->mPort));
}
@@ -200,12 +198,12 @@ bool LLURLRequest::configure(AICurlEasyRequest_wat const& curlEasyRequest_w)
{
switch(mAction)
{
case HTTP_HEAD:
case LLHTTPClient::HTTP_HEAD:
curlEasyRequest_w->setopt(CURLOPT_NOBODY, 1);
rv = true;
break;
case HTTP_GET:
case LLHTTPClient::HTTP_GET:
curlEasyRequest_w->setopt(CURLOPT_HTTPGET, 1);
// Set Accept-Encoding to allow response compression
@@ -213,18 +211,18 @@ bool LLURLRequest::configure(AICurlEasyRequest_wat const& curlEasyRequest_w)
rv = true;
break;
case HTTP_PUT:
{
// Disable the expect http 1.1 extension. POST and PUT default
// to using this, causing the broken server to get confused.
curlEasyRequest_w->addHeader("Expect:");
curlEasyRequest_w->setopt(CURLOPT_UPLOAD, 1);
curlEasyRequest_w->setopt(CURLOPT_INFILESIZE, mBodySize);
case LLHTTPClient::HTTP_PUT:
// Set the handle for an http put
curlEasyRequest_w->setPut(mBodySize, mKeepAlive);
// Set Accept-Encoding to allow response compression
curlEasyRequest_w->setoptString(CURLOPT_ENCODING, mNoCompression ? "identity" : "");
rv = true;
break;
}
case HTTP_POST:
{
case LLHTTPClient::HTTP_POST:
// Set the handle for an http post
curlEasyRequest_w->setPost(mBodySize, mKeepAlive);
@@ -232,14 +230,14 @@ bool LLURLRequest::configure(AICurlEasyRequest_wat const& curlEasyRequest_w)
curlEasyRequest_w->setoptString(CURLOPT_ENCODING, mNoCompression ? "identity" : "");
rv = true;
break;
}
case HTTP_DELETE:
case LLHTTPClient::HTTP_DELETE:
// Set the handle for an http post
curlEasyRequest_w->setoptString(CURLOPT_CUSTOMREQUEST, "DELETE");
rv = true;
break;
case HTTP_MOVE:
case LLHTTPClient::HTTP_MOVE:
// Set the handle for an http post
curlEasyRequest_w->setoptString(CURLOPT_CUSTOMREQUEST, "MOVE");
rv = true;
@@ -260,3 +258,33 @@ bool LLURLRequest::configure(AICurlEasyRequest_wat const& curlEasyRequest_w)
}
return rv;
}
// Called from AIStateMachine::mainloop, but put here because we don't want to include llurlrequest.h there of course.
void print_statemachine_diagnostics(U64 total_clocks, U64 max_delta, AIEngine::queued_type::const_reference slowest_element)
{
AIStateMachine const& slowest_state_machine = slowest_element.statemachine();
LLURLRequest const* request = dynamic_cast<LLURLRequest const*>(&slowest_state_machine);
F64 const tfactor = 1000 / calc_clock_frequency();
std::ostringstream msg;
if (total_clocks > max_delta)
{
msg << "AIStateMachine::mainloop did run for " << (total_clocks * tfactor) << " ms. The slowest ";
}
else
{
msg << "AIStateMachine::mainloop: A ";
}
msg << "state machine ";
if (request)
{
msg << "(" << request->getResponderName() << ") ";
}
msg << "ran for " << (max_delta * tfactor) << " ms";
if (slowest_state_machine.getRuntime() > max_delta)
{
msg << " (" << (slowest_state_machine.getRuntime() * tfactor) << " ms in total now)";
}
msg << ".";
llwarns << msg.str() << llendl;
}

View File

@@ -51,20 +51,7 @@ class Injector
class LLURLRequest : public AICurlEasyRequestStateMachine {
public:
/**
* @brief This enumeration is for specifying the type of request.
*/
enum ERequestAction
{
INVALID,
HTTP_HEAD,
HTTP_GET,
HTTP_PUT,
HTTP_POST,
HTTP_DELETE,
HTTP_MOVE, // Caller will need to set 'Destination' header
REQUEST_ACTION_COUNT
};
typedef LLHTTPClient::ERequestAction ERequestAction;
/**
* @brief Turn the request action into an http verb.
@@ -79,6 +66,11 @@ class LLURLRequest : public AICurlEasyRequestStateMachine {
*/
LLURLRequest(ERequestAction action, std::string const& url, Injector* body, LLHTTPClient::ResponderPtr responder, AIHTTPHeaders& headers, bool keepalive, bool is_auth, bool no_compression);
/**
* @brief Cached value of responder->getName() as passed to the constructor.
*/
char const* getResponderName(void) const { return mResponderNameCache; }
protected:
// Call abort(), not delete.
/*virtual*/ ~LLURLRequest() { }
@@ -118,6 +110,7 @@ class LLURLRequest : public AICurlEasyRequestStateMachine {
U32 mBodySize;
LLHTTPClient::ResponderPtr mResponder;
AIHTTPHeaders mHeaders;
char const* mResponderNameCache;
protected:
// Handle initializing the object.

View File

@@ -80,7 +80,6 @@
#include "v3math.h"
#include "v4math.h"
#include "lltransfertargetvfile.h"
#include "llmemtype.h"
#include "llpacketring.h"
class AIHTTPTimeoutPolicy;
@@ -799,7 +798,6 @@ S32 LLMessageSystem::getReceiveBytes() const
void LLMessageSystem::processAcks()
{
LLMemType mt_pa(LLMemType::MTYPE_MESSAGE_PROCESS_ACKS);
F64 mt_sec = getMessageTimeSeconds();
{
gTransferManager.updateTransfers();
@@ -4031,7 +4029,6 @@ void LLMessageSystem::setTimeDecodesSpamThreshold( F32 seconds )
// TODO: babbage: move gServicePump in to LLMessageSystem?
bool LLMessageSystem::checkAllMessages(S64 frame_count, LLPumpIO* http_pump)
{
LLMemType mt_cam(LLMemType::MTYPE_MESSAGE_CHECK_ALL);
if(checkMessages(frame_count))
{
return true;

View File

@@ -44,8 +44,8 @@ set(llprimitive_HEADER_FILES
llprimtexturelist.h
lltextureanim.h
lltextureentry.h
lltreeparams.h
lltree_common.h
lltreeparams.h
llvolumemessage.h
llvolumexml.h
material_codes.h

View File

@@ -27,7 +27,6 @@
#include "linden_common.h"
#include "material_codes.h"
#include "llmemtype.h"
#include "llerror.h"
#include "message.h"
#include "llprimitive.h"
@@ -188,7 +187,6 @@ void LLPrimitive::clearTextureList()
// static
LLPrimitive *LLPrimitive::createPrimitive(LLPCode p_code)
{
LLMemType m1(LLMemType::MTYPE_PRIMITIVE);
LLPrimitive *retval = new LLPrimitive();
if (retval)
@@ -206,7 +204,6 @@ LLPrimitive *LLPrimitive::createPrimitive(LLPCode p_code)
//===============================================================
void LLPrimitive::init_primitive(LLPCode p_code)
{
LLMemType m1(LLMemType::MTYPE_PRIMITIVE);
clearTextureList();
mPrimitiveCode = p_code;
}
@@ -698,7 +695,6 @@ S32 face_index_from_id(LLFaceID face_ID, const std::vector<LLProfile::Face>& fac
BOOL LLPrimitive::setVolume(const LLVolumeParams &volume_params, const S32 detail, bool unique_volume)
{
LLMemType m1(LLMemType::MTYPE_VOLUME);
LLVolume *volumep;
if (unique_volume)
{

View File

@@ -28,7 +28,6 @@
#include "llprimtexturelist.h"
#include "lltextureentry.h"
#include "llmemtype.h"
// static
//int (TMyClass::*pt2Member)(float, char, char) = NULL; // C++
@@ -367,7 +366,6 @@ S32 LLPrimTextureList::size() const
// sets the size of the mEntryList container
void LLPrimTextureList::setSize(S32 new_size)
{
LLMemType m1(LLMemType::MTYPE_PRIMITIVE);
if (new_size < 0)
{
new_size = 0;

View File

@@ -25,17 +25,20 @@ include_directories(
set(llrender_SOURCE_FILES
llcubemap.cpp
llfont.cpp
llfontgl.cpp
llfontbitmapcache.cpp
llfontfreetype.cpp
llfontgl.cpp
llfontregistry.cpp
llgl.cpp
llgldbg.cpp
llglslshader.cpp
llgltexture.cpp
llimagegl.cpp
llpostprocess.cpp
llrender.cpp
llrender2dutils.cpp
llrendersphere.cpp
llrendertarget.cpp
llshadermgr.cpp
lltexture.cpp
lluiimage.cpp
@@ -46,9 +49,9 @@ set(llrender_HEADER_FILES
CMakeLists.txt
llcubemap.h
llfontgl.h
llfont.h
llfontbitmapcache.h
llfontfreetype.h
llfontgl.h
llfontregistry.h
llgl.h
llgldbg.h
@@ -73,29 +76,5 @@ set_source_files_properties(${llrender_HEADER_FILES}
list(APPEND llrender_SOURCE_FILES ${llrender_HEADER_FILES})
if (SERVER AND NOT WINDOWS AND NOT DARWIN)
copy_server_sources(
llgl
llrender
)
set_source_files_properties(
${server_SOURCE_FILES}
PROPERTIES
COMPILE_FLAGS "-DLL_MESA=1 -DLL_MESA_HEADLESS=1"
)
add_library (llrenderheadless
${llrender_SOURCE_FILES}
${server_SOURCE_FILES}
)
add_dependencies(llrenderheadless prepare)
else (SERVER AND NOT WINDOWS AND NOT DARWIN)
list(APPEND llrender_SOURCE_FILES
llgl.cpp
llrender.cpp
llrendertarget.cpp
)
endif (SERVER AND NOT WINDOWS AND NOT DARWIN)
add_library (llrender ${llrender_SOURCE_FILES})
add_dependencies(llrender prepare)

View File

@@ -1,6 +1,6 @@
/**
* @file llfont.cpp
* @brief Font library wrapper
* @file llfontfreetype.cpp
* @brief Freetype font library wrapper
*
* $LicenseInfo:firstyear=2002&license=viewergpl$
*
@@ -32,18 +32,10 @@
#include "linden_common.h"
#include "llfont.h"
#include "llfontfreetype.h"
// Freetype stuff
#if !defined(LL_LINUX) || defined(LL_STANDALONE)
# include <ft2build.h>
#else
// I had to do some work to avoid the system-installed FreeType headers... --ryan.
//This path no longer exists.
//# include "llfreetype2/freetype/ft2build.h"
//This works fine.
# include "../include/ft2build.h"
#endif
#include <ft2build.h>
// For some reason, this won't work if it's not wrapped in the ifdef
#ifdef FT_FREETYPE_H
@@ -65,12 +57,15 @@ LLFontManager *gFontManagerp = NULL;
FT_Library gFTLibrary = NULL;
bool LLFont::sOpenGLcrashOnRestart = false;
bool LLFontFreetype::sOpenGLcrashOnRestart = false;
//static
void LLFontManager::initClass()
{
gFontManagerp = new LLFontManager;
if (!gFontManagerp)
{
gFontManagerp = new LLFontManager;
}
}
//static
@@ -92,7 +87,6 @@ LLFontManager::LLFontManager()
}
}
LLFontManager::~LLFontManager()
{
FT_Done_FreeType(gFTLibrary);
@@ -101,14 +95,14 @@ LLFontManager::~LLFontManager()
LLFontGlyphInfo::LLFontGlyphInfo(U32 index)
: mGlyphIndex(index),
mXBitmapOffset(0), // Offset to the origin in the bitmap
mYBitmapOffset(0), // Offset to the origin in the bitmap
mXBearing(0), // Distance from baseline to left in pixels
mYBearing(0), // Distance from baseline to top in pixels
mWidth(0), // In pixels
mHeight(0), // In pixels
mXAdvance(0.f), // In pixels
mYAdvance(0.f), // In pixels
mXBitmapOffset(0), // Offset to the origin in the bitmap
mYBitmapOffset(0), // Offset to the origin in the bitmap
mXBearing(0), // Distance from baseline to left in pixels
mYBearing(0), // Distance from baseline to top in pixels
mIsRendered(FALSE),
mMetricsValid(FALSE)
{}
@@ -126,33 +120,29 @@ LLFontList::~LLFontList()
// The (now dangling) pointers in the vector will be cleaned up when the vector is deleted by the superclass destructor.
}
}
void LLFontList::addAtEnd(LLFont *font)
void LLFontList::addAtEnd(LLFontFreetype *font)
{
// Purely a convenience function
this->push_back(font);
}
LLFont::LLFont()
LLFontFreetype::LLFontFreetype()
: mFontBitmapCachep(new LLFontBitmapCache),
mValid(FALSE),
mAscender(0.f),
mDescender(0.f),
mLineHeight(0.f),
mFallbackFontp(NULL),
mIsFallback(FALSE),
mFTFace(NULL),
mRenderGlyphCount(0),
mAddGlyphCount(0),
mPointSize(0)
{
mFontBitmapCachep = new LLFontBitmapCache;
mValid = FALSE;
mAscender = 0.f;
mDescender = 0.f;
mLineHeight = 0.f;
mFallbackFontp = NULL;
mIsFallback = FALSE;
mFTFace = NULL;
mRenderGlyphCount = 0;
mAddGlyphCount = 0;
mPointSize = 0;
}
LLFont::~LLFont()
LLFontFreetype::~LLFontFreetype()
{
// Clean up freetype libs.
if (mFTFace)
@@ -165,25 +155,7 @@ LLFont::~LLFont()
// mFontBitmapCachep will be cleaned up by LLPointer destructor.
}
// virtual
F32 LLFont::getLineHeight() const
{
return mLineHeight;
}
// virtual
F32 LLFont::getAscenderHeight() const
{
return mAscender;
}
// virtual
F32 LLFont::getDescenderHeight() const
{
return mDescender;
}
BOOL LLFont::loadFace(const std::string& filename, const F32 point_size, const F32 vert_dpi, const F32 horz_dpi, const S32 components, BOOL is_fallback)
BOOL LLFontFreetype::loadFace(const std::string& filename, const F32 point_size, const F32 vert_dpi, const F32 horz_dpi, const S32 components, BOOL is_fallback)
{
// Don't leak face objects. This is also needed to deal with
// changed font file names.
@@ -260,38 +232,115 @@ BOOL LLFont::loadFace(const std::string& filename, const F32 point_size, const F
return TRUE;
}
void LLFont::resetBitmapCache()
//virtual
F32 LLFontFreetype::getLineHeight() const
{
// Iterate through glyphs and clear the mIsRendered flag
for (char_glyph_info_map_t::iterator iter = mCharGlyphInfoMap.begin();
iter != mCharGlyphInfoMap.end(); ++iter)
{
iter->second->mIsRendered = FALSE;
//FIXME: this is only strictly necessary when resetting the entire font,
//not just flushing the bitmap
iter->second->mMetricsValid = FALSE;
}
mFontBitmapCachep->reset();
if (!mIsFallback || !sOpenGLcrashOnRestart) // because this often crashes under Linux...
{
// Add the empty glyph`5
addGlyph(0, 0);
}
return mLineHeight;
}
LLFontGlyphInfo* LLFont::getGlyphInfo(const llwchar wch) const
//virtual
F32 LLFontFreetype::getAscenderHeight() const
{
char_glyph_info_map_t::iterator iter = mCharGlyphInfoMap.find(wch);
if (iter != mCharGlyphInfoMap.end())
{
return iter->second;
}
return NULL;
return mAscender;
}
//virtual
F32 LLFontFreetype::getDescenderHeight() const
{
return mDescender;
}
BOOL LLFont::hasGlyph(const llwchar wch) const
F32 LLFontFreetype::getXAdvance(const llwchar wch) const
{
if (mFTFace == NULL)
return 0.0;
llassert(!mIsFallback);
U32 glyph_index;
// Return existing info only if it is current
LLFontGlyphInfo* gi = getGlyphInfo(wch);
if (gi && gi->mMetricsValid)
{
return gi->mXAdvance;
}
const LLFontFreetype* fontp = this;
// Initialize char to glyph map
glyph_index = FT_Get_Char_Index(mFTFace, wch);
if (glyph_index == 0 && mFallbackFontp)
{
LLFontList::iterator iter;
for(iter = mFallbackFontp->begin(); (iter != mFallbackFontp->end()) && (glyph_index == 0); iter++)
{
glyph_index = FT_Get_Char_Index((*iter)->mFTFace, wch);
if(glyph_index)
{
fontp = *iter;
}
}
}
if (glyph_index)
{
// This font has this glyph
fontp->renderGlyph(glyph_index);
// Create the entry if it's not there
char_glyph_info_map_t::iterator iter2 = mCharGlyphInfoMap.find(wch);
if (iter2 == mCharGlyphInfoMap.end())
{
gi = new LLFontGlyphInfo(glyph_index);
insertGlyphInfo(wch, gi);
}
else
{
gi = iter2->second;
}
gi->mWidth = fontp->mFTFace->glyph->bitmap.width;
gi->mHeight = fontp->mFTFace->glyph->bitmap.rows;
// Convert these from 26.6 units to float pixels.
gi->mXAdvance = fontp->mFTFace->glyph->advance.x / 64.f;
gi->mYAdvance = fontp->mFTFace->glyph->advance.y / 64.f;
gi->mMetricsValid = TRUE;
return gi->mXAdvance;
}
else
{
gi = get_if_there(mCharGlyphInfoMap, (llwchar)0, (LLFontGlyphInfo*)NULL);
if (gi)
{
return gi->mXAdvance;
}
}
// Last ditch fallback - no glyphs defined at all.
return (F32)mFontBitmapCachep->getMaxCharWidth();
}
F32 LLFontFreetype::getXKerning(const llwchar char_left, const llwchar char_right) const
{
if (mFTFace == NULL)
return 0.0;
llassert(!mIsFallback);
LLFontGlyphInfo* left_glyph_info = get_if_there(mCharGlyphInfoMap, char_left, (LLFontGlyphInfo*)NULL);
U32 left_glyph = left_glyph_info ? left_glyph_info->mGlyphIndex : 0;
// Kern this puppy.
LLFontGlyphInfo* right_glyph_info = get_if_there(mCharGlyphInfoMap, char_right, (LLFontGlyphInfo*)NULL);
U32 right_glyph = right_glyph_info ? right_glyph_info->mGlyphIndex : 0;
FT_Vector delta;
llverify(!FT_Get_Kerning(mFTFace, left_glyph, right_glyph, ft_kerning_unfitted, &delta));
return delta.x*(1.f/64.f);
}
BOOL LLFontFreetype::hasGlyph(const llwchar wch) const
{
llassert(!mIsFallback);
const LLFontGlyphInfo* gi = getGlyphInfo(wch);
@@ -305,7 +354,7 @@ BOOL LLFont::hasGlyph(const llwchar wch) const
}
}
BOOL LLFont::addChar(const llwchar wch) const
BOOL LLFontFreetype::addChar(const llwchar wch) const
{
if (mFTFace == NULL)
return FALSE;
@@ -345,21 +394,7 @@ BOOL LLFont::addChar(const llwchar wch) const
return FALSE;
}
void LLFont::insertGlyphInfo(llwchar wch, LLFontGlyphInfo* gi) const
{
char_glyph_info_map_t::iterator iter = mCharGlyphInfoMap.find(wch);
if (iter != mCharGlyphInfoMap.end())
{
delete iter->second;
iter->second = gi;
}
else
{
mCharGlyphInfoMap[wch] = gi;
}
}
BOOL LLFont::addGlyphFromFont(const LLFont *fontp, const llwchar wch, const U32 glyph_index) const
BOOL LLFontFreetype::addGlyphFromFont(const LLFontFreetype *fontp, const llwchar wch, const U32 glyph_index) const
{
if (mFTFace == NULL)
return FALSE;
@@ -460,120 +495,69 @@ BOOL LLFont::addGlyphFromFont(const LLFont *fontp, const llwchar wch, const U32
return TRUE;
}
BOOL LLFont::addGlyph(const llwchar wch, const U32 glyph_index) const
LLFontGlyphInfo* LLFontFreetype::getGlyphInfo(const llwchar wch) const
{
char_glyph_info_map_t::iterator iter = mCharGlyphInfoMap.find(wch);
if (iter != mCharGlyphInfoMap.end())
{
return iter->second;
}
return NULL;
}
void LLFontFreetype::insertGlyphInfo(llwchar wch, LLFontGlyphInfo* gi) const
{
char_glyph_info_map_t::iterator iter = mCharGlyphInfoMap.find(wch);
if (iter != mCharGlyphInfoMap.end())
{
delete iter->second;
iter->second = gi;
}
else
{
mCharGlyphInfoMap[wch] = gi;
}
}
BOOL LLFontFreetype::addGlyph(const llwchar wch, const U32 glyph_index) const
{
return addGlyphFromFont(this, wch, glyph_index);
}
F32 LLFont::getXAdvance(const llwchar wch) const
{
if (mFTFace == NULL)
return 0.0;
llassert(!mIsFallback);
U32 glyph_index;
// Return existing info only if it is current
LLFontGlyphInfo* gi = getGlyphInfo(wch);
if (gi && gi->mMetricsValid)
{
return gi->mXAdvance;
}
const LLFont* fontp = this;
// Initialize char to glyph map
glyph_index = FT_Get_Char_Index(mFTFace, wch);
if (glyph_index == 0 && mFallbackFontp)
{
LLFontList::iterator iter;
for(iter = mFallbackFontp->begin(); (iter != mFallbackFontp->end()) && (glyph_index == 0); iter++)
{
glyph_index = FT_Get_Char_Index((*iter)->mFTFace, wch);
if(glyph_index)
{
fontp = *iter;
}
}
}
if (glyph_index)
{
// This font has this glyph
fontp->renderGlyph(glyph_index);
// Create the entry if it's not there
char_glyph_info_map_t::iterator iter2 = mCharGlyphInfoMap.find(wch);
if (iter2 == mCharGlyphInfoMap.end())
{
gi = new LLFontGlyphInfo(glyph_index);
insertGlyphInfo(wch, gi);
}
else
{
gi = iter2->second;
}
gi->mWidth = fontp->mFTFace->glyph->bitmap.width;
gi->mHeight = fontp->mFTFace->glyph->bitmap.rows;
// Convert these from 26.6 units to float pixels.
gi->mXAdvance = fontp->mFTFace->glyph->advance.x / 64.f;
gi->mYAdvance = fontp->mFTFace->glyph->advance.y / 64.f;
gi->mMetricsValid = TRUE;
return gi->mXAdvance;
}
else
{
gi = get_if_there(mCharGlyphInfoMap, (llwchar)0, (LLFontGlyphInfo*)NULL);
if (gi)
{
return gi->mXAdvance;
}
}
// Last ditch fallback - no glyphs defined at all.
return (F32)mFontBitmapCachep->getMaxCharWidth();
}
void LLFont::renderGlyph(const U32 glyph_index) const
void LLFontFreetype::renderGlyph(const U32 glyph_index) const
{
if (mFTFace == NULL)
return;
int error = FT_Load_Glyph(mFTFace, glyph_index, FT_LOAD_DEFAULT );
llassert(!error);
llassert_always(! FT_Load_Glyph(mFTFace, glyph_index, FT_LOAD_DEFAULT));
error = FT_Render_Glyph(mFTFace->glyph, gFontRenderMode);
llassert_always(! FT_Render_Glyph(mFTFace->glyph, gFontRenderMode) );
mRenderGlyphCount++;
llassert(!error);
}
F32 LLFont::getXKerning(const llwchar char_left, const llwchar char_right) const
void LLFontFreetype::resetBitmapCache()
{
if (mFTFace == NULL)
return 0.0;
// Iterate through glyphs and clear the mIsRendered flag
for (char_glyph_info_map_t::iterator iter = mCharGlyphInfoMap.begin();
iter != mCharGlyphInfoMap.end(); ++iter)
{
iter->second->mIsRendered = FALSE;
//FIXME: this is only strictly necessary when resetting the entire font,
//not just flushing the bitmap
iter->second->mMetricsValid = FALSE;
}
mFontBitmapCachep->reset();
llassert(!mIsFallback);
LLFontGlyphInfo* left_glyph_info = get_if_there(mCharGlyphInfoMap, char_left, (LLFontGlyphInfo*)NULL);
U32 left_glyph = left_glyph_info ? left_glyph_info->mGlyphIndex : 0;
// Kern this puppy.
LLFontGlyphInfo* right_glyph_info = get_if_there(mCharGlyphInfoMap, char_right, (LLFontGlyphInfo*)NULL);
U32 right_glyph = right_glyph_info ? right_glyph_info->mGlyphIndex : 0;
FT_Vector delta;
llverify(!FT_Get_Kerning(mFTFace, left_glyph, right_glyph, ft_kerning_unfitted, &delta));
return delta.x*(1.f/64.f);
if (!mIsFallback || !sOpenGLcrashOnRestart) // because this often crashes under Linux...
{
// Add the empty glyph`5
addGlyph(0, 0);
}
}
void LLFont::setSubImageLuminanceAlpha(const U32 x,
void LLFontFreetype::setSubImageLuminanceAlpha(const U32 x,
const U32 y,
const U32 bitmap_num,
const U32 width,

View File

@@ -30,11 +30,10 @@
* $/LicenseInfo$
*/
#ifndef LL_LLFONT_H
#define LL_LLFONT_H
#ifndef LL_LLFONTFREETYPE_H
#define LL_LLFONTFREETYPE_H
#include <map>
//#include "lllocalidhashmap.h"
#include "llmemory.h"
#include "llstl.h"
@@ -43,7 +42,7 @@
class LLImageRaw;
class LLFontManager;
class LLFont;
class LLFontFreetype;
// Hack. FT_Face is just a typedef for a pointer to a struct,
// but there's no simple forward declarations file for FreeType,
@@ -59,7 +58,7 @@ class LLFontManager
public:
static void initClass();
static void cleanupClass();
public:
LLFontManager();
virtual ~LLFontManager();
@@ -88,19 +87,19 @@ public:
};
// Used for lists of fallback fonts
class LLFontList : public std::vector<LLFont*>
class LLFontList : public std::vector<LLFontFreetype*>
{
public:
LLFontList();
~LLFontList();
void addAtEnd(LLFont *font);
void addAtEnd(LLFontFreetype *font);
};
class LLFont
class LLFontFreetype
{
public:
LLFont();
virtual ~LLFont();
LLFontFreetype();
virtual ~LLFontFreetype();
// is_fallback should be true for fallback fonts that aren't used
// to render directly (Unicode backup, primarily)
@@ -157,7 +156,7 @@ protected:
virtual BOOL hasGlyph(const llwchar wch) const; // Has a glyph for this character
virtual BOOL addChar(const llwchar wch) const; // Add a new character to the font if necessary
virtual BOOL addGlyph(const llwchar wch, const U32 glyph_index) const; // Add a new glyph to the existing font
virtual BOOL addGlyphFromFont(const LLFont *fontp, const llwchar wch, const U32 glyph_index) const; // Add a glyph from this font to the other (returns the glyph_index, 0 if not found)
virtual BOOL addGlyphFromFont(const LLFontFreetype *fontp, const llwchar wch, const U32 glyph_index) const; // Add a glyph from this font to the other (returns the glyph_index, 0 if not found)
virtual LLFontGlyphInfo* getGlyphInfo(const llwchar wch) const;
@@ -195,4 +194,4 @@ protected:
mutable S32 mAddGlyphCount;
};
#endif // LL_FONT_
#endif // LL_FONTFREETYPE_H

View File

@@ -26,10 +26,12 @@
#include "linden_common.h"
#include <boost/tokenizer.hpp>
#include "llfont.h"
#include "llfontgl.h"
// Linden library includes
#include "llfontfreetype.h"
#include "llfontbitmapcache.h"
#include "llfontregistry.h"
#include "llgl.h"
@@ -38,6 +40,9 @@
#include "llstl.h"
#include "llfasttimer.h"
// Third party library includes
#include <boost/tokenizer.hpp>
const S32 BOLD_OFFSET = 1;
// static class members
@@ -79,7 +84,7 @@ F32 llfont_round_y(F32 y)
}
LLFontGL::LLFontGL()
: LLFont()
: LLFontFreetype()
{
clearEmbeddedChars();
}
@@ -128,7 +133,7 @@ void LLFontGL::destroyGL()
BOOL LLFontGL::loadFace(const std::string& filename, const F32 point_size, const F32 vert_dpi, const F32 horz_dpi, const S32 components, BOOL is_fallback)
{
if (!LLFont::loadFace(filename, point_size, vert_dpi, horz_dpi, components, is_fallback))
if (!LLFontFreetype::loadFace(filename, point_size, vert_dpi, horz_dpi, components, is_fallback))
{
return FALSE;
}
@@ -138,7 +143,7 @@ BOOL LLFontGL::loadFace(const std::string& filename, const F32 point_size, const
BOOL LLFontGL::addChar(const llwchar wch) const
{
if (!LLFont::addChar(wch))
if (!LLFontFreetype::addChar(wch))
{
return FALSE;
}
@@ -288,7 +293,7 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons
F32 inv_width = 1.f / mFontBitmapCachep->getBitmapWidth();
F32 inv_height = 1.f / mFontBitmapCachep->getBitmapHeight();
const S32 LAST_CHARACTER = LLFont::LAST_CHAR_FULL;
const S32 LAST_CHARACTER = LLFontFreetype::LAST_CHAR_FULL;
BOOL draw_ellipses = FALSE;
@@ -546,7 +551,7 @@ F32 LLFontGL::getWidthF32(const std::string& utf8text, const S32 begin_offset, c
F32 LLFontGL::getWidthF32(const llwchar* wchars, const S32 begin_offset, const S32 max_chars, BOOL use_embedded) const
{
const S32 LAST_CHARACTER = LLFont::LAST_CHAR_FULL;
const S32 LAST_CHARACTER = LLFontFreetype::LAST_CHAR_FULL;
F32 cur_x = 0;
const S32 max_index = begin_offset + max_chars;
@@ -981,7 +986,7 @@ void LLFontGL::destroyAllGL()
{
if (sFontRegistry)
{
if (LLFont::sOpenGLcrashOnRestart)
if (LLFontFreetype::sOpenGLcrashOnRestart)
{
// This will leak memory but will prevent a crash...
sFontRegistry = NULL;

View File

@@ -28,7 +28,7 @@
#ifndef LL_LLFONTGL_H
#define LL_LLFONTGL_H
#include "llfont.h"
#include "llfontfreetype.h"
#include "lltexture.h"
#include "v2math.h"
#include "llcoord.h"
@@ -44,7 +44,7 @@ class LLFontDescriptor;
// Structure used to store previously requested fonts.
class LLFontRegistry;
class LLFontGL : public LLFont
class LLFontGL : public LLFontFreetype
{
public:
enum HAlign
@@ -66,12 +66,11 @@ public:
enum StyleFlags
{
// text style to render. May be combined (these are bit flags)
// text style to render. May be combined (these are bit flags)
NORMAL = 0x00,
BOLD = 0x01,
ITALIC = 0x02,
UNDERLINE = 0x04,
UNDERLINE = 0x04
};
enum ShadowType

View File

@@ -27,6 +27,7 @@
#include "linden_common.h"
#include "llgl.h"
#include "llfontfreetype.h"
#include "llfontgl.h"
#include "llfontregistry.h"
#include <boost/tokenizer.hpp>
@@ -188,21 +189,20 @@ bool LLFontRegistry::parseFontInfo(const std::string& xml_filename)
path_it != xml_paths.end();
++path_it)
{
LLXMLNodePtr root;
std::string full_filename = gDirUtilp->findSkinnedFilename(*path_it, xml_filename);
bool parsed_file = LLXMLNode::parseFile(full_filename, root, NULL);
if (!parsed_file)
continue;
if ( root.isNull() || ! root->hasName( "fonts" ) )
{
llwarns << "Bad font info file: "
<< full_filename << llendl;
continue;
}
std::string root_name;
root->getAttributeString("name",root_name);
if (root->hasName("fonts"))
@@ -214,7 +214,7 @@ bool LLFontRegistry::parseFontInfo(const std::string& xml_filename)
}
if (success)
dump();
return success;
}

View File

@@ -44,7 +44,6 @@
#include "llmath.h"
#include "m4math.h"
#include "llstring.h"
#include "llmemtype.h"
#include "llstacktrace.h"
#include "llglheaders.h"
@@ -603,11 +602,12 @@ bool LLGLManager::initGL()
if (mGLVendor.substr(0,4) == "ATI ")
{
mGLVendorShort = "ATI";
BOOL mobile = FALSE;
if (mGLRenderer.find("MOBILITY") != std::string::npos)
{
mobile = TRUE;
}
// "mobile" appears to be unused, and this code was causing warnings.
//BOOL mobile = FALSE;
//if (mGLRenderer.find("MOBILITY") != std::string::npos)
//{
// mobile = TRUE;
//}
mIsATI = TRUE;
#if LL_WINDOWS && !LL_MESA_HEADLESS
@@ -1444,8 +1444,7 @@ void assert_glerror()
void clear_glerror()
{
// Create or update texture to be used with this data
GLenum error;
error = glGetError();
glGetError();
}
///////////////////////////////////////////////////////////////
@@ -2266,7 +2265,6 @@ void LLGLNamePool::release(GLuint name)
//static
void LLGLNamePool::upkeepPools()
{
LLMemType mt(LLMemType::MTYPE_UPKEEP_POOLS);
for (tracker_t::instance_iter iter = beginInstances(); iter != endInstances(); ++iter)
{
LLGLNamePool & pool = *iter;

View File

@@ -65,9 +65,9 @@ bool LLImageGL::sCompressTextures = false;
std::set<LLImageGL*> LLImageGL::sImageList;
// ****************************************************************************************************
//****************************************************************************************************
//The below for texture auditing use only
// ****************************************************************************************************
//****************************************************************************************************
//-----------------------
//debug use
BOOL gAuditTexture = FALSE ;
@@ -816,8 +816,9 @@ void LLImageGL::setImage(const U8* data_in, BOOL data_hasmips)
S32 w = width, h = height;
const U8* prev_mip_data = 0;
const U8* cur_mip_data = 0;
S32 prev_mip_size = 0;
#ifdef SHOW_ASSERT
S32 cur_mip_size = 0;
#endif
mMipLevels = nummips;
@@ -826,18 +827,24 @@ void LLImageGL::setImage(const U8* data_in, BOOL data_hasmips)
if (m==0)
{
cur_mip_data = data_in;
#ifdef SHOW_ASSERT
cur_mip_size = width * height * mComponents;
#endif
}
else
{
S32 bytes = w * h * mComponents;
#ifdef SHOW_ASSERT
llassert(prev_mip_data);
llassert(prev_mip_size == bytes*4);
llassert(cur_mip_size == bytes*4);
#endif
U8* new_data = new U8[bytes];
llassert_always(new_data);
LLImageBase::generateMip(prev_mip_data, new_data, w, h, mComponents);
cur_mip_data = new_data;
#ifdef SHOW_ASSERT
cur_mip_size = bytes;
#endif
}
llassert(w > 0 && h > 0 && cur_mip_data);
{
@@ -870,7 +877,6 @@ void LLImageGL::setImage(const U8* data_in, BOOL data_hasmips)
delete[] prev_mip_data;
}
prev_mip_data = cur_mip_data;
prev_mip_size = cur_mip_size;
w >>= 1;
h >>= 1;
}

View File

@@ -31,7 +31,6 @@
#include "llvertexbuffer.h"
// #include "llrender.h"
#include "llglheaders.h"
#include "llmemtype.h"
#include "llrender.h"
#include "llvector4a.h"
#include "llshadermgr.h"
@@ -325,7 +324,6 @@ void LLVertexBuffer::setupClientArrays(U32 data_mask)
{
if (sLastMask != data_mask)
{
bool error = false;
if (gGLManager.mGLSLVersionMajor < 2 && gGLManager.mGLSLVersionMinor < 30)
{
@@ -392,7 +390,6 @@ void LLVertexBuffer::setupClientArrays(U32 data_mask)
{
if (gDebugSession)
{
error = true;
gFailLog << "Bad client state! " << array[i] << " disabled." << std::endl;
}
else
@@ -412,7 +409,6 @@ void LLVertexBuffer::setupClientArrays(U32 data_mask)
{ //needs to be disabled, make sure it was (DEBUG TEMPORARY)
if (gDebugSession)
{
error = true;
gFailLog << "Bad client state! " << array[i] << " enabled." << std::endl;
}
else
@@ -779,7 +775,6 @@ void LLVertexBuffer::unbind()
//static
void LLVertexBuffer::cleanupClass()
{
LLMemType mt2(LLMemType::MTYPE_VERTEX_CLEANUP_CLASS);
unbind();
sStreamIBOPool.cleanup();
@@ -860,8 +855,6 @@ LLVertexBuffer::LLVertexBuffer(U32 typemask, S32 usage) :
mMappable(false),
mFence(NULL)
{
LLMemType mt2(LLMemType::MTYPE_VERTEX_CONSTRUCTOR);
mMappable = (mUsage == GL_DYNAMIC_DRAW_ARB && !sDisableVBOMapping);
//zero out offsets
@@ -921,7 +914,6 @@ S32 LLVertexBuffer::getSize() const
//virtual
LLVertexBuffer::~LLVertexBuffer()
{
LLMemType mt2(LLMemType::MTYPE_VERTEX_DESTRUCTOR);
destroyGLBuffer();
destroyGLIndices();
@@ -1041,8 +1033,6 @@ void LLVertexBuffer::releaseIndices()
void LLVertexBuffer::createGLBuffer(U32 size)
{
LLMemType mt2(LLMemType::MTYPE_VERTEX_CREATE_VERTICES);
if (mGLBuffer)
{
destroyGLBuffer();
@@ -1072,8 +1062,6 @@ void LLVertexBuffer::createGLBuffer(U32 size)
void LLVertexBuffer::createGLIndices(U32 size)
{
LLMemType mt2(LLMemType::MTYPE_VERTEX_CREATE_INDICES);
if (mGLIndices)
{
destroyGLIndices();
@@ -1108,7 +1096,6 @@ void LLVertexBuffer::createGLIndices(U32 size)
void LLVertexBuffer::destroyGLBuffer()
{
LLMemType mt2(LLMemType::MTYPE_VERTEX_DESTROY_BUFFER);
if (mGLBuffer)
{
if (mMappedDataUsingVBOs)
@@ -1129,7 +1116,6 @@ void LLVertexBuffer::destroyGLBuffer()
void LLVertexBuffer::destroyGLIndices()
{
LLMemType mt2(LLMemType::MTYPE_VERTEX_DESTROY_INDICES);
if (mGLIndices)
{
if (mMappedIndexDataUsingVBOs)
@@ -1150,8 +1136,6 @@ void LLVertexBuffer::destroyGLIndices()
void LLVertexBuffer::updateNumVerts(S32 nverts)
{
LLMemType mt2(LLMemType::MTYPE_VERTEX_UPDATE_VERTS);
llassert(nverts >= 0);
if (nverts > 65536)
@@ -1174,8 +1158,6 @@ void LLVertexBuffer::updateNumVerts(S32 nverts)
void LLVertexBuffer::updateNumIndices(S32 nindices)
{
LLMemType mt2(LLMemType::MTYPE_VERTEX_UPDATE_INDICES);
llassert(nindices >= 0);
U32 needed_size = sizeof(U16) * (U32)nindices;
@@ -1192,8 +1174,6 @@ void LLVertexBuffer::updateNumIndices(S32 nindices)
void LLVertexBuffer::allocateBuffer(S32 nverts, S32 nindices, bool create)
{
LLMemType mt2(LLMemType::MTYPE_VERTEX_ALLOCATE_BUFFER);
stop_glerror();
if (nverts < 0 || nindices < 0 ||
@@ -1344,8 +1324,6 @@ void LLVertexBuffer::resizeBuffer(S32 newnverts, S32 newnindices)
llassert(newnverts >= 0);
llassert(newnindices >= 0);
LLMemType mt2(LLMemType::MTYPE_VERTEX_RESIZE_BUFFER);
updateNumVerts(newnverts);
updateNumIndices(newnindices);
@@ -1393,7 +1371,6 @@ static LLFastTimer::DeclareTimer FTM_VBO_MAP_BUFFER("VBO Map");
volatile U8* LLVertexBuffer::mapVertexBuffer(S32 type, S32 index, S32 count, bool map_range)
{
bindGLBuffer(true);
LLMemType mt2(LLMemType::MTYPE_VERTEX_MAP_BUFFER);
if (mFinal)
{
llerrs << "LLVertexBuffer::mapVeretxBuffer() called on a finalized buffer." << llendl;
@@ -1442,7 +1419,6 @@ volatile U8* LLVertexBuffer::mapVertexBuffer(S32 type, S32 index, S32 count, boo
if (!mVertexLocked)
{
LLMemType mt_v(LLMemType::MTYPE_VERTEX_MAP_BUFFER_VERTICES);
mVertexLocked = true;
sMappedCount++;
stop_glerror();
@@ -1573,7 +1549,6 @@ static LLFastTimer::DeclareTimer FTM_VBO_MAP_INDEX("IBO Map");
volatile U8* LLVertexBuffer::mapIndexBuffer(S32 index, S32 count, bool map_range)
{
LLMemType mt2(LLMemType::MTYPE_VERTEX_MAP_BUFFER);
bindGLIndices(true);
if (mFinal)
{
@@ -1620,8 +1595,6 @@ volatile U8* LLVertexBuffer::mapIndexBuffer(S32 index, S32 count, bool map_range
if (!mIndexLocked)
{
LLMemType mt_v(LLMemType::MTYPE_VERTEX_MAP_BUFFER_INDICES);
mIndexLocked = true;
sMappedCount++;
stop_glerror();
@@ -1744,7 +1717,6 @@ static LLFastTimer::DeclareTimer FTM_IBO_FLUSH_RANGE("Flush IBO Range");
void LLVertexBuffer::unmapBuffer()
{
LLMemType mt2(LLMemType::MTYPE_VERTEX_UNMAP_BUFFER);
if (!useVBOs())
{
return; //nothing to unmap
@@ -2098,7 +2070,6 @@ void LLVertexBuffer::setBuffer(U32 data_mask)
{
flush();
LLMemType mt2(LLMemType::MTYPE_VERTEX_SET_BUFFER);
//set up pointers if the data mask is different ...
bool setup = (sLastMask != data_mask);
@@ -2144,7 +2115,6 @@ void LLVertexBuffer::setBuffer(U32 data_mask)
setup = setup || bindBuffer || bindIndices;
}
bool error = false;
if (gDebugGL && !mGLArray)
{
GLint buff;
@@ -2153,7 +2123,6 @@ void LLVertexBuffer::setBuffer(U32 data_mask)
{
if (gDebugSession)
{
error = true;
gFailLog << "Invalid GL vertex buffer bound: " << buff << std::endl;
}
else
@@ -2169,7 +2138,6 @@ void LLVertexBuffer::setBuffer(U32 data_mask)
{
if (gDebugSession)
{
error = true;
gFailLog << "Invalid GL index buffer bound: " << buff << std::endl;
}
else
@@ -2240,7 +2208,6 @@ void LLVertexBuffer::setBuffer(U32 data_mask)
// virtual (default)
void LLVertexBuffer::setupVertexBuffer(U32 data_mask)
{
LLMemType mt2(LLMemType::MTYPE_VERTEX_SETUP_VERTEX_BUFFER);
stop_glerror();
volatile U8* base = useVBOs() ? (U8*) mAlignedOffset : mMappedData;

View File

@@ -30,7 +30,6 @@ set(llui_SOURCE_FILES
llclipboard.cpp
llcombobox.cpp
llctrlselectioninterface.cpp
lldelayeduidelete.cpp
lldraghandle.cpp
lleditmenuhandler.cpp
llfloater.cpp
@@ -73,9 +72,9 @@ set(llui_SOURCE_FILES
lluictrlfactory.cpp
lluistring.cpp
llundo.cpp
llview.cpp
llviewborder.cpp
llviewmodel.cpp
llview.cpp
llviewquery.cpp
)
@@ -90,7 +89,6 @@ set(llui_HEADER_FILES
llclipboard.h
llcombobox.h
llctrlselectioninterface.h
lldelayeduidelete.h
lldraghandle.h
lleditmenuhandler.h
llfloater.h
@@ -105,8 +103,8 @@ set(llui_HEADER_FILES
llmenugl.h
llmodaldialog.h
llmultifloater.h
llmultisliderctrl.h
llmultislider.h
llmultisliderctrl.h
llnotificationptr.h
llnotifications.h
llnotificationsutil.h
@@ -122,8 +120,8 @@ set(llui_HEADER_FILES
llscrollcontainer.h
llscrollingpanellist.h
llscrolllistctrl.h
llsliderctrl.h
llslider.h
llsliderctrl.h
llspinctrl.h
llstyle.h
lltabcontainer.h
@@ -131,18 +129,18 @@ set(llui_HEADER_FILES
lltexteditor.h
lltextparser.h
lltrans.h
lluiconstants.h
lluictrlfactory.h
lluictrl.h
lluifwd.h
llui.h
lluicolor.h
lluiconstants.h
lluictrl.h
lluictrlfactory.h
lluifwd.h
lluistring.h
lluixmltags.h
llundo.h
llview.h
llviewborder.h
llviewmodel.h
llview.h
llviewquery.h
)

View File

@@ -315,11 +315,11 @@ LLAlertDialog::LLAlertDialog( LLNotificationPtr notification, bool modal)
if (form->getIgnoreType() == LLNotificationForm::IGNORE_WITH_DEFAULT_RESPONSE)
{
setCheckBox(LLNotifications::instance().getGlobalString("skipnexttime"), ignore_label);
setCheckBox(LLNotificationTemplates::instance().getGlobalString("skipnexttime"), ignore_label);
}
else if (form->getIgnoreType() == LLNotificationForm::IGNORE_WITH_LAST_RESPONSE)
{
setCheckBox(LLNotifications::instance().getGlobalString("alwayschoose"), ignore_label);
setCheckBox(LLNotificationTemplates::instance().getGlobalString("alwayschoose"), ignore_label);
}
}

View File

@@ -1,67 +0,0 @@
// <edit>
#include "linden_common.h"
#include "lldelayeduidelete.h"
#define DELETE_DELAY 0.1f
#define DELETES_PER_DELAY 512
LLDeleteScheduler* gDeleteScheduler;
std::list<LLDeleteJob*> LLDeleteScheduler::sJobs;
LLDeleteScheduler::LLDeleteScheduler() : LLEventTimer(DELETE_DELAY)
{
}
void LLDeleteScheduler::addViewDeleteJob(std::list<LLView*> views)
{
if(!views.empty())
{
LLViewDeleteJob* job = new LLViewDeleteJob(views);
sJobs.push_back(job);
}
}
BOOL LLDeleteScheduler::tick() // IMPORTANT: never return TRUE
{
if(!sJobs.empty())
{
U32 completed = 0;
do
{
LLDeleteJob* job = sJobs.front();
if(job->work(completed))
{
delete job;
sJobs.pop_front();
}
} while((completed < DELETES_PER_DELAY) && !sJobs.empty());
}
return FALSE; // EVER
}
BOOL LLDeleteJob::work(U32& completed)
{
llwarns << "THIS IS SPOSED TO BE OVERRIDDEN" << llendl;
return TRUE;
}
LLViewDeleteJob::LLViewDeleteJob(std::list<LLView*> views)
: mList(views)
{
}
LLViewDeleteJob::~LLViewDeleteJob()
{
}
BOOL LLViewDeleteJob::work(U32& completed)
{
do
{
if(!mList.empty())
{
LLView* view = mList.front();
delete view;
mList.pop_front();
}
else
{
return TRUE; // job done
}
} while(++completed < DELETES_PER_DELAY);
return FALSE;
}
// </edit>

View File

@@ -1,32 +0,0 @@
// <edit>
#ifndef LL_LLDELAYEDUIDELETE_H
#define LL_LLDELAYEDUIDELETE_H
#include "lleventtimer.h"
#include "llview.h"
class LLDeleteJob
{
public:
virtual BOOL work(U32& completed);
virtual ~LLDeleteJob() {}
};
class LLViewDeleteJob : public LLDeleteJob
{
public:
LLViewDeleteJob(std::list<LLView*> views);
virtual ~LLViewDeleteJob();
virtual BOOL work(U32& completed);
private:
std::list<LLView*> mList;
};
class LLDeleteScheduler : public LLEventTimer
{
public:
LLDeleteScheduler();
void addViewDeleteJob(std::list<LLView*> views);
BOOL tick();
private:
static std::list<LLDeleteJob*> sJobs;
};
extern LLDeleteScheduler* gDeleteScheduler;
#endif
// </edit>

View File

@@ -277,30 +277,14 @@ void LLFloater::initFloater(const std::string& title,
mMinimized = FALSE;
mExpandedRect.set(0,0,0,0);
S32 close_pad; // space to the right of close box
S32 close_box_size; // For layout purposes, how big is the close box?
if (close_btn)
{
close_box_size = LLFLOATER_CLOSE_BOX_SIZE;
close_pad = 0;
}
else
{
close_box_size = 0;
close_pad = 0;
}
S32 minimize_box_size;
S32 minimize_pad;
if (minimizable && !drag_on_left)
{
minimize_box_size = LLFLOATER_CLOSE_BOX_SIZE;
minimize_pad = 0;
}
else
{
minimize_box_size = 0;
minimize_pad = 0;
}
// Drag Handle

View File

@@ -100,10 +100,10 @@ private:
for (LLNotificationSet::iterator it = mItems.begin(); it != mItems.end(); ++it)
{
if (!LLNotifications::instance().templateExists((*it)->getName())) continue;
if (!LLNotificationTemplates::instance().templateExists((*it)->getName())) continue;
// only store notifications flagged as persisting
LLNotificationTemplatePtr templatep = LLNotifications::instance().getTemplate((*it)->getName());
LLNotificationTemplatePtr templatep = LLNotificationTemplates::instance().getTemplate((*it)->getName());
if (!templatep->mPersist) continue;
data.append((*it)->asLLSD());
@@ -228,7 +228,7 @@ LLNotificationForm::LLNotificationForm(const std::string& name, const LLXMLNodeP
LLXMLNodePtr child = xml_node->getFirstChild();
while(child)
{
child = LLNotifications::instance().checkForXMLTemplate(child);
child = LLNotificationTemplates::instance().checkForXMLTemplate(child);
LLSD item_entry;
std::string element_name = child->getName()->mString;
@@ -662,7 +662,7 @@ bool LLNotification::isEquivalentTo(LLNotificationPtr that) const
void LLNotification::init(const std::string& template_name, const LLSD& form_elements)
{
mTemplatep = LLNotifications::instance().getTemplate(template_name);
mTemplatep = LLNotificationTemplates::instance().getTemplate(template_name);
if (!mTemplatep) return;
const LLStringUtil::format_map_t& default_args = LLTrans::getDefaultArgs();
@@ -1098,12 +1098,19 @@ LLNotificationChannelPtr LLNotifications::getChannel(const std::string& channelN
return p->second;
}
// this function is called once at construction time, after the object is constructed.
void LLNotificationTemplates::initSingleton()
{
loadTemplates();
}
// this function is called once at construction time, after the object is constructed.
void LLNotifications::initSingleton()
{
loadTemplates();
createDefaultChannels();
loadNotifications();
// Cannot create default channels here, since that recursively accesses the singleton.
// Instead we call createDefaultChannels() from LLAppViewer::init().
//createDefaultChannels();
}
void LLNotifications::createDefaultChannels()
@@ -1142,7 +1149,7 @@ void LLNotifications::createDefaultChannels()
static std::string sStringSkipNextTime("Skip this dialog next time");
static std::string sStringAlwaysChoose("Always choose this option");
bool LLNotifications::addTemplate(const std::string &name,
bool LLNotificationTemplates::addTemplate(const std::string &name,
LLNotificationTemplatePtr theTemplate)
{
if (mTemplates.count(name))
@@ -1154,7 +1161,7 @@ bool LLNotifications::addTemplate(const std::string &name,
return true;
}
LLNotificationTemplatePtr LLNotifications::getTemplate(const std::string& name)
LLNotificationTemplatePtr LLNotificationTemplates::getTemplate(const std::string& name)
{
if (mTemplates.count(name))
{
@@ -1166,12 +1173,12 @@ LLNotificationTemplatePtr LLNotifications::getTemplate(const std::string& name)
}
}
bool LLNotifications::templateExists(const std::string& name)
bool LLNotificationTemplates::templateExists(const std::string& name)
{
return (mTemplates.count(name) != 0);
}
void LLNotifications::clearTemplates()
void LLNotificationTemplates::clearTemplates()
{
mTemplates.clear();
}
@@ -1192,7 +1199,7 @@ void LLNotifications::forceResponse(const LLNotification::Params& params, S32 op
temp_notify->respond(response);
}
LLNotifications::TemplateNames LLNotifications::getTemplateNames() const
LLNotificationTemplates::TemplateNames LLNotificationTemplates::getTemplateNames() const
{
TemplateNames names;
for (TemplateMap::const_iterator it = mTemplates.begin(); it != mTemplates.end(); ++it)
@@ -1242,7 +1249,7 @@ void replaceSubstitutionStrings(LLXMLNodePtr node, StringMap& replacements)
// returns true if the template request was invalid and there's nothing else we
// can do with this node, false if you should keep processing (it may have
// replaced the contents of the node referred to)
LLXMLNodePtr LLNotifications::checkForXMLTemplate(LLXMLNodePtr item)
LLXMLNodePtr LLNotificationTemplates::checkForXMLTemplate(LLXMLNodePtr item)
{
if (item->hasName("usetemplate"))
{
@@ -1271,7 +1278,7 @@ LLXMLNodePtr LLNotifications::checkForXMLTemplate(LLXMLNodePtr item)
return item;
}
bool LLNotifications::loadTemplates()
bool LLNotificationTemplates::loadTemplates()
{
const std::string xml_filename = "notifications.xml";
LLXMLNodePtr root;
@@ -1289,11 +1296,6 @@ bool LLNotifications::loadTemplates()
for (LLXMLNodePtr item = root->getFirstChild();
item.notNull(); item = item->getNextSibling())
{
// we do this FIRST so that item can be changed if we
// encounter a usetemplate -- we just replace the
// current xml node and keep processing
item = checkForXMLTemplate(item);
if (item->hasName("global"))
{
std::string global_name;
@@ -1321,7 +1323,35 @@ bool LLNotifications::loadTemplates()
" found in " << xml_filename << llendl;
continue;
}
}
return true;
}
bool LLNotifications::loadNotifications()
{
const std::string xml_filename = "notifications.xml";
LLXMLNodePtr root;
BOOL success = LLUICtrlFactory::getLayeredXMLNode(xml_filename, root);
if (!success || root.isNull() || !root->hasName( "notifications" ))
{
llerrs << "Problem reading UI Notifications file: " << xml_filename << llendl;
return false;
}
for (LLXMLNodePtr item = root->getFirstChild();
item.notNull(); item = item->getNextSibling())
{
// we do this FIRST so that item can be changed if we
// encounter a usetemplate -- we just replace the
// current xml node and keep processing
item = LLNotificationTemplates::instance().checkForXMLTemplate(item);
if (!item->hasName("notification"))
continue;
// now we know we have a notification entry, so let's build it
LLNotificationTemplatePtr pTemplate(new LLNotificationTemplate());
@@ -1369,7 +1399,7 @@ bool LLNotifications::loadTemplates()
for (LLXMLNodePtr child = item->getFirstChild();
!child.isNull(); child = child->getNextSibling())
{
child = checkForXMLTemplate(child);
child = LLNotificationTemplates::instance().checkForXMLTemplate(child);
// <url>
if (child->hasName("url"))
@@ -1405,7 +1435,7 @@ bool LLNotifications::loadTemplates()
pTemplate->mForm = LLNotificationFormPtr(new LLNotificationForm(pTemplate->mName, child));
}
}
addTemplate(pTemplate->mName, pTemplate);
LLNotificationTemplates::instance().addTemplate(pTemplate->mName, pTemplate);
}
//std::ostringstream ostream;
@@ -1485,7 +1515,7 @@ void LLNotifications::update(const LLNotificationPtr pNotif)
}
LLNotificationPtr LLNotifications::find(LLUUID uuid)
LLNotificationPtr LLNotifications::find(LLUUID const& uuid)
{
LLNotificationPtr target = LLNotificationPtr(new LLNotification(uuid));
LLNotificationSet::iterator it=mItems.find(target);
@@ -1505,7 +1535,7 @@ void LLNotifications::forEachNotification(NotificationProcess process)
std::for_each(mItems.begin(), mItems.end(), process);
}
std::string LLNotifications::getGlobalString(const std::string& key) const
std::string LLNotificationTemplates::getGlobalString(const std::string& key) const
{
GlobalStringMap::const_iterator it = mGlobalStrings.find(key);
if (it != mGlobalStrings.end())

View File

@@ -679,45 +679,20 @@ private:
LLNotificationComparator mComparator;
};
class LLNotifications :
public LLSingleton<LLNotifications>,
public LLNotificationChannelBase
class LLNotificationTemplates :
public LLSingleton<LLNotificationTemplates>
{
LOG_CLASS(LLNotifications);
LOG_CLASS(LLNotificationTemplates);
friend class LLSingleton<LLNotificationTemplates>;
// This class may not use LLNotifications.
typedef char LLNotifications;
friend class LLSingleton<LLNotifications>;
public:
// load notification descriptions from file;
// OK to call more than once because it will reload
bool loadTemplates();
LLXMLNodePtr checkForXMLTemplate(LLXMLNodePtr item);
// we provide a collection of simple add notification functions so that it's reasonable to create notifications in one line
LLNotificationPtr add(const std::string& name,
const LLSD& substitutions = LLSD(),
const LLSD& payload = LLSD());
LLNotificationPtr add(const std::string& name,
const LLSD& substitutions,
const LLSD& payload,
const std::string& functor_name);
LLNotificationPtr add(const std::string& name,
const LLSD& substitutions,
const LLSD& payload,
LLNotificationFunctorRegistry::ResponseFunctor functor);
LLNotificationPtr add(const LLNotification::Params& p);
void add(const LLNotificationPtr pNotif);
void cancel(LLNotificationPtr pNotif);
void update(const LLNotificationPtr pNotif);
LLNotificationPtr find(LLUUID uuid);
typedef boost::function<void (LLNotificationPtr)> NotificationProcess;
void forEachNotification(NotificationProcess process);
// This is all stuff for managing the templates
// take your template out
LLNotificationTemplatePtr getTemplate(const std::string& name);
@@ -736,17 +711,67 @@ public:
// useful if you're reloading the file
void clearTemplates(); // erase all templates
void forceResponse(const LLNotification::Params& params, S32 option);
// put your template in (should only be called from LLNotifications).
bool addTemplate(const std::string& name, LLNotificationTemplatePtr theTemplate);
std::string getGlobalString(const std::string& key) const;
private:
// we're a singleton, so we don't have a public constructor
LLNotificationTemplates() { }
/*virtual*/ void initSingleton();
TemplateMap mTemplates;
typedef std::map<std::string, LLXMLNodePtr> XMLTemplateMap;
XMLTemplateMap mXmlTemplates;
typedef std::map<std::string, std::string> GlobalStringMap;
GlobalStringMap mGlobalStrings;
};
class LLNotifications :
public LLSingleton<LLNotifications>,
public LLNotificationChannelBase
{
LOG_CLASS(LLNotifications);
friend class LLSingleton<LLNotifications>;
public:
// load notification descriptions from file;
// OK to call more than once because it will reload
bool loadNotifications();
void createDefaultChannels();
// we provide a collection of simple add notification functions so that it's reasonable to create notifications in one line
LLNotificationPtr add(const std::string& name,
const LLSD& substitutions = LLSD(),
const LLSD& payload = LLSD());
LLNotificationPtr add(const std::string& name,
const LLSD& substitutions,
const LLSD& payload,
const std::string& functor_name);
LLNotificationPtr add(const std::string& name,
const LLSD& substitutions,
const LLSD& payload,
LLNotificationFunctorRegistry::ResponseFunctor functor);
LLNotificationPtr add(const LLNotification::Params& p);
void forceResponse(const LLNotification::Params& params, S32 option);
typedef std::map<std::string, LLNotificationChannelPtr> ChannelMap;
ChannelMap mChannels;
void addChannel(LLNotificationChannelPtr pChan);
LLNotificationChannelPtr getChannel(const std::string& channelName);
void add(const LLNotificationPtr pNotif);
void cancel(LLNotificationPtr pNotif);
void update(const LLNotificationPtr pNotif);
LLNotificationPtr find(LLUUID const& uuid);
std::string getGlobalString(const std::string& key) const;
typedef boost::function<void (LLNotificationPtr)> NotificationProcess;
void forEachNotification(NotificationProcess process);
private:
// we're a singleton, so we don't have a public constructor
@@ -760,22 +785,11 @@ private:
bool uniqueFilter(LLNotificationPtr pNotification);
bool uniqueHandler(const LLSD& payload);
bool failedUniquenessTest(const LLSD& payload);
LLNotificationChannelPtr pHistoryChannel;
LLNotificationChannelPtr pExpirationChannel;
// put your template in
bool addTemplate(const std::string& name, LLNotificationTemplatePtr theTemplate);
TemplateMap mTemplates;
std::string mFileName;
typedef std::map<std::string, LLXMLNodePtr> XMLTemplateMap;
XMLTemplateMap mXmlTemplates;
LLNotificationMap mUniqueNotifications;
typedef std::map<std::string, std::string> GlobalStringMap;
GlobalStringMap mGlobalStrings;
};

View File

@@ -1065,7 +1065,6 @@ struct LLLayoutStack::LLEmbeddedPanel
mVisibleAmt(1.f) // default to fully visible
{
LLResizeBar::Side side = (orientation == HORIZONTAL) ? LLResizeBar::RIGHT : LLResizeBar::BOTTOM;
LLRect resize_bar_rect = panelp->getRect();
S32 min_dim;
if (orientation == HORIZONTAL)

Some files were not shown because too many files have changed in this diff Show More