From 2945882258ad1befe8e8094c0a1a655e4ddbcd30 Mon Sep 17 00:00:00 2001
From: Kyle Ambroff <ambroff@lindenlab.com>
Date: Wed, 17 Sep 2008 10:21:38 +0000
Subject: [PATCH] svn merge -r95195:96886
 svn+ssh://svn.lindenlab.com/svn/linden/branches/Branch_1-24-Server -->
 release

Merging fixes from 1.24 Server.

From vcr-maint-2:
* QAR-856: viewer crash log analyzer updates.

From direct-slurl-1:
* login.cgi: simplification of the way start-locations are chosen and the new-user browser tutorial is shown.
* No longer fake ever-logged-in flag
* support for dataservice query string encryption

from maint-server-4:
* DEV-19961: llInstantMessages of length N fail.

from landstore-v2-01-merge:
* DEV-12330: Allow Neighbors & Tweaks.
* DEV-14126: Re-order items on Region Detail page.
* DEV-14064: Add "Delete" order buttons in the View Cart area.
* DEV-15026: Indicate in the Event Log whether purchase is a Openspace or regular region.
* DEV-15242: disable checkout button after first click.
* DEV-15285: Region Names in cart or fulfilled should expire after 30 min or when delivered.
* DEV-14018: No currency listed for land prices
* DEV-1688: Tool: Ability to view and clear Allowed Neighbors from a region.
* DEV-17199: Fatal error when adding your login name to your allowed neighbors list.
* DEV-17251: Deleting an unavailable item from the shopping cart causes a fatal error.
* DEV-17291: Fatal error occurs when performing various activities.
* DEV-17177: Typo on Land store 2.01 checkout page.

From 1.24:
* DEV-19865 (SVC-2927): Abandoning land changes land name and description even when done by an Estate Manager.
* DEV-19916 (SVC-2938): bug fix for llGetNextEmail() failure.
* DEV-19936 (SVC-2962): adding a value to a list also modifies the list in place.
* SVC-2750, SVC-2958, SVC-2973: Changed LSL scheduler logic to yield if finished and no state change is pending.
* indra/lib/python/indra/agent/auth.py no longer assumes there is a critical message, and checks credential as specified by OGP rev3.
* DEV-20051: Added defensive checks on script rez path.
* Improvements to scripts/make_deploy_group.py.
* DEV-18897: llScriptReset wasn't resetting events for LSL scripts.
* DEV-20127: Fix for stl misuse in newsim/llsimparcel.cpp.
* DEV-18897: Mono Beta - LSL attach() event survives reset.
* DEV-20212 (VWR-9026): String fix - Attempting to teleport to "Help Island" produces a dialog referencing "Orientation Island"
* DEV-20164: llListen caching indefinitely across states.
* DEV-19950: timer() event triggers before on_rez(), & state_entry()
* DEV-19712 (SVC-2908): C# error messages with Mono Compiled scripts
* Fixes for chat service unit tests.
* DEV-19106: (SVC-1571): Rezzing a coalesced objects with 1024 scripted prims fails.
---
 indra/llcommon/llkeythrottle.h                |  2 +-
 indra/llcommon/llversionserver.h              |  4 +-
 indra/llmessage/lliosocket.cpp                |  3 +
 indra/lscript/lscript_execute.h               | 45 ++++++------
 .../lscript_execute/lscript_execute.cpp       | 73 ++++++++++++-------
 5 files changed, 74 insertions(+), 53 deletions(-)

diff --git a/indra/llcommon/llkeythrottle.h b/indra/llcommon/llkeythrottle.h
index ac2f4254f29..7bbf2ad6161 100644
--- a/indra/llcommon/llkeythrottle.h
+++ b/indra/llcommon/llkeythrottle.h
@@ -243,7 +243,7 @@ class LLKeyThrottle
 	}
 
 	// Set the throttling behavior
-	void setParameters( U32 limit, F32 interval, BOOL realtime )
+	void setParameters( U32 limit, F32 interval, BOOL realtime = TRUE )
 	{
 		// limit is the maximum number of keys
 		// allowed per interval (in seconds or frames)
diff --git a/indra/llcommon/llversionserver.h b/indra/llcommon/llversionserver.h
index fd5f6497c20..efd611090c5 100644
--- a/indra/llcommon/llversionserver.h
+++ b/indra/llcommon/llversionserver.h
@@ -34,8 +34,8 @@
 
 const S32 LL_VERSION_MAJOR = 1;
 const S32 LL_VERSION_MINOR = 24;
-const S32 LL_VERSION_PATCH = 0;
-const S32 LL_VERSION_BUILD = 93453;
+const S32 LL_VERSION_PATCH = 6;
+const S32 LL_VERSION_BUILD = 0;
 
 const char * const LL_CHANNEL = "Second Life Server";
 
diff --git a/indra/llmessage/lliosocket.cpp b/indra/llmessage/lliosocket.cpp
index ad309434ac9..5f756e9cc25 100644
--- a/indra/llmessage/lliosocket.cpp
+++ b/indra/llmessage/lliosocket.cpp
@@ -355,8 +355,11 @@ LLIOPipe::EStatus LLIOSocketReader::process_impl(
 	}
 	else if(APR_STATUS_IS_EAGAIN(status))
 	{
+/*Commented out by Aura 9-9-8 for DEV-19961.
 		// everything is fine, but we can terminate this process pump.
+	
 		rv = STATUS_BREAK;
+*/
 	}
 	else
 	{
diff --git a/indra/lscript/lscript_execute.h b/indra/lscript/lscript_execute.h
index 271b53aae18..2f67e77c939 100644
--- a/indra/lscript/lscript_execute.h
+++ b/indra/lscript/lscript_execute.h
@@ -370,7 +370,7 @@ class LLScriptExecute
 	LLScriptExecute();
 	virtual ~LLScriptExecute() {;}
 
-	virtual S32 getVersion() = 0;
+	virtual S32 getVersion() const = 0;
 	virtual void deleteAllEvents() = 0;
 	virtual void addEvent(LLScriptDataCollection* event) = 0;
 	virtual U32 getEventCount() = 0;
@@ -384,12 +384,12 @@ class LLScriptExecute
 	virtual void setSleep(F32 value) = 0;
 	virtual F32 getEnergy() const = 0;
 	virtual void setEnergy(F32 value) = 0;
-	virtual U64 getCurrentEvents(S32 version) = 0;
-	virtual void setCurrentEvents(U64 value, S32 version) = 0;
-	virtual U64 getEventHandlers(S32 version) = 0;
-	virtual void setEventHandlers(U64 value, S32 version) = 0;
-	virtual U64 getCurrentHandler(S32 version) = 0;
-	virtual void setCurrentHandler(U64 value, S32 version) = 0;
+	virtual U64 getCurrentEvents() = 0;
+	virtual void setCurrentEvents(U64 value) = 0;
+	virtual U64 getEventHandlers() = 0;
+	virtual void setEventHandlers(U64 value) = 0;
+	virtual U64 getCurrentHandler() = 0;
+	virtual void setCurrentHandler(U64 value) = 0;
 	virtual BOOL isFinished() const = 0;
 	virtual BOOL isStateChangePending() const = 0;
 	virtual S32 writeState(U8 **dest, U32 header_size, U32 footer_size) = 0; // Allocate memory for header, state and footer return size of state.
@@ -409,17 +409,17 @@ class LLScriptExecute
 
 	// Run handler for event for a maximum of time_slice seconds.
 	// Updates current handler and current events registers.
-	virtual void callEventHandler(LSCRIPTStateEventType event, S32 major_version, const LLUUID &id, F32 time_slice) = 0;;
+	virtual void callEventHandler(LSCRIPTStateEventType event, const LLUUID &id, F32 time_slice) = 0;;
 
 	// Run handler for next queued event for maximum of time_slice seconds. 
 	// Updates current handler and current events registers.
 	// Removes processed event from queue.
-	virtual void callNextQueuedEventHandler(U64 event_register, S32 major_version, const LLUUID &id, F32 time_slice) = 0;
+	virtual void callNextQueuedEventHandler(U64 event_register, const LLUUID &id, F32 time_slice) = 0;
 
 	// Run handler for event for a maximum of time_slice seconds.
 	// Updates current handler and current events registers.
 	// Removes processed event from queue.
-	virtual void callQueuedEventHandler(LSCRIPTStateEventType event, S32 major_version, const LLUUID &id, F32 time_slice) = 0;
+	virtual void callQueuedEventHandler(LSCRIPTStateEventType event, const LLUUID &id, F32 time_slice) = 0;
 
 	// Switch to next state.
 	// Returns new set of handled events.
@@ -428,14 +428,14 @@ class LLScriptExecute
 	// Returns time taken.
 	virtual F32 runQuanta(BOOL b_print, const LLUUID &id,
 						  const char **errorstr, 
-						  BOOL &state_transition, F32 quanta,
+						  F32 quanta,
 						  U32& events_processed, LLTimer& timer);
 
 	// Run smallest possible amount of code: an instruction for LSL2, a segment
 	// between save tests for Mono
 	void runInstructions(BOOL b_print, const LLUUID &id,
 						 const char **errorstr, 
-						 BOOL &state_transition, U32& events_processed,
+						 U32& events_processed,
 						 F32 quanta);
 
 	bool isYieldDue() const;
@@ -461,7 +461,7 @@ class LLScriptExecuteLSL2 : public LLScriptExecute
 	LLScriptExecuteLSL2(const U8* bytecode, U32 bytecode_size);
 	virtual ~LLScriptExecuteLSL2();
 
-	virtual S32 getVersion() {return get_register(mBuffer, LREG_VN);}
+	virtual S32 getVersion() const {return get_register(mBuffer, LREG_VN);}
 	virtual void deleteAllEvents() {mEventData.mEventDataList.deleteAllData();}
 	virtual void addEvent(LLScriptDataCollection* event);
 	virtual U32 getEventCount() {return mEventData.mEventDataList.getLength();}
@@ -475,12 +475,12 @@ class LLScriptExecuteLSL2 : public LLScriptExecute
 	virtual void setSleep(F32 value);
 	virtual F32 getEnergy() const;
 	virtual void setEnergy(F32 value);
-	virtual U64 getCurrentEvents(S32 version) {return get_event_register(mBuffer, LREG_CE, version);}
-	virtual void setCurrentEvents(U64 value, S32 version) {return set_event_register(mBuffer, LREG_CE, value, version);}
-	virtual U64 getEventHandlers(S32 version) {return get_event_register(mBuffer, LREG_ER, version);}
-	virtual void setEventHandlers(U64 value, S32 version) {set_event_register(mBuffer, LREG_ER, value, version);}
-	virtual U64 getCurrentHandler(S32 version);
-	virtual void setCurrentHandler(U64 value, S32 version) {return set_event_register(mBuffer, LREG_IE, value, version);}	
+	virtual U64 getCurrentEvents() {return get_event_register(mBuffer, LREG_CE, getMajorVersion());}
+	virtual void setCurrentEvents(U64 value) {return set_event_register(mBuffer, LREG_CE, value, getMajorVersion());}
+	virtual U64 getEventHandlers() {return get_event_register(mBuffer, LREG_ER, getMajorVersion());}
+	virtual void setEventHandlers(U64 value) {set_event_register(mBuffer, LREG_ER, value, getMajorVersion());}
+	virtual U64 getCurrentHandler();
+	virtual void setCurrentHandler(U64 value) {return set_event_register(mBuffer, LREG_IE, value, getMajorVersion());}	
 	virtual BOOL isFinished() const {return get_register(mBuffer, LREG_IP) == 0;}
 	virtual BOOL isStateChangePending() const {return get_register(mBuffer, LREG_CS) != get_register(mBuffer, LREG_NS);}
 	virtual S32 writeState(U8 **dest, U32 header_size, U32 footer_size); // Not including Events.
@@ -500,17 +500,17 @@ class LLScriptExecuteLSL2 : public LLScriptExecute
 
 	// Run handler for event for a maximum of time_slice seconds.
 	// Updates current handler and current events registers.
-	virtual void callEventHandler(LSCRIPTStateEventType event, S32 major_version, const LLUUID &id, F32 time_slice);
+	virtual void callEventHandler(LSCRIPTStateEventType event, const LLUUID &id, F32 time_slice);
 
 	// Run handler for next queued event for maximum of time_slice seconds. 
 	// Updates current handler and current events registers.
 	// Removes processed event from queue.
-	virtual void callNextQueuedEventHandler(U64 event_register, S32 major_version, const LLUUID &id, F32 time_slice);
+	virtual void callNextQueuedEventHandler(U64 event_register, const LLUUID &id, F32 time_slice);
 
 	// Run handler for event for a maximum of time_slice seconds.
 	// Updates current handler and current events registers.
 	// Removes processed event from queue.
-	virtual void callQueuedEventHandler(LSCRIPTStateEventType event, S32 major_version, const LLUUID &id, F32 time_slice);
+	virtual void callQueuedEventHandler(LSCRIPTStateEventType event, const LLUUID &id, F32 time_slice);
 
 	// Switch to next state.
 	// Returns new set of handled events.
@@ -527,6 +527,7 @@ class LLScriptExecuteLSL2 : public LLScriptExecute
 	U32						mBytecodeSize;
 
 private:
+	S32 getMajorVersion() const;
 	void		recordBoundaryError( const LLUUID &id );
 	void		setStateEventOpcoodeStartSafely( S32 state, LSCRIPTStateEventType event, const LLUUID &id );
 
diff --git a/indra/lscript/lscript_execute/lscript_execute.cpp b/indra/lscript/lscript_execute/lscript_execute.cpp
index 6f1c2158d5c..52e3af320ce 100644
--- a/indra/lscript/lscript_execute/lscript_execute.cpp
+++ b/indra/lscript/lscript_execute/lscript_execute.cpp
@@ -330,8 +330,9 @@ void LLScriptExecuteLSL2::resumeEventHandler(BOOL b_print, const LLUUID &id, F32
 	// NOTE: Babbage: all mExecuteFuncs return false.
 }
 
-void LLScriptExecuteLSL2::callEventHandler(LSCRIPTStateEventType event, S32 major_version, const LLUUID &id, F32 time_slice)
+void LLScriptExecuteLSL2::callEventHandler(LSCRIPTStateEventType event, const LLUUID &id, F32 time_slice)
 {
+	S32 major_version = getMajorVersion();
 	// push a zero to be popped
 	lscript_push(mBuffer, 0);
 	// push sp as current bp
@@ -406,8 +407,9 @@ void LLScriptExecuteLSL2::callEventHandler(LSCRIPTStateEventType event, S32 majo
 //	set_ip(mBuffer, opcode_start);
 //}
 
-void LLScriptExecuteLSL2::callQueuedEventHandler(LSCRIPTStateEventType event, S32 major_version, const LLUUID &id, F32 time_slice)
+void LLScriptExecuteLSL2::callQueuedEventHandler(LSCRIPTStateEventType event, const LLUUID &id, F32 time_slice)
 {
+	S32 major_version = getMajorVersion();
 	LLScriptDataCollection* eventdata;
 
 	for (eventdata = mEventData.mEventDataList.getFirstData(); eventdata; eventdata = mEventData.mEventDataList.getNextData())
@@ -455,8 +457,9 @@ void LLScriptExecuteLSL2::callQueuedEventHandler(LSCRIPTStateEventType event, S3
 	}
 }
 
-void LLScriptExecuteLSL2::callNextQueuedEventHandler(U64 event_register, S32 major_version, const LLUUID &id, F32 time_slice)
+void LLScriptExecuteLSL2::callNextQueuedEventHandler(U64 event_register, const LLUUID &id, F32 time_slice)
 {
+	S32 major_version = getMajorVersion();
 	LLScriptDataCollection* eventdata = mEventData.getNextEvent();
 	if (eventdata)
 	{
@@ -544,9 +547,9 @@ void LLScriptExecuteLSL2::setSleep(F32 value)
 }
 
 //virtual 
-U64 LLScriptExecuteLSL2::getCurrentHandler(S32 version)
+U64 LLScriptExecuteLSL2::getCurrentHandler()
 {
-	return get_event_register(mBuffer, LREG_IE, version);
+	return get_event_register(mBuffer, LREG_IE, getMajorVersion());
 }
 
 //virtual 
@@ -727,6 +730,20 @@ void LLScriptExecuteLSL2::reset()
 	bytestream2bytestream(mBuffer, dest_offset, src, src_offset, size);
 }
 
+S32 LLScriptExecuteLSL2::getMajorVersion() const
+{
+	S32 version = getVersion();
+	S32 major_version = 0;
+	if (version == LSL2_VERSION1_END_NUMBER){
+		major_version = 1;
+	}
+	else if (version == LSL2_VERSION_NUMBER)
+	{
+		major_version = 2;
+	}
+	return major_version;
+}
+
 LLScriptExecute::LLScriptExecute() :
 	mReset(FALSE)
 {
@@ -754,6 +771,10 @@ bool LLScriptExecute::isYieldDue() const
 		return true;
 	}
 
+	// State changes can occur within a single time slice,
+	// but LLScriptData's clean up is required. Yield here
+	// to allow LLScriptData to perform cleanup and then call
+	// runQuanta again.
 	if(isStateChangePending())
 	{
 		return true;
@@ -766,7 +787,6 @@ bool LLScriptExecute::isYieldDue() const
 // a single instruction for LSL2, a segment between save tests for Mono
 void LLScriptExecute::runInstructions(BOOL b_print, const LLUUID &id, 
 									 const char **errorstr, 
-									 BOOL &state_transition, 
 									 U32& events_processed,
 									 F32 quanta)
 {
@@ -809,17 +829,15 @@ void LLScriptExecute::runInstructions(BOOL b_print, const LLUUID &id,
 	else
 	{
 		// make sure that IE is zero
-		setCurrentHandler(0, major_version);
+		setCurrentHandler(0);
 
 		//	if no, we're in a state and waiting for an event
-		U64 current_events = getCurrentEvents(major_version);
-		U64 event_register = getEventHandlers(major_version);
+		U64 current_events = getCurrentEvents();
+		U64 event_register = getEventHandlers();
 
 		//	check NS to see if need to switch states (NS != CS)
 		if (isStateChangePending())
 		{
-			state_transition = TRUE;
-
 			// ok, blow away any pending events
 			deleteAllEvents();
 
@@ -827,16 +845,16 @@ void LLScriptExecute::runInstructions(BOOL b_print, const LLUUID &id,
 			if (current_events & LSCRIPTStateBitField[LSTT_STATE_EXIT])
 			{
 				// if yes, clear state exit flag
-				setCurrentHandler(LSCRIPTStateBitField[LSTT_STATE_EXIT], major_version);
+				setCurrentHandler(LSCRIPTStateBitField[LSTT_STATE_EXIT]);
 				current_events &= ~LSCRIPTStateBitField[LSTT_STATE_EXIT];
-				setCurrentEvents(current_events, major_version);
+				setCurrentEvents(current_events);
 
 				// check state exit event handler
 				// if there is a handler, call it
 				if (event_register & LSCRIPTStateBitField[LSTT_STATE_EXIT])
 				{
 					++events_processed;
-					callEventHandler(LSTT_STATE_EXIT, major_version, id, quanta);
+					callEventHandler(LSTT_STATE_EXIT, id, quanta);
 					return;
 				}
 			}
@@ -844,32 +862,32 @@ void LLScriptExecute::runInstructions(BOOL b_print, const LLUUID &id,
 			// if no handler or no state exit flag switch to new state
 			// set state entry flag and clear other CE flags
 			current_events = LSCRIPTStateBitField[LSTT_STATE_ENTRY];
-			setCurrentEvents(current_events, major_version);
+			setCurrentEvents(current_events);
 
 			U64 handled_events = nextState();
-			setEventHandlers(handled_events, major_version);
+			setEventHandlers(handled_events);
 		}
 
 		// try to get next event from stack
 		BOOL b_done = FALSE;
 		LSCRIPTStateEventType event = LSTT_NULL;
 
-		current_events = getCurrentEvents(major_version);
-		event_register = getEventHandlers(major_version);
+		current_events = getCurrentEvents();
+		event_register = getEventHandlers();
 
 		// first, check to see if state_entry or onrez are raised and handled
 		if ((current_events & LSCRIPTStateBitField[LSTT_STATE_ENTRY])
 			&&(current_events & event_register))
 		{
 			++events_processed;
-			callEventHandler(LSTT_STATE_ENTRY, major_version, id, quanta);
+			callEventHandler(LSTT_STATE_ENTRY, id, quanta);
 			b_done = TRUE;
 		}
 		else if ((current_events & LSCRIPTStateBitField[LSTT_REZ])
 				 &&(current_events & event_register))
 		{
 			++events_processed;
-			callQueuedEventHandler(LSTT_REZ, major_version, id, quanta);
+			callQueuedEventHandler(LSTT_REZ, id, quanta);
 			b_done = TRUE;
 		}
 
@@ -879,7 +897,7 @@ void LLScriptExecute::runInstructions(BOOL b_print, const LLUUID &id,
 			if(getEventCount() > 0)
 			{
 				++events_processed;
-				callNextQueuedEventHandler(event_register, major_version, id, quanta);
+				callNextQueuedEventHandler(event_register, id, quanta);
 				b_done = TRUE;
 			}
 			else
@@ -890,7 +908,7 @@ void LLScriptExecute::runInstructions(BOOL b_print, const LLUUID &id,
 				{
 					event = return_first_event((S32)handled_current);
 					++events_processed;
-					callEventHandler(event, major_version, id, quanta);
+					callEventHandler(event, id, quanta);
 				}
 				b_done = TRUE;
 			}
@@ -898,8 +916,8 @@ void LLScriptExecute::runInstructions(BOOL b_print, const LLUUID &id,
 	}
 }
 
-// Run for a single timeslice, or until a yield is due
-F32 LLScriptExecute::runQuanta(BOOL b_print, const LLUUID &id, const char **errorstr, BOOL &state_transition, F32 quanta, U32& events_processed, LLTimer& timer)
+// Run for a single timeslice, or until a yield or state transition is due
+F32 LLScriptExecute::runQuanta(BOOL b_print, const LLUUID &id, const char **errorstr, F32 quanta, U32& events_processed, LLTimer& timer)
 {
 	U32 timer_checks = 0;
 	F32 inloop = 0;
@@ -910,7 +928,7 @@ F32 LLScriptExecute::runQuanta(BOOL b_print, const LLUUID &id, const char **erro
 	// on current execution speed.
 	while(true)
 	{
-		runInstructions(b_print, id, errorstr, state_transition, 
+		runInstructions(b_print, id, errorstr,
 						events_processed, quanta);
 		
 		static const S32 lsl_timer_check_skip = 4;
@@ -3280,7 +3298,7 @@ BOOL run_state(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
 	{
 		major_version = 2;
 	}
-
+					
 	S32 current_state = get_register(buffer, LREG_CS);
 	if (state != current_state)
 	{
@@ -3988,7 +4006,6 @@ void lscript_run(const std::string& filename, BOOL b_debug)
 	LLTimer	timer;
 
 	const char *error;
-	BOOL b_state;
 	LLScriptExecuteLSL2 *execute = NULL;
 
 	if (filename.empty())
@@ -4012,7 +4029,7 @@ void lscript_run(const std::string& filename, BOOL b_debug)
 
 		do {
 			LLTimer timer2;
-			execute->runQuanta(b_debug, LLUUID::null, &error, b_state, 
+			execute->runQuanta(b_debug, LLUUID::null, &error,
 							   time_slice, events_processed, timer2);
 		} while (!execute->isFinished());
 
-- 
GitLab