From 189599b6ff0c4e6b81e761fbc990c057189359f2 Mon Sep 17 00:00:00 2001
From: Robert Knop <prospero@lindenlab.com>
Date: Thu, 4 Dec 2008 22:36:34 +0000
Subject: [PATCH] Merging from server/server-1.25 back to trunk.

  svn merge -r99446:104838 svn+ssh://svn.lindenlab.com/svn/linden/branches/server/server-1.25

Conflicts resolved by Prospero, except for one scary conflict in
SendConfirmationEmail.php which was resolved by jarv.
---
 indra/lib/python/indra/base/llsd.py           | 11 ++--
 indra/llcommon/indra_constants.h              | 13 ++++-
 indra/llcommon/llapp.cpp                      | 26 ++++++++--
 indra/llcommon/llapp.h                        |  8 ++-
 indra/llcommon/llversionserver.h              |  4 +-
 indra/llmessage/llcircuit.cpp                 | 33 ++++++------
 indra/llmessage/llcircuit.h                   | 16 +++---
 indra/llmessage/llregionflags.h               |  8 +--
 indra/llmessage/message.cpp                   | 12 +++--
 indra/llmessage/message.h                     |  9 ++--
 indra/lscript/lscript_compile/indra.l         | 27 ++++++++--
 .../lscript/lscript_compile/lscript_tree.cpp  |  4 +-
 .../lscript_execute/lscript_execute.cpp       |  9 ++--
 indra/newview/llinventorybridge.cpp           | 47 ++++++++++++++++-
 indra/newview/llinventorybridge.h             |  3 +-
 indra/newview/llstartup.cpp                   | 14 ++++-
 indra/test/lltemplatemessagebuilder_tut.cpp   |  7 ++-
 indra/test/message_tut.cpp                    |  8 ++-
 install.xml                                   | 14 ++---
 scripts/messages/message_template.msg         | 52 +++++++++++++++++++
 20 files changed, 261 insertions(+), 64 deletions(-)

diff --git a/indra/lib/python/indra/base/llsd.py b/indra/lib/python/indra/base/llsd.py
index 057d4e31dc5..e6141b62651 100644
--- a/indra/lib/python/indra/base/llsd.py
+++ b/indra/lib/python/indra/base/llsd.py
@@ -36,10 +36,13 @@
 from indra.util.fastest_elementtree import ElementTreeError, fromstring
 from indra.base import lluuid
 
-try:
-    import cllsd
-except ImportError:
-    cllsd = None
+# cllsd.c in server/server-1.25 has memory leaks,
+#   so disabling cllsd for now
+#try:
+#    import cllsd
+#except ImportError:
+#    cllsd = None
+cllsd = None
 
 int_regex = re.compile(r"[-+]?\d+")
 real_regex = re.compile(r"[-+]?(\d+(\.\d*)?|\d*\.\d+)([eE][-+]?\d+)?")
diff --git a/indra/llcommon/indra_constants.h b/indra/llcommon/indra_constants.h
index a3e3aec3600..c13113a9f21 100644
--- a/indra/llcommon/indra_constants.h
+++ b/indra/llcommon/indra_constants.h
@@ -4,7 +4,7 @@
  *
  * $LicenseInfo:firstyear=2001&license=viewergpl$
  * 
- * Copyright (c) 2001-2007, Linden Research, Inc.
+ * Copyright (c) 2001-2008, Linden Research, Inc.
  * 
  * Second Life Viewer Source Code
  * The source code in this file ("Source Code") is provided by Linden Lab
@@ -77,6 +77,14 @@ enum LAND_STAT_REPORT_TYPE
 
 const U32 STAT_FILTER_MASK	= 0x1FFFFFFF;
 
+// Region absolute limits
+static const S32		REGION_AGENT_COUNT_MIN = 1;
+static const S32		REGION_AGENT_COUNT_MAX = 200;			// Must fit in U8 for the moment (RegionInfo msg)
+static const S32		REGION_PRIM_COUNT_MIN = 0;
+static const S32		REGION_PRIM_COUNT_MAX = 40000;
+static const F32		REGION_PRIM_BONUS_MIN = 1.0;
+static const F32		REGION_PRIM_BONUS_MAX = 10.0;
+
 // Default maximum number of tasks/prims per region.
 const U32 DEFAULT_MAX_REGION_WIDE_PRIM_COUNT = 15000;
 
@@ -229,10 +237,11 @@ const S32 KEY_COUNT = 256;
 const F32 DEFAULT_WATER_HEIGHT 	= 20.0f;
 
 // Maturity ratings for simulators
-const U8 SIM_ACCESS_MIN 	= 0;
+const U8 SIM_ACCESS_MIN 	= 0;		// Treated as 'unknown', usually ends up being SIM_ACCESS_PG
 const U8 SIM_ACCESS_TRIAL	= 7;
 const U8 SIM_ACCESS_PG		= 13;
 const U8 SIM_ACCESS_MATURE	= 21;
+const U8 SIM_ACCESS_ADULT	= 42;		// Seriously Adult Only
 const U8 SIM_ACCESS_DOWN	= 254;
 const U8 SIM_ACCESS_MAX 	= SIM_ACCESS_MATURE;
 
diff --git a/indra/llcommon/llapp.cpp b/indra/llcommon/llapp.cpp
index 88262516178..c2f93b51ac9 100644
--- a/indra/llcommon/llapp.cpp
+++ b/indra/llcommon/llapp.cpp
@@ -88,6 +88,12 @@ LLAppChildCallback LLApp::sDefaultChildCallback = NULL;
 
 
 LLApp::LLApp() : mThreadErrorp(NULL)
+{
+	commonCtor();
+	startErrorThread();
+}
+
+void LLApp::commonCtor()
 {
 	// Set our status to running
 	setStatus(APP_STATUS_RUNNING);
@@ -96,9 +102,9 @@ LLApp::LLApp() : mThreadErrorp(NULL)
 
 #if !LL_WINDOWS
 	// This must be initialized before the error handler.
-	sSigChildCount = new LLAtomicU32(0);	
+	sSigChildCount = new LLAtomicU32(0);
 #endif
-	
+
 	// Setup error handling
 	setupErrorHandling();
 
@@ -118,6 +124,13 @@ LLApp::LLApp() : mThreadErrorp(NULL)
 
 	// Set the application to this instance.
 	sApplication = this;
+
+}
+
+LLApp::LLApp(LLErrorThread *error_thread) :
+	mThreadErrorp(error_thread)
+{
+	commonCtor();
 }
 
 
@@ -261,17 +274,20 @@ void LLApp::setupErrorHandling()
 
 #endif
 
+}
+
+void LLApp::startErrorThread()
+{
 	//
 	// Start the error handling thread, which is responsible for taking action
 	// when the app goes into the APP_STATUS_ERROR state
 	//
-	llinfos << "LLApp::setupErrorHandling - Starting error thread" << llendl;
+	llinfos << "Starting error thread" << llendl;
 	mThreadErrorp = new LLErrorThread();
 	mThreadErrorp->setUserData((void *) this);
-	mThreadErrorp->start();
+	mThreadErrorp->start();	
 }
 
-
 void LLApp::setErrorHandler(LLAppErrorHandler handler)
 {
 	LLApp::sErrorHandler = handler;
diff --git a/indra/llcommon/llapp.h b/indra/llcommon/llapp.h
index c5a1546883b..4142f8ece27 100644
--- a/indra/llcommon/llapp.h
+++ b/indra/llcommon/llapp.h
@@ -77,6 +77,11 @@ class LLApp
 	LLApp();
 	virtual ~LLApp();
 
+protected:
+	LLApp(LLErrorThread* error_thread);
+	void commonCtor();
+public:
+	
 	/** 
 	 * @brief Return the static app instance if one was created.
 	 */
@@ -245,8 +250,9 @@ class LLApp
 	void stepFrame();
 
 private:
+	void startErrorThread();
+	
 	void setupErrorHandling();		// Do platform-specific error-handling setup (signals, structured exceptions)
-
 	static void runErrorHandler(); // run shortly after we detect an error, ran in the relatively robust context of the LLErrorThread - preferred.
 	static void runSyncErrorHandler(); // run IMMEDIATELY when we get an error, ran in the context of the faulting thread.
 
diff --git a/indra/llcommon/llversionserver.h b/indra/llcommon/llversionserver.h
index aa3d580dc13..2b5c48fd15b 100644
--- a/indra/llcommon/llversionserver.h
+++ b/indra/llcommon/llversionserver.h
@@ -33,9 +33,9 @@
 #define LL_LLVERSIONSERVER_H
 
 const S32 LL_VERSION_MAJOR = 1;
-const S32 LL_VERSION_MINOR = 25;
+const S32 LL_VERSION_MINOR = 26;
 const S32 LL_VERSION_PATCH = 0;
-const S32 LL_VERSION_BUILD = 104413;
+const S32 LL_VERSION_BUILD = 103578;
 
 const char * const LL_CHANNEL = "Second Life Server";
 
diff --git a/indra/llmessage/llcircuit.cpp b/indra/llmessage/llcircuit.cpp
index 9ad84d82421..cc05e9bf47f 100644
--- a/indra/llmessage/llcircuit.cpp
+++ b/indra/llmessage/llcircuit.cpp
@@ -62,7 +62,6 @@
 #include "lltransfermanager.h"
 #include "llmodularmath.h"
 
-const F32 PING_INTERVAL = 5.f; // seconds
 const S32 PING_START_BLOCK = 3;		// How many pings behind we have to be to consider ourself blocked.
 const S32 PING_RELEASE_BLOCK = 2;	// How many pings behind we have to be to consider ourself unblocked.
 
@@ -70,7 +69,8 @@ const F32 TARGET_PERIOD_LENGTH = 5.f;	// seconds
 const F32 LL_DUPLICATE_SUPPRESSION_TIMEOUT = 60.f; //seconds - this can be long, as time-based cleanup is
 													// only done when wrapping packetids, now...
 
-LLCircuitData::LLCircuitData(const LLHost &host, TPACKETID in_id)
+LLCircuitData::LLCircuitData(const LLHost &host, TPACKETID in_id, 
+							 const F32 circuit_heartbeat_interval, const F32 circuit_timeout)
 :	mHost (host),
 	mWrapID(0),
 	mPacketsOutID(0), 
@@ -105,7 +105,9 @@ LLCircuitData::LLCircuitData(const LLHost &host, TPACKETID in_id)
 	mPeakBPSOut(0),
 	mPeriodTime(0.0),
 	mExistenceTimer(),
-	mCurrentResendCount(0)
+	mCurrentResendCount(0),
+	mHeartbeatInterval(circuit_heartbeat_interval), 
+	mHeartbeatTimeout(circuit_timeout)
 {
 	// Need to guarantee that this time is up to date, we may be creating a circuit even though we haven't been
 	//  running a message system loop.
@@ -113,9 +115,9 @@ LLCircuitData::LLCircuitData(const LLHost &host, TPACKETID in_id)
 	F32 distribution_offset = ll_frand();
 	
 	mPingTime = mt_sec;
-	mLastPingSendTime = mt_sec + PING_INTERVAL * distribution_offset;
+	mLastPingSendTime = mt_sec + mHeartbeatInterval * distribution_offset;
 	mLastPingReceivedTime = mt_sec;
-	mNextPingSendTime = mLastPingSendTime + 0.95*PING_INTERVAL + ll_frand(0.1f*PING_INTERVAL);
+	mNextPingSendTime = mLastPingSendTime + 0.95*mHeartbeatInterval + ll_frand(0.1f*mHeartbeatInterval);
 	mPeriodTime = mt_sec;
 
 	mTimeoutCallback = NULL;
@@ -429,7 +431,8 @@ S32 LLCircuitData::resendUnackedPackets(const F64 now)
 }
 
 
-LLCircuit::LLCircuit() : mLastCircuit(NULL)
+LLCircuit::LLCircuit(const F32 circuit_heartbeat_interval, const F32 circuit_timeout) : mLastCircuit(NULL),  
+	mHeartbeatInterval(circuit_heartbeat_interval), mHeartbeatTimeout(circuit_timeout)
 {
 }
 
@@ -447,7 +450,7 @@ LLCircuitData *LLCircuit::addCircuitData(const LLHost &host, TPACKETID in_id)
 {
 	// This should really validate if one already exists
 	llinfos << "LLCircuit::addCircuitData for " << host << llendl;
-	LLCircuitData *tempp = new LLCircuitData(host, in_id);
+	LLCircuitData *tempp = new LLCircuitData(host, in_id, mHeartbeatInterval, mHeartbeatTimeout);
 	mCircuitData.insert(circuit_data_map::value_type(host, tempp));
 	mPingSet.insert(tempp);
 
@@ -801,7 +804,7 @@ void LLCircuit::updateWatchDogTimers(LLMessageSystem *msgsys)
 			// Always remember to remove it from the set before changing the sorting
 			// key (mNextPingSendTime)
 			mPingSet.erase(psit);
-			cdp->mNextPingSendTime = cur_time + PING_INTERVAL;
+			cdp->mNextPingSendTime = cur_time + mHeartbeatInterval;
 			mPingSet.insert(cdp);
 			continue;
 		}
@@ -819,7 +822,7 @@ void LLCircuit::updateWatchDogTimers(LLMessageSystem *msgsys)
 			if (cdp->updateWatchDogTimers(msgsys))
             {
 				// Randomize our pings a bit by doing some up to 5% early or late
-				F64 dt = 0.95f*PING_INTERVAL + ll_frand(0.1f*PING_INTERVAL);
+				F64 dt = 0.95f*mHeartbeatInterval + ll_frand(0.1f*mHeartbeatInterval);
 
 				// Remove it, and reinsert it with the new next ping time.
 				// Always remove before changing the sorting key.
@@ -1047,7 +1050,7 @@ BOOL LLCircuitData::checkCircuitTimeout()
 	F64 time_since_last_ping = LLMessageSystem::getMessageTimeSeconds() - mLastPingReceivedTime;
 
 	// Nota Bene: This needs to be turned off if you are debugging multiple simulators
-	if (time_since_last_ping > PING_INTERVAL_MAX)
+	if (time_since_last_ping > mHeartbeatTimeout)
 	{
 		llwarns << "LLCircuitData::checkCircuitTimeout for " << mHost << " last ping " << time_since_last_ping << " seconds ago." <<llendl;
 		setAlive(FALSE);
@@ -1063,10 +1066,7 @@ BOOL LLCircuitData::checkCircuitTimeout()
 			return FALSE;
 		}
 	}
-	else if (time_since_last_ping > PING_INTERVAL_ALARM)
-	{
-		//llwarns << "Unresponsive circuit: " << mHost << ": " << time_since_last_ping << " seconds since last ping."<< llendl;
-	}
+
 	return TRUE;
 }
 
@@ -1280,7 +1280,7 @@ void LLCircuitData::pingTimerStop(const U8 ping_id)
 		delta_ping += 256;
 	}
 
-	U32 msec = (U32) ((delta_ping*PING_INTERVAL + time) * 1000.f);
+	U32 msec = (U32) ((delta_ping*mHeartbeatInterval  + time) * 1000.f);
 	setPingDelay(msec);
 
 	mPingsInTransit = delta_ping;
@@ -1371,7 +1371,8 @@ F32 LLCircuitData::getPingInTransitTime()
 
 	if (mPingsInTransit)
 	{
-		time_since_ping_was_sent =  (F32)((mPingsInTransit*PING_INTERVAL - 1) + (LLMessageSystem::getMessageTimeSeconds() - mPingTime))*1000.f;
+		time_since_ping_was_sent =  (F32)((mPingsInTransit*mHeartbeatInterval - 1) 
+			+ (LLMessageSystem::getMessageTimeSeconds() - mPingTime))*1000.f;
 	}
 
 	return time_since_ping_was_sent;
diff --git a/indra/llmessage/llcircuit.h b/indra/llmessage/llcircuit.h
index 492313da93d..99da6e7aaf4 100644
--- a/indra/llmessage/llcircuit.h
+++ b/indra/llmessage/llcircuit.h
@@ -50,10 +50,6 @@
 //
 // Constants
 //
-const F32 PING_INTERVAL_MAX = 100.f;
-const F32 PING_INTERVAL_ALARM = 50.f;
-
-
 const F32 LL_AVERAGED_PING_ALPHA = 0.2f;  // relaxation constant on ping running average
 const F32 LL_AVERAGED_PING_MAX = 2000;    // msec
 const F32 LL_AVERAGED_PING_MIN =  100;    // msec  // IW: increased to avoid retransmits when a process is slow
@@ -85,7 +81,8 @@ class LLSD;
 class LLCircuitData
 {
 public:
-	LLCircuitData(const LLHost &host, TPACKETID in_id);
+	LLCircuitData(const LLHost &host, TPACKETID in_id, 
+				  const F32 circuit_heartbeat_interval, const F32 circuit_timeout);
 	~LLCircuitData();
 
 	S32		resendUnackedPackets(const F64 now);
@@ -283,6 +280,9 @@ class LLCircuitData
 	S32		mCurrentResendCount;	// Number of resent packets since last spam
     LLStatRate  mOutOfOrderRate;    // Rate of out of order packets coming in.
     U32     mLastPacketGap;         // Gap in sequence number of last packet.
+
+	const F32 mHeartbeatInterval;
+	const F32 mHeartbeatTimeout;
 };
 
 
@@ -292,7 +292,7 @@ class LLCircuit
 {
 public:
 	// CREATORS
-	LLCircuit();
+	LLCircuit(const F32 circuit_heartbeat_interval, const F32 circuit_timeout);
 	~LLCircuit();
 
 	// ACCESSORS
@@ -345,5 +345,9 @@ class LLCircuit
 	// optimize the many, many times we call findCircuit. This may be
 	// set in otherwise const methods, so it is declared mutable.
 	mutable LLCircuitData* mLastCircuit;
+
+private:
+	const F32 mHeartbeatInterval;
+	const F32 mHeartbeatTimeout;
 };
 #endif
diff --git a/indra/llmessage/llregionflags.h b/indra/llmessage/llregionflags.h
index 972a184a621..53a1e4ea1ae 100644
--- a/indra/llmessage/llregionflags.h
+++ b/indra/llmessage/llregionflags.h
@@ -4,7 +4,7 @@
  *
  * $LicenseInfo:firstyear=2002&license=viewergpl$
  * 
- * Copyright (c) 2002-2007, Linden Research, Inc.
+ * Copyright (c) 2002-2008, Linden Research, Inc.
  * 
  * Second Life Viewer Source Code
  * The source code in this file ("Source Code") is provided by Linden Lab
@@ -60,8 +60,10 @@ const U32 REGION_FLAGS_BLOCK_LAND_RESELL		= (1 << 7);
 // All content wiped once per night
 const U32 REGION_FLAGS_SANDBOX					= (1 << 8);
 const U32 REGION_FLAGS_NULL_LAYER				= (1 << 9);
-const U32 REGION_FLAGS_SKIP_AGENT_ACTION		= (1 << 10);
-const U32 REGION_FLAGS_SKIP_UPDATE_INTEREST_LIST= (1 << 11);
+// const U32 REGION_FLAGS_SKIP_AGENT_ACTION		= (1 << 10);
+const U32 REGION_FLAGS_HARD_ALLOW_LAND_TRANSFER	= (1 << 10);	// Region allows land reselling
+// const U32 REGION_FLAGS_SKIP_UPDATE_INTEREST_LIST= (1 << 11);
+const U32 REGION_FLAGS_HARD_ALLOW_POST_CLASSIFIED	= (1 << 11);	// Region allows posting of classified ads
 const U32 REGION_FLAGS_SKIP_COLLISIONS			= (1 << 12); // Pin all non agent rigid bodies
 const U32 REGION_FLAGS_SKIP_SCRIPTS				= (1 << 13);
 const U32 REGION_FLAGS_SKIP_PHYSICS				= (1 << 14); // Skip all physics
diff --git a/indra/llmessage/message.cpp b/indra/llmessage/message.cpp
index 0e2a5cbf7fb..7c304bd00bf 100644
--- a/indra/llmessage/message.cpp
+++ b/indra/llmessage/message.cpp
@@ -290,7 +290,9 @@ LLMessageSystem::LLMessageSystem(const std::string& filename, U32 port,
 								 S32 version_major,
 								 S32 version_minor,
 								 S32 version_patch,
-								 bool failure_is_fatal)
+								 bool failure_is_fatal,
+								 const F32 circuit_heartbeat_interval, const F32 circuit_timeout) :
+	mCircuitInfo(circuit_heartbeat_interval, circuit_timeout)
 {
 	init();
 
@@ -2496,7 +2498,9 @@ bool start_messaging_system(
 	bool b_dump_prehash_file,
 	const std::string& secret,
 	const LLUseCircuitCodeResponder* responder,
-	bool failure_is_fatal)
+	bool failure_is_fatal,
+	const F32 circuit_heartbeat_interval, 
+	const F32 circuit_timeout)
 {
 	gMessageSystem = new LLMessageSystem(
 		template_name,
@@ -2504,7 +2508,9 @@ bool start_messaging_system(
 		version_major, 
 		version_minor, 
 		version_patch,
-		failure_is_fatal);
+		failure_is_fatal,
+		circuit_heartbeat_interval,
+		circuit_timeout);
 	g_shared_secret.assign(secret);
 
 	if (!gMessageSystem)
diff --git a/indra/llmessage/message.h b/indra/llmessage/message.h
index 46fa3251dee..2f10b149c60 100644
--- a/indra/llmessage/message.h
+++ b/indra/llmessage/message.h
@@ -285,7 +285,8 @@ class LLMessageSystem
 	// Read file and build message templates
 	LLMessageSystem(const std::string& filename, U32 port, S32 version_major,
 					S32 version_minor, S32 version_patch,
-					bool failure_is_fatal = true);
+					bool failure_is_fatal,
+					const F32 circuit_heartbeat_interval, const F32 circuit_timeout);
 
 	~LLMessageSystem();
 
@@ -780,8 +781,10 @@ bool start_messaging_system(
 	S32 version_patch,
 	bool b_dump_prehash_file,
 	const std::string& secret,
-	const LLUseCircuitCodeResponder* responder = NULL,
-	bool failure_is_fatal = true);
+	const LLUseCircuitCodeResponder* responder,
+	bool failure_is_fatal,
+	const F32 circuit_heartbeat_interval, 
+	const F32 circuit_timeout);
 
 void end_messaging_system();
 
diff --git a/indra/lscript/lscript_compile/indra.l b/indra/lscript/lscript_compile/indra.l
index 3e62195dc8c..2616b47c736 100644
--- a/indra/lscript/lscript_compile/indra.l
+++ b/indra/lscript/lscript_compile/indra.l
@@ -36,7 +36,8 @@ FS			(f|F)
 #include "llclickaction.h"
 
 void count();
-void comment();
+void line_comment();
+void block_comment();
 void parse_string();
 
 #define YYLMAX 16384
@@ -60,7 +61,8 @@ extern "C" { int yyerror(const char *fmt, ...); }
 %}
 
 %%
-"//"					{ gInternalLine++; gInternalColumn = 0; comment(); }
+"//"					{ gInternalLine++; gInternalColumn = 0; line_comment(); }
+"/*"					{ block_comment(); }
 
 "integer"			{ count(); return(INTEGER); }
 "float"				{ count(); return(FLOAT_TYPE); }
@@ -790,7 +792,7 @@ S32 yywrap()
 	return(1);
 }
 
-void comment()
+void line_comment()
 {
 	char c;
 
@@ -798,6 +800,25 @@ void comment()
 		;
 }
 
+void block_comment()
+{
+	char c1 = 0;
+	char c2 = yyinput();
+	while (c2 != 0 && c2 != EOF && !(c1 == '*' && c2 == '/')) {
+		if (c2 == '\n')
+		{
+			gInternalLine++;
+			gInternalColumn = 0;
+		}
+		else if (c2 == '\t')
+			gInternalColumn += 4 - (gInternalColumn % 8);
+		else
+			gInternalColumn++;
+		c1 = c2;
+		c2 = yyinput();
+	}
+}
+
 void count()
 {
 	S32 i;
diff --git a/indra/lscript/lscript_compile/lscript_tree.cpp b/indra/lscript/lscript_compile/lscript_tree.cpp
index 66f88258451..cd2dc87c5e9 100644
--- a/indra/lscript/lscript_compile/lscript_tree.cpp
+++ b/indra/lscript/lscript_compile/lscript_tree.cpp
@@ -630,7 +630,9 @@ static void print_cil_cast(LLFILE* fp, LSCRIPTType srcType, LSCRIPTType targetTy
 		switch(targetType)
 		{
 		case LST_INTEGER:
-			fprintf(fp, "conv.i4\n");
+			//fprintf(fp, "call int32 [LslLibrary]LindenLab.SecondLife.LslRunTime::ToInteger(float32)\n");
+			fprintf(fp, "conv.i4\n"); // TODO replace this line with the above
+			// we the entire grid is > 1.25.1
 			break;
 		case LST_STRING:
 			fprintf(fp, "call string [LslLibrary]LindenLab.SecondLife.LslRunTime::ToString(float32)\n");
diff --git a/indra/lscript/lscript_execute/lscript_execute.cpp b/indra/lscript/lscript_execute/lscript_execute.cpp
index 52e3af320ce..6280719748e 100644
--- a/indra/lscript/lscript_execute/lscript_execute.cpp
+++ b/indra/lscript/lscript_execute/lscript_execute.cpp
@@ -891,14 +891,13 @@ void LLScriptExecute::runInstructions(BOOL b_print, const LLUUID &id,
 			b_done = TRUE;
 		}
 
-		while (!b_done)
+		if (!b_done)
 		{
 			// Call handler for next queued event.
 			if(getEventCount() > 0)
 			{
 				++events_processed;
 				callNextQueuedEventHandler(event_register, id, quanta);
-				b_done = TRUE;
 			}
 			else
 			{
@@ -910,8 +909,8 @@ void LLScriptExecute::runInstructions(BOOL b_print, const LLUUID &id,
 					++events_processed;
 					callEventHandler(event, id, quanta);
 				}
-				b_done = TRUE;
 			}
+			b_done = TRUE;
 		}
 	}
 }
@@ -946,6 +945,10 @@ F32 LLScriptExecute::runQuanta(BOOL b_print, const LLUUID &id, const char **erro
 			timer_checks = 0;
 		}
 	}
+	if (inloop == 0.0f)
+	{
+		inloop = timer.getElapsedTimeF32();
+	}
 	return inloop;
 }
 
diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp
index d3671239bb4..a4b80ed7c1d 100644
--- a/indra/newview/llinventorybridge.cpp
+++ b/indra/newview/llinventorybridge.cpp
@@ -755,6 +755,10 @@ void LLItemBridge::performAction(LLFolderView* folder, LLInventoryModel* model,
 		model->deleteObject(mUUID);
 		model->notifyObservers();
 	}
+	else if ("restoreToWorld" == action)
+	{
+		restoreToWorld();
+	}
 	else if ("restore" == action)
 	{
 		restoreItem();
@@ -811,6 +815,47 @@ void LLItemBridge::restoreItem()
 	}
 }
 
+void LLItemBridge::restoreToWorld()
+{
+	LLViewerInventoryItem* itemp = (LLViewerInventoryItem*)getItem();
+	if (itemp)
+	{
+		LLMessageSystem* msg = gMessageSystem;
+		msg->newMessage("RezRestoreToWorld");
+		msg->nextBlockFast(_PREHASH_AgentData);
+		msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
+		msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
+
+		msg->nextBlockFast(_PREHASH_InventoryData);
+		itemp->packMessage(msg);
+		msg->sendReliable(gAgent.getRegion()->getHost());
+	}
+
+	//Similar functionality to the drag and drop rez logic
+	BOOL remove_from_inventory = FALSE;
+
+	//remove local inventory copy, sim will deal with permissions and removing the item
+	//from the actual inventory if its a no-copy etc
+	if(!itemp->getPermissions().allowCopyBy(gAgent.getID()))
+	{
+		remove_from_inventory = TRUE;
+	}
+
+	// Check if it's in the trash. (again similar to the normal rez logic)
+	LLUUID trash_id;
+	trash_id = gInventory.findCategoryUUIDForType(LLAssetType::AT_TRASH);
+	if(gInventory.isObjectDescendentOf(itemp->getUUID(), trash_id))
+	{
+		remove_from_inventory = TRUE;
+	}
+
+	if(remove_from_inventory)
+	{
+		gInventory.deleteObject(itemp->getUUID());
+		gInventory.notifyObservers();
+	}
+}
+
 LLUIImagePtr LLItemBridge::getIcon() const
 {
 	return LLUI::getUIImage(ICON_NAME[OBJECT_ICON_NAME]);
@@ -3375,6 +3420,7 @@ void LLObjectBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
 				items.push_back(std::string("Object Wear"));
 				items.push_back(std::string("Attach To"));
 				items.push_back(std::string("Attach To HUD"));
+				items.push_back(std::string("Restore to Last Position"));
 
 				LLMenuGL* attach_menu = menu.getChildMenuByName("Attach To", TRUE);
 				LLMenuGL* attach_hud_menu = menu.getChildMenuByName("Attach To HUD", TRUE);
@@ -4363,7 +4409,6 @@ void LLWearableBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
 		items.push_back(std::string("Wearable Wear"));
 		items.push_back(std::string("Wearable Edit"));
 
-
 		if ((flags & FIRST_SELECTED_ITEM) == 0)
 		{
 			disabled_items.push_back(std::string("Wearable Edit"));
diff --git a/indra/newview/llinventorybridge.h b/indra/newview/llinventorybridge.h
index d038c10c738..5df3ba23af3 100644
--- a/indra/newview/llinventorybridge.h
+++ b/indra/newview/llinventorybridge.h
@@ -159,6 +159,7 @@ class LLInvFVBridge : public LLFolderViewEventListener
 
 	virtual const std::string& getPrefix() { return LLStringUtil::null; }
 	virtual void restoreItem() {}
+	virtual void restoreToWorld() {}
 
 	// LLFolderViewEventListener functions
 	virtual const std::string& getName() const;
@@ -234,6 +235,7 @@ class LLItemBridge : public LLInvFVBridge
 
 	virtual void selectItem();
 	virtual void restoreItem();
+	virtual void restoreToWorld();
 
 	virtual LLUIImagePtr getIcon() const;
 	virtual const std::string& getDisplayName() const;
@@ -274,7 +276,6 @@ class LLFolderBridge : public LLInvFVBridge
 	virtual void selectItem();
 	virtual void restoreItem();
 
-
 	virtual LLUIImagePtr getIcon() const;
 	virtual BOOL renameItem(const std::string& new_name);
 	virtual BOOL removeItem();
diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp
index 21af491408d..ca310cf8e47 100644
--- a/indra/newview/llstartup.cpp
+++ b/indra/newview/llstartup.cpp
@@ -478,6 +478,14 @@ bool idle_startup()
 			  }
 
 			LLHTTPSender::setDefaultSender(new LLNullHTTPSender());
+
+			// TODO parameterize 
+			const F32 circuit_heartbeat_interval = 5;
+			const F32 circuit_timeout = 100;
+
+			const LLUseCircuitCodeResponder* responder = NULL;
+			bool failure_is_fatal = true;
+			
 			if(!start_messaging_system(
 				   message_template_path,
 				   port,
@@ -485,7 +493,11 @@ bool idle_startup()
 				   LL_VERSION_MINOR,
 				   LL_VERSION_PATCH,
 				   FALSE,
-				   std::string()))
+				   std::string(),
+				   responder,
+				   failure_is_fatal,
+				   circuit_heartbeat_interval,
+				   circuit_timeout))
 			{
 				std::string msg = LLTrans::getString("LoginFailedNoNetwork");
 				msg.append(llformat(" Error: %d", gMessageSystem->getErrorCode()));
diff --git a/indra/test/lltemplatemessagebuilder_tut.cpp b/indra/test/lltemplatemessagebuilder_tut.cpp
index 52d14367610..c71d63a2d79 100644
--- a/indra/test/lltemplatemessagebuilder_tut.cpp
+++ b/indra/test/lltemplatemessagebuilder_tut.cpp
@@ -59,6 +59,9 @@ namespace tut
 			if(! init)
 			{
 				ll_init_apr();
+				const F32 circuit_heartbeat_interval=5;
+				const F32 circuit_timeout=100;
+
 				start_messaging_system("notafile", 13035,
 									   LL_VERSION_MAJOR,
 									   LL_VERSION_MINOR,        
@@ -66,7 +69,9 @@ namespace tut
 									   FALSE,        
 									   "notasharedsecret",
 									   NULL,
-									   false);
+									   false,
+									   circuit_heartbeat_interval,
+									   circuit_timeout);
 				//init_prehash_data();
 				init = true;
 			}
diff --git a/indra/test/message_tut.cpp b/indra/test/message_tut.cpp
index d426511d240..0cafdcd679a 100644
--- a/indra/test/message_tut.cpp
+++ b/indra/test/message_tut.cpp
@@ -70,6 +70,9 @@ namespace tut
 				//init_prehash_data();
 				init = true;
 			}
+			const F32 circuit_heartbeat_interval=5;
+			const F32 circuit_timeout=100;
+
 
 			// currently test disconnected message system
 			start_messaging_system("notafile", 13035,
@@ -79,7 +82,10 @@ namespace tut
 								   FALSE,        
 								   "notasharedsecret",
 								   NULL,
-								   false);
+								   false,
+								   circuit_heartbeat_interval,
+								   circuit_timeout
+								   );
 			// generate temp dir
 			std::ostringstream ostr;
 #if LL_WINDOWS
diff --git a/install.xml b/install.xml
index 1d4c83269b1..a1dcd7d0f58 100644
--- a/install.xml
+++ b/install.xml
@@ -662,30 +662,30 @@
           <key>linux</key>
           <map>
             <key>md5sum</key>
-            <string>e398a04adb84796072dcc1f5efc69f4a</string>
+            <string>af7b1fc9072443009f19e43fb3c8342f</string>
             <key>url</key>
-            <uri>scp:install-packages.lindenlab.com:/local/www/install-packages/doc/havok-4.6.1-linux-20080912.tar.bz2</uri>
+            <uri>scp:install-packages.lindenlab.com:/local/www/install-packages/doc/havok-4.6.1-linux-20081029.tar.bz2</uri>
           </map>
           <key>linux32</key>
           <map>
             <key>md5sum</key>
-            <string>5a7821cb8aa471051e0361a74d115613</string>
+            <string>ca909a0a48c3dcc61656f1635fc3e3b4</string>
             <key>url</key>
-            <uri>scp:install-packages.lindenlab.com:/local/www/install-packages/doc/havok-4.6.1-linux-i686-gcc-4.1-20080915.tar.bz2</uri>
+            <uri>scp:install-packages.lindenlab.com:/local/www/install-packages/doc/havok-4.6.1-linux-i686-gcc-4.1-20081030.tar.bz2</uri>
           </map>
           <key>linux64</key>
           <map>
             <key>md5sum</key>
-            <string>b2095827a940c791240339dac677ef2d</string>
+            <string>cd4076d6caf5fabff36bf48bd01e4ba8</string>
             <key>url</key>
-            <uri>scp:install-packages.lindenlab.com:/local/www/install-packages/doc/havok-4.6.1-linux64-20080909.tar.bz2</uri>
+            <uri>scp:install-packages.lindenlab.com:/local/www/install-packages/doc/havok-4.6.1-linux64-20081030.tar.bz2</uri>
           </map>
           <key>windows</key>
           <map>
             <key>md5sum</key>
             <string>f25fbb29c2275267233c79f0c68ca37f</string>
             <key>url</key>
-            <uri>scp:install-packages.lindenlab.com:/local/www/install-packages/doc/havok-4.6.1-windows-20081010.tar.bz2</uri>
+            <uri>scp:install-packages.lindenlab.com:/local/www/install-packages/doc/havok-4.6.1-windows-20081030.tar.bz2</uri>
           </map>
         </map>
       </map>
diff --git a/scripts/messages/message_template.msg b/scripts/messages/message_template.msg
index a7835adbfe6..6d9062228e6 100644
--- a/scripts/messages/message_template.msg
+++ b/scripts/messages/message_template.msg
@@ -2942,6 +2942,14 @@ version 2.0
 		{	UseEstateSun		BOOL		}
 		{	SunHour				F32			}	// last value set by estate or region controls JC
 	}
+	{
+		RegionInfo2		Single
+		{	ProductSKU			Variable 1	}	// string
+		{	ProductName			Variable 1	}	// string
+		{	MaxAgents32			U32			}	// Identical to RegionInfo.MaxAgents but allows greater range
+		{	HardMaxAgents		U32			}
+		{	HardMaxObjects		U32			}
+	}
 }
 
 // GodUpdateRegionInfo
@@ -3059,6 +3067,14 @@ version 2.0
 		RegionInfo2	Single
 		{	RegionID		LLUUID	}
 	}
+	{
+		RegionInfo3	Single
+		{	CPUClassID				S32		}
+		{	CPURatio				S32		}
+		{	ColoName				Variable	1	}	// string
+		{	ProductSKU				Variable	1	}	// string
+		{	ProductName				Variable	1	}	// string
+	}
 }
 
 // RegionHandshakeReply
@@ -8854,3 +8870,39 @@ version 2.0
 	}
 }
 
+
+// This message is sent from viewer -> simulator when the viewer wants
+// to rez an object out of inventory back to its position before it
+// last moved into the inventory
+{
+	RezRestoreToWorld Low 425 NotTrusted Unencoded UDPDeprecated
+	{
+		AgentData		Single
+		{	AgentID		LLUUID  }
+		{	SessionID	LLUUID	}
+	}
+	{
+		InventoryData			Single
+		{	ItemID				LLUUID	}
+		{	FolderID			LLUUID	}
+		{	CreatorID			LLUUID	}	// permissions
+		{	OwnerID				LLUUID	}	// permissions
+		{	GroupID				LLUUID	}	// permissions
+		{	BaseMask			U32	}	// permissions
+		{	OwnerMask			U32	}	// permissions
+		{	GroupMask			U32	}	// permissions
+		{	EveryoneMask		U32	}	// permissions
+		{	NextOwnerMask		U32	}	// permissions
+		{	GroupOwned			BOOL	}	// permissions
+		{	TransactionID		LLUUID	}
+		{	Type				S8	}
+		{	InvType				S8	}
+		{	Flags				U32	}
+		{	SaleType			U8	}
+		{	SalePrice			S32	}
+		{	Name				Variable	1	}
+		{	Description			Variable	1	}
+		{	CreationDate		S32	}
+		{	CRC				U32	}
+	}
+}
-- 
GitLab