diff --git a/.hgtags b/.hgtags
index a700aa94eadc9c53b27be76cf9843c8dfe166500..0e0898afb022e96841dc06bcc2577e034ef87124 100644
--- a/.hgtags
+++ b/.hgtags
@@ -43,3 +43,11 @@ dc6483491b4af559060bccaef8e9045a303212dd 2.4.0-beta1
 25bd6007e3d2fc15db9326ed4b18a24a5969a46a 2.4.0-beta2
 1ed382c6a08ba3850b6ce9061bc551ddece0ea07 2.4.0-release
 a82e5b1e22c7f90e3c7977d146b80588f004ed0d 2.5.0-start
+76f586a8e22b1abe6b2339758c8ac0fa718975de 76f586a8e22b
+76f586a8e22b1abe6b2339758c8ac0fa718975de 76f586a8e22b
+0000000000000000000000000000000000000000 76f586a8e22b
+0000000000000000000000000000000000000000 76f586a8e22b
+345b17e7cf630db77e840b4fe3451bd476d750a3 76f586a8e22b
+345b17e7cf630db77e840b4fe3451bd476d750a3 2.5.0-beta1
+345b17e7cf630db77e840b4fe3451bd476d750a3 76f586a8e22b
+0000000000000000000000000000000000000000 76f586a8e22b
diff --git a/doc/contributions.txt b/doc/contributions.txt
index f21354b4069d4d9516fa8761d39f4721a18e5014..1ec878846d5d9310cca1ba1833309c8970607280 100644
--- a/doc/contributions.txt
+++ b/doc/contributions.txt
@@ -72,6 +72,7 @@ Aleric Inglewood
 	VWR-10837
 	VWR-12691
 	VWR-12984
+	VWR-13040
 	VWR-13996
 	VWR-14426
 	VWR-24247
@@ -79,6 +80,9 @@ Aleric Inglewood
 	VWR-24252
 	VWR-24254
 	VWR-24261
+	VWR-24315
+	VWR-24317
+	VWR-24320
 	SNOW-84
 	SNOW-477
 	SNOW-744
@@ -393,6 +397,7 @@ Kitty Barnett
 	STORM-288
 	STORM-799
 	STORM-800
+    VWR-24217
 Kunnis Basiat
 	VWR-82
 	VWR-102
@@ -736,6 +741,7 @@ Thickbrick Sleaford
 	VWR-9287
 	VWR-13483
 	VWR-13947
+	VWR-24420
 Thraxis Epsilon
 	SVC-371
 	VWR-383
diff --git a/etc/message.xml b/etc/message.xml
index 7c4a927cc5e7997b7533e98ec4d2143c60f19b87..764aea387945c6797d4b14a67e5df4c1f7f65397 100644
--- a/etc/message.xml
+++ b/etc/message.xml
@@ -678,20 +678,17 @@
 			<key>EstateChangeInfo</key>
 			<boolean>true</boolean>
 		
-			<key>FetchInventoryDescendents</key>
+			<key>FetchInventoryDescendents2</key>
 			<boolean>false</boolean>
 		
-			<key>WebFetchInventoryDescendents</key>
-			<boolean>true</boolean>
-		
-			<key>FetchInventory</key>
-			<boolean>true</boolean>
+			<key>FetchInventory2</key>
+			<boolean>false</boolean>
 		
-			<key>FetchLibDescendents</key>
-			<boolean>true</boolean>
+			<key>FetchLibDescendents2</key>
+			<boolean>false</boolean>
 		
-			<key>FetchLib</key>
-			<boolean>true</boolean>
+			<key>FetchLib2</key>
+			<boolean>false</boolean>
 
 			<key>UploadBakedTexture</key>
 			<boolean>true</boolean>
diff --git a/indra/cmake/Boost.cmake b/indra/cmake/Boost.cmake
index 012d3c2ab204853214cdd09db8f79762c3d6806c..7ce57a5572336c4927a7f2b6e4e97d4e3aecb745 100644
--- a/indra/cmake/Boost.cmake
+++ b/indra/cmake/Boost.cmake
@@ -10,8 +10,6 @@ if (STANDALONE)
   set(BOOST_PROGRAM_OPTIONS_LIBRARY boost_program_options-mt)
   set(BOOST_REGEX_LIBRARY boost_regex-mt)
   set(BOOST_SIGNALS_LIBRARY boost_signals-mt)
-  set(BOOST_SYSTEM_LIBRARY boost_system-mt)
-  set(BOOST_FILESYSTEM_LIBRARY boost_filesystem-mt)
 else (STANDALONE)
   use_prebuilt_binary(boost)
   set(Boost_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/include)
@@ -28,12 +26,6 @@ else (STANDALONE)
       set(BOOST_SIGNALS_LIBRARY 
           optimized libboost_signals-vc71-mt-s-${BOOST_VERSION}
           debug libboost_signals-vc71-mt-sgd-${BOOST_VERSION})
-      set(BOOST_SYSTEM_LIBRARY 
-          optimized libboost_system-vc71-mt-s-${BOOST_VERSION}
-          debug libboost_system-vc71-mt-sgd-${BOOST_VERSION})
-      set(BOOST_FILESYSTEM_LIBRARY 
-          optimized libboost_filesystem-vc71-mt-s-${BOOST_VERSION}
-          debug libboost_filesystem-vc71-mt-sgd-${BOOST_VERSION})
     else (MSVC71)
       set(BOOST_PROGRAM_OPTIONS_LIBRARY 
           optimized libboost_program_options-vc80-mt-${BOOST_VERSION}
@@ -44,24 +36,14 @@ else (STANDALONE)
       set(BOOST_SIGNALS_LIBRARY 
           optimized libboost_signals-vc80-mt-${BOOST_VERSION}
           debug libboost_signals-vc80-mt-gd-${BOOST_VERSION})
-      set(BOOST_SYSTEM_LIBRARY 
-          optimized libboost_system-vc80-mt-${BOOST_VERSION}
-          debug libboost_system-vc80-mt-gd-${BOOST_VERSION})
-      set(BOOST_FILESYSTEM_LIBRARY 
-          optimized libboost_filesystem-vc80-mt-${BOOST_VERSION}
-          debug libboost_filesystem-vc80-mt-gd-${BOOST_VERSION})
     endif (MSVC71)
   elseif (DARWIN)
     set(BOOST_PROGRAM_OPTIONS_LIBRARY boost_program_options-xgcc40-mt)
     set(BOOST_REGEX_LIBRARY boost_regex-xgcc40-mt)
     set(BOOST_SIGNALS_LIBRARY boost_signals-xgcc40-mt)
-    set(BOOST_SYSTEM_LIBRARY boost_system-xgcc40-mt)
-    set(BOOST_FILESYSTEM_LIBRARY boost_filesystem-xgcc40-mt)
   elseif (LINUX)
     set(BOOST_PROGRAM_OPTIONS_LIBRARY boost_program_options-gcc41-mt)
     set(BOOST_REGEX_LIBRARY boost_regex-gcc41-mt)
     set(BOOST_SIGNALS_LIBRARY boost_signals-gcc41-mt)
-    set(BOOST_SYSTEM_LIBRARY boost_system-gcc41-mt)
-    set(BOOST_FILESYSTEM_LIBRARY boost_filesystem-gcc41-mt)
   endif (WINDOWS)
 endif (STANDALONE)
diff --git a/indra/integration_tests/llui_libtest/llui_libtest.cpp b/indra/integration_tests/llui_libtest/llui_libtest.cpp
index 217e26c3ca527380c91fd8bbc1e1d42d3debc83b..c34115ee8064a6d8a63b3ad03ad85e7d44b5dfed 100644
--- a/indra/integration_tests/llui_libtest/llui_libtest.cpp
+++ b/indra/integration_tests/llui_libtest/llui_libtest.cpp
@@ -33,7 +33,6 @@
 // linden library includes
 #include "llcontrol.h"		// LLControlGroup
 #include "lldir.h"
-#include "lldiriterator.h"
 #include "llerrorcontrol.h"
 #include "llfloater.h"
 #include "llfontfreetype.h"
@@ -175,9 +174,7 @@ void export_test_floaters()
 	std::string delim = gDirUtilp->getDirDelimiter();
 	std::string xui_dir = get_xui_dir() + "en" + delim;
 	std::string filename;
-
-	LLDirIterator iter(xui_dir, "floater_test_*.xml");
-	while (iter.next(filename))
+	while (gDirUtilp->getNextFileInDir(xui_dir, "floater_test_*.xml", filename))
 	{
 		if (filename.find("_new.xml") != std::string::npos)
 		{
diff --git a/indra/linux_updater/linux_updater.cpp b/indra/linux_updater/linux_updater.cpp
index 808ab3f64f81ab2da3d945212f7a510a251018ef..d909516bf8fbce6872458eec049e0b4c836df6ae 100644
--- a/indra/linux_updater/linux_updater.cpp
+++ b/indra/linux_updater/linux_updater.cpp
@@ -33,7 +33,6 @@
 #include "llerrorcontrol.h"
 #include "llfile.h"
 #include "lldir.h"
-#include "lldiriterator.h"
 #include "llxmlnode.h"
 #include "lltrans.h"
 
@@ -56,8 +55,6 @@ typedef struct _updater_app_state {
 	std::string strings_dirs;
 	std::string strings_file;
 
-	LLDirIterator *image_dir_iter;
-
 	GtkWidget *window;
 	GtkWidget *progress_bar;
 	GtkWidget *image;
@@ -111,7 +108,7 @@ bool translate_init(std::string comma_delim_path_list,
 void updater_app_ui_init(void);
 void updater_app_quit(UpdaterAppState *app_state);
 void parse_args_and_init(int argc, char **argv, UpdaterAppState *app_state);
-std::string next_image_filename(std::string& image_path, LLDirIterator& iter);
+std::string next_image_filename(std::string& image_path);
 void display_error(GtkWidget *parent, std::string title, std::string message);
 BOOL install_package(std::string package_file, std::string destination);
 BOOL spawn_viewer(UpdaterAppState *app_state);
@@ -177,7 +174,7 @@ void updater_app_ui_init(UpdaterAppState *app_state)
 
 		// load the first image
 		app_state->image = gtk_image_new_from_file
-			(next_image_filename(app_state->image_dir, *app_state->image_dir_iter).c_str());
+			(next_image_filename(app_state->image_dir).c_str());
 		gtk_widget_set_size_request(app_state->image, 340, 310);
 		gtk_container_add(GTK_CONTAINER(frame), app_state->image);
 
@@ -208,7 +205,7 @@ gboolean rotate_image_cb(gpointer data)
 	llassert(data != NULL);
 	app_state = (UpdaterAppState *) data;
 
-	filename = next_image_filename(app_state->image_dir, *app_state->image_dir_iter);
+	filename = next_image_filename(app_state->image_dir);
 
 	gdk_threads_enter();
 	gtk_image_set_from_file(GTK_IMAGE(app_state->image), filename.c_str());
@@ -217,10 +214,10 @@ gboolean rotate_image_cb(gpointer data)
 	return TRUE;
 }
 
-std::string next_image_filename(std::string& image_path, LLDirIterator& iter)
+std::string next_image_filename(std::string& image_path)
 {
 	std::string image_filename;
-	iter.next(image_filename);
+	gDirUtilp->getNextFileInDir(image_path, "/*.jpg", image_filename);
 	return image_path + "/" + image_filename;
 }
 
@@ -744,7 +741,6 @@ void parse_args_and_init(int argc, char **argv, UpdaterAppState *app_state)
 		else if ((!strcmp(argv[i], "--image-dir")) && (++i < argc))
 		{
 			app_state->image_dir = argv[i];
-			app_state->image_dir_iter = new LLDirIterator(argv[i], "/*.jpg");
 		}
 		else if ((!strcmp(argv[i], "--dest")) && (++i < argc))
 		{
@@ -829,7 +825,6 @@ int main(int argc, char **argv)
 	}
 
 	bool success = !app_state->failure;
-	delete app_state->image_dir_iter;
 	delete app_state;
 	return success ? 0 : 1;
 }
diff --git a/indra/llaudio/llaudioengine.cpp b/indra/llaudio/llaudioengine.cpp
index c9cb1cd6e7c80366564891c9440a1630ea203a73..5e540ad8c58bd2b2ad4b7614329509aa43270a21 100644
--- a/indra/llaudio/llaudioengine.cpp
+++ b/indra/llaudio/llaudioengine.cpp
@@ -97,7 +97,11 @@ void LLAudioEngine::setDefaults()
 	}
 
 	mMasterGain = 1.f;
-	mInternalGain = 0.f;
+	// Setting mInternalGain to an out of range value fixes the issue reported in STORM-830.
+	// There is an edge case in setMasterGain during startup which prevents setInternalGain from 
+	// being called if the master volume setting and mInternalGain both equal 0, so using -1 forces
+	// the if statement in setMasterGain to execute when the viewer starts up.
+	mInternalGain = -1.f;
 	mNextWindUpdate = 0.f;
 
 	mStreamingAudioImpl = NULL;
diff --git a/indra/llcommon/llavatarname.cpp b/indra/llcommon/llavatarname.cpp
index b1ec9e9875fde02adad2c946446f460086ae6cfb..ad1845d387a29614ad5956fba454dcdccd9aa236 100644
--- a/indra/llcommon/llavatarname.cpp
+++ b/indra/llcommon/llavatarname.cpp
@@ -48,7 +48,7 @@ LLAvatarName::LLAvatarName()
 	mLegacyFirstName(),
 	mLegacyLastName(),
 	mIsDisplayNameDefault(false),
-	mIsDummy(false),
+	mIsTemporaryName(false),
 	mExpires(F64_MAX),
 	mNextUpdate(0.0)
 { }
diff --git a/indra/llcommon/llavatarname.h b/indra/llcommon/llavatarname.h
index 145aeccd35c1a4e6a738f4b2b5a00d6283e2c91e..ba258d6d52420788bf5256905bff53f2295426a2 100644
--- a/indra/llcommon/llavatarname.h
+++ b/indra/llcommon/llavatarname.h
@@ -79,7 +79,7 @@ class LL_COMMON_API LLAvatarName
 	// Under error conditions, we may insert "dummy" records with
 	// names like "???" into caches as placeholders.  These can be
 	// shown in UI, but are not serialized.
-	bool mIsDummy;
+	bool mIsTemporaryName;
 
 	// Names can change, so need to keep track of when name was
 	// last checked.
diff --git a/indra/llcommon/llfile.cpp b/indra/llcommon/llfile.cpp
index 8f02391e75a7dcbcf6f2d1b8734aca1550d7969f..c32a776c3f591f81e22fbabaf88af90d61266d7d 100644
--- a/indra/llcommon/llfile.cpp
+++ b/indra/llcommon/llfile.cpp
@@ -92,6 +92,17 @@ LLFILE*	LLFile::_fsopen(const std::string& filename, const char* mode, int shari
 #endif
 }
 
+int	LLFile::close(LLFILE * file)
+{
+	int ret_value = 0;
+	if (file)
+	{
+		ret_value = fclose(file);
+	}
+	return ret_value;
+}
+
+
 int	LLFile::remove(const std::string& filename)
 {
 #if	LL_WINDOWS
diff --git a/indra/llcommon/llfile.h b/indra/llcommon/llfile.h
index 4913af7cb54dc52d09b81c2b67a6180e0673db90..dd7d36513a06d13c81638c1d7eafbdac2e60ab9e 100644
--- a/indra/llcommon/llfile.h
+++ b/indra/llcommon/llfile.h
@@ -71,6 +71,8 @@ class LL_COMMON_API LLFile
 	static	LLFILE*	fopen(const std::string& filename,const char* accessmode);	/* Flawfinder: ignore */
 	static	LLFILE*	_fsopen(const std::string& filename,const char* accessmode,int	sharingFlag);
 
+	static	int		close(LLFILE * file);
+
 	// perms is a permissions mask like 0777 or 0700.  In most cases it will
 	// be overridden by the user's umask.  It is ignored on Windows.
 	static	int		mkdir(const std::string& filename, int perms = 0700);
diff --git a/indra/llimage/llpngwrapper.cpp b/indra/llimage/llpngwrapper.cpp
index fe737e2072ab3be51faaa4052463221a22638668..2cc7d3c460c7ed93146271a1e013ab26d7ef7b49 100644
--- a/indra/llimage/llpngwrapper.cpp
+++ b/indra/llimage/llpngwrapper.cpp
@@ -50,8 +50,6 @@ LLPngWrapper::LLPngWrapper()
 	  mCompressionType( 0 ),
 	  mFilterMethod( 0 ),
 	  mFinalSize( 0 ),
-	  mHasBKGD(false),
-	  mBackgroundColor(),
 	  mGamma(0.f)
 {
 }
@@ -111,9 +109,9 @@ void LLPngWrapper::writeFlush(png_structp png_ptr)
 }
 
 // Read the PNG file using the libpng.  The low-level interface is used here
-// because we want to do various transformations (including setting the
-// matte background if any, and applying gama) which can't be done with
-// the high-level interface. The scanline also begins at the bottom of
+// because we want to do various transformations (including applying gama)
+// which can't be done with the high-level interface.
+// The scanline also begins at the bottom of
 // the image (per SecondLife conventions) instead of at the top, so we
 // must assign row-pointers in "reverse" order.
 BOOL LLPngWrapper::readPng(U8* src, LLImageRaw* rawImage, ImageInfo *infop)
@@ -201,8 +199,7 @@ void LLPngWrapper::normalizeImage()
 	//		2. Convert grayscales to RGB
 	//		3. Create alpha layer from transparency
 	//		4. Ensure 8-bpp for all images
-	//		5. Apply background matte if any
-	//		6. Set (or guess) gamma
+	//		5. Set (or guess) gamma
 
 	if (mColorType == PNG_COLOR_TYPE_PALETTE)
 	{
@@ -229,12 +226,6 @@ void LLPngWrapper::normalizeImage()
 	{
 		png_set_strip_16(mReadPngPtr);
 	}
-	mHasBKGD = png_get_bKGD(mReadPngPtr, mReadInfoPtr, &mBackgroundColor);
-	if (mHasBKGD)
-	{
-		png_set_background(mReadPngPtr, mBackgroundColor,
-			PNG_BACKGROUND_GAMMA_FILE, 1, 1.0);
-	}
 
 #if LL_DARWIN
 	const F64 SCREEN_GAMMA = 1.8;
@@ -261,7 +252,6 @@ void LLPngWrapper::updateMetaData()
     mBitDepth = png_get_bit_depth(mReadPngPtr, mReadInfoPtr);
     mColorType = png_get_color_type(mReadPngPtr, mReadInfoPtr);
 	mChannels = png_get_channels(mReadPngPtr, mReadInfoPtr);
-	mHasBKGD = png_get_bKGD(mReadPngPtr, mReadInfoPtr, &mBackgroundColor);
 }
 
 // Method to write raw image into PNG at dest. The raw scanline begins
diff --git a/indra/llimage/llpngwrapper.h b/indra/llimage/llpngwrapper.h
index 47a4207d6677a9927ed2322cd817359025e758e5..739f4359961c6155bcfb3bd68fb11c70326b8883 100644
--- a/indra/llimage/llpngwrapper.h
+++ b/indra/llimage/llpngwrapper.h
@@ -88,9 +88,6 @@ class LLPngWrapper
 
 	U32 mFinalSize;
 
-	bool mHasBKGD;
-	png_color_16p mBackgroundColor;
-
 	F64 mGamma;
 
 	std::string mErrorMessage;
diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp
index 03c28eb2a56bae5c34059273f637ec3a76fe4a79..767001b6337ad05a358914ef3406331aa3effa4a 100644
--- a/indra/llmessage/llavatarnamecache.cpp
+++ b/indra/llmessage/llavatarnamecache.cpp
@@ -81,8 +81,11 @@ namespace LLAvatarNameCache
 	// only need per-frame timing resolution
 	LLFrameTimer sRequestTimer;
 
-	// Periodically clean out expired entries from the cache
-	//LLFrameTimer sEraseExpiredTimer;
+    /// Maximum time an unrefreshed cache entry is allowed
+    const F64 MAX_UNREFRESHED_TIME = 20.0 * 60.0;
+
+    /// Time when unrefreshed cached names were checked last
+    static F64 sLastExpireCheck;
 
 	//-----------------------------------------------------------------------
 	// Internal methods
@@ -99,8 +102,9 @@ namespace LLAvatarNameCache
 
 	// Legacy name system callback
 	void legacyNameCallback(const LLUUID& agent_id,
-		const std::string& full_name,
-		bool is_group);
+							const std::string& full_name,
+							bool is_group
+							);
 
 	void requestNamesViaLegacy();
 
@@ -117,7 +121,7 @@ namespace LLAvatarNameCache
 	bool isRequestPending(const LLUUID& agent_id);
 
 	// Erase expired names from cache
-	void eraseExpired();
+	void eraseUnrefreshed();
 
 	bool expirationFromCacheControl(LLSD headers, F64 *expires);
 }
@@ -187,6 +191,7 @@ class LLAvatarNameResponder : public LLHTTPClient::Responder
 	{
 		// Pull expiration out of headers if available
 		F64 expires = LLAvatarNameCache::nameExpirationFromHeaders(mHeaders);
+		F64 now = LLFrameTimer::getTotalSeconds();
 
 		LLSD agents = content["agents"];
 		LLSD::array_const_iterator it = agents.beginArray();
@@ -207,84 +212,91 @@ class LLAvatarNameResponder : public LLHTTPClient::Responder
 				av_name.mDisplayName = av_name.mUsername;
 			}
 
+			LL_DEBUGS("AvNameCache") << "LLAvatarNameResponder::result for " << agent_id << " "
+									 << "user '" << av_name.mUsername << "' "
+									 << "display '" << av_name.mDisplayName << "' "
+									 << "expires in " << expires - now << " seconds"
+									 << LL_ENDL;
+			
 			// cache it and fire signals
 			LLAvatarNameCache::processName(agent_id, av_name, true);
 		}
 
 		// Same logic as error response case
 		LLSD unresolved_agents = content["bad_ids"];
-		if (unresolved_agents.size() > 0)
+		S32  num_unresolved = unresolved_agents.size();
+		if (num_unresolved > 0)
 		{
-			const std::string DUMMY_NAME("\?\?\?");
-			LLAvatarName av_name;
-			av_name.mUsername = DUMMY_NAME;
-			av_name.mDisplayName = DUMMY_NAME;
-			av_name.mIsDisplayNameDefault = false;
-			av_name.mIsDummy = true;
-			av_name.mExpires = expires;
-
+            LL_WARNS("AvNameCache") << "LLAvatarNameResponder::result " << num_unresolved << " unresolved ids; "
+                                    << "expires in " << expires - now << " seconds"
+                                    << LL_ENDL;
 			it = unresolved_agents.beginArray();
 			for ( ; it != unresolved_agents.endArray(); ++it)
 			{
 				const LLUUID& agent_id = *it;
-				// cache it and fire signals
-				LLAvatarNameCache::processName(agent_id, av_name, true);
+
+				LL_WARNS("AvNameCache") << "LLAvatarNameResponder::result "
+                                        << "failed id " << agent_id
+                                        << LL_ENDL;
+
+                LLAvatarNameCache::handleAgentError(agent_id);
 			}
 		}
-	}
+        LL_DEBUGS("AvNameCache") << "LLAvatarNameResponder::result " 
+                                 << LLAvatarNameCache::sCache.size() << " cached names"
+                                 << LL_ENDL;
+    }
 
 	/*virtual*/ void error(U32 status, const std::string& reason)
 	{
 		// If there's an error, it might be caused by PeopleApi,
 		// or when loading textures on startup and using a very slow 
-		// network, this query may time out. Fallback to the legacy
-		// cache. 
-
-		llwarns << "LLAvatarNameResponder error " << status << " " << reason << llendl;
+		// network, this query may time out.
+		// What we should do depends on whether or not we have a cached name
+		LL_WARNS("AvNameCache") << "LLAvatarNameResponder::error " << status << " " << reason
+								<< LL_ENDL;
 
-		// Add dummy records for all agent IDs in this request
+		// Add dummy records for any agent IDs in this request that we do not have cached already
 		std::vector<LLUUID>::const_iterator it = mAgentIDs.begin();
 		for ( ; it != mAgentIDs.end(); ++it)
 		{
 			const LLUUID& agent_id = *it;
-			gCacheName->get(agent_id, false,  // legacy compatibility
-						boost::bind(&LLAvatarNameCache::legacyNameCallback,
-						_1, _2, _3));
-		}
-	}
-
-	// Return time to retry a request that generated an error, based on
-	// error type and headers.  Return value is seconds-since-epoch.
-	F64 errorRetryTimestamp(S32 status)
-	{
-		F64 now = LLFrameTimer::getTotalSeconds();
-
-		// Retry-After takes priority
-		LLSD retry_after = mHeaders["retry-after"];
-		if (retry_after.isDefined())
-		{
-			// We only support the delta-seconds type
-			S32 delta_seconds = retry_after.asInteger();
-			if (delta_seconds > 0)
-			{
-				// ...valid delta-seconds
-				return now + F64(delta_seconds);
-			}
+			LLAvatarNameCache::handleAgentError(agent_id);
 		}
-
-		// If no Retry-After, look for Cache-Control max-age
-		F64 expires = 0.0;
-		if (LLAvatarNameCache::expirationFromCacheControl(mHeaders, &expires))
-		{
-			return expires;
-		}
-
-		// No information in header, make a guess
-		const F64 DEFAULT_DELAY = 120.0; // 2 mintues
-		return now + DEFAULT_DELAY;
 	}
 };
 
+// Provide some fallback for agents that return errors
+void LLAvatarNameCache::handleAgentError(const LLUUID& agent_id)
+{
+	std::map<LLUUID,LLAvatarName>::iterator existing = sCache.find(agent_id);
+	if (existing == sCache.end())
+    {
+        // there is no existing cache entry, so make a temporary name from legacy
+        LL_WARNS("AvNameCache") << "LLAvatarNameCache get legacy for agent "
+                                << agent_id << LL_ENDL;
+        gCacheName->get(agent_id, false,  // legacy compatibility
+                        boost::bind(&LLAvatarNameCache::legacyNameCallback,
+                                    _1, _2, _3));
+    }
+	else
+    {
+        // we have a chached (but probably expired) entry - since that would have
+        // been returned by the get method, there is no need to signal anyone
+
+        // Clear this agent from the pending list
+        LLAvatarNameCache::sPendingQueue.erase(agent_id);
+
+        const LLAvatarName& av_name = existing->second;
+        LL_DEBUGS("AvNameCache") << "LLAvatarNameCache use cache for agent "
+                                 << agent_id 
+                                 << "user '" << av_name.mUsername << "' "
+                                 << "display '" << av_name.mDisplayName << "' "
+                                 << "expires in " << av_name.mExpires - LLFrameTimer::getTotalSeconds() << " seconds"
+                                 << LL_ENDL;
+    }
+}
+
 void LLAvatarNameCache::processName(const LLUUID& agent_id,
 									const LLAvatarName& av_name,
 									bool add_to_cache)
@@ -326,6 +338,7 @@ void LLAvatarNameCache::requestNamesViaCapability()
 	std::vector<LLUUID> agent_ids;
 	agent_ids.reserve(128);
 	
+	U32 ids = 0;
 	ask_queue_t::const_iterator it = sAskQueue.begin();
 	for ( ; it != sAskQueue.end(); ++it)
 	{
@@ -336,11 +349,13 @@ void LLAvatarNameCache::requestNamesViaCapability()
 			// ...starting new request
 			url += sNameLookupURL;
 			url += "?ids=";
+			ids = 1;
 		}
 		else
 		{
 			// ...continuing existing request
 			url += "&ids=";
+			ids++;
 		}
 		url += agent_id.asString();
 		agent_ids.push_back(agent_id);
@@ -350,8 +365,10 @@ void LLAvatarNameCache::requestNamesViaCapability()
 
 		if (url.size() > NAME_URL_SEND_THRESHOLD)
 		{
-			//llinfos << "requestNames " << url << llendl;
-			LLHTTPClient::get(url, new LLAvatarNameResponder(agent_ids));//, LLSD(), 10.0f);
+			LL_DEBUGS("AvNameCache") << "LLAvatarNameCache::requestNamesViaCapability first "
+									 << ids << " ids"
+									 << LL_ENDL;
+			LLHTTPClient::get(url, new LLAvatarNameResponder(agent_ids));
 			url.clear();
 			agent_ids.clear();
 		}
@@ -359,8 +376,10 @@ void LLAvatarNameCache::requestNamesViaCapability()
 
 	if (!url.empty())
 	{
-		//llinfos << "requestNames " << url << llendl;
-		LLHTTPClient::get(url, new LLAvatarNameResponder(agent_ids));//, LLSD(), 10.0f);
+		LL_DEBUGS("AvNameCache") << "LLAvatarNameCache::requestNamesViaCapability all "
+								 << ids << " ids"
+								 << LL_ENDL;
+		LLHTTPClient::get(url, new LLAvatarNameResponder(agent_ids));
 		url.clear();
 		agent_ids.clear();
 	}
@@ -376,6 +395,11 @@ void LLAvatarNameCache::legacyNameCallback(const LLUUID& agent_id,
 	// Construct a dummy record for this name.  By convention, SLID is blank
 	// Never expires, but not written to disk, so lasts until end of session.
 	LLAvatarName av_name;
+	LL_DEBUGS("AvNameCache") << "LLAvatarNameCache::legacyNameCallback "
+							 << "agent " << agent_id << " "
+							 << "full name '" << full_name << "'"
+							 << ( is_group ? " [group]" : "" )
+							 << LL_ENDL;
 	buildLegacyName(full_name, &av_name);
 
 	// Don't add to cache, the data already exists in the legacy name system
@@ -397,6 +421,8 @@ void LLAvatarNameCache::requestNamesViaLegacy()
 		// invoked below.  This should never happen in practice.
 		sPendingQueue[agent_id] = now;
 
+		LL_DEBUGS("AvNameCache") << "LLAvatarNameCache::requestNamesViaLegacy agent " << agent_id << LL_ENDL;
+
 		gCacheName->get(agent_id, false,  // legacy compatibility
 			boost::bind(&LLAvatarNameCache::legacyNameCallback,
 				_1, _2, _3));
@@ -435,21 +461,24 @@ void LLAvatarNameCache::importFile(std::istream& istr)
 		av_name.fromLLSD( it->second );
 		sCache[agent_id] = av_name;
 	}
-	// entries may have expired since we last ran the viewer, just
-	// clean them out now
-	eraseExpired();
-	llinfos << "loaded " << sCache.size() << llendl;
+    LL_INFOS("AvNameCache") << "loaded " << sCache.size() << LL_ENDL;
+
+	// Some entries may have expired since the cache was stored,
+    // but they will be flushed in the first call to eraseUnrefreshed
+    // from LLAvatarNameResponder::idle
 }
 
 void LLAvatarNameCache::exportFile(std::ostream& ostr)
 {
 	LLSD agents;
+	F64 max_unrefreshed = LLFrameTimer::getTotalSeconds() - MAX_UNREFRESHED_TIME;
 	cache_t::const_iterator it = sCache.begin();
 	for ( ; it != sCache.end(); ++it)
 	{
 		const LLUUID& agent_id = it->first;
 		const LLAvatarName& av_name = it->second;
-		if (!av_name.mIsDummy)
+		// Do not write temporary or expired entries to the stored cache
+		if (!av_name.mIsTemporaryName && av_name.mExpires >= max_unrefreshed)
 		{
 			// key must be a string
 			agents[agent_id.asString()] = av_name.asLLSD();
@@ -484,62 +513,63 @@ void LLAvatarNameCache::idle()
 	//	return;
 	//}
 
-	// Must be large relative to above
-
-	// No longer deleting expired entries, just re-requesting in the get
-	// this way first synchronous get call on an expired entry won't return
-	// legacy name.  LF
-
-	//const F32 ERASE_EXPIRED_TIMEOUT = 60.f; // seconds
-	//if (sEraseExpiredTimer.checkExpirationAndReset(ERASE_EXPIRED_TIMEOUT))
-	//{
-	//	eraseExpired();
-	//}
-
-	if (sAskQueue.empty())
+	if (!sAskQueue.empty())
 	{
-		return;
+        if (useDisplayNames())
+        {
+            requestNamesViaCapability();
+        }
+        else
+        {
+            // ...fall back to legacy name cache system
+            requestNamesViaLegacy();
+        }
 	}
 
-	if (useDisplayNames())
-	{
-		requestNamesViaCapability();
-	}
-	else
-	{
-		// ...fall back to legacy name cache system
-		requestNamesViaLegacy();
-	}
+    // erase anything that has not been refreshed for more than MAX_UNREFRESHED_TIME
+    eraseUnrefreshed();
 }
 
 bool LLAvatarNameCache::isRequestPending(const LLUUID& agent_id)
 {
+	bool isPending = false;
 	const F64 PENDING_TIMEOUT_SECS = 5.0 * 60.0;
-	F64 now = LLFrameTimer::getTotalSeconds();
-	F64 expire_time = now - PENDING_TIMEOUT_SECS;
 
 	pending_queue_t::const_iterator it = sPendingQueue.find(agent_id);
 	if (it != sPendingQueue.end())
 	{
-		bool request_expired = (it->second < expire_time);
-		return !request_expired;
+		// in the list of requests in flight, retry if too old
+		F64 expire_time = LLFrameTimer::getTotalSeconds() - PENDING_TIMEOUT_SECS;
+		isPending = (it->second > expire_time);
 	}
-	return false;
+	return isPending;
 }
 
-void LLAvatarNameCache::eraseExpired()
+void LLAvatarNameCache::eraseUnrefreshed()
 {
 	F64 now = LLFrameTimer::getTotalSeconds();
-	cache_t::iterator it = sCache.begin();
-	while (it != sCache.end())
-	{
-		cache_t::iterator cur = it;
-		++it;
-		const LLAvatarName& av_name = cur->second;
-		if (av_name.mExpires < now)
-		{
-			sCache.erase(cur);
-		}
+	F64 max_unrefreshed = now - MAX_UNREFRESHED_TIME;
+
+    if (!sLastExpireCheck || sLastExpireCheck < max_unrefreshed)
+    {
+        sLastExpireCheck = now;
+        cache_t::iterator it = sCache.begin();
+        while (it != sCache.end())
+        {
+            cache_t::iterator cur = it;
+            ++it;
+            const LLAvatarName& av_name = cur->second;
+            if (av_name.mExpires < max_unrefreshed)
+            {
+                const LLUUID& agent_id = it->first;
+                LL_DEBUGS("AvNameCache") << agent_id 
+                                         << " user '" << av_name.mUsername << "' "
+                                         << "expired " << now - av_name.mExpires << " secs ago"
+                                         << LL_ENDL;
+                sCache.erase(cur);
+            }
+        }
+        LL_INFOS("AvNameCache") << sCache.size() << " cached avatar names" << LL_ENDL;
 	}
 }
 
@@ -550,8 +580,11 @@ void LLAvatarNameCache::buildLegacyName(const std::string& full_name,
 	av_name->mUsername = "";
 	av_name->mDisplayName = full_name;
 	av_name->mIsDisplayNameDefault = true;
-	av_name->mIsDummy = true;
-	av_name->mExpires = F64_MAX;
+	av_name->mIsTemporaryName = true;
+	av_name->mExpires = F64_MAX; // not used because these are not cached
+	LL_DEBUGS("AvNameCache") << "LLAvatarNameCache::buildLegacyName "
+							 << full_name
+							 << LL_ENDL;
 }
 
 // fills in av_name if it has it in the cache, even if expired (can check expiry time)
@@ -574,6 +607,9 @@ bool LLAvatarNameCache::get(const LLUUID& agent_id, LLAvatarName *av_name)
 				{
 					if (!isRequestPending(agent_id))
 					{
+						LL_DEBUGS("AvNameCache") << "LLAvatarNameCache::get "
+												 << "refresh agent " << agent_id
+												 << LL_ENDL;
 						sAskQueue.insert(agent_id);
 					}
 				}
@@ -595,6 +631,9 @@ bool LLAvatarNameCache::get(const LLUUID& agent_id, LLAvatarName *av_name)
 
 	if (!isRequestPending(agent_id))
 	{
+		LL_DEBUGS("AvNameCache") << "LLAvatarNameCache::get "
+								 << "queue request for agent " << agent_id
+								 << LL_ENDL;
 		sAskQueue.insert(agent_id);
 	}
 
@@ -627,7 +666,6 @@ void LLAvatarNameCache::get(const LLUUID& agent_id, callback_slot_t slot)
 				{
 					// ...name already exists in cache, fire callback now
 					fireSignal(agent_id, slot, av_name);
-
 					return;
 				}
 			}
@@ -723,6 +761,9 @@ F64 LLAvatarNameCache::nameExpirationFromHeaders(LLSD headers)
 
 bool LLAvatarNameCache::expirationFromCacheControl(LLSD headers, F64 *expires)
 {
+	bool fromCacheControl = false;
+	F64 now = LLFrameTimer::getTotalSeconds();
+
 	// Allow the header to override the default
 	LLSD cache_control_header = headers["cache-control"];
 	if (cache_control_header.isDefined())
@@ -731,12 +772,16 @@ bool LLAvatarNameCache::expirationFromCacheControl(LLSD headers, F64 *expires)
 		std::string cache_control = cache_control_header.asString();
 		if (max_age_from_cache_control(cache_control, &max_age))
 		{
-			F64 now = LLFrameTimer::getTotalSeconds();
 			*expires = now + (F64)max_age;
-			return true;
+			fromCacheControl = true;
 		}
 	}
-	return false;
+	LL_DEBUGS("AvNameCache")
+		<< ( fromCacheControl ? "expires based on cache control " : "default expiration " )
+		<< "in " << *expires - now << " seconds"
+		<< LL_ENDL;
+	
+	return fromCacheControl;
 }
 
 
diff --git a/indra/llmessage/llavatarnamecache.h b/indra/llmessage/llavatarnamecache.h
index 8f21ace96a5ae5774e8105a51a292bb7a1ad3318..59c1329ffa5db3ac04a0775434a0a928f7bf2981 100644
--- a/indra/llmessage/llavatarnamecache.h
+++ b/indra/llmessage/llavatarnamecache.h
@@ -82,6 +82,9 @@ namespace LLAvatarNameCache
 
 	void erase(const LLUUID& agent_id);
 
+    /// Provide some fallback for agents that return errors
+	void handleAgentError(const LLUUID& agent_id);
+
 	// Force a re-fetch of the most recent data, but keep the current
 	// data in cache
 	void fetch(const LLUUID& agent_id);
diff --git a/indra/llui/llnotifications.cpp b/indra/llui/llnotifications.cpp
index cd0f0e36b0509d5d40bc311b4d5f8c2be8589ac7..cc9edfcdeabbc92c1cc05a05962608cf5adf5b86 100644
--- a/indra/llui/llnotifications.cpp
+++ b/indra/llui/llnotifications.cpp
@@ -1367,7 +1367,6 @@ LLNotifications::TemplateNames LLNotifications::getTemplateNames() const
 typedef std::map<std::string, std::string> StringMap;
 void replaceSubstitutionStrings(LLXMLNodePtr node, StringMap& replacements)
 {
-	//llwarns << "replaceSubstitutionStrings" << llendl;
 	// walk the list of attributes looking for replacements
 	for (LLXMLAttribList::iterator it=node->mAttributes.begin();
 		 it != node->mAttributes.end(); ++it)
@@ -1381,13 +1380,12 @@ void replaceSubstitutionStrings(LLXMLNodePtr node, StringMap& replacements)
 			if (found != replacements.end())
 			{
 				replacement = found->second;
-				//llwarns << "replaceSubstituionStrings: value: " << value << " repl: " << replacement << llendl;
-
+				lldebugs << "replaceSubstitutionStrings: value: \"" << value << "\" repl: \"" << replacement << "\"." << llendl;
 				it->second->setValue(replacement);
 			}
 			else
 			{
-				llwarns << "replaceSubstituionStrings FAILURE: value: " << value << " repl: " << replacement << llendl;
+				llwarns << "replaceSubstitutionStrings FAILURE: could not find replacement \"" << value << "\"." << llendl;
 			}
 		}
 	}
diff --git a/indra/llvfs/CMakeLists.txt b/indra/llvfs/CMakeLists.txt
index a3782d824b4cbbcf0abe31ecb5d754238cf3c8a5..722f4e2bfdef9c6212c9edf06f2abee5f55ff996 100644
--- a/indra/llvfs/CMakeLists.txt
+++ b/indra/llvfs/CMakeLists.txt
@@ -12,7 +12,6 @@ include_directories(
 
 set(llvfs_SOURCE_FILES
     lldir.cpp
-    lldiriterator.cpp
     lllfsthread.cpp
     llpidlock.cpp
     llvfile.cpp
@@ -25,7 +24,6 @@ set(llvfs_HEADER_FILES
 
     lldir.h
     lldirguard.h
-    lldiriterator.h
     lllfsthread.h
     llpidlock.h
     llvfile.h
@@ -62,11 +60,6 @@ list(APPEND llvfs_SOURCE_FILES ${llvfs_HEADER_FILES})
 
 add_library (llvfs ${llvfs_SOURCE_FILES})
 
-target_link_libraries(llvfs
-    ${BOOST_FILESYSTEM_LIBRARY}
-    ${BOOST_SYSTEM_LIBRARY}
-    )
-
 if (DARWIN)
   include(CMakeFindFrameworks)
   find_library(CARBON_LIBRARY Carbon)
diff --git a/indra/llvfs/lldir.cpp b/indra/llvfs/lldir.cpp
index ab7d15dfefdcbec79c3d894b19dee81f0352b0a3..64556bcb4c34dcacd2b48f391dbfebf0eb528421 100644
--- a/indra/llvfs/lldir.cpp
+++ b/indra/llvfs/lldir.cpp
@@ -40,8 +40,6 @@
 #include "lltimer.h"	// ms_sleep()
 #include "lluuid.h"
 
-#include "lldiriterator.h"
-
 #if LL_WINDOWS
 #include "lldir_win32.h"
 LLDir_Win32 gDirUtil;
@@ -85,9 +83,7 @@ S32 LLDir::deleteFilesInDir(const std::string &dirname, const std::string &mask)
 	std::string filename; 
 	std::string fullpath;
 	S32 result;
-
-	LLDirIterator iter(dirname, mask);
-	while (iter.next(filename))
+	while (getNextFileInDir(dirname, mask, filename))
 	{
 		fullpath = dirname;
 		fullpath += getDirDelimiter();
diff --git a/indra/llvfs/lldir.h b/indra/llvfs/lldir.h
index 5ee8bdb542da2ebc4ee3d10ce114a7df3c1e20b6..42996fd051b9f5cc8ed949645fa7fda5c4c58f74 100644
--- a/indra/llvfs/lldir.h
+++ b/indra/llvfs/lldir.h
@@ -75,6 +75,31 @@ class LLDir
 // pure virtual functions
 	virtual U32 countFilesInDir(const std::string &dirname, const std::string &mask) = 0;
 
+    /// Walk the files in a directory, with file pattern matching
+	virtual BOOL getNextFileInDir(const std::string& dirname, ///< directory path - must end in trailing slash!
+                                  const std::string& mask,    ///< file pattern string (use "*" for all)
+                                  std::string& fname          ///< output: found file name
+                                  ) = 0;
+    /**<
+     * @returns true if a file was found, false if the entire directory has been scanned.
+     *
+     * @note that this function is NOT thread safe
+     *
+     * This function may not be used to scan part of a directory, then start a new search of a different
+     * directory, and then restart the first search where it left off; the entire search must run to
+     * completion or be abandoned - there is no restart.
+     *
+     * @bug: See http://jira.secondlife.com/browse/VWR-23697
+     *       and/or the tests in test/lldir_test.cpp
+     *       This is known to fail with patterns that have both:
+     *       a wildcard left of a . and more than one sequential ? right of a .
+     *       the pattern foo.??x appears to work
+     *       but *.??x or foo?.??x do not
+     *
+     * @todo this really should be rewritten as an iterator object, and the
+     *       filtering should be done in a platform-independent way.
+     */
+
 	virtual std::string getCurPath() = 0;
 	virtual BOOL fileExists(const std::string &filename) const = 0;
 
diff --git a/indra/llvfs/lldir_linux.cpp b/indra/llvfs/lldir_linux.cpp
index 4ba2f519b0f8080d700dd4c672abeac8ce803962..73f2336f94fa70bf2d43bc6b924ed6262b7bd2e8 100644
--- a/indra/llvfs/lldir_linux.cpp
+++ b/indra/llvfs/lldir_linux.cpp
@@ -242,6 +242,68 @@ U32 LLDir_Linux::countFilesInDir(const std::string &dirname, const std::string &
 	return (file_count);
 }
 
+// get the next file in the directory
+BOOL LLDir_Linux::getNextFileInDir(const std::string &dirname, const std::string &mask, std::string &fname)
+{
+	glob_t g;
+	BOOL result = FALSE;
+	fname = "";
+	
+	if(!(dirname == mCurrentDir))
+	{
+		// different dir specified, close old search
+		mCurrentDirIndex = -1;
+		mCurrentDirCount = -1;
+		mCurrentDir = dirname;
+	}
+	
+	std::string tmp_str;
+	tmp_str = dirname;
+	tmp_str += mask;
+
+	if(glob(tmp_str.c_str(), GLOB_NOSORT, NULL, &g) == 0)
+	{
+		if(g.gl_pathc > 0)
+		{
+			if((int)g.gl_pathc != mCurrentDirCount)
+			{
+				// Number of matches has changed since the last search, meaning a file has been added or deleted.
+				// Reset the index.
+				mCurrentDirIndex = -1;
+				mCurrentDirCount = g.gl_pathc;
+			}
+	
+			mCurrentDirIndex++;
+	
+			if(mCurrentDirIndex < (int)g.gl_pathc)
+			{
+//				llinfos << "getNextFileInDir: returning number " << mCurrentDirIndex << ", path is " << g.gl_pathv[mCurrentDirIndex] << llendl;
+
+				// The API wants just the filename, not the full path.
+				//fname = g.gl_pathv[mCurrentDirIndex];
+
+				char *s = strrchr(g.gl_pathv[mCurrentDirIndex], '/');
+				
+				if(s == NULL)
+					s = g.gl_pathv[mCurrentDirIndex];
+				else if(s[0] == '/')
+					s++;
+					
+				fname = s;
+				
+				result = TRUE;
+			}
+		}
+		
+		globfree(&g);
+	}
+	
+	return(result);
+}
+
+
+
+
 std::string LLDir_Linux::getCurPath()
 {
 	char tmp_str[LL_MAX_PATH];	/* Flawfinder: ignore */ 
diff --git a/indra/llvfs/lldir_linux.h b/indra/llvfs/lldir_linux.h
index ff4c48759a03327d6b04191d3b179451ad0fd3fd..451e81ae93c560114b83f556120f3fd42f6dbec9 100644
--- a/indra/llvfs/lldir_linux.h
+++ b/indra/llvfs/lldir_linux.h
@@ -43,6 +43,7 @@ class LLDir_Linux : public LLDir
 public:	
 	virtual std::string getCurPath();
 	virtual U32 countFilesInDir(const std::string &dirname, const std::string &mask);
+	virtual BOOL getNextFileInDir(const std::string &dirname, const std::string &mask, std::string &fname);
 	/*virtual*/ BOOL fileExists(const std::string &filename) const;
 
 	/*virtual*/ std::string getLLPluginLauncher();
diff --git a/indra/llvfs/lldir_mac.cpp b/indra/llvfs/lldir_mac.cpp
index 2d039527c06fa05286ddcbd04226a4425c0e85fb..445285aa43ac2c5dae2c11187e73280dc88614db 100644
--- a/indra/llvfs/lldir_mac.cpp
+++ b/indra/llvfs/lldir_mac.cpp
@@ -258,6 +258,67 @@ U32 LLDir_Mac::countFilesInDir(const std::string &dirname, const std::string &ma
 	return (file_count);
 }
 
+// get the next file in the directory
+BOOL LLDir_Mac::getNextFileInDir(const std::string &dirname, const std::string &mask, std::string &fname)
+{
+	glob_t g;
+	BOOL result = FALSE;
+	fname = "";
+	
+	if(!(dirname == mCurrentDir))
+	{
+		// different dir specified, close old search
+		mCurrentDirIndex = -1;
+		mCurrentDirCount = -1;
+		mCurrentDir = dirname;
+	}
+	
+	std::string tmp_str;
+	tmp_str = dirname;
+	tmp_str += mask;
+
+	if(glob(tmp_str.c_str(), GLOB_NOSORT, NULL, &g) == 0)
+	{
+		if(g.gl_pathc > 0)
+		{
+			if(g.gl_pathc != mCurrentDirCount)
+			{
+				// Number of matches has changed since the last search, meaning a file has been added or deleted.
+				// Reset the index.
+				mCurrentDirIndex = -1;
+				mCurrentDirCount = g.gl_pathc;
+			}
+	
+			mCurrentDirIndex++;
+	
+			if(mCurrentDirIndex < g.gl_pathc)
+			{
+//				llinfos << "getNextFileInDir: returning number " << mCurrentDirIndex << ", path is " << g.gl_pathv[mCurrentDirIndex] << llendl;
+
+				// The API wants just the filename, not the full path.
+				//fname = g.gl_pathv[mCurrentDirIndex];
+
+				char *s = strrchr(g.gl_pathv[mCurrentDirIndex], '/');
+				
+				if(s == NULL)
+					s = g.gl_pathv[mCurrentDirIndex];
+				else if(s[0] == '/')
+					s++;
+					
+				fname = s;
+				
+				result = TRUE;
+			}
+		}
+		
+		globfree(&g);
+	}
+	
+	return(result);
+}
+
+
+
 S32 LLDir_Mac::deleteFilesInDir(const std::string &dirname, const std::string &mask)
 {
 	glob_t g;
diff --git a/indra/llvfs/lldir_mac.h b/indra/llvfs/lldir_mac.h
index e60d5e41c2deca2e9aaca01d8f34306fbb896c1a..4eac3c3ae6fce824624bc7c048b8922c6c86e517 100644
--- a/indra/llvfs/lldir_mac.h
+++ b/indra/llvfs/lldir_mac.h
@@ -43,6 +43,7 @@ class LLDir_Mac : public LLDir
 	virtual S32 deleteFilesInDir(const std::string &dirname, const std::string &mask);
 	virtual std::string getCurPath();
 	virtual U32 countFilesInDir(const std::string &dirname, const std::string &mask);
+	virtual BOOL getNextFileInDir(const std::string &dirname, const std::string &mask, std::string &fname);
 	virtual BOOL fileExists(const std::string &filename) const;
 
 	/*virtual*/ std::string getLLPluginLauncher();
diff --git a/indra/llvfs/lldir_solaris.cpp b/indra/llvfs/lldir_solaris.cpp
index 21f8c3acdbeefa56272bac597cf5b1d1858ba46c..515fd66b6e9a9f4d2aef1647ad78134a15419f0c 100644
--- a/indra/llvfs/lldir_solaris.cpp
+++ b/indra/llvfs/lldir_solaris.cpp
@@ -260,6 +260,68 @@ U32 LLDir_Solaris::countFilesInDir(const std::string &dirname, const std::string
 	return (file_count);
 }
 
+// get the next file in the directory
+BOOL LLDir_Solaris::getNextFileInDir(const std::string &dirname, const std::string &mask, std::string &fname)
+{
+	glob_t g;
+	BOOL result = FALSE;
+	fname = "";
+	
+	if(!(dirname == mCurrentDir))
+	{
+		// different dir specified, close old search
+		mCurrentDirIndex = -1;
+		mCurrentDirCount = -1;
+		mCurrentDir = dirname;
+	}
+	
+	std::string tmp_str;
+	tmp_str = dirname;
+	tmp_str += mask;
+
+	if(glob(tmp_str.c_str(), GLOB_NOSORT, NULL, &g) == 0)
+	{
+		if(g.gl_pathc > 0)
+		{
+			if((int)g.gl_pathc != mCurrentDirCount)
+			{
+				// Number of matches has changed since the last search, meaning a file has been added or deleted.
+				// Reset the index.
+				mCurrentDirIndex = -1;
+				mCurrentDirCount = g.gl_pathc;
+			}
+	
+			mCurrentDirIndex++;
+	
+			if(mCurrentDirIndex < (int)g.gl_pathc)
+			{
+//				llinfos << "getNextFileInDir: returning number " << mCurrentDirIndex << ", path is " << g.gl_pathv[mCurrentDirIndex] << llendl;
+
+				// The API wants just the filename, not the full path.
+				//fname = g.gl_pathv[mCurrentDirIndex];
+
+				char *s = strrchr(g.gl_pathv[mCurrentDirIndex], '/');
+				
+				if(s == NULL)
+					s = g.gl_pathv[mCurrentDirIndex];
+				else if(s[0] == '/')
+					s++;
+					
+				fname = s;
+				
+				result = TRUE;
+			}
+		}
+		
+		globfree(&g);
+	}
+	
+	return(result);
+}
+
+
+
+
 std::string LLDir_Solaris::getCurPath()
 {
 	char tmp_str[LL_MAX_PATH];	/* Flawfinder: ignore */ 
diff --git a/indra/llvfs/lldir_solaris.h b/indra/llvfs/lldir_solaris.h
index f7e1a6301dbdc19a713e568d44cb28812b048427..4a1794f53950dab8f147dae3c4bc9cfe4e3b1088 100644
--- a/indra/llvfs/lldir_solaris.h
+++ b/indra/llvfs/lldir_solaris.h
@@ -43,6 +43,7 @@ class LLDir_Solaris : public LLDir
 public:	
 	virtual std::string getCurPath();
 	virtual U32 countFilesInDir(const std::string &dirname, const std::string &mask);
+	virtual BOOL getNextFileInDir(const std::string &dirname, const std::string &mask, std::string &fname);
 	/*virtual*/ BOOL fileExists(const std::string &filename) const;
 
 private:
diff --git a/indra/llvfs/lldir_win32.cpp b/indra/llvfs/lldir_win32.cpp
index 2f96fbbbc10d2aeee4a78a3c29742aacad05c6e2..33718e520d71b4c3e2595574187c22d0224c0ce7 100644
--- a/indra/llvfs/lldir_win32.cpp
+++ b/indra/llvfs/lldir_win32.cpp
@@ -236,6 +236,67 @@ U32 LLDir_Win32::countFilesInDir(const std::string &dirname, const std::string &
 	return (file_count);
 }
 
+
+// get the next file in the directory
+BOOL LLDir_Win32::getNextFileInDir(const std::string &dirname, const std::string &mask, std::string &fname)
+{
+    BOOL fileFound = FALSE;
+	fname = "";
+
+	WIN32_FIND_DATAW FileData;
+    llutf16string pathname = utf8str_to_utf16str(dirname) + utf8str_to_utf16str(mask);
+
+	if (pathname != mCurrentDir)
+	{
+		// different dir specified, close old search
+		if (mCurrentDir[0])
+		{
+			FindClose(mDirSearch_h);
+		}
+		mCurrentDir = pathname;
+
+		// and open new one
+		// Check error opening Directory structure
+		if ((mDirSearch_h = FindFirstFile(pathname.c_str(), &FileData)) != INVALID_HANDLE_VALUE)   
+		{
+           fileFound = TRUE;
+		}
+	}
+
+    // Loop to skip over the current (.) and parent (..) directory entries
+    // (apparently returned in Win7 but not XP)
+    do
+    {
+       if (   fileFound
+           && (  (lstrcmp(FileData.cFileName, (LPCTSTR)TEXT(".")) == 0)
+               ||(lstrcmp(FileData.cFileName, (LPCTSTR)TEXT("..")) == 0)
+               )
+           )
+       {
+          fileFound = FALSE;
+       }
+    } while (   mDirSearch_h != INVALID_HANDLE_VALUE
+             && !fileFound
+             && (fileFound = FindNextFile(mDirSearch_h, &FileData)
+                 )
+             );
+
+    if (!fileFound && GetLastError() == ERROR_NO_MORE_FILES)
+    {
+       // No more files, so reset to beginning of directory
+       FindClose(mDirSearch_h);
+       mCurrentDir[0] = '\000';
+    }
+
+    if (fileFound)
+    {
+        // convert from TCHAR to char
+        fname = utf16str_to_utf8str(FileData.cFileName);
+	}
+    
+	return fileFound;
+}
+
 std::string LLDir_Win32::getCurPath()
 {
 	WCHAR w_str[MAX_PATH];
diff --git a/indra/llvfs/lldir_win32.h b/indra/llvfs/lldir_win32.h
index 19c610eb8b2f6aeee28622a62568a7e14df7517d..4c932c932c8f06d6015c106f2b2cd8c9bd50e7f6 100644
--- a/indra/llvfs/lldir_win32.h
+++ b/indra/llvfs/lldir_win32.h
@@ -40,12 +40,15 @@ class LLDir_Win32 : public LLDir
 
 	/*virtual*/ std::string getCurPath();
 	/*virtual*/ U32 countFilesInDir(const std::string &dirname, const std::string &mask);
+	/*virtual*/ BOOL getNextFileInDir(const std::string &dirname, const std::string &mask, std::string &fname);
 	/*virtual*/ BOOL fileExists(const std::string &filename) const;
 
 	/*virtual*/ std::string getLLPluginLauncher();
 	/*virtual*/ std::string getLLPluginFilename(std::string base_name);
 
 private:
+	BOOL LLDir_Win32::getNextFileInDir(const llutf16string &dirname, const std::string &mask, std::string &fname);
+	
 	void* mDirSearch_h;
 	llutf16string mCurrentDir;
 };
diff --git a/indra/llvfs/lldiriterator.cpp b/indra/llvfs/lldiriterator.cpp
deleted file mode 100644
index 5536ed8f69a97c49721cf0242d8a97bf5d89ad1f..0000000000000000000000000000000000000000
--- a/indra/llvfs/lldiriterator.cpp
+++ /dev/null
@@ -1,203 +0,0 @@
-/**
- * @file lldiriterator.cpp
- * @brief Iterator through directory entries matching the search pattern.
- *
- * $LicenseInfo:firstyear=2010&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 "lldiriterator.h"
-
-#include <boost/filesystem.hpp>
-#include <boost/regex.hpp>
-
-namespace fs = boost::filesystem;
-
-static std::string glob_to_regex(const std::string& glob);
-
-class LLDirIterator::Impl
-{
-public:
-	Impl(const std::string &dirname, const std::string &mask);
-	~Impl();
-
-	bool next(std::string &fname);
-
-private:
-	boost::regex			mFilterExp;
-	fs::directory_iterator	mIter;
-	bool					mIsValid;
-};
-
-LLDirIterator::Impl::Impl(const std::string &dirname, const std::string &mask)
-	: mIsValid(false)
-{
-	fs::path dir_path(dirname);
-
-	// Check if path exists.
-	if (!fs::exists(dir_path))
-	{
-		llerrs << "Invalid path: \"" << dir_path.string() << "\"" << llendl;
-		return;
-	}
-
-	// Initialize the directory iterator for the given path.
-	try
-	{
-		mIter = fs::directory_iterator(dir_path);
-	}
-	catch (fs::basic_filesystem_error<fs::path>& e)
-	{
-		llerrs << e.what() << llendl;
-		return;
-	}
-
-	// Convert the glob mask to a regular expression
-	std::string exp = glob_to_regex(mask);
-
-	// Initialize boost::regex with the expression converted from
-	// the glob mask.
-	// An exception is thrown if the expression is not valid.
-	try
-	{
-		mFilterExp.assign(exp);
-	}
-	catch (boost::regex_error& e)
-	{
-		llerrs << "\"" << exp << "\" is not a valid regular expression: "
-				<< e.what() << llendl;
-		return;
-	}
-
-	mIsValid = true;
-}
-
-LLDirIterator::Impl::~Impl()
-{
-}
-
-bool LLDirIterator::Impl::next(std::string &fname)
-{
-	fname = "";
-
-	if (!mIsValid)
-	{
-		llerrs << "The iterator is not correctly initialized." << llendl;
-		return false;
-	}
-
-	fs::directory_iterator end_itr; // default construction yields past-the-end
-	bool found = false;
-	while (mIter != end_itr && !found)
-	{
-		boost::smatch match;
-		std::string name = mIter->path().filename();
-		if (found = boost::regex_match(name, match, mFilterExp))
-		{
-			fname = name;
-		}
-
-		++mIter;
-	}
-
-	return found;
-}
-
-std::string glob_to_regex(const std::string& glob)
-{
-	std::string regex;
-	regex.reserve(glob.size()<<1);
-	S32 braces = 0;
-	bool escaped = false;
-	bool square_brace_open = false;
-
-	for (std::string::const_iterator i = glob.begin(); i != glob.end(); ++i)
-	{
-		char c = *i;
-
-		switch (c)
-		{
-			case '.':
-				regex+="\\.";
-				break;
-			case '*':
-				if (glob.begin() == i)
-				{
-					regex+="[^.].*";
-				}
-				else
-				{
-					regex+= escaped ? "*" : ".*";
-				}
-				break;
-			case '?':
-				regex+= escaped ? '?' : '.';
-				break;
-			case '{':
-				braces++;
-				regex+='(';
-				break;
-			case '}':
-				if (!braces)
-				{
-					llerrs << "glob_to_regex: Closing brace without an equivalent opening brace: " << glob << llendl;
-				}
-
-				regex+=')';
-				braces--;
-				break;
-			case ',':
-				regex+= braces ? '|' : c;
-				break;
-			case '!':
-				regex+= square_brace_open ? '^' : c;
-				break;
-			default:
-				regex+=c;
-				break;
-		}
-
-		escaped = ('\\' == c);
-		square_brace_open = ('[' == c);
-	}
-
-	if (braces)
-	{
-		llerrs << "glob_to_regex: Unterminated brace expression: " << glob << llendl;
-	}
-
-	return regex;
-}
-
-LLDirIterator::LLDirIterator(const std::string &dirname, const std::string &mask)
-{
-	mImpl = new Impl(dirname, mask);
-}
-
-LLDirIterator::~LLDirIterator()
-{
-	delete mImpl;
-}
-
-bool LLDirIterator::next(std::string &fname)
-{
-	return mImpl->next(fname);
-}
diff --git a/indra/llvfs/lldiriterator.h b/indra/llvfs/lldiriterator.h
deleted file mode 100644
index 0b48be41b321c71935957773ea5a43494c9d5959..0000000000000000000000000000000000000000
--- a/indra/llvfs/lldiriterator.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/**
- * @file lldiriterator.h
- * @brief Iterator through directory entries matching the search pattern.
- *
- * $LicenseInfo:firstyear=2010&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_LLDIRITERATOR_H
-#define LL_LLDIRITERATOR_H
-
-#include "linden_common.h"
-
-/**
- * Class LLDirIterator
- *
- * Iterates through directory entries matching the search pattern.
- */
-class LLDirIterator
-{
-public:
-	/**
-	 * Constructs LLDirIterator object to search for glob pattern
-	 * matches in a directory.
-	 *
-	 * @param dirname - name of a directory to search in.
-	 * @param mask - search pattern, a glob expression
-	 *
-	 * Wildcards supported in glob expressions:
-	 * --------------------------------------------------------------
-	 * | Wildcard 	| Matches										|
-	 * --------------------------------------------------------------
-	 * | 	* 		|zero or more characters						|
-	 * | 	?		|exactly one character							|
-	 * | [abcde]	|exactly one character listed					|
-	 * | [a-e]		|exactly one character in the given range		|
-	 * | [!abcde]	|any character that is not listed				|
-	 * | [!a-e]		|any character that is not in the given range	|
-	 * | {abc,xyz}	|exactly one entire word in the options given	|
-	 * --------------------------------------------------------------
-	 */
-	LLDirIterator(const std::string &dirname, const std::string &mask);
-
-	~LLDirIterator();
-
-	/**
-	 * Searches for the next directory entry matching the glob mask
-	 * specified upon iterator construction.
-	 * Returns true if a match is found, sets fname
-	 * parameter to the name of the matched directory entry and
-	 * increments the iterator position.
-	 *
-	 * Typical usage:
-	 * <code>
-	 * LLDirIterator iter(directory, pattern);
-	 * if ( iter.next(scanResult) )
-	 * </code>
-	 *
-	 * @param fname - name of the matched directory entry.
-	 * @return true if a match is found, false otherwise.
-	 */
-	bool next(std::string &fname);
-
-protected:
-	class Impl;
-	Impl* mImpl;
-};
-
-#endif //LL_LLDIRITERATOR_H
diff --git a/indra/llvfs/tests/lldir_test.cpp b/indra/llvfs/tests/lldir_test.cpp
index ea321c5ae958829d739137eae3548f5cbf07c540..8788bd63e87d2b8030324ffcd0e0434057844151 100644
--- a/indra/llvfs/tests/lldir_test.cpp
+++ b/indra/llvfs/tests/lldir_test.cpp
@@ -28,7 +28,6 @@
 #include "linden_common.h"
 
 #include "../lldir.h"
-#include "../lldiriterator.h"
 
 #include "../test/lltut.h"
 
@@ -260,12 +259,13 @@ namespace tut
 
    std::string makeTestFile( const std::string& dir, const std::string& file )
    {
-      std::string path = dir + file;
+      std::string delim = gDirUtilp->getDirDelimiter();
+      std::string path = dir + delim + file;
       LLFILE* handle = LLFile::fopen( path, "w" );
       ensure("failed to open test file '"+path+"'", handle != NULL );
       // Harbison & Steele, 4th ed., p. 366: "If an error occurs, fputs
       // returns EOF; otherwise, it returns some other, nonnegative value."
-      ensure("failed to write to test file '"+path+"'", EOF != fputs("test file", handle) );
+      ensure("failed to write to test file '"+path+"'", fputs("test file", handle) >= 0);
       fclose(handle);
       return path;
    }
@@ -290,7 +290,7 @@ namespace tut
    }
 
    static const char* DirScanFilename[5] = { "file1.abc", "file2.abc", "file1.xyz", "file2.xyz", "file1.mno" };
-
+   
    void scanTest(const std::string& directory, const std::string& pattern, bool correctResult[5])
    {
 
@@ -300,8 +300,7 @@ namespace tut
       bool  filesFound[5] = { false, false, false, false, false };
       //std::cerr << "searching '"+directory+"' for '"+pattern+"'\n";
 
-      LLDirIterator iter(directory, pattern);
-      while ( found <= 5 && iter.next(scanResult) )
+      while ( found <= 5 && gDirUtilp->getNextFileInDir(directory, pattern, scanResult) )
       {
          found++;
          //std::cerr << "  found '"+scanResult+"'\n";
@@ -335,15 +334,15 @@ namespace tut
    
    template<> template<>
    void LLDirTest_object_t::test<5>()
-      // LLDirIterator::next
+      // getNextFileInDir
    {
       std::string delim = gDirUtilp->getDirDelimiter();
       std::string dirTemp = LLFile::tmpdir();
 
       // Create the same 5 file names of the two directories
 
-      std::string dir1 = makeTestDir(dirTemp + "LLDirIterator");
-      std::string dir2 = makeTestDir(dirTemp + "LLDirIterator");
+      std::string dir1 = makeTestDir(dirTemp + "getNextFileInDir");
+      std::string dir2 = makeTestDir(dirTemp + "getNextFileInDir");
       std::string dir1files[5];
       std::string dir2files[5];
       for (int i=0; i<5; i++)
@@ -381,17 +380,19 @@ namespace tut
       scanTest(dir2, "file?.x?z", expected7);
 
       // Scan dir2 and see if any file?.??c files are found
-      bool  expected8[5] = { true, true, false, false, false };
-      scanTest(dir2, "file?.??c", expected8);
-      scanTest(dir2, "*.??c", expected8);
+      // THESE FAIL ON Mac and Windows, SO ARE COMMENTED OUT FOR NOW
+      //      bool  expected8[5] = { true, true, false, false, false };
+      //      scanTest(dir2, "file?.??c", expected8);
+      //      scanTest(dir2, "*.??c", expected8);
 
       // Scan dir1 and see if any *.?n? files are found
       bool  expected9[5] = { false, false, false, false, true };
       scanTest(dir1, "*.?n?", expected9);
 
       // Scan dir1 and see if any *.???? files are found
-      bool  expected10[5] = { false, false, false, false, false };
-      scanTest(dir1, "*.????", expected10);
+      // THIS ONE FAILS ON WINDOWS (returns three charater suffixes) SO IS COMMENTED OUT FOR NOW
+      // bool  expected10[5] = { false, false, false, false, false };
+      // scanTest(dir1, "*.????", expected10);
 
       // Scan dir1 and see if any ?????.* files are found
       bool  expected11[5] = { true, true, true, true, true };
@@ -401,15 +402,6 @@ namespace tut
       bool  expected12[5] = { false, false, true, true, false };
       scanTest(dir1, "??l??.xyz", expected12);
 
-      bool expected13[5] = { true, false, true, false, false };
-      scanTest(dir1, "file1.{abc,xyz}", expected13);
-
-      bool expected14[5] = { true, true, false, false, false };
-      scanTest(dir1, "file[0-9].abc", expected14);
-
-      bool expected15[5] = { true, true, false, false, false };
-      scanTest(dir1, "file[!a-z].abc", expected15);
-
       // clean up all test files and directories
       for (int i=0; i<5; i++)
       {
diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt
index a61c35abd2046eaecbe2b2e7da7a5b88c0c9fdec..5d2342e92568471d4bbd2aec66de721f9c15c73a 100644
--- a/indra/newview/CMakeLists.txt
+++ b/indra/newview/CMakeLists.txt
@@ -530,6 +530,7 @@ set(viewer_SOURCE_FILES
     llviewerregion.cpp
     llviewershadermgr.cpp
     llviewerstats.cpp
+    llviewerstatsrecorder.cpp
     llviewertexteditor.cpp
     llviewertexture.cpp
     llviewertextureanim.cpp
@@ -1063,6 +1064,7 @@ set(viewer_HEADER_FILES
     llviewerregion.h
     llviewershadermgr.h
     llviewerstats.h
+    llviewerstatsrecorder.h
     llviewertexteditor.h
     llviewertexture.h
     llviewertextureanim.h
diff --git a/indra/newview/app_settings/lindenlab.pem b/indra/newview/app_settings/lindenlab.pem
index cf88d0e04799bf09835f2c78959e9e8bce3d75f9..eddae0426def81a5524850381d29b865bf87b22e 100644
--- a/indra/newview/app_settings/lindenlab.pem
+++ b/indra/newview/app_settings/lindenlab.pem
@@ -24,4 +24,74 @@ xA39CIJ65Zozs28Eg1aV9/Y+Of7TnWhW+U3J3/wD/GghaAGiKK6vMn9gJBIdBX/9
 e6ef37VGyiOEFFjnUIbuk0RWty0orN76q/lI/xjCi15XSA/VSq2j4vmnwfZcPTDu
 glmQ1A==
 -----END CERTIFICATE-----
-
+-----BEGIN CERTIFICATE-----
+MIIEkDCCA3igAwIBAgICTSUwDQYJKoZIhvcNAQEFBQAwQDELMAkGA1UEBhMCVVMx
+FzAVBgNVBAoTDkdlb1RydXN0LCBJbmMuMRgwFgYDVQQDEw9HZW9UcnVzdCBTU0wg
+Q0EwHhcNMTAxMjIwMTkxMTI2WhcNMTIwMjIxMTI1NDAzWjCBnzEpMCcGA1UEBRMg
+UkMteW9jbXIwdXRmRTdOMVBlaHJHQXdqL0lNc2hJZS0xCzAJBgNVBAYTAlVTMRMw
+EQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1TYW4gRnJhbmNpc2NvMR0wGwYD
+VQQKExRMaW5kZW4gUmVzZWFyY2ggSW5jLjEZMBcGA1UEAwwQKi5zZWNvbmRsaWZl
+LmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAN/VCCu1SZ5x4vNp
+XZZ8r3lzqeLwjxVZfMSQCKM4lV5DFbqiZMMBto4Y/ib7i0audzuTDnImCLsfzlTu
+7iZLoJNy42/43Rq4xtaDZ7joxALFmzXUKEipgHiTTbAbLQNCS4wPXts3tScODVZY
+/mhlmXdlLuGxJbqoyOEP6NEQbgXWDCKDERnAEG/FJBVHKyBfg3abrrIuQNwYCKCS
+2OZ5Z5MveGmY4tSKUOOi/c0vV9HsanQn/ymybZjxR5Kmb1CvQr7VVtbpR1MhlGkc
+sfJz1NFIFxdXkUggIny+XSG1dAAJRFFumyRM+X/eh0NHNmAI14JJ43hB6Zw3dzzl
+An9BSeECAwEAAaOCATIwggEuMB8GA1UdIwQYMBaAFEJ5VBthzVUrPmPVPEhX9Z/7
+Rc5KMA4GA1UdDwEB/wQEAwIFoDAdBgNVHSUEFjAUBggrBgEFBQcDAQYIKwYBBQUH
+AwIwKwYDVR0RBCQwIoIQKi5zZWNvbmRsaWZlLmNvbYIOc2Vjb25kbGlmZS5jb20w
+PQYDVR0fBDYwNDAyoDCgLoYsaHR0cDovL2d0c3NsLWNybC5nZW90cnVzdC5jb20v
+Y3Jscy9ndHNzbC5jcmwwHQYDVR0OBBYEFK9UTMkc4Fh/Ug4fVs6UVhxP6my0MAwG
+A1UdEwEB/wQCMAAwQwYIKwYBBQUHAQEENzA1MDMGCCsGAQUFBzAChidodHRwOi8v
+Z3Rzc2wtYWlhLmdlb3RydXN0LmNvbS9ndHNzbC5jcnQwDQYJKoZIhvcNAQEFBQAD
+ggEBACIR9yggGHDcZ60AMNdFmZ8XJeahTuv6q2X/It2JxqSQp5BVQUei0NGIYYOt
+yg0JFBZn5KqXiQ5Zz84K4hdvh/6grCEAn4v37sozSbkeZ92Lec8NOZR42HfYIOCo
+Hx9q7CNRxdhv6ehV4LekaRBxrtp5etVsIDaWvRZEswCWl46VuLrfjcpauj6DAdOQ
+FfPVAW+4nPgLr8KapZMnXYnabIwrj9DQLQ88w/D7durenu/SYJEahWW9mb++n9is
+eMjyuyzYW0PTUBTaDsj+2ZmHJtoR1tBiLqh0Q62UQnmDgsf5SK5PTb8jnta/1SvN
+3pirsuvjMPV19zuH6b9NpJfXfd0=
+-----END CERTIFICATE-----
+-----BEGIN CERTIFICATE-----
+MIIDfTCCAuagAwIBAgIDErvmMA0GCSqGSIb3DQEBBQUAME4xCzAJBgNVBAYTAlVT
+MRAwDgYDVQQKEwdFcXVpZmF4MS0wKwYDVQQLEyRFcXVpZmF4IFNlY3VyZSBDZXJ0
+aWZpY2F0ZSBBdXRob3JpdHkwHhcNMDIwNTIxMDQwMDAwWhcNMTgwODIxMDQwMDAw
+WjBCMQswCQYDVQQGEwJVUzEWMBQGA1UEChMNR2VvVHJ1c3QgSW5jLjEbMBkGA1UE
+AxMSR2VvVHJ1c3QgR2xvYmFsIENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB
+CgKCAQEA2swYYzD99BcjGlZ+W988bDjkcbd4kdS8odhM+KhDtgPpTSEHCIjaWC9m
+OSm9BXiLnTjoBbdqfnGk5sRgprDvgOSJKA+eJdbtg/OtppHHmMlCGDUUna2YRpIu
+T8rxh0PBFpVXLVDviS2Aelet8u5fa9IAjbkU+BQVNdnARqN7csiRv8lVK83Qlz6c
+JmTM386DGXHKTubU1XupGc1V3sjs0l44U+VcT4wt/lAjNvxm5suOpDkZALeVAjmR
+Cw7+OC7RHQWa9k0+bw8HHa8sHo9gOeL6NlMTOdReJivbPagUvTLrGAMoUgRx5asz
+PeE4uwc2hGKceeoWMPRfwCvocWvk+QIDAQABo4HwMIHtMB8GA1UdIwQYMBaAFEjm
+aPkr0rKV10fYIyAQTzOYkJ/UMB0GA1UdDgQWBBTAephojYn7qwVkDBF9qn1luMrM
+TjAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjA6BgNVHR8EMzAxMC+g
+LaArhilodHRwOi8vY3JsLmdlb3RydXN0LmNvbS9jcmxzL3NlY3VyZWNhLmNybDBO
+BgNVHSAERzBFMEMGBFUdIAAwOzA5BggrBgEFBQcCARYtaHR0cHM6Ly93d3cuZ2Vv
+dHJ1c3QuY29tL3Jlc291cmNlcy9yZXBvc2l0b3J5MA0GCSqGSIb3DQEBBQUAA4GB
+AHbhEm5OSxYShjAGsoEIz/AIx8dxfmbuwu3UOx//8PDITtZDOLC5MH0Y0FWDomrL
+NhGc6Ehmo21/uBPUR/6LWlxz/K7ZGzIZOKuXNBSqltLroxwUCEm2u+WR74M26x1W
+b8ravHNjkOR/ez4iyz0H7V84dJzjA1BOoa+Y7mHyhD8S
+-----END CERTIFICATE-----
+-----BEGIN CERTIFICATE-----
+MIID2TCCAsGgAwIBAgIDAjbQMA0GCSqGSIb3DQEBBQUAMEIxCzAJBgNVBAYTAlVT
+MRYwFAYDVQQKEw1HZW9UcnVzdCBJbmMuMRswGQYDVQQDExJHZW9UcnVzdCBHbG9i
+YWwgQ0EwHhcNMTAwMjE5MjIzOTI2WhcNMjAwMjE4MjIzOTI2WjBAMQswCQYDVQQG
+EwJVUzEXMBUGA1UEChMOR2VvVHJ1c3QsIEluYy4xGDAWBgNVBAMTD0dlb1RydXN0
+IFNTTCBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAJCzgMHk5Uat
+cGA9uuUU3Z6KXot1WubKbUGlI+g5hSZ6p1V3mkihkn46HhrxJ6ujTDnMyz1Hr4Gu
+FmpcN+9FQf37mpc8oEOdxt8XIdGKolbCA0mEEoE+yQpUYGa5jFTk+eb5lPHgX3UR
+8im55IaisYmtph6DKWOy8FQchQt65+EuDa+kvc3nsVrXjAVaDktzKIt1XTTYdwvh
+dGLicTBi2LyKBeUxY0pUiWozeKdOVSQdl+8a5BLGDzAYtDRN4dgjOyFbLTAZJQ50
+96QhS6CkIMlszZhWwPKoXz4mdaAN+DaIiixafWcwqQ/RmXAueOFRJq9VeiS+jDkN
+d53eAsMMvR8CAwEAAaOB2TCB1jAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFEJ5
+VBthzVUrPmPVPEhX9Z/7Rc5KMB8GA1UdIwQYMBaAFMB6mGiNifurBWQMEX2qfWW4
+ysxOMBIGA1UdEwEB/wQIMAYBAf8CAQAwOgYDVR0fBDMwMTAvoC2gK4YpaHR0cDov
+L2NybC5nZW90cnVzdC5jb20vY3Jscy9ndGdsb2JhbC5jcmwwNAYIKwYBBQUHAQEE
+KDAmMCQGCCsGAQUFBzABhhhodHRwOi8vb2NzcC5nZW90cnVzdC5jb20wDQYJKoZI
+hvcNAQEFBQADggEBANTvU4ToGr2hiwTAqfVfoRB4RV2yV2pOJMtlTjGXkZrUJPji
+J2ZwMZzBYlQG55cdOprApClICq8kx6jEmlTBfEx4TCtoLF0XplR4TEbigMMfOHES
+0tdT41SFULgCy+5jOvhWiU1Vuy7AyBh3hjELC3DwfjWDpCoTZFZnNF0WX3OsewYk
+2k9QbSqr0E1TQcKOu3EDSSmGGM8hQkx0YlEVxW+o78Qn5Rsz3VqI138S0adhJR/V
+4NwdzxoQ2KDLX4z6DOW/cf/lXUQdpj6HR/oaToODEj+IZpWYeZqF6wJHzSXj8gYE
+TpnKXKBuervdo5AaRTPvvz7SBMS24CqFZUE+ENQ=
+-----END CERTIFICATE-----
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index ef6f8fd3eee14dea0001feeae55a175a1cce4a35..a22f197b85bf885b16a33d950ea03adb1c2f9c27 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -12445,16 +12445,5 @@
       <key>Value</key>
       <string>name</string>
     </map>
-    <key>ReleaseNotesURL</key>
-    <map>
-      <key>Comment</key>
-      <string>Release notes URL template</string>
-      <key>Persist</key>
-      <integer>1</integer>
-      <key>Type</key>
-      <string>String</string>
-      <key>Value</key>
-      <string>http://secondlife.com/app/releasenotes/?channel=[CHANNEL]&amp;version=[VERSION]</string>
-    </map>
 </map>
 </llsd>
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index f0711db3bd1ce67d478a96a14e34027958f7223e..6a9dfaf21b6cbe21e3ade86ecc8983f129a04e04 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -44,6 +44,7 @@
 #include "llagentwearables.h"
 #include "llwindow.h"
 #include "llviewerstats.h"
+#include "llviewerstatsrecorder.h"
 #include "llmd5.h"
 #include "llpumpio.h"
 #include "llmimetypes.h"
@@ -89,7 +90,6 @@
 
 // Linden library includes
 #include "llavatarnamecache.h"
-#include "lldiriterator.h"
 #include "llimagej2c.h"
 #include "llmemory.h"
 #include "llprimitive.h"
@@ -473,8 +473,6 @@ static void settings_to_globals()
 	gDebugWindowProc = gSavedSettings.getBOOL("DebugWindowProc");
 	gShowObjectUpdates = gSavedSettings.getBOOL("ShowObjectUpdates");
 	LLWorldMapView::sMapScale = gSavedSettings.getF32("MapScale");
-
-	LLCubeMap::sUseCubeMaps = LLFeatureManager::getInstance()->isFeatureAvailable("RenderCubeMap");
 }
 
 static void settings_modify()
@@ -668,6 +666,10 @@ bool LLAppViewer::init()
 
     mAlloc.setProfilingEnabled(gSavedSettings.getBOOL("MemProfiling"));
 
+#if LL_RECORD_VIEWER_STATS
+	LLViewerStatsRecorder::initClass();
+#endif
+
     // *NOTE:Mani - LLCurl::initClass is not thread safe. 
     // Called before threads are created.
     LLCurl::initClass();
@@ -850,6 +852,9 @@ bool LLAppViewer::init()
 	gGLActive = TRUE;
 	initWindow();
 
+	// initWindow also initializes the Feature List, so now we can initialize this global.
+	LLCubeMap::sUseCubeMaps = LLFeatureManager::getInstance()->isFeatureAvailable("RenderCubeMap");
+
 	// call all self-registered classes
 	LLInitClassList::instance().fireCallbacks();
 
@@ -991,6 +996,8 @@ bool LLAppViewer::init()
 
 	LLAgentLanguage::init();
 
+
+
 	return true;
 }
 
@@ -1391,16 +1398,6 @@ bool LLAppViewer::cleanup()
 	}
 	mPlugins.clear();
 
-	//----------------------------------------------
-	//this test code will be removed after the test
-	//test manual call stack tracer
-	if(gSavedSettings.getBOOL("QAMode"))
-	{
-		LLError::LLCallStacks::print() ;
-	}
-	//end of the test code
-	//----------------------------------------------
-
 	//flag all elements as needing to be destroyed immediately
 	// to ensure shutdown order
 	LLMortician::setZealous(TRUE);
@@ -1711,6 +1708,10 @@ bool LLAppViewer::cleanup()
 	}
 	LLMetricPerformanceTesterBasic::cleanClass() ;
 
+#if LL_RECORD_VIEWER_STATS
+	LLViewerStatsRecorder::cleanupClass();
+#endif
+
 	llinfos << "Cleaning up Media and Textures" << llendflush;
 
 	//Note:
@@ -3066,35 +3067,32 @@ void LLAppViewer::initMarkerFile()
 	std::string llerror_marker_file = gDirUtilp->getExpandedFilename(LL_PATH_LOGS, LLERROR_MARKER_FILE_NAME);
 	std::string error_marker_file = gDirUtilp->getExpandedFilename(LL_PATH_LOGS, ERROR_MARKER_FILE_NAME);
 
-	
 	if (LLAPRFile::isExist(mMarkerFileName, NULL, LL_APR_RB) && !anotherInstanceRunning())
 	{
 		gLastExecEvent = LAST_EXEC_FROZE;
 		LL_INFOS("MarkerFile") << "Exec marker found: program froze on previous execution" << LL_ENDL;
 	}    
-    
 	if(LLAPRFile::isExist(logout_marker_file, NULL, LL_APR_RB))
 	{
-		LL_INFOS("MarkerFile") << "Last exec LLError crashed, setting LastExecEvent to " << LAST_EXEC_LLERROR_CRASH << LL_ENDL;
 		gLastExecEvent = LAST_EXEC_LOGOUT_FROZE;
+		LL_INFOS("MarkerFile") << "Last exec LLError crashed, setting LastExecEvent to " << gLastExecEvent << LL_ENDL;
+		LLAPRFile::remove(logout_marker_file);
 	}
 	if(LLAPRFile::isExist(llerror_marker_file, NULL, LL_APR_RB))
 	{
-		llinfos << "Last exec LLError crashed, setting LastExecEvent to " << LAST_EXEC_LLERROR_CRASH << llendl;
 		if(gLastExecEvent == LAST_EXEC_LOGOUT_FROZE) gLastExecEvent = LAST_EXEC_LOGOUT_CRASH;
 		else gLastExecEvent = LAST_EXEC_LLERROR_CRASH;
+		LL_INFOS("MarkerFile") << "Last exec LLError crashed, setting LastExecEvent to " << gLastExecEvent << LL_ENDL;
+		LLAPRFile::remove(llerror_marker_file);
 	}
 	if(LLAPRFile::isExist(error_marker_file, NULL, LL_APR_RB))
 	{
-		LL_INFOS("MarkerFile") << "Last exec crashed, setting LastExecEvent to " << LAST_EXEC_OTHER_CRASH << LL_ENDL;
 		if(gLastExecEvent == LAST_EXEC_LOGOUT_FROZE) gLastExecEvent = LAST_EXEC_LOGOUT_CRASH;
 		else gLastExecEvent = LAST_EXEC_OTHER_CRASH;
+		LL_INFOS("MarkerFile") << "Last exec crashed, setting LastExecEvent to " << gLastExecEvent << LL_ENDL;
+		LLAPRFile::remove(error_marker_file);
 	}
-	
-	LLAPRFile::remove(logout_marker_file);
-	LLAPRFile::remove(llerror_marker_file);
-	LLAPRFile::remove(error_marker_file);
-	
+
 	// No new markers if another instance is running.
 	if(anotherInstanceRunning()) 
 	{
@@ -3292,9 +3290,7 @@ void LLAppViewer::migrateCacheDirectory()
 			S32 file_count = 0;
 			std::string file_name;
 			std::string mask = delimiter + "*.*";
-
-			LLDirIterator iter(old_cache_dir, mask);
-			while (iter.next(file_name))
+			while (gDirUtilp->getNextFileInDir(old_cache_dir, mask, file_name))
 			{
 				if (file_name == "." || file_name == "..") continue;
 				std::string source_path = old_cache_dir + delimiter + file_name;
@@ -3513,8 +3509,7 @@ bool LLAppViewer::initCache()
 		dir = gDirUtilp->getExpandedFilename(LL_PATH_CACHE,"");
 
 		std::string found_file;
-		LLDirIterator iter(dir, mask);
-		if (iter.next(found_file))
+		if (gDirUtilp->getNextFileInDir(dir, mask, found_file))
 		{
 			old_vfs_data_file = dir + gDirUtilp->getDirDelimiter() + found_file;
 
@@ -3739,6 +3734,7 @@ void LLAppViewer::loadNameCache()
 	// display names cache
 	std::string filename =
 		gDirUtilp->getExpandedFilename(LL_PATH_CACHE, "avatar_name_cache.xml");
+	LL_INFOS("AvNameCache") << filename << LL_ENDL;
 	llifstream name_cache_stream(filename);
 	if(name_cache_stream.is_open())
 	{
diff --git a/indra/newview/llappviewerlinux.cpp b/indra/newview/llappviewerlinux.cpp
index fc7a27e5e04ec302e8d0ff161e2de215c888717f..898cc1c0ba8686bc615b685e2d17353c5d51dbb9 100644
--- a/indra/newview/llappviewerlinux.cpp
+++ b/indra/newview/llappviewerlinux.cpp
@@ -30,7 +30,6 @@
 
 #include "llcommandlineparser.h"
 
-#include "lldiriterator.h"
 #include "llmemtype.h"
 #include "llurldispatcher.h"		// SLURL from other app instance
 #include "llviewernetwork.h"
@@ -505,9 +504,7 @@ std::string LLAppViewerLinux::generateSerialNumber()
 
 	// trawl /dev/disk/by-uuid looking for a good-looking UUID to grab
 	std::string this_name;
-
-	LLDirIterator iter(uuiddir, "*");
-	while (iter.next(this_name))
+	while (gDirUtilp->getNextFileInDir(uuiddir, "*", this_name))
 	{
 		if (this_name.length() > best.length() ||
 		    (this_name.length() == best.length() &&
diff --git a/indra/newview/llcolorswatch.cpp b/indra/newview/llcolorswatch.cpp
index 4a1ba6f1b5fe91903323ccb8f5ad23b280eb7305..6f02192d0aeacd99ef5fce0215591d876dd78bfa 100644
--- a/indra/newview/llcolorswatch.cpp
+++ b/indra/newview/llcolorswatch.cpp
@@ -319,7 +319,7 @@ void LLColorSwatchCtrl::onColorChanged ( void* data, EColorPickOp pick_op )
 // This is called when the main floatercustomize panel is closed.
 // Since this class has pointers up to its parents, we need to cleanup
 // this class first in order to avoid a crash.
-void LLColorSwatchCtrl::onParentFloaterClosed()
+void LLColorSwatchCtrl::closeFloaterColorPicker()
 {
 	LLFloaterColorPicker* pickerp = (LLFloaterColorPicker*)mPickerHandle.get();
 	if (pickerp)
diff --git a/indra/newview/llcolorswatch.h b/indra/newview/llcolorswatch.h
index cd859ea1286c052a51d4247c627907f9f562d4d1..5bdd1712d2002cc84166b2643fb5fd9b7057085e 100644
--- a/indra/newview/llcolorswatch.h
+++ b/indra/newview/llcolorswatch.h
@@ -100,7 +100,7 @@ class LLColorSwatchCtrl
 	/*virtual*/ void	setEnabled( BOOL enabled );
 
 	static void		onColorChanged ( void* data, EColorPickOp pick_op = COLOR_CHANGE );
-	void			onParentFloaterClosed();
+	void			closeFloaterColorPicker();
 
 protected:
 	BOOL			mValid;
diff --git a/indra/newview/llfeaturemanager.cpp b/indra/newview/llfeaturemanager.cpp
index ca2ef5f5b8e1bdafcf462cccf502359253947c76..4e16cc4217dcb1c1c67f7fa944c929b2f8a822e2 100644
--- a/indra/newview/llfeaturemanager.cpp
+++ b/indra/newview/llfeaturemanager.cpp
@@ -290,11 +290,9 @@ BOOL LLFeatureManager::parseFeatureTable(std::string filename)
 	mTableVersion = version;
 
 	LLFeatureList *flp = NULL;
-	while (!file.eof() && file.good())
+	while (file >> name)
 	{
 		char buffer[MAX_STRING];		 /*Flawfinder: ignore*/
-
-		file >> name;
 		
 		if (name.substr(0,2) == "//")
 		{
@@ -303,13 +301,6 @@ BOOL LLFeatureManager::parseFeatureTable(std::string filename)
 			continue;
 		}
 
-		if (name.empty())
-		{
-			// This is a blank line
-			file.getline(buffer, MAX_STRING);
-			continue;
-		}
-
 		if (name == "list")
 		{
 			if (flp)
diff --git a/indra/newview/llfloatersettingsdebug.cpp b/indra/newview/llfloatersettingsdebug.cpp
index 71882fbb839b91e2f250b4af29d29d19835e6a4d..07f5220ab7f8419cc50d5b0723c1d7f7e63a97dc 100644
--- a/indra/newview/llfloatersettingsdebug.cpp
+++ b/indra/newview/llfloatersettingsdebug.cpp
@@ -178,7 +178,7 @@ void LLFloaterSettingsDebug::onClickDefault()
 
 	if (controlp)
 	{
-		controlp->resetToDefault();
+		controlp->resetToDefault(true);
 		updateControl(controlp);
 	}
 }
diff --git a/indra/newview/llfloateruipreview.cpp b/indra/newview/llfloateruipreview.cpp
index 182d3d23f1a868355b19dfb6be4fe03959a2ade6..11b3379814a52d3de44e343675abd7196417e5e9 100644
--- a/indra/newview/llfloateruipreview.cpp
+++ b/indra/newview/llfloateruipreview.cpp
@@ -35,7 +35,6 @@
 #include "llfloateruipreview.h"			// Own header
 
 // Internal utility
-#include "lldiriterator.h"
 #include "lleventtimer.h"
 #include "llexternaleditor.h"
 #include "llrender.h"
@@ -482,11 +481,9 @@ BOOL LLFloaterUIPreview::postBuild()
 	std::string language_directory;
 	std::string xui_dir = get_xui_dir();	// directory containing localizations -- don't forget trailing delim
 	mLanguageSelection->removeall();																				// clear out anything temporarily in list from XML
-
-	LLDirIterator iter(xui_dir, "*");
 	while(found)																									// for every directory
 	{
-		if((found = iter.next(language_directory)))							// get next directory
+		if((found = gDirUtilp->getNextFileInDir(xui_dir, "*", language_directory)))							// get next directory
 		{
 			std::string full_path = xui_dir + language_directory;
 			if(LLFile::isfile(full_path.c_str()))																	// if it's not a directory, skip it
@@ -638,51 +635,42 @@ void LLFloaterUIPreview::refreshList()
 	mFileList->clearRows();		// empty list
 	std::string name;
 	BOOL found = TRUE;
-
-	LLDirIterator floater_iter(getLocalizedDirectory(), "floater_*.xml");
 	while(found)				// for every floater file that matches the pattern
 	{
-		if((found = floater_iter.next(name)))	// get next file matching pattern
+		if((found = gDirUtilp->getNextFileInDir(getLocalizedDirectory(), "floater_*.xml", name)))	// get next file matching pattern
 		{
 			addFloaterEntry(name.c_str());	// and add it to the list (file name only; localization code takes care of rest of path)
 		}
 	}
 	found = TRUE;
-
-	LLDirIterator inspect_iter(getLocalizedDirectory(), "inspect_*.xml");
 	while(found)				// for every inspector file that matches the pattern
 	{
-		if((found = inspect_iter.next(name)))	// get next file matching pattern
+		if((found = gDirUtilp->getNextFileInDir(getLocalizedDirectory(), "inspect_*.xml", name)))	// get next file matching pattern
 		{
 			addFloaterEntry(name.c_str());	// and add it to the list (file name only; localization code takes care of rest of path)
 		}
 	}
 	found = TRUE;
-
-	LLDirIterator menu_iter(getLocalizedDirectory(), "menu_*.xml");
 	while(found)				// for every menu file that matches the pattern
 	{
-		if((found = menu_iter.next(name)))	// get next file matching pattern
+		if((found = gDirUtilp->getNextFileInDir(getLocalizedDirectory(), "menu_*.xml", name)))	// get next file matching pattern
 		{
 			addFloaterEntry(name.c_str());	// and add it to the list (file name only; localization code takes care of rest of path)
 		}
 	}
 	found = TRUE;
-
-	LLDirIterator panel_iter(getLocalizedDirectory(), "panel_*.xml");
 	while(found)				// for every panel file that matches the pattern
 	{
-		if((found = panel_iter.next(name)))	// get next file matching pattern
+		if((found = gDirUtilp->getNextFileInDir(getLocalizedDirectory(), "panel_*.xml", name)))	// get next file matching pattern
 		{
 			addFloaterEntry(name.c_str());	// and add it to the list (file name only; localization code takes care of rest of path)
 		}
 	}
-	found = TRUE;
 
-	LLDirIterator sidepanel_iter(getLocalizedDirectory(), "sidepanel_*.xml");
+	found = TRUE;
 	while(found)				// for every sidepanel file that matches the pattern
 	{
-		if((found = sidepanel_iter.next(name)))	// get next file matching pattern
+		if((found = gDirUtilp->getNextFileInDir(getLocalizedDirectory(), "sidepanel_*.xml", name)))	// get next file matching pattern
 		{
 			addFloaterEntry(name.c_str());	// and add it to the list (file name only; localization code takes care of rest of path)
 		}
diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp
index afd565bb26424a7882edbb444ece40a2bb2b6afe..9623554200f4675e0e23997595f2c53c0d360169 100644
--- a/indra/newview/llimview.cpp
+++ b/indra/newview/llimview.cpp
@@ -279,7 +279,7 @@ LLIMModel::LLIMSession::LLIMSession(const LLUUID& session_id, const std::string&
 
 void LLIMModel::LLIMSession::onAdHocNameCache(const LLAvatarName& av_name)
 {
-	if (av_name.mIsDummy)
+	if (av_name.mIsTemporaryName)
 	{
 		S32 separator_index = mName.rfind(" ");
 		std::string name = mName.substr(0, separator_index);
diff --git a/indra/newview/llinventorymodelbackgroundfetch.cpp b/indra/newview/llinventorymodelbackgroundfetch.cpp
index eab8f187a70d7f9901122d3686a2b98e04efdef3..570e48d52694ab47f0fe1ec0dfa5090fc5bb9ef8 100644
--- a/indra/newview/llinventorymodelbackgroundfetch.cpp
+++ b/indra/newview/llinventorymodelbackgroundfetch.cpp
@@ -181,7 +181,7 @@ void LLInventoryModelBackgroundFetch::backgroundFetch()
 	if (mBackgroundFetchActive && gAgent.getRegion())
 	{
 		// If we'll be using the capability, we'll be sending batches and the background thing isn't as important.
-		std::string url = gAgent.getRegion()->getCapability("WebFetchInventoryDescendents");   
+		std::string url = gAgent.getRegion()->getCapability("FetchInventoryDescendents2");   
 		if (!url.empty()) 
 		{
 			bulkFetch(url);
@@ -604,7 +604,7 @@ void LLInventoryModelBackgroundFetch::bulkFetch(std::string url)
 		}
 		if (body_lib["folders"].size())
 		{
-			std::string url_lib = gAgent.getRegion()->getCapability("FetchLibDescendents");
+			std::string url_lib = gAgent.getRegion()->getCapability("FetchLibDescendents2");
 			
 			LLInventoryModelFetchDescendentsResponder *fetcher = new LLInventoryModelFetchDescendentsResponder(body_lib, recursive_cats);
 			LLHTTPClient::post(url_lib, body_lib, fetcher, 300.0);
diff --git a/indra/newview/llinventoryobserver.cpp b/indra/newview/llinventoryobserver.cpp
index 91ff8c7867c4d9e5519a4e5ae15bcbd458d50418..0fd4b2bee54fabc12bba9eb36cbe57899bb4e835 100644
--- a/indra/newview/llinventoryobserver.cpp
+++ b/indra/newview/llinventoryobserver.cpp
@@ -203,8 +203,8 @@ void fetch_items_from_llsd(const LLSD& items_llsd)
 {
 	if (!items_llsd.size() || gDisconnected) return;
 	LLSD body;
-	body[0]["cap_name"] = "FetchInventory";
-	body[1]["cap_name"] = "FetchLib";
+	body[0]["cap_name"] = "FetchInventory2";
+	body[1]["cap_name"] = "FetchLib2";
 	for (S32 i=0; i<items_llsd.size();i++)
 	{
 		if (items_llsd[i]["owner_id"].asString() == gAgent.getID().asString())
diff --git a/indra/newview/lllogchat.cpp b/indra/newview/lllogchat.cpp
index b09cfbe90754f7db7186b2d637b6d9db01023f8e..9adf374c71642fc0f3525b36453d93572c7af1b2 100644
--- a/indra/newview/lllogchat.cpp
+++ b/indra/newview/lllogchat.cpp
@@ -32,7 +32,6 @@
 #include "lltrans.h"
 #include "llviewercontrol.h"
 
-#include "lldiriterator.h"
 #include "llinstantmessage.h"
 #include "llsingleton.h" // for LLSingleton
 
@@ -602,8 +601,7 @@ std::string LLLogChat::oldLogFileName(std::string filename)
 	//LL_INFOS("") << "Checking:" << directory << " for " << pattern << LL_ENDL;/* uncomment if you want to verify step, delete on commit */
 	std::vector<std::string> allfiles;
 
-	LLDirIterator iter(directory, pattern);
-	while (iter.next(scanResult))
+    while (gDirUtilp->getNextFileInDir(directory, pattern, scanResult))
     {
 		//LL_INFOS("") << "Found   :" << scanResult << LL_ENDL;
         allfiles.push_back(scanResult);
diff --git a/indra/newview/lllogininstance.cpp b/indra/newview/lllogininstance.cpp
index d866db1829240ac0ffbae648b380cacdaf8f39cc..33e051bfab8e6286f73c64862a8fe6ee05019c54 100644
--- a/indra/newview/lllogininstance.cpp
+++ b/indra/newview/lllogininstance.cpp
@@ -214,6 +214,9 @@ void MandatoryUpdateMachine::start(void)
 			case LLUpdaterService::CHECKING_FOR_UPDATE:
 				setCurrentState(new CheckingForUpdate(*this));
 				break;
+			case LLUpdaterService::TEMPORARY_ERROR:
+				setCurrentState(new Error(*this));
+				break;
 			case LLUpdaterService::DOWNLOADING:
 				setCurrentState(new WaitingForDownload(*this));
 				break;
@@ -289,6 +292,7 @@ bool MandatoryUpdateMachine::CheckingForUpdate::onEvent(LLSD const & event)
 			case LLUpdaterService::DOWNLOADING:
 				mMachine.setCurrentState(new WaitingForDownload(mMachine));
 				break;
+			case LLUpdaterService::TEMPORARY_ERROR:
 			case LLUpdaterService::UP_TO_DATE:
 			case LLUpdaterService::TERMINAL:
 			case LLUpdaterService::FAILURE:
@@ -324,7 +328,7 @@ MandatoryUpdateMachine::Error::Error(MandatoryUpdateMachine & machine):
 void MandatoryUpdateMachine::Error::enter(void)
 {
 	llinfos << "entering error" << llendl;
-	LLNotificationsUtil::add("FailedUpdateInstall", LLSD(), LLSD(), boost::bind(&MandatoryUpdateMachine::Error::onButtonClicked, this, _1, _2));
+	LLNotificationsUtil::add("FailedRequiredUpdateInstall", LLSD(), LLSD(), boost::bind(&MandatoryUpdateMachine::Error::onButtonClicked, this, _1, _2));
 }
 
 
@@ -468,7 +472,6 @@ LLLoginInstance::LLLoginInstance() :
 	mLoginModule(new LLLogin()),
 	mNotifications(NULL),
 	mLoginState("offline"),
-	mUserInteraction(true),
 	mSkipOptionalUpdate(false),
 	mAttemptComplete(false),
 	mTransferRate(0.0f),
@@ -637,64 +640,57 @@ void LLLoginInstance::handleLoginFailure(const LLSD& event)
 	LLSD response = event["data"];
 	std::string reason_response = response["reason"].asString();
 	std::string message_response = response["message"].asString();
-	if(mUserInteraction)
+	// For the cases of critical message or TOS agreement,
+	// start the TOS dialog. The dialog response will be handled
+	// by the LLLoginInstance::handleTOSResponse() callback.
+	// The callback intiates the login attempt next step, either 
+	// to reconnect or to end the attempt in failure.
+	if(reason_response == "tos")
 	{
-		// For the cases of critical message or TOS agreement,
-		// start the TOS dialog. The dialog response will be handled
-		// by the LLLoginInstance::handleTOSResponse() callback.
-		// The callback intiates the login attempt next step, either 
-		// to reconnect or to end the attempt in failure.
-		if(reason_response == "tos")
-		{
-			LLSD data(LLSD::emptyMap());
-			data["message"] = message_response;
-			data["reply_pump"] = TOS_REPLY_PUMP;
-			gViewerWindow->setShowProgress(FALSE);
-			LLFloaterReg::showInstance("message_tos", data);
-			LLEventPumps::instance().obtain(TOS_REPLY_PUMP)
-				.listen(TOS_LISTENER_NAME,
-						boost::bind(&LLLoginInstance::handleTOSResponse, 
-									this, _1, "agree_to_tos"));
-		}
-		else if(reason_response == "critical")
-		{
-			LLSD data(LLSD::emptyMap());
-			data["message"] = message_response;
-			data["reply_pump"] = TOS_REPLY_PUMP;
-			if(response.has("error_code"))
-			{
-				data["error_code"] = response["error_code"];
-			}
-			if(response.has("certificate"))
-			{
-				data["certificate"] = response["certificate"];
-			}
-			
-			gViewerWindow->setShowProgress(FALSE);
-			LLFloaterReg::showInstance("message_critical", data);
-			LLEventPumps::instance().obtain(TOS_REPLY_PUMP)
-				.listen(TOS_LISTENER_NAME,
-						boost::bind(&LLLoginInstance::handleTOSResponse, 
-									this, _1, "read_critical"));
-		}
-		else if(reason_response == "update" || gSavedSettings.getBOOL("ForceMandatoryUpdate"))
+		LLSD data(LLSD::emptyMap());
+		data["message"] = message_response;
+		data["reply_pump"] = TOS_REPLY_PUMP;
+		gViewerWindow->setShowProgress(FALSE);
+		LLFloaterReg::showInstance("message_tos", data);
+		LLEventPumps::instance().obtain(TOS_REPLY_PUMP)
+			.listen(TOS_LISTENER_NAME,
+					boost::bind(&LLLoginInstance::handleTOSResponse, 
+								this, _1, "agree_to_tos"));
+	}
+	else if(reason_response == "critical")
+	{
+		LLSD data(LLSD::emptyMap());
+		data["message"] = message_response;
+		data["reply_pump"] = TOS_REPLY_PUMP;
+		if(response.has("error_code"))
 		{
-			gSavedSettings.setBOOL("ForceMandatoryUpdate", FALSE);
-			updateApp(true, message_response);
+			data["error_code"] = response["error_code"];
 		}
-		else if(reason_response == "optional")
+		if(response.has("certificate"))
 		{
-			updateApp(false, message_response);
+			data["certificate"] = response["certificate"];
 		}
-		else
-		{	
-			attemptComplete();
-		}	
+		
+		gViewerWindow->setShowProgress(FALSE);
+		LLFloaterReg::showInstance("message_critical", data);
+		LLEventPumps::instance().obtain(TOS_REPLY_PUMP)
+			.listen(TOS_LISTENER_NAME,
+					boost::bind(&LLLoginInstance::handleTOSResponse, 
+								this, _1, "read_critical"));
 	}
-	else // no user interaction
+	else if(reason_response == "update" || gSavedSettings.getBOOL("ForceMandatoryUpdate"))
 	{
-		attemptComplete();
+		gSavedSettings.setBOOL("ForceMandatoryUpdate", FALSE);
+		updateApp(true, message_response);
 	}
+	else if(reason_response == "optional")
+	{
+		updateApp(false, message_response);
+	}
+	else
+	{	
+		attemptComplete();
+	}	
 }
 
 void LLLoginInstance::handleLoginSuccess(const LLSD& event)
diff --git a/indra/newview/lllogininstance.h b/indra/newview/lllogininstance.h
index b872d7d1b1a417b2e78025e4ba7f9aa2f34a4e6f..8b5343121907415e70fe547eafd05d32571259cd 100644
--- a/indra/newview/lllogininstance.h
+++ b/indra/newview/lllogininstance.h
@@ -61,12 +61,6 @@ class LLLoginInstance : public LLSingleton<LLLoginInstance>
 	// Only valid when authSuccess == true.
 	const F64 getLastTransferRateBPS() { return mTransferRate; }
 
-		// Set whether this class will drive user interaction.
-	// If not, login failures like 'need tos agreement' will 
-	// end the login attempt.
-	void setUserInteraction(bool state) { mUserInteraction = state; } 
-	bool getUserInteraction() { return mUserInteraction; }
-
 	// Whether to tell login to skip optional update request.
 	// False by default.
 	void setSkipOptionalUpdate(bool state) { mSkipOptionalUpdate = state; }
@@ -100,7 +94,6 @@ class LLLoginInstance : public LLSingleton<LLLoginInstance>
 	std::string mLoginState;
 	LLSD mRequestData;
 	LLSD mResponseData;
-	bool mUserInteraction; 
 	bool mSkipOptionalUpdate;
 	bool mAttemptComplete;
 	F64 mTransferRate;
diff --git a/indra/newview/llpaneleditwearable.cpp b/indra/newview/llpaneleditwearable.cpp
index 90ed8b9e587a106dca3b0330913081c165d139bf..4a74b7925c1965afd7313369e74301d356d52df3 100644
--- a/indra/newview/llpaneleditwearable.cpp
+++ b/indra/newview/llpaneleditwearable.cpp
@@ -569,6 +569,7 @@ static void update_color_swatch_ctrl(LLPanelEditWearable* self, LLPanel* panel,
 	if (color_swatch_ctrl)
 	{
 		color_swatch_ctrl->set(self->getWearable()->getClothesColor(entry->mTextureIndex));
+		color_swatch_ctrl->closeFloaterColorPicker();
 	}
 }
 
diff --git a/indra/newview/llpanellandmarks.cpp b/indra/newview/llpanellandmarks.cpp
index e8c8273a9d038e0f64f143183bf9eda2a1eb4f27..80f68621697fe9487b0529ed1cf5e53b815b795d 100644
--- a/indra/newview/llpanellandmarks.cpp
+++ b/indra/newview/llpanellandmarks.cpp
@@ -71,6 +71,7 @@ static void collapse_all_folders(LLFolderView* root_folder);
 static void expand_all_folders(LLFolderView* root_folder);
 static bool has_expanded_folders(LLFolderView* root_folder);
 static bool has_collapsed_folders(LLFolderView* root_folder);
+static void toggle_restore_menu(LLMenuGL* menu, BOOL visible, BOOL enabled);
 
 /**
  * Functor counting expanded and collapsed folders in folder view tree to know
@@ -708,6 +709,9 @@ void LLLandmarksPanel::initListCommandsHandlers()
 	mGearFolderMenu = LLUICtrlFactory::getInstance()->createFromFile<LLToggleableMenu>("menu_places_gear_folder.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance());
 	mMenuAdd = LLUICtrlFactory::getInstance()->createFromFile<LLMenuGL>("menu_place_add_button.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance());
 
+	mGearLandmarkMenu->setVisibilityChangeCallback(boost::bind(&LLLandmarksPanel::onMenuVisibilityChange, this, _1, _2));
+	mGearFolderMenu->setVisibilityChangeCallback(boost::bind(&LLLandmarksPanel::onMenuVisibilityChange, this, _1, _2));
+
 	mListCommands->childSetAction(ADD_BUTTON_NAME, boost::bind(&LLLandmarksPanel::showActionMenu, this, mMenuAdd, ADD_BUTTON_NAME));
 }
 
@@ -1079,6 +1083,60 @@ void LLLandmarksPanel::onCustomAction(const LLSD& userdata)
 	{
 		doActionOnCurSelectedLandmark(boost::bind(&LLLandmarksPanel::doCreatePick, this, _1));
 	}
+	else if ("restore" == command_name && mCurrentSelectedList)
+	{
+		mCurrentSelectedList->doToSelected(userdata);
+	}
+}
+
+void LLLandmarksPanel::onMenuVisibilityChange(LLUICtrl* ctrl, const LLSD& param)
+{
+	bool new_visibility = param["visibility"].asBoolean();
+
+	// We don't have to update items visibility if the menu is hiding.
+	if (!new_visibility) return;
+
+	BOOL are_any_items_in_trash = FALSE;
+	BOOL are_all_items_in_trash = TRUE;
+
+	LLFolderView* root_folder_view = mCurrentSelectedList ? mCurrentSelectedList->getRootFolder() : NULL;
+	if(root_folder_view)
+	{
+		const LLUUID trash_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_TRASH);
+
+		std::set<LLUUID> selected_uuids = root_folder_view->getSelectionList();
+
+		// Iterate through selected items to find out if any of these items are in Trash
+		// or all the items are in Trash category.
+		for (std::set<LLUUID>::const_iterator iter = selected_uuids.begin(); iter != selected_uuids.end(); ++iter)
+		{
+			LLFolderViewItem* item = root_folder_view->getItemByID(*iter);
+
+			// If no item is found it might be a folder id.
+			if (!item)
+			{
+				item = root_folder_view->getFolderByID(*iter);
+			}
+			if (!item) continue;
+
+			LLFolderViewEventListener* listenerp = item->getListener();
+			if(!listenerp) continue;
+
+			// Trash category itself should not be included because it can't be
+			// actually restored from trash.
+			are_all_items_in_trash &= listenerp->isItemInTrash() && *iter != trash_id;
+
+			// If there are any selected items in Trash including the Trash category itself
+			// we show "Restore Item" in context menu and hide other irrelevant items.
+			are_any_items_in_trash |= listenerp->isItemInTrash();
+		}
+	}
+
+	// Display "Restore Item" menu entry if at least one of the selected items
+	// is in Trash or the Trash category itself is among selected items.
+	// Hide other menu entries in this case.
+	// Enable this menu entry only if all selected items are in the Trash category.
+	toggle_restore_menu((LLMenuGL*)ctrl, are_any_items_in_trash, are_all_items_in_trash);
 }
 
 /*
@@ -1414,4 +1472,31 @@ static bool has_collapsed_folders(LLFolderView* root_folder)
 
 	return true;
 }
+
+// Displays "Restore Item" context menu entry while hiding
+// all other entries or vice versa.
+// Sets "Restore Item" enabled state.
+void toggle_restore_menu(LLMenuGL *menu, BOOL visible, BOOL enabled)
+{
+	if (!menu) return;
+
+	const LLView::child_list_t *list = menu->getChildList();
+	for (LLView::child_list_t::const_iterator itor = list->begin();
+		 itor != list->end();
+		 ++itor)
+	{
+		LLView *menu_item = (*itor);
+		std::string name = menu_item->getName();
+
+		if ("restore_item" == name)
+		{
+			menu_item->setVisible(visible);
+			menu_item->setEnabled(enabled);
+		}
+		else
+		{
+			menu_item->setVisible(!visible);
+		}
+	}
+}
 // EOF
diff --git a/indra/newview/llpanellandmarks.h b/indra/newview/llpanellandmarks.h
index 8dcbca04406542ff0fc9b96bb416a8641b1b9454..b2f4e92473f587a0bce100d3e0d4da6f051e1bce 100644
--- a/indra/newview/llpanellandmarks.h
+++ b/indra/newview/llpanellandmarks.h
@@ -128,6 +128,14 @@ class LLLandmarksPanel : public LLPanelPlacesTab, LLRemoteParcelInfoObserver
 	bool isActionEnabled(const LLSD& command_name) const;
 	void onCustomAction(const LLSD& command_name);
 
+	/**
+	 * Updates context menu depending on the selected items location.
+	 *
+	 * For items in Trash category the menu includes the "Restore Item"
+	 * context menu entry.
+	 */
+	void onMenuVisibilityChange(LLUICtrl* ctrl, const LLSD& param);
+
 	/**
 	 * Determines if an item can be modified via context/gear menu.
 	 *
diff --git a/indra/newview/llpanellogin.cpp b/indra/newview/llpanellogin.cpp
index c143aff2d413fdbc42436ada6ef6735cf6bea88a..8d3b1fd7a0dbe0f9ee77c81eaae98ac7ba061db5 100644
--- a/indra/newview/llpanellogin.cpp
+++ b/indra/newview/llpanellogin.cpp
@@ -35,6 +35,7 @@
 #include "llsecondlifeurls.h"
 #include "v4color.h"
 
+#include "llappviewer.h"
 #include "llbutton.h"
 #include "llcheckboxctrl.h"
 #include "llcommandhandler.h"		// for secondlife:///app/login/
@@ -859,6 +860,13 @@ void LLPanelLogin::loadLoginPage()
 	char* curl_grid = curl_escape(LLGridManager::getInstance()->getGridLabel().c_str(), 0);
 	oStr << "&grid=" << curl_grid;
 	curl_free(curl_grid);
+	
+	// add OS info
+	char * os_info = curl_escape(LLAppViewer::instance()->getOSInfo().getOSStringSimple().c_str(), 0);
+	oStr << "&os=" << os_info;
+	curl_free(os_info);
+	
+	
 	gViewerWindow->setMenuBackgroundColor(false, !LLGridManager::getInstance()->isInProductionGrid());
 	gLoginMenuBarView->setBackgroundColor(gMenuBarView->getBackgroundColor());
 	
diff --git a/indra/newview/llpanelobjectinventory.cpp b/indra/newview/llpanelobjectinventory.cpp
index 211b9cf4b1a281fa23089b9386b1825daba8a6b1..0b6267c9e6e70ba098158ec471ff185f1ad5b27f 100644
--- a/indra/newview/llpanelobjectinventory.cpp
+++ b/indra/newview/llpanelobjectinventory.cpp
@@ -766,22 +766,12 @@ BOOL LLTaskCategoryBridge::startDrag(EDragAndDropType* type, LLUUID* id) const
 		LLViewerObject* object = gObjectList.findObject(mPanel->getTaskUUID());
 		if(object)
 		{
-			const LLInventoryItem *inv = dynamic_cast<LLInventoryItem*>(object->getInventoryObject(mUUID));
-			if (inv)
+			const LLInventoryObject* cat = object->getInventoryObject(mUUID);
+			if ( (cat) && (move_inv_category_world_to_agent(mUUID, LLUUID::null, FALSE)) )
 			{
-				const LLPermissions& perm = inv->getPermissions();
-				bool can_copy = gAgent.allowOperation(PERM_COPY, perm,
-														GP_OBJECT_MANIPULATE);
-				if((can_copy && perm.allowTransferTo(gAgent.getID()))
-				   || object->permYouOwner())
-//				   || gAgent.isGodlike())
-
-				{
-					*type = LLViewerAssetType::lookupDragAndDropType(inv->getType());
-
-					*id = inv->getUUID();
-					return TRUE;
-				}
+				*type = LLViewerAssetType::lookupDragAndDropType(cat->getType());
+				*id = mUUID;
+				return TRUE;
 			}
 		}
 	}
diff --git a/indra/newview/llselectmgr.h b/indra/newview/llselectmgr.h
index 7478ed5f9a3db2d1ff850a048c2f7c632e9d8d17..65a9a493f606f5bd69e39c1c0247c6e9ee95afb7 100644
--- a/indra/newview/llselectmgr.h
+++ b/indra/newview/llselectmgr.h
@@ -235,7 +235,7 @@ class LLObjectSelection : public LLRefCount
 	{
 		bool operator()(LLSelectNode* node);
 	};
-	typedef boost::filter_iterator<is_root, list_t::iterator > valid_root_iterator;
+	typedef boost::filter_iterator<is_valid_root, list_t::iterator > valid_root_iterator;
 	valid_root_iterator valid_root_begin() { return valid_root_iterator(mList.begin(), mList.end()); }
 	valid_root_iterator valid_root_end() { return valid_root_iterator(mList.end(), mList.end()); }
 	
diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp
index 960e72ee421e9b3ac65de574fc0489ca81273c7a..8adb8c30e05410e2f6e393ca38bb9363bc89710c 100644
--- a/indra/newview/llspatialpartition.cpp
+++ b/indra/newview/llspatialpartition.cpp
@@ -2578,6 +2578,49 @@ void renderCrossHairs(LLVector3 position, F32 size, LLColor4 color)
 	gGL.end();
 }
 
+void renderUpdateType(LLDrawable* drawablep)
+{
+	LLViewerObject* vobj = drawablep->getVObj();
+	if (!vobj || OUT_UNKNOWN == vobj->getLastUpdateType())
+	{
+		return;
+	}
+	LLGLEnable blend(GL_BLEND);
+	switch (vobj->getLastUpdateType())
+	{
+	case OUT_FULL:
+		glColor4f(0,1,0,0.5f);
+		break;
+	case OUT_TERSE_IMPROVED:
+		glColor4f(0,1,1,0.5f);
+		break;
+	case OUT_FULL_COMPRESSED:
+		if (vobj->getLastUpdateCached())
+		{
+			glColor4f(1,0,0,0.5f);
+		}
+		else
+		{
+			glColor4f(1,1,0,0.5f);
+		}
+		break;
+	case OUT_FULL_CACHED:
+		glColor4f(0,0,1,0.5f);
+		break;
+	default:
+		llwarns << "Unknown update_type " << vobj->getLastUpdateType() << llendl;
+		break;
+	};
+	S32 num_faces = drawablep->getNumFaces();
+	if (num_faces)
+	{
+		for (S32 i = 0; i < num_faces; ++i)
+		{
+			pushVerts(drawablep->getFace(i), LLVertexBuffer::MAP_VERTEX);
+		}
+	}
+}
+
 
 void renderBoundingBox(LLDrawable* drawable, BOOL set_color = TRUE)
 {
@@ -3018,6 +3061,10 @@ class LLOctreeRenderNonOccluded : public LLOctreeTraveler<LLDrawable>
 			{
 				renderRaycast(drawable);
 			}
+			if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_UPDATE_TYPE))
+			{
+				renderUpdateType(drawable);
+			}
 
 			LLVOAvatar* avatar = dynamic_cast<LLVOAvatar*>(drawable->getVObj().get());
 			
@@ -3180,6 +3227,7 @@ void LLSpatialPartition::renderDebug()
 									  LLPipeline::RENDER_DEBUG_OCCLUSION |
 									  LLPipeline::RENDER_DEBUG_LIGHTS |
 									  LLPipeline::RENDER_DEBUG_BATCH_SIZE |
+									  LLPipeline::RENDER_DEBUG_UPDATE_TYPE |
 									  LLPipeline::RENDER_DEBUG_BBOXES |
 									  LLPipeline::RENDER_DEBUG_POINTS |
 									  LLPipeline::RENDER_DEBUG_TEXTURE_PRIORITY |
diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp
index 5617eea4c339a3763c1ad151c3ca47552307e488..0eac7d5e2a7464127611cdf6225ba387b32fb14a 100644
--- a/indra/newview/llstartup.cpp
+++ b/indra/newview/llstartup.cpp
@@ -981,7 +981,6 @@ bool idle_startup()
 			login->setSkipOptionalUpdate(true);
 		}
 
-		login->setUserInteraction(show_connect_box);
 		login->setSerialNumber(LLAppViewer::instance()->getSerialNumber());
 		login->setLastExecEvent(gLastExecEvent);
 		login->setUpdaterLauncher(boost::bind(&LLAppViewer::launchUpdater, LLAppViewer::instance()));
diff --git a/indra/newview/lltexturecache.cpp b/indra/newview/lltexturecache.cpp
index 6a213309a0bff583ceb3b205df5fd4189ee01b40..92080d1fd75757d37706711dd6153628aabc8951 100644
--- a/indra/newview/lltexturecache.cpp
+++ b/indra/newview/lltexturecache.cpp
@@ -1858,8 +1858,22 @@ void LLTextureCache::removeCachedTexture(const LLUUID& id)
 //called after mHeaderMutex is locked.
 void LLTextureCache::removeEntry(S32 idx, Entry& entry, std::string& filename)
 {
+ 	bool file_maybe_exists = true;	// Always attempt to remove when idx is invalid.
+
 	if(idx >= 0) //valid entry
 	{
+		if (entry.mBodySize == 0)	// Always attempt to remove when mBodySize > 0.
+		{
+		  if (LLAPRFile::isExist(filename, getLocalAPRFilePool()))		// Sanity check. Shouldn't exist when body size is 0.
+		  {
+			  LL_WARNS("TextureCache") << "Entry has body size of zero but file " << filename << " exists. Deleting this file, too." << LL_ENDL;
+		  }
+		  else
+		  {
+			  file_maybe_exists = false;
+		  }
+		}
+
 		entry.mImageSize = -1;
 		entry.mBodySize = 0;
 		mHeaderIDMap.erase(entry.mID);
@@ -1869,7 +1883,10 @@ void LLTextureCache::removeEntry(S32 idx, Entry& entry, std::string& filename)
 		mFreeList.insert(idx);	
 	}
 
-	LLAPRFile::remove(filename, getLocalAPRFilePool());		
+	if (file_maybe_exists)
+	{
+		LLAPRFile::remove(filename, getLocalAPRFilePool());		
+	}
 }
 
 bool LLTextureCache::removeFromCache(const LLUUID& id)
diff --git a/indra/newview/llviewerinventory.cpp b/indra/newview/llviewerinventory.cpp
index b3642a2c1e295f1e1580402788dc921a2a27f1e2..cc851e676b7035e3248e3d3684bedcea64e95775 100644
--- a/indra/newview/llviewerinventory.cpp
+++ b/indra/newview/llviewerinventory.cpp
@@ -366,11 +366,11 @@ void LLViewerInventoryItem::fetchFromServer(void) const
 		{
 		  if(gAgent.getID() != mPermissions.getOwner())
 		    {
-		      url = region->getCapability("FetchLib");
+		      url = region->getCapability("FetchLib2");
 		    }
 		  else
 		    {	
-		      url = region->getCapability("FetchInventory");
+		      url = region->getCapability("FetchInventory2");
 		    }
 		}
 		else
@@ -648,7 +648,7 @@ bool LLViewerInventoryCategory::fetch()
 		std::string url;
 		if (gAgent.getRegion())
 		{
-			url = gAgent.getRegion()->getCapability("WebFetchInventoryDescendents");
+			url = gAgent.getRegion()->getCapability("FetchInventoryDescendents2");
 		}
 		else
 		{
@@ -660,7 +660,7 @@ bool LLViewerInventoryCategory::fetch()
 		}
 		else
 		{	//Deprecated, but if we don't have a capability, use the old system.
-			llinfos << "WebFetchInventoryDescendents capability not found.  Using deprecated UDP message." << llendl;
+			llinfos << "FetchInventoryDescendents2 capability not found.  Using deprecated UDP message." << llendl;
 			LLMessageSystem* msg = gMessageSystem;
 			msg->newMessage("FetchInventoryDescendents");
 			msg->nextBlock("AgentData");
diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp
index 8a0d0a6623b8138b67227c8225781656979a17be..d3b6dcd86f2f937121d61890f9c997ae0869fd08 100644
--- a/indra/newview/llviewermedia.cpp
+++ b/indra/newview/llviewermedia.cpp
@@ -54,7 +54,6 @@
 #include "llfilepicker.h"
 #include "llnotifications.h"
 
-#include "lldiriterator.h"
 #include "llevent.h"		// LLSimpleListener
 #include "llnotificationsutil.h"
 #include "lluuid.h"
@@ -1116,8 +1115,7 @@ void LLViewerMedia::clearAllCookies()
 	}
 	
 	// the hard part: iterate over all user directories and delete the cookie file from each one
-	LLDirIterator dir_iter(base_dir, "*_*");
-	while (dir_iter.next(filename))
+	while(gDirUtilp->getNextFileInDir(base_dir, "*_*", filename))
 	{
 		target = base_dir;
 		target += filename;
diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp
index 60b118284b18cc010bc6ad138d0e8e1885fd8494..7cc04e0338a0e81e8be7c2c3831531e4b471dfed 100644
--- a/indra/newview/llviewermenu.cpp
+++ b/indra/newview/llviewermenu.cpp
@@ -906,6 +906,10 @@ U32 info_display_from_string(std::string info_display)
 	{
 		return LLPipeline::RENDER_DEBUG_BATCH_SIZE;
 	}
+	else if ("update type" == info_display)
+	{
+		return LLPipeline::RENDER_DEBUG_UPDATE_TYPE;
+	}
 	else if ("texture anim" == info_display)
 	{
 		return LLPipeline::RENDER_DEBUG_TEXTURE_ANIM;
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp
index 7dc5d96689d4449471ee7a736ca676137f444bf4..6fc85a39449ac2b44bc13747dd1106802b18bc4d 100644
--- a/indra/newview/llviewermessage.cpp
+++ b/indra/newview/llviewermessage.cpp
@@ -171,31 +171,6 @@ const BOOL SCRIPT_QUESTION_IS_CAUTION[SCRIPT_PERMISSION_EOF] =
 	FALSE	// ControlYourCamera
 };
 
-// Extract channel and version from a string like "SL Web Viewer Beta 10.11.29.215604".
-// (channel: "SL Web Viewer Beta", version: "10.11.29.215604")
-static bool parse_version_info(const std::string& version_info, std::string& channel, std::string& ver)
-{
-	size_t last_space = version_info.rfind(" ");
-	channel = version_info;
-
-	if (last_space != std::string::npos)
-	{
-		try
-		{
-			ver = version_info.substr(last_space + 1);
-			channel.replace(last_space, ver.length() + 1, ""); // strip version
-		}
-		catch (std::out_of_range)
-		{
-			return false;
-		}
-
-		return true;
-	}
-
-	return false;
-}
-
 bool friendship_offer_callback(const LLSD& notification, const LLSD& response)
 {
 	S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
@@ -3848,31 +3823,6 @@ void process_agent_movement_complete(LLMessageSystem* msg, void**)
 		return;
 	}
 
-	if (!gLastVersionChannel.empty())
-	{
-		std::string url = regionp->getCapability("ServerReleaseNotes");
-		if (url.empty())
-		{
-			// The capability hasn't arrived yet or is not supported,
-			// fall back to parsing server version channel.
-			std::string channel, ver;
-			if (!parse_version_info(version_channel, channel, ver))
-			{
-				llwarns << "Failed to parse server version channel (" << version_channel << ")" << llendl;
-			}
-
-			url = gSavedSettings.getString("ReleaseNotesURL");
-			LLSD args;
-			args["CHANNEL"] = LLWeb::escapeURL(channel);
-			args["VERSION"] = LLWeb::escapeURL(ver);
-			LLStringUtil::format(url, args);
-		}
-
-		LLSD args;
-		args["URL"] = url;
-		LLNotificationsUtil::add("ServerVersionChanged", args);
-	}
-
 	gLastVersionChannel = version_channel;
 }
 
diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index 18d6e4c8c87c3c79e9c1ea1994965aabff37770d..48794c4c9d24b2a917017465aa439e83608f8255 100644
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -234,7 +234,9 @@ LLViewerObject::LLViewerObject(const LLUUID &id, const LLPCode pcode, LLViewerRe
 	mState(0),
 	mMedia(NULL),
 	mClickAction(0),
-	mAttachmentItemID(LLUUID::null)
+	mAttachmentItemID(LLUUID::null),
+	mLastUpdateType(OUT_UNKNOWN),
+	mLastUpdateCached(FALSE)
 {
 	if (!is_global)
 	{
@@ -5403,6 +5405,26 @@ void LLViewerObject::setAttachmentItemID(const LLUUID &id)
 	mAttachmentItemID = id;
 }
 
+EObjectUpdateType LLViewerObject::getLastUpdateType() const
+{
+	return mLastUpdateType;
+}
+
+void LLViewerObject::setLastUpdateType(EObjectUpdateType last_update_type)
+{
+	mLastUpdateType = last_update_type;
+}
+
+BOOL LLViewerObject::getLastUpdateCached() const
+{
+	return mLastUpdateCached;
+}
+
+void LLViewerObject::setLastUpdateCached(BOOL last_update_cached)
+{
+	mLastUpdateCached = last_update_cached;
+}
+
 const LLUUID &LLViewerObject::extractAttachmentItemID()
 {
 	LLUUID item_id = LLUUID::null;
diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h
index 5c1a34d5555c86c74dbed636a71b8cb02378dd6a..614a5e59fa20d586b083d23560626f1e9fa66c58 100644
--- a/indra/newview/llviewerobject.h
+++ b/indra/newview/llviewerobject.h
@@ -77,6 +77,7 @@ typedef enum e_object_update_type
 	OUT_TERSE_IMPROVED,
 	OUT_FULL_COMPRESSED,
 	OUT_FULL_CACHED,
+	OUT_UNKNOWN,
 } EObjectUpdateType;
 
 
@@ -693,8 +694,15 @@ class LLViewerObject : public LLPrimitive, public LLRefCount, public LLGLUpdate
 	const LLUUID &getAttachmentItemID() const;
 	void setAttachmentItemID(const LLUUID &id);
 	const LLUUID &extractAttachmentItemID(); // find&set the inventory item ID of the attached object
+	EObjectUpdateType getLastUpdateType() const;
+	void setLastUpdateType(EObjectUpdateType last_update_type);
+	BOOL getLastUpdateCached() const;
+	void setLastUpdateCached(BOOL last_update_cached);
+
 private:
 	LLUUID mAttachmentItemID; // ItemID of the associated object is in user inventory.
+	EObjectUpdateType	mLastUpdateType;
+	BOOL	mLastUpdateCached;
 };
 
 ///////////////////
diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp
index f5a32438cfef2effc43e3372208c528b924b9e0a..5849ab4307c016364537d3bac79839daf0f7f768 100644
--- a/indra/newview/llviewerobjectlist.cpp
+++ b/indra/newview/llviewerobjectlist.cpp
@@ -56,6 +56,7 @@
 #include "llresmgr.h"
 #include "llviewerregion.h"
 #include "llviewerstats.h"
+#include "llviewerstatsrecorder.h"
 #include "llvoavatarself.h"
 #include "lltoolmgr.h"
 #include "lltoolpie.h"
@@ -302,8 +303,10 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys,
 	// have to transform to absolute coordinates.
 	num_objects = mesgsys->getNumberOfBlocksFast(_PREHASH_ObjectData);
 
+	// I don't think this case is ever hit.  TODO* Test this.
 	if (!cached && !compressed && update_type != OUT_FULL)
 	{
+		//llinfos << "TEST: !cached && !compressed && update_type != OUT_FULL" << llendl;
 		gTerseObjectUpdates += num_objects;
 		S32 size;
 		if (mesgsys->getReceiveCompressedSize())
@@ -314,7 +317,7 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys,
 		{
 			size = mesgsys->getReceiveSize();
 		}
-		// llinfos << "Received terse " << num_objects << " in " << size << " byte (" << size/num_objects << ")" << llendl;
+		//llinfos << "Received terse " << num_objects << " in " << size << " byte (" << size/num_objects << ")" << llendl;
 	}
 	else
 	{
@@ -345,9 +348,14 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys,
 	U8 compressed_dpbuffer[2048];
 	LLDataPackerBinaryBuffer compressed_dp(compressed_dpbuffer, 2048);
 	LLDataPacker *cached_dpp = NULL;
-	
+
+#if LL_RECORD_VIEWER_STATS
+	LLViewerStatsRecorder::instance()->beginObjectUpdateEvents(regionp);
+#endif
+
 	for (i = 0; i < num_objects; i++)
 	{
+		// timer is unused?
 		LLTimer update_timer;
 		BOOL justCreated = FALSE;
 
@@ -359,9 +367,11 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys,
 			mesgsys->getU32Fast(_PREHASH_ObjectData, _PREHASH_CRC, crc, i);
 		
 			// Lookup data packer and add this id to cache miss lists if necessary.
-			cached_dpp = regionp->getDP(id, crc);
+			U8 cache_miss_type = LLViewerRegion::CACHE_MISS_TYPE_NONE;
+			cached_dpp = regionp->getDP(id, crc, cache_miss_type);
 			if (cached_dpp)
 			{
+				// Cache Hit.
 				cached_dpp->reset();
 				cached_dpp->unpackUUID(fullid, "ID");
 				cached_dpp->unpackU32(local_id, "LocalID");
@@ -369,6 +379,11 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys,
 			}
 			else
 			{
+				// Cache Miss.
+				#if LL_RECORD_VIEWER_STATS
+				LLViewerStatsRecorder::instance()->recordCacheMissEvent(id, update_type, cache_miss_type);
+				#endif
+
 				continue; // no data packer, skip this object
 			}
 		}
@@ -380,13 +395,15 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys,
 			compressed_dp.reset();
 
 			U32 flags = 0;
-			if (update_type != OUT_TERSE_IMPROVED)
+			if (update_type != OUT_TERSE_IMPROVED) // OUT_FULL_COMPRESSED only?
 			{
 				mesgsys->getU32Fast(_PREHASH_ObjectData, _PREHASH_UpdateFlags, flags, i);
 			}
 			
+			// I don't think we ever use this flag from the server.  DK 2010/12/09
 			if (flags & FLAGS_ZLIB_COMPRESSED)
 			{
+				//llinfos << "TEST: flags & FLAGS_ZLIB_COMPRESSED" << llendl;
 				compressed_length = mesgsys->getSizeFast(_PREHASH_ObjectData, i, _PREHASH_Data);
 				mesgsys->getBinaryDataFast(_PREHASH_ObjectData, _PREHASH_Data, compbuffer, 0, i);
 				uncompressed_length = 2048;
@@ -402,7 +419,7 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys,
 			}
 
 
-			if (update_type != OUT_TERSE_IMPROVED)
+			if (update_type != OUT_TERSE_IMPROVED) // OUT_FULL_COMPRESSED only?
 			{
 				compressed_dp.unpackUUID(fullid, "ID");
 				compressed_dp.unpackU32(local_id, "LocalID");
@@ -422,7 +439,7 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys,
 				}
 			}
 		}
-		else if (update_type != OUT_FULL)
+		else if (update_type != OUT_FULL) // !compressed, !OUT_FULL ==> OUT_FULL_CACHED only?
 		{
 			mesgsys->getU32Fast(_PREHASH_ObjectData, _PREHASH_ID, local_id, i);
 			getUUIDFromLocal(fullid,
@@ -435,7 +452,7 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys,
 				mNumUnknownUpdates++;
 			}
 		}
-		else
+		else // OUT_FULL only?
 		{
 			mesgsys->getUUIDFast(_PREHASH_ObjectData, _PREHASH_FullID, fullid, i);
 			mesgsys->getU32Fast(_PREHASH_ObjectData, _PREHASH_ID, local_id, i);
@@ -467,12 +484,12 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys,
 							gMessageSystem->getSenderPort());
 			
 			if (objectp->mLocalID != local_id)
-			{    // Update local ID in object with the one sent from the region
+			{	// Update local ID in object with the one sent from the region
 				objectp->mLocalID = local_id;
 			}
 			
 			if (objectp->getRegion() != regionp)
-			{    // Object changed region, so update it
+			{	// Object changed region, so update it
 				objectp->updateRegion(regionp); // for LLVOAvatar
 			}
 		}
@@ -483,18 +500,24 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys,
 			{
 				if (update_type == OUT_TERSE_IMPROVED)
 				{
-					// llinfos << "terse update for an unknown object:" << fullid << llendl;
+					// llinfos << "terse update for an unknown object (compressed):" << fullid << llendl;
+					#if LL_RECORD_VIEWER_STATS
+					LLViewerStatsRecorder::instance()->recordObjectUpdateFailure(local_id, update_type);
+					#endif
 					continue;
 				}
 			}
-			else if (cached)
+			else if (cached) // Cache hit only?
 			{
 			}
 			else
 			{
 				if (update_type != OUT_FULL)
 				{
-					// llinfos << "terse update for an unknown object:" << fullid << llendl;
+					//llinfos << "terse update for an unknown object:" << fullid << llendl;
+					#if LL_RECORD_VIEWER_STATS
+					LLViewerStatsRecorder::instance()->recordObjectUpdateFailure(local_id, update_type);
+					#endif
 					continue;
 				}
 
@@ -504,7 +527,10 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys,
 			if (mDeadObjects.find(fullid) != mDeadObjects.end())
 			{
 				mNumDeadObjectUpdates++;
-				// llinfos << "update for a dead object:" << fullid << llendl;
+				//llinfos << "update for a dead object:" << fullid << llendl;
+				#if LL_RECORD_VIEWER_STATS
+				LLViewerStatsRecorder::instance()->recordObjectUpdateFailure(local_id, update_type);
+				#endif
 				continue;
 			}
 #endif
@@ -512,6 +538,10 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys,
 			objectp = createObject(pcode, regionp, fullid, local_id, gMessageSystem->getSender());
 			if (!objectp)
 			{
+				llinfos << "createObject failure for object: " << fullid << llendl;
+				#if LL_RECORD_VIEWER_STATS
+				LLViewerStatsRecorder::instance()->recordObjectUpdateFailure(local_id, update_type);
+				#endif
 				continue;
 			}
 			justCreated = TRUE;
@@ -524,19 +554,26 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys,
 			llwarns << "Dead object " << objectp->mID << " in UUID map 1!" << llendl;
 		}
 
+		bool bCached = false;
 		if (compressed)
 		{
-			if (update_type != OUT_TERSE_IMPROVED)
+			if (update_type != OUT_TERSE_IMPROVED) // OUT_FULL_COMPRESSED only?
 			{
 				objectp->mLocalID = local_id;
 			}
 			processUpdateCore(objectp, user_data, i, update_type, &compressed_dp, justCreated);
-			if (update_type != OUT_TERSE_IMPROVED)
+			if (update_type != OUT_TERSE_IMPROVED) // OUT_FULL_COMPRESSED only?
 			{
+				bCached = true;
+				#if LL_RECORD_VIEWER_STATS
+				LLViewerRegion::eCacheUpdateResult result = objectp->mRegionp->cacheFullUpdate(objectp, compressed_dp);
+				LLViewerStatsRecorder::instance()->recordCacheFullUpdate(local_id, update_type, result, objectp);
+				#else
 				objectp->mRegionp->cacheFullUpdate(objectp, compressed_dp);
+				#endif
 			}
 		}
-		else if (cached)
+		else if (cached) // Cache hit only?
 		{
 			objectp->mLocalID = local_id;
 			processUpdateCore(objectp, user_data, i, update_type, cached_dpp, justCreated);
@@ -549,8 +586,17 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys,
 			}
 			processUpdateCore(objectp, user_data, i, update_type, NULL, justCreated);
 		}
+		#if LL_RECORD_VIEWER_STATS
+		LLViewerStatsRecorder::instance()->recordObjectUpdateEvent(local_id, update_type, objectp);
+		#endif
+		objectp->setLastUpdateType(update_type);
+		objectp->setLastUpdateCached(bCached);
 	}
 
+#if LL_RECORD_VIEWER_STATS
+	LLViewerStatsRecorder::instance()->endObjectUpdateEvents();
+#endif
+
 	LLVOAvatar::cullAvatarsByPixelArea();
 }
 
@@ -681,12 +727,12 @@ void LLViewerObjectList::update(LLAgent &agent, LLWorld &world)
 
 	// update global timer
 	F32 last_time = gFrameTimeSeconds;
-	U64 time = totalTime();                 // this will become the new gFrameTime when the update is done
+	U64 time = totalTime();				 // this will become the new gFrameTime when the update is done
 	// Time _can_ go backwards, for example if the user changes the system clock.
 	// It doesn't cause any fatal problems (just some oddness with stats), so we shouldn't assert here.
 //	llassert(time > gFrameTime);
 	F64 time_diff = U64_to_F64(time - gFrameTime)/(F64)SEC_TO_MICROSEC;
-	gFrameTime    = time;
+	gFrameTime	= time;
 	F64 time_since_start = U64_to_F64(gFrameTime - gStartTime)/(F64)SEC_TO_MICROSEC;
 	gFrameTimeSeconds = (F32)time_since_start;
 
@@ -788,7 +834,7 @@ void LLViewerObjectList::update(LLAgent &agent, LLWorld &world)
 		{
 			std::string id_str;
 			objectp->mID.toString(id_str);
-			std::string tmpstr = std::string("Par:    ") + id_str;
+			std::string tmpstr = std::string("Par:	") + id_str;
 			addDebugBeacon(objectp->getPositionAgent(),
 							tmpstr,
 							LLColor4(1.f,0.f,0.f,1.f),
@@ -808,12 +854,12 @@ void LLViewerObjectList::update(LLAgent &agent, LLWorld &world)
 			std::string tmpstr;
 			if (objectp->getParent())
 			{
-				tmpstr = std::string("ChP:    ") + id_str;
+				tmpstr = std::string("ChP:	") + id_str;
 				text_color = LLColor4(0.f, 1.f, 0.f, 1.f);
 			}
 			else
 			{
-				tmpstr = std::string("ChNoP:    ") + id_str;
+				tmpstr = std::string("ChNoP:	") + id_str;
 				text_color = LLColor4(1.f, 0.f, 0.f, 1.f);
 			}
 			id = sIndexAndLocalIDToUUID[oi.mParentInfo];
@@ -1519,8 +1565,8 @@ void LLViewerObjectList::findOrphans(LLViewerObject* objectp, U32 ip, U32 port)
 			llinfos << "Agent: " << objectp->getPositionAgent() << llendl;
 			addDebugBeacon(objectp->getPositionAgent(),"");
 #endif
-            gPipeline.markMoved(objectp->mDrawable);                
-            objectp->setChanged(LLXform::MOVED | LLXform::SILHOUETTE);
+			gPipeline.markMoved(objectp->mDrawable);				
+			objectp->setChanged(LLXform::MOVED | LLXform::SILHOUETTE);
 
 			// Flag the object as no longer orphaned
 			childp->mOrphaned = FALSE;
diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index 2a67d12b648d6ae985003f437183ae75b4632ddb..c7649001c5479563dac58a045907b465917fbc55 100644
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -59,6 +59,7 @@
 #include "llurldispatcher.h"
 #include "llviewerobjectlist.h"
 #include "llviewerparceloverlay.h"
+#include "llviewerstatsrecorder.h"
 #include "llvlmanager.h"
 #include "llvlcomposition.h"
 #include "llvocache.h"
@@ -1032,7 +1033,7 @@ void LLViewerRegion::getInfo(LLSD& info)
 	info["Region"]["Handle"]["y"] = (LLSD::Integer)y;
 }
 
-void LLViewerRegion::cacheFullUpdate(LLViewerObject* objectp, LLDataPackerBinaryBuffer &dp)
+LLViewerRegion::eCacheUpdateResult LLViewerRegion::cacheFullUpdate(LLViewerObject* objectp, LLDataPackerBinaryBuffer &dp)
 {
 	U32 local_id = objectp->getLocalID();
 	U32 crc = objectp->getCRC();
@@ -1046,35 +1047,36 @@ void LLViewerRegion::cacheFullUpdate(LLViewerObject* objectp, LLDataPackerBinary
 		{
 			// Record a hit
 			entry->recordDupe();
+			return CACHE_UPDATE_DUPE;
 		}
-		else
-		{
-			// Update the cache entry
-			mCacheMap.erase(local_id);
-			delete entry;
-			entry = new LLVOCacheEntry(local_id, crc, dp);
-			mCacheMap[local_id] = entry;
-		}
-	}
-	else
-	{
-		// we haven't seen this object before
 
-		// Create new entry and add to map
-		if (mCacheMap.size() > MAX_OBJECT_CACHE_ENTRIES)
-		{
-			mCacheMap.erase(mCacheMap.begin());
-		}
+		// Update the cache entry
+		mCacheMap.erase(local_id);
+		delete entry;
 		entry = new LLVOCacheEntry(local_id, crc, dp);
-
 		mCacheMap[local_id] = entry;
+		return CACHE_UPDATE_CHANGED;
 	}
-	return ;
+
+	// we haven't seen this object before
+
+	// Create new entry and add to map
+	eCacheUpdateResult result = CACHE_UPDATE_ADDED;
+	if (mCacheMap.size() > MAX_OBJECT_CACHE_ENTRIES)
+	{
+		mCacheMap.erase(mCacheMap.begin());
+		result = CACHE_UPDATE_REPLACED;
+		
+	}
+	entry = new LLVOCacheEntry(local_id, crc, dp);
+
+	mCacheMap[local_id] = entry;
+	return result;
 }
 
 // Get data packer for this object, if we have cached data
 // AND the CRC matches. JC
-LLDataPacker *LLViewerRegion::getDP(U32 local_id, U32 crc)
+LLDataPacker *LLViewerRegion::getDP(U32 local_id, U32 crc, U8 &cache_miss_type)
 {
 	llassert(mCacheLoaded);
 
@@ -1087,17 +1089,20 @@ LLDataPacker *LLViewerRegion::getDP(U32 local_id, U32 crc)
 		{
 			// Record a hit
 			entry->recordHit();
+			cache_miss_type = CACHE_MISS_TYPE_NONE;
 			return entry->getDP(crc);
 		}
 		else
 		{
 			// llinfos << "CRC miss for " << local_id << llendl;
+			cache_miss_type = CACHE_MISS_TYPE_CRC;
 			mCacheMissCRC.put(local_id);
 		}
 	}
 	else
 	{
 		// llinfos << "Cache miss for " << local_id << llendl;
+		cache_miss_type = CACHE_MISS_TYPE_FULL;
 		mCacheMissFull.put(local_id);
 	}
 	return NULL;
@@ -1119,9 +1124,6 @@ void LLViewerRegion::requestCacheMisses()
 	S32 blocks = 0;
 	S32 i;
 
-	const U8 CACHE_MISS_TYPE_FULL = 0;
-	const U8 CACHE_MISS_TYPE_CRC  = 1;
-
 	// Send full cache miss updates.  For these, we KNOW we don't
 	// have a viewer object.
 	for (i = 0; i < full_count; i++)
@@ -1184,6 +1186,11 @@ void LLViewerRegion::requestCacheMisses()
 
 	mCacheDirty = TRUE ;
 	// llinfos << "KILLDEBUG Sent cache miss full " << full_count << " crc " << crc_count << llendl;
+	#if LL_RECORD_VIEWER_STATS
+	LLViewerStatsRecorder::instance()->beginObjectUpdateEvents(this);
+	LLViewerStatsRecorder::instance()->recordRequestCacheMissesEvent(full_count + crc_count);
+	LLViewerStatsRecorder::instance()->endObjectUpdateEvents();
+	#endif
 }
 
 void LLViewerRegion::dumpCache()
@@ -1372,11 +1379,12 @@ void LLViewerRegion::setSeedCapability(const std::string& url)
 	capabilityNames.append("DispatchRegionInfo");
 	capabilityNames.append("EstateChangeInfo");
 	capabilityNames.append("EventQueueGet");
-	capabilityNames.append("FetchInventory");
 	capabilityNames.append("ObjectMedia");
 	capabilityNames.append("ObjectMediaNavigate");
-	capabilityNames.append("FetchLib");
-	capabilityNames.append("FetchLibDescendents");
+	capabilityNames.append("FetchLib2");
+	capabilityNames.append("FetchLibDescendents2");
+	capabilityNames.append("FetchInventory2");
+	capabilityNames.append("FetchInventoryDescendents2");
 	capabilityNames.append("GetDisplayNames");
 	capabilityNames.append("GetTexture");
 	capabilityNames.append("GroupProposalBallot");
@@ -1416,7 +1424,6 @@ void LLViewerRegion::setSeedCapability(const std::string& url)
 	capabilityNames.append("ViewerMetrics");
 	capabilityNames.append("ViewerStartAuction");
 	capabilityNames.append("ViewerStats");
-	capabilityNames.append("WebFetchInventoryDescendents");
 	// Please add new capabilities alphabetically to reduce
 	// merge conflicts.
 
diff --git a/indra/newview/llviewerregion.h b/indra/newview/llviewerregion.h
index 3d3f1d62a6678ea280c0d70404ece557a3ef972e..7c6559203e5fa7606685f67a5cc8b328e1ffdf4a 100644
--- a/indra/newview/llviewerregion.h
+++ b/indra/newview/llviewerregion.h
@@ -51,7 +51,7 @@
 // Surface id's
 #define LAND  1
 #define WATER 2
-const U32	MAX_OBJECT_CACHE_ENTRIES = 10000;
+const U32	MAX_OBJECT_CACHE_ENTRIES = 50000;
 
 
 class LLEventPoll;
@@ -275,9 +275,24 @@ class LLViewerRegion: public LLCapabilityProvider // implements this interface
 
 	void getInfo(LLSD& info);
 
+	typedef enum
+	{
+		CACHE_MISS_TYPE_FULL = 0,
+		CACHE_MISS_TYPE_CRC,
+		CACHE_MISS_TYPE_NONE
+	} eCacheMissType;
+
+	typedef enum
+	{
+		CACHE_UPDATE_DUPE = 0,
+		CACHE_UPDATE_CHANGED,
+		CACHE_UPDATE_ADDED,
+		CACHE_UPDATE_REPLACED
+	} eCacheUpdateResult;
+
 	// handle a full update message
-	void cacheFullUpdate(LLViewerObject* objectp, LLDataPackerBinaryBuffer &dp);
-	LLDataPacker *getDP(U32 local_id, U32 crc);
+	eCacheUpdateResult cacheFullUpdate(LLViewerObject* objectp, LLDataPackerBinaryBuffer &dp);
+	LLDataPacker *getDP(U32 local_id, U32 crc, U8 &cache_miss_type);
 	void requestCacheMisses();
 	void addCacheMissFull(const U32 local_id);
 
diff --git a/indra/newview/llviewerstatsrecorder.cpp b/indra/newview/llviewerstatsrecorder.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..e9d21b4848e4c6d8069df681eaf66cee337a96aa
--- /dev/null
+++ b/indra/newview/llviewerstatsrecorder.cpp
@@ -0,0 +1,258 @@
+/**
+ * @file llviewerstatsrecorder.cpp
+ * @brief record info about viewer events to a metrics log file
+ *
+ * $LicenseInfo:firstyear=2010&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 "llviewerprecompiledheaders.h"
+#include "llviewerstatsrecorder.h"
+
+#if LL_RECORD_VIEWER_STATS
+
+#include "llfile.h"
+#include "llviewerregion.h"
+#include "llviewerobject.h"
+
+
+// To do - something using region name or global position
+#if LL_WINDOWS
+	static const std::string STATS_FILE_NAME("C:\\ViewerObjectCacheStats.csv");
+#else
+	static const std::string STATS_FILE_NAME("/tmp/viewerstats.csv");
+#endif
+
+LLViewerStatsRecorder* LLViewerStatsRecorder::sInstance = NULL;
+LLViewerStatsRecorder::LLViewerStatsRecorder() :
+	mObjectCacheFile(NULL),
+	mTimer(),
+	mRegionp(NULL),
+	mStartTime(0.f),
+	mProcessingTime(0.f)
+{
+	if (NULL != sInstance)
+	{
+		llerrs << "Attempted to create multiple instances of LLViewerStatsRecorder!" << llendl;
+	}
+	sInstance = this;
+	clearStats();
+}
+
+LLViewerStatsRecorder::~LLViewerStatsRecorder()
+{
+	if (mObjectCacheFile != NULL)
+	{
+		LLFile::close(mObjectCacheFile);
+		mObjectCacheFile = NULL;
+	}
+}
+
+// static
+void LLViewerStatsRecorder::initClass()
+{
+	sInstance = new LLViewerStatsRecorder();
+}
+
+// static
+void LLViewerStatsRecorder::cleanupClass()
+{
+	delete sInstance;
+	sInstance = NULL;
+}
+
+
+void LLViewerStatsRecorder::initStatsRecorder(LLViewerRegion *regionp)
+{
+	if (mObjectCacheFile == NULL)
+	{
+		mStartTime = LLTimer::getTotalTime();
+		mObjectCacheFile = LLFile::fopen(STATS_FILE_NAME, "wb");
+		if (mObjectCacheFile)
+		{	// Write column headers
+			std::ostringstream data_msg;
+			data_msg << "EventTime, "
+				<< "ProcessingTime, "
+				<< "CacheHits, "
+				<< "CacheFullMisses, "
+				<< "CacheCrcMisses, "
+				<< "FullUpdates, "
+				<< "TerseUpdates, "
+				<< "CacheMissRequests, "
+				<< "CacheMissResponses, "
+				<< "CacheUpdateDupes, "
+				<< "CacheUpdateChanges, "
+				<< "CacheUpdateAdds, "
+				<< "CacheUpdateReplacements, "
+				<< "UpdateFailures"
+				<< "\n";
+
+			fwrite(data_msg.str().c_str(), 1, data_msg.str().size(), mObjectCacheFile );
+		}
+	}
+}
+
+void LLViewerStatsRecorder::beginObjectUpdateEvents(LLViewerRegion *regionp)
+{
+	initStatsRecorder(regionp);
+	mRegionp = regionp;
+	mProcessingTime = LLTimer::getTotalTime();
+	clearStats();
+}
+
+void LLViewerStatsRecorder::clearStats()
+{
+	mObjectCacheHitCount = 0;
+	mObjectCacheMissFullCount = 0;
+	mObjectCacheMissCrcCount = 0;
+	mObjectFullUpdates = 0;
+	mObjectTerseUpdates = 0;
+	mObjectCacheMissRequests = 0;
+	mObjectCacheMissResponses = 0;
+	mObjectCacheUpdateDupes = 0;
+	mObjectCacheUpdateChanges = 0;
+	mObjectCacheUpdateAdds = 0;
+	mObjectCacheUpdateReplacements = 0;
+	mObjectUpdateFailures = 0;
+}
+
+
+void LLViewerStatsRecorder::recordObjectUpdateFailure(U32 local_id, const EObjectUpdateType update_type)
+{
+	mObjectUpdateFailures++;
+}
+
+void LLViewerStatsRecorder::recordCacheMissEvent(U32 local_id, const EObjectUpdateType update_type, U8 cache_miss_type)
+{
+	if (LLViewerRegion::CACHE_MISS_TYPE_FULL == cache_miss_type)
+	{
+		mObjectCacheMissFullCount++;
+	}
+	else
+	{
+		mObjectCacheMissCrcCount++;
+	}
+}
+
+void LLViewerStatsRecorder::recordObjectUpdateEvent(U32 local_id, const EObjectUpdateType update_type, LLViewerObject * objectp)
+{
+	switch (update_type)
+	{
+	case OUT_FULL:
+		mObjectFullUpdates++;
+		break;
+	case OUT_TERSE_IMPROVED:
+		mObjectTerseUpdates++;
+		break;
+	case OUT_FULL_COMPRESSED:
+		mObjectCacheMissResponses++;
+		break;
+	case OUT_FULL_CACHED:
+		mObjectCacheHitCount++;
+		break;
+	default:
+		llwarns << "Unknown update_type" << llendl;
+		break;
+	};
+}
+
+void LLViewerStatsRecorder::recordCacheFullUpdate(U32 local_id, const EObjectUpdateType update_type, LLViewerRegion::eCacheUpdateResult update_result, LLViewerObject* objectp)
+{
+	switch (update_result)
+	{
+		case LLViewerRegion::CACHE_UPDATE_DUPE:
+			mObjectCacheUpdateDupes++;
+			break;
+		case LLViewerRegion::CACHE_UPDATE_CHANGED:
+			mObjectCacheUpdateChanges++;
+			break;
+		case LLViewerRegion::CACHE_UPDATE_ADDED:
+			mObjectCacheUpdateAdds++;
+			break;
+		case LLViewerRegion::CACHE_UPDATE_REPLACED:
+			mObjectCacheUpdateReplacements++;
+			break;
+		default:
+			llwarns << "Unknown update_result type" << llendl;
+			break;
+	};
+}
+
+void LLViewerStatsRecorder::recordRequestCacheMissesEvent(S32 count)
+{
+	mObjectCacheMissRequests += count;
+}
+
+void LLViewerStatsRecorder::endObjectUpdateEvents()
+{
+	llinfos << "ILX: " 
+		<< mObjectCacheHitCount << " hits, " 
+		<< mObjectCacheMissFullCount << " full misses, "
+		<< mObjectCacheMissCrcCount << " crc misses, "
+		<< mObjectFullUpdates << " full updates, "
+		<< mObjectTerseUpdates << " terse updates, "
+		<< mObjectCacheMissRequests << " cache miss requests, "
+		<< mObjectCacheMissResponses << " cache miss responses, "
+		<< mObjectCacheUpdateDupes << " cache update dupes, "
+		<< mObjectCacheUpdateChanges << " cache update changes, "
+		<< mObjectCacheUpdateAdds << " cache update adds, "
+		<< mObjectCacheUpdateReplacements << " cache update replacements, "
+		<< mObjectUpdateFailures << " update failures"
+		<< llendl;
+
+	S32 total_objects = mObjectCacheHitCount + mObjectCacheMissCrcCount + mObjectCacheMissFullCount + mObjectFullUpdates + mObjectTerseUpdates + mObjectCacheMissRequests + mObjectCacheMissResponses + mObjectCacheUpdateDupes + mObjectCacheUpdateChanges + mObjectCacheUpdateAdds + mObjectCacheUpdateReplacements + mObjectUpdateFailures;
+	if (mObjectCacheFile != NULL &&
+		total_objects > 0)
+	{
+		std::ostringstream data_msg;
+		F32 processing32 = (F32) ((LLTimer::getTotalTime() - mProcessingTime) / 1000.0);
+
+		data_msg << getTimeSinceStart()
+			<< ", " << processing32
+			<< ", " << mObjectCacheHitCount
+			<< ", " << mObjectCacheMissFullCount
+			<< ", " << mObjectCacheMissCrcCount
+			<< ", " << mObjectFullUpdates
+			<< ", " << mObjectTerseUpdates
+			<< ", " << mObjectCacheMissRequests
+			<< ", " << mObjectCacheMissResponses
+			<< ", " << mObjectCacheUpdateDupes
+			<< ", " << mObjectCacheUpdateChanges
+			<< ", " << mObjectCacheUpdateAdds
+			<< ", " << mObjectCacheUpdateReplacements
+			<< ", " << mObjectUpdateFailures
+			<< "\n";
+
+		fwrite(data_msg.str().c_str(), 1, data_msg.str().size(), mObjectCacheFile );
+	}
+
+	clearStats();
+}
+
+F32 LLViewerStatsRecorder::getTimeSinceStart()
+{
+	return (F32) ((LLTimer::getTotalTime() - mStartTime) / 1000.0);
+}
+
+#endif
+
+
+
diff --git a/indra/newview/llviewerstatsrecorder.h b/indra/newview/llviewerstatsrecorder.h
new file mode 100644
index 0000000000000000000000000000000000000000..612ac380f7f9c92ef13f9c79cfbb91e0f6686550
--- /dev/null
+++ b/indra/newview/llviewerstatsrecorder.h
@@ -0,0 +1,97 @@
+/**
+ * @file llviewerstatsrecorder.h
+ * @brief record info about viewer events to a metrics log file
+ *
+ * $LicenseInfo:firstyear=2010&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 LLVIEWERSTATSRECORDER_H
+#define LLVIEWERSTATSRECORDER_H
+
+
+// This is a diagnostic class used to record information from the viewer
+// for analysis.
+
+// This is normally 0.  Set to 1 to enable viewer stats recording
+#define LL_RECORD_VIEWER_STATS	0
+
+
+#if LL_RECORD_VIEWER_STATS
+#include "llframetimer.h"
+#include "llviewerobject.h"
+#include "llviewerregion.h"
+
+class LLMutex;
+class LLViewerRegion;
+class LLViewerObject;
+
+class LLViewerStatsRecorder
+{
+ public:
+	LLViewerStatsRecorder();
+	~LLViewerStatsRecorder();
+
+	static void initClass();
+	static void cleanupClass();
+	static LLViewerStatsRecorder* instance() {return sInstance; }
+
+	void initStatsRecorder(LLViewerRegion *regionp);
+
+	void beginObjectUpdateEvents(LLViewerRegion *regionp);
+	void recordObjectUpdateFailure(U32 local_id, const EObjectUpdateType update_type);
+	void recordCacheMissEvent(U32 local_id, const EObjectUpdateType update_type, U8 cache_miss_type);
+	void recordObjectUpdateEvent(U32 local_id, const EObjectUpdateType update_type, LLViewerObject * objectp);
+	void recordCacheFullUpdate(U32 local_id, const EObjectUpdateType update_type, LLViewerRegion::eCacheUpdateResult update_result, LLViewerObject* objectp);
+	void recordRequestCacheMissesEvent(S32 count);
+	void endObjectUpdateEvents();
+
+	F32 getTimeSinceStart();
+
+private:
+	static LLViewerStatsRecorder* sInstance;
+
+	LLFILE *	mObjectCacheFile;		// File to write data into
+	LLFrameTimer	mTimer;
+	LLViewerRegion*	mRegionp;
+	F64			mStartTime;
+	F64			mProcessingTime;
+
+	S32			mObjectCacheHitCount;
+	S32			mObjectCacheMissFullCount;
+	S32			mObjectCacheMissCrcCount;
+	S32			mObjectFullUpdates;
+	S32			mObjectTerseUpdates;
+	S32			mObjectCacheMissRequests;
+	S32			mObjectCacheMissResponses;
+	S32			mObjectCacheUpdateDupes;
+	S32			mObjectCacheUpdateChanges;
+	S32			mObjectCacheUpdateAdds;
+	S32			mObjectCacheUpdateReplacements;
+	S32			mObjectUpdateFailures;
+
+
+	void	clearStats();
+};
+#endif	// LL_RECORD_VIEWER_STATS
+
+#endif // LLVIEWERSTATSRECORDER_H
+
diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index 145ee31260b94e43d1580fe2e6a129501a6f83a0..c26008d6406dcb71d9b313267576689b463cfea7 100644
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -40,6 +40,7 @@ BOOL check_write(LLAPRFile* apr_file, void* src, S32 n_bytes)
 	return apr_file->write(src, n_bytes) == n_bytes ;
 }
 
+
 //---------------------------------------------------------------------------
 // LLVOCacheEntry
 //---------------------------------------------------------------------------
@@ -212,8 +213,8 @@ BOOL LLVOCacheEntry::writeToFile(LLAPRFile* apr_file) const
 		if(success)
 		{
 			success = check_write(apr_file, (void*)mBuffer, size);
+		}
 	}
-}
 
 	return success ;
 }
@@ -224,7 +225,8 @@ BOOL LLVOCacheEntry::writeToFile(LLAPRFile* apr_file) const
 // Format string used to construct filename for the object cache
 static const char OBJECT_CACHE_FILENAME[] = "objects_%d_%d.slc";
 
-const U32 NUM_ENTRIES_TO_PURGE = 16 ;
+// Throw out 1/20 (5%) of our cache entries if we run out of room.
+const U32 ENTRIES_PURGE_FACTOR = 20;
 const char* object_cache_dirname = "objectcache";
 const char* header_filename = "object.cache";
 
@@ -259,7 +261,6 @@ void LLVOCache::destroyClass()
 LLVOCache::LLVOCache():
 	mInitialized(FALSE),
 	mReadOnly(TRUE),
-	mNumEntries(0),
 	mCacheSize(1)
 {
 	mEnabled = gSavedSettings.getBOOL("ObjectCacheEnabled");
@@ -286,8 +287,15 @@ void LLVOCache::setDirNames(ELLPath location)
 
 void LLVOCache::initCache(ELLPath location, U32 size, U32 cache_version)
 {
-	if(mInitialized || !mEnabled)
+	if(!mEnabled)
 	{
+		llwarns << "Not initializing cache: Cache is currently disabled." << llendl;
+		return ;
+	}
+
+	if(mInitialized)
+	{
+		llwarns << "Cache already initialized." << llendl;
 		return ;
 	}
 
@@ -299,7 +307,6 @@ void LLVOCache::initCache(ELLPath location, U32 size, U32 cache_version)
 
 	mCacheSize = size;
 
-	mMetaInfo.mVersion = cache_version;
 	readCacheHeader();
 	mInitialized = TRUE ;
 
@@ -321,12 +328,14 @@ void LLVOCache::removeCache(ELLPath location)
 {
 	if(mReadOnly)
 	{
+		llwarns << "Not removing cache at " << location << ": Cache is currently in read-only mode." << llendl;
 		return ;
 	}
 
 	std::string delem = gDirUtilp->getDirDelimiter();
 	std::string mask = delem + "*";
 	std::string cache_dir = gDirUtilp->getExpandedFilename(location, object_cache_dirname);
+	llinfos << "Removing cache at " << cache_dir << llendl;
 	gDirUtilp->deleteFilesInDir(cache_dir, mask); //delete all files
 	LLFile::rmdir(cache_dir);
 
@@ -339,11 +348,13 @@ void LLVOCache::removeCache()
 	llassert_always(mInitialized) ;
 	if(mReadOnly)
 	{
+		llwarns << "Not clearing object cache: Cache is currently in read-only mode." << llendl;
 		return ;
 	}
 
 	std::string delem = gDirUtilp->getDirDelimiter();
 	std::string mask = delem + "*";
+	llinfos << "Removing cache at " << mObjectCacheDirName << llendl;
 	gDirUtilp->deleteFilesInDir(mObjectCacheDirName, mask); 
 
 	clearCacheInMemory() ;
@@ -352,16 +363,8 @@ void LLVOCache::removeCache()
 
 void LLVOCache::clearCacheInMemory()
 {
-	if(!mHeaderEntryQueue.empty()) 
-	{
-		for(header_entry_queue_t::iterator iter = mHeaderEntryQueue.begin(); iter != mHeaderEntryQueue.end(); ++iter)
-		{
-			delete *iter ;
-		}
-		mHeaderEntryQueue.clear();
-		mHandleEntryMap.clear();
-		mNumEntries = 0 ;
-	}
+	std::for_each(mHandleEntryMap.begin(), mHandleEntryMap.end(), DeletePairedPointer());
+	mHandleEntryMap.clear();
 }
 
 void LLVOCache::getObjectCacheFilename(U64 handle, std::string& filename) 
@@ -379,6 +382,7 @@ void LLVOCache::removeFromCache(U64 handle)
 {
 	if(mReadOnly)
 	{
+		llwarns << "Not removing cache for handle " << handle << ": Cache is currently in read-only mode." << llendl;
 		return ;
 	}
 
@@ -387,24 +391,28 @@ void LLVOCache::removeFromCache(U64 handle)
 	LLAPRFile::remove(filename, mLocalAPRFilePoolp);	
 }
 
-BOOL LLVOCache::checkRead(LLAPRFile* apr_file, void* src, S32 n_bytes) 
+BOOL LLVOCache::checkRead(LLAPRFile* apr_file, void* src, S32 n_bytes, bool remove_cache_on_error)
 {
 	if(!check_read(apr_file, src, n_bytes))
 	{
-		delete apr_file ;
-		removeCache() ;
+		if (remove_cache_on_error)
+		{
+			removeCache() ;
+		}
 		return FALSE ;
 	}
 
 	return TRUE ;
 }
 
-BOOL LLVOCache::checkWrite(LLAPRFile* apr_file, void* src, S32 n_bytes) 
+BOOL LLVOCache::checkWrite(LLAPRFile* apr_file, void* src, S32 n_bytes, bool remove_cache_on_error) 
 {
 	if(!check_write(apr_file, src, n_bytes))
 	{
-		delete apr_file ;
-		removeCache() ;
+		if (remove_cache_on_error)
+		{
+			removeCache() ;
+		}
 		return FALSE ;
 	}
 
@@ -415,7 +423,8 @@ void LLVOCache::readCacheHeader()
 {
 	if(!mEnabled)
 	{
-		return ;
+		llwarns << "Not reading cache header: Cache is currently disabled." << llendl;
+		return;
 	}
 
 	//clear stale info.
@@ -423,33 +432,35 @@ void LLVOCache::readCacheHeader()
 
 	if (LLAPRFile::isExist(mHeaderFileName, mLocalAPRFilePoolp))
 	{
-		LLAPRFile* apr_file = new LLAPRFile(mHeaderFileName, APR_READ|APR_BINARY, mLocalAPRFilePoolp);		
+		LLAPRFile* apr_file = new LLAPRFile(mHeaderFileName, APR_FOPEN_READ|APR_FOPEN_BINARY, mLocalAPRFilePoolp);		
 		
 		//read the meta element
-		if(!checkRead(apr_file, &mMetaInfo, sizeof(HeaderMetaInfo)))
+		bool remove_cache_on_error = false;
+		if(!checkRead(apr_file, &mMetaInfo, sizeof(HeaderMetaInfo), remove_cache_on_error))
 		{
-			return ;
+			llwarns << "Error reading meta information from cache header." << llendl;
+			delete apr_file;
+			return;
 		}
 
 		HeaderEntryInfo* entry ;
-		mNumEntries = 0 ;
-		while(mNumEntries < mCacheSize)
+		for(U32 entry_index = 0; entry_index < mCacheSize; ++entry_index)
 		{
 			entry = new HeaderEntryInfo() ;
-			if(!checkRead(apr_file, entry, sizeof(HeaderEntryInfo)))
+			if(!checkRead(apr_file, entry, sizeof(HeaderEntryInfo), remove_cache_on_error))
 			{
+				llwarns << "Error reading cache header entry. (entry_index=" << entry_index << ")" << llendl;
 				delete entry ;			
-				return ;
+				break;
 			}
 			else if(!entry->mTime) //end of the cache.
 			{
 				delete entry ;
-				return ;
+				break;
 			}
 
-			entry->mIndex = mNumEntries++ ;
-			mHeaderEntryQueue.insert(entry) ;
-			mHandleEntryMap[entry->mHandle] = entry ;
+			entry->mIndex = entry_index;
+			mHandleEntryMap[entry->mHandle] = entry;
 		}
 
 		delete apr_file ;
@@ -462,40 +473,57 @@ void LLVOCache::readCacheHeader()
 
 void LLVOCache::writeCacheHeader()
 {
-	if(mReadOnly || !mEnabled)
+	if (!mEnabled)
 	{
-		return ;
-	}	
+		llwarns << "Not writing cache header: Cache is currently disabled." << llendl;
+		return;
+	}
+
+	if(mReadOnly)
+	{
+		llwarns << "Not writing cache header: Cache is currently in read-only mode." << llendl;
+		return;
+	}
 
-	LLAPRFile* apr_file = new LLAPRFile(mHeaderFileName, APR_CREATE|APR_WRITE|APR_BINARY, mLocalAPRFilePoolp);
+	LLAPRFile* apr_file = new LLAPRFile(mHeaderFileName, APR_FOPEN_CREATE|APR_FOPEN_WRITE|APR_FOPEN_BINARY|APR_FOPEN_TRUNCATE, mLocalAPRFilePoolp);
 
 	//write the meta element
 	if(!checkWrite(apr_file, &mMetaInfo, sizeof(HeaderMetaInfo)))
 	{
-		return ;
+		llwarns << "Error writing meta information to cache header." << llendl;
+		delete apr_file;
+		return;
 	}
 
-	mNumEntries = 0 ;
-	for(header_entry_queue_t::iterator iter = mHeaderEntryQueue.begin() ; iter != mHeaderEntryQueue.end(); ++iter)
+	U32 entry_index = 0;
+	handle_entry_map_t::iterator iter_end = mHandleEntryMap.end();
+	for(handle_entry_map_t::iterator iter = mHandleEntryMap.begin();
+		iter != iter_end;
+		++iter)
 	{
-		(*iter)->mIndex = mNumEntries++ ;
-		if(!checkWrite(apr_file, (void*)*iter, sizeof(HeaderEntryInfo)))
+		HeaderEntryInfo* entry = iter->second;
+		entry->mIndex = entry_index++;
+		if(!checkWrite(apr_file, (void*)entry, sizeof(HeaderEntryInfo)))
 		{
-			return ;
+			llwarns << "Failed to write cache header for entry " << entry->mHandle << " (entry_index = " << entry_index << ")" << llendl;
+			delete apr_file;
+			return;
 		}
 	}
 
-	mNumEntries = mHeaderEntryQueue.size() ;
-	if(mNumEntries < mCacheSize)
+	// Why do we need to fill the cache header with default entries?  DK 2010-12-14
+	// It looks like we currently rely on the file being pre-allocated so we can seek during updateEntry().
+	if(entry_index < mCacheSize)
 	{
 		HeaderEntryInfo* entry = new HeaderEntryInfo() ;
-		for(U32 i = mNumEntries ; i < mCacheSize; i++)
+		for(; entry_index < mCacheSize; ++entry_index)
 		{
 			//fill the cache with the default entry.
 			if(!checkWrite(apr_file, entry, sizeof(HeaderEntryInfo)))
 			{
+				llwarns << "Failed to fill cache header with default entries (entry_index = " << entry_index << ").  Switching to read-only mode." << llendl;
 				mReadOnly = TRUE ; //disable the cache.
-				return ;
+				break;
 			}
 		}
 		delete entry ;
@@ -505,16 +533,19 @@ void LLVOCache::writeCacheHeader()
 
 BOOL LLVOCache::updateEntry(const HeaderEntryInfo* entry)
 {
-	LLAPRFile* apr_file = new LLAPRFile(mHeaderFileName, APR_WRITE|APR_BINARY, mLocalAPRFilePoolp);
+	LLAPRFile* apr_file = new LLAPRFile(mHeaderFileName, APR_FOPEN_WRITE|APR_FOPEN_BINARY, mLocalAPRFilePoolp);
 	apr_file->seek(APR_SET, entry->mIndex * sizeof(HeaderEntryInfo) + sizeof(HeaderMetaInfo)) ;
 
-	return checkWrite(apr_file, (void*)entry, sizeof(HeaderEntryInfo)) ;
+	BOOL result = checkWrite(apr_file, (void*)entry, sizeof(HeaderEntryInfo)) ;
+	delete apr_file;
+	return result;
 }
 
 void LLVOCache::readFromCache(U64 handle, const LLUUID& id, LLVOCacheEntry::vocache_entry_map_t& cache_entry_map) 
 {
 	if(!mEnabled)
 	{
+		llwarns << "Not reading cache for handle " << handle << "): Cache is currently disabled." << llendl;
 		return ;
 	}
 	llassert_always(mInitialized);
@@ -522,22 +553,24 @@ void LLVOCache::readFromCache(U64 handle, const LLUUID& id, LLVOCacheEntry::voca
 	handle_entry_map_t::iterator iter = mHandleEntryMap.find(handle) ;
 	if(iter == mHandleEntryMap.end()) //no cache
 	{
+		llwarns << "No handle map entry for " << handle << llendl;
 		return ;
 	}
 
 	std::string filename;
 	getObjectCacheFilename(handle, filename);
-	LLAPRFile* apr_file = new LLAPRFile(filename, APR_READ|APR_BINARY, mLocalAPRFilePoolp);
+	LLAPRFile* apr_file = new LLAPRFile(filename, APR_FOPEN_READ|APR_FOPEN_BINARY, mLocalAPRFilePoolp);
 
 	LLUUID cache_id ;
 	if(!checkRead(apr_file, cache_id.mData, UUID_BYTES))
 	{
+		llwarns << "Error reading cache_id from " << filename << llendl;
+		delete apr_file;
 		return ;
 	}
 	if(cache_id != id)
 	{
-		llinfos << "Cache ID doesn't match for this region, discarding"<< llendl;
-
+		llwarns << "Cache ID (" << cache_id << ") doesn't match id for this region (" << id << "), discarding.  handle = " << handle << llendl;
 		delete apr_file ;
 		return ;
 	}
@@ -545,6 +578,8 @@ void LLVOCache::readFromCache(U64 handle, const LLUUID& id, LLVOCacheEntry::voca
 	S32 num_entries;
 	if(!checkRead(apr_file, &num_entries, sizeof(S32)))
 	{
+		llwarns << "Error reading num_entries from " << filename << llendl;
+		delete apr_file;
 		return ;
 	}
 	
@@ -553,13 +588,12 @@ void LLVOCache::readFromCache(U64 handle, const LLUUID& id, LLVOCacheEntry::voca
 		LLVOCacheEntry* entry = new LLVOCacheEntry(apr_file);
 		if (!entry->getLocalID())
 		{
-			llwarns << "Aborting cache file load for " << filename << ", cache file corruption!" << llendl;
+			llwarns << "Aborting cache file load for " << filename << ", cache file corruption! (entry number = " << i << ")" << llendl;
 			delete entry ;
 			break;
 		}
 		cache_entry_map[entry->getLocalID()] = entry;
 	}
-	num_entries = cache_entry_map.size() ;
 
 	delete apr_file ;
 	return ;
@@ -567,86 +601,104 @@ void LLVOCache::readFromCache(U64 handle, const LLUUID& id, LLVOCacheEntry::voca
 	
 void LLVOCache::purgeEntries()
 {
-	U32 limit = mCacheSize - NUM_ENTRIES_TO_PURGE ;
-	while(mHeaderEntryQueue.size() > limit)
-	{
-		header_entry_queue_t::iterator iter = mHeaderEntryQueue.begin() ;
-		HeaderEntryInfo* entry = *iter ;
+	U32 limit = mCacheSize - (mCacheSize / ENTRIES_PURGE_FACTOR);
+	limit = llclamp(limit, (U32)1, mCacheSize);
+	// Construct a vector of entries out of the map so we can sort by time.
+	std::vector<HeaderEntryInfo*> header_vector;
+	handle_entry_map_t::iterator iter_end = mHandleEntryMap.end();
+	for (handle_entry_map_t::iterator iter = mHandleEntryMap.begin();
+		iter != iter_end;
+		++iter)
+	{
+		header_vector.push_back(iter->second);
+	}
+	// Sort by time, oldest first.
+	std::sort(header_vector.begin(), header_vector.end(), header_entry_less());
+	while(header_vector.size() > limit)
+	{
+		HeaderEntryInfo* entry = header_vector.front();
 		
-		removeFromCache(entry->mHandle) ;
-		mHandleEntryMap.erase(entry->mHandle) ;		
-		mHeaderEntryQueue.erase(iter) ;
-		delete entry ;
+		removeFromCache(entry->mHandle);
+		mHandleEntryMap.erase(entry->mHandle);
+		header_vector.erase(header_vector.begin());
+		delete entry;
 	}
 
 	writeCacheHeader() ;
+	// *TODO: Verify that we can avoid re-reading the cache header.  DK 2010-12-14
 	readCacheHeader() ;
-	mNumEntries = mHandleEntryMap.size() ;
 }
 
 void LLVOCache::writeToCache(U64 handle, const LLUUID& id, const LLVOCacheEntry::vocache_entry_map_t& cache_entry_map, BOOL dirty_cache) 
 {
 	if(!mEnabled)
 	{
+		llwarns << "Not writing cache for handle " << handle << "): Cache is currently disabled." << llendl;
 		return ;
 	}
 	llassert_always(mInitialized);
 
 	if(mReadOnly)
 	{
+		llwarns << "Not writing cache for handle " << handle << "): Cache is currently in read-only mode." << llendl;
 		return ;
 	}
 
+	U32 num_handle_entries = mHandleEntryMap.size();
+	
 	HeaderEntryInfo* entry;
 	handle_entry_map_t::iterator iter = mHandleEntryMap.find(handle) ;
 	if(iter == mHandleEntryMap.end()) //new entry
-	{		
-		if(mNumEntries >= mCacheSize)
+	{
+		if(num_handle_entries >= mCacheSize)
 		{
 			purgeEntries() ;
+			num_handle_entries = mHandleEntryMap.size();
 		}
 		
 		entry = new HeaderEntryInfo();
 		entry->mHandle = handle ;
 		entry->mTime = time(NULL) ;
-		entry->mIndex = mNumEntries++ ;
-		mHeaderEntryQueue.insert(entry) ;
+		entry->mIndex = num_handle_entries++;
 		mHandleEntryMap[handle] = entry ;
 	}
 	else
 	{
+		// Update access time.
 		entry = iter->second ;
 		entry->mTime = time(NULL) ;
-
-		//resort
-		mHeaderEntryQueue.erase(entry) ;
-		mHeaderEntryQueue.insert(entry) ;
 	}
 
 	//update cache header
 	if(!updateEntry(entry))
 	{
+		llwarns << "Failed to update cache header index " << entry->mIndex << ". handle = " << handle << llendl;
 		return ; //update failed.
 	}
 
 	if(!dirty_cache)
 	{
+		llwarns << "Skipping write to cache for handle " << handle << ": cache not dirty" << llendl;
 		return ; //nothing changed, no need to update.
 	}
 
 	//write to cache file
 	std::string filename;
 	getObjectCacheFilename(handle, filename);
-	LLAPRFile* apr_file = new LLAPRFile(filename, APR_CREATE|APR_WRITE|APR_BINARY, mLocalAPRFilePoolp);
+	LLAPRFile* apr_file = new LLAPRFile(filename, APR_FOPEN_CREATE|APR_FOPEN_WRITE|APR_FOPEN_BINARY|APR_FOPEN_TRUNCATE, mLocalAPRFilePoolp);
 	
 	if(!checkWrite(apr_file, (void*)id.mData, UUID_BYTES))
 	{
+		llwarns << "Error writing id to " << filename << llendl;
+		delete apr_file;
 		return ;
 	}
 
 	S32 num_entries = cache_entry_map.size() ;
 	if(!checkWrite(apr_file, &num_entries, sizeof(S32)))
 	{
+		llwarns << "Error writing num_entries to " << filename << llendl;
+		delete apr_file;
 		return ;
 	}
 
@@ -654,10 +706,10 @@ void LLVOCache::writeToCache(U64 handle, const LLUUID& id, const LLVOCacheEntry:
 	{
 		if(!iter->second->writeToFile(apr_file))
 		{
+			llwarns << "Aborting cache file write for " << filename << ", error writing to file!" << llendl;
 			//failed
-			delete apr_file ;
 			removeCache() ;
-			return ;
+			break;
 		}
 	}
 
diff --git a/indra/newview/llvocache.h b/indra/newview/llvocache.h
index ed2bc8bafecbeaa49e600cc2afe1d46e93e7c05f..e1030079793a01a91e36c9c9cee9f670ae69dc57 100644
--- a/indra/newview/llvocache.h
+++ b/indra/newview/llvocache.h
@@ -95,10 +95,13 @@ class LLVOCache
 	{
 		bool operator()(const HeaderEntryInfo* lhs, const HeaderEntryInfo* rhs) const
 		{
-			return lhs->mTime < rhs->mTime; // older entry in front of queue (set)
+			if (lhs->mTime == rhs->mTime)
+			{
+				return lhs->mHandle < rhs->mHandle;
+			}
+			return lhs->mTime < rhs->mTime; // older entry in front
 		}
 	};
-	typedef std::set<HeaderEntryInfo*, header_entry_less> header_entry_queue_t;
 	typedef std::map<U64, HeaderEntryInfo*> handle_entry_map_t;
 private:
 	LLVOCache() ;
@@ -125,8 +128,8 @@ class LLVOCache
 	void removeCache() ;
 	void purgeEntries();
 	BOOL updateEntry(const HeaderEntryInfo* entry);
-	BOOL checkRead(LLAPRFile* apr_file, void* src, S32 n_bytes) ;
-	BOOL checkWrite(LLAPRFile* apr_file, void* src, S32 n_bytes) ;
+	BOOL checkRead(LLAPRFile* apr_file, void* src, S32 n_bytes, bool remove_cache_on_error = true) ;
+	BOOL checkWrite(LLAPRFile* apr_file, void* src, S32 n_bytes, bool remove_cache_on_error = true) ;
 	
 private:
 	BOOL                 mEnabled;
@@ -134,11 +137,9 @@ class LLVOCache
 	BOOL                 mReadOnly ;
 	HeaderMetaInfo       mMetaInfo;
 	U32                  mCacheSize;
-	U32                  mNumEntries;
 	std::string          mHeaderFileName ;
 	std::string          mObjectCacheDirName;
 	LLVolatileAPRPool*   mLocalAPRFilePoolp ; 	
-	header_entry_queue_t mHeaderEntryQueue;
 	handle_entry_map_t   mHandleEntryMap;	
 
 	static LLVOCache* sInstance ;
diff --git a/indra/newview/llwaterparammanager.cpp b/indra/newview/llwaterparammanager.cpp
index 4f6ec4ca616ccb4721b9eb7b82b016f97acf9817..d239347810648188b9b7dd2917a8030d8d6d99a7 100644
--- a/indra/newview/llwaterparammanager.cpp
+++ b/indra/newview/llwaterparammanager.cpp
@@ -33,7 +33,6 @@
 #include "pipeline.h"
 #include "llsky.h"
 
-#include "lldiriterator.h"
 #include "llfloaterreg.h"
 #include "llsliderctrl.h"
 #include "llspinctrl.h"
@@ -86,12 +85,11 @@ void LLWaterParamManager::loadAllPresets(const std::string& file_name)
 	std::string path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/water", ""));
 	LL_DEBUGS2("AppInit", "Shaders") << "Loading Default water settings from " << path_name << LL_ENDL;
 			
-	bool found = true;
-	LLDirIterator app_settings_iter(path_name, "*.xml");
+	bool found = true;			
 	while(found) 
 	{
 		std::string name;
-		found = app_settings_iter.next(name);
+		found = gDirUtilp->getNextFileInDir(path_name, "*.xml", name);
 		if(found)
 		{
 
@@ -113,12 +111,11 @@ void LLWaterParamManager::loadAllPresets(const std::string& file_name)
 	std::string path_name2(gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight/water", ""));
 	LL_DEBUGS2("AppInit", "Shaders") << "Loading User water settings from " << path_name2 << LL_ENDL;
 			
-	found = true;
-	LLDirIterator user_settings_iter(path_name2, "*.xml");
+	found = true;			
 	while(found) 
 	{
 		std::string name;
-		found = user_settings_iter.next(name);
+		found = gDirUtilp->getNextFileInDir(path_name2, "*.xml", name);
 		if(found)
 		{
 			name=name.erase(name.length()-4);
diff --git a/indra/newview/llwlparammanager.cpp b/indra/newview/llwlparammanager.cpp
index 848efcbb49e5f8e28f3bd393df7767dd003b27ee..e5f52dfc979b5ef4cd09c8366d6b5263d541b9ba 100644
--- a/indra/newview/llwlparammanager.cpp
+++ b/indra/newview/llwlparammanager.cpp
@@ -31,7 +31,6 @@
 #include "pipeline.h"
 #include "llsky.h"
 
-#include "lldiriterator.h"
 #include "llfloaterreg.h"
 #include "llsliderctrl.h"
 #include "llspinctrl.h"
@@ -101,12 +100,11 @@ void LLWLParamManager::loadPresets(const std::string& file_name)
 	std::string path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/skies", ""));
 	LL_DEBUGS2("AppInit", "Shaders") << "Loading Default WindLight settings from " << path_name << LL_ENDL;
 			
-	bool found = true;
-	LLDirIterator app_settings_iter(path_name, "*.xml");
+	bool found = true;			
 	while(found) 
 	{
 		std::string name;
-		found = app_settings_iter.next(name);
+		found = gDirUtilp->getNextFileInDir(path_name, "*.xml", name);
 		if(found)
 		{
 
@@ -128,12 +126,11 @@ void LLWLParamManager::loadPresets(const std::string& file_name)
 	std::string path_name2(gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight/skies", ""));
 	LL_DEBUGS2("AppInit", "Shaders") << "Loading User WindLight settings from " << path_name2 << LL_ENDL;
 			
-	found = true;
-	LLDirIterator user_settings_iter(path_name2, "*.xml");
+	found = true;			
 	while(found) 
 	{
 		std::string name;
-		found = user_settings_iter.next(name);
+		found = gDirUtilp->getNextFileInDir(path_name2, "*.xml", name);
 		if(found)
 		{
 			name=name.erase(name.length()-4);
diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h
index 3f785a99fef3f178e8ea1fa4ed5f90173630dd56..cef3d87f3605c84c554d51a09ad755d35a69e175 100644
--- a/indra/newview/pipeline.h
+++ b/indra/newview/pipeline.h
@@ -424,6 +424,7 @@ class LLPipeline
 		RENDER_DEBUG_AVATAR_VOLUME      = 0x0100000,
 		RENDER_DEBUG_BUILD_QUEUE		= 0x0200000,
 		RENDER_DEBUG_AGENT_TARGET       = 0x0400000,
+		RENDER_DEBUG_UPDATE_TYPE		= 0x0800000,
 	};
 
 public:
diff --git a/indra/newview/skins/default/xui/da/notifications.xml b/indra/newview/skins/default/xui/da/notifications.xml
index 593e686d4c126da89574cedc0946567e368c84ee..27024f4eaaf4d443fe82af5702af5e2e7975aeae 100644
--- a/indra/newview/skins/default/xui/da/notifications.xml
+++ b/indra/newview/skins/default/xui/da/notifications.xml
@@ -1580,9 +1580,6 @@ Klik på Acceptér for at deltage eller Afvis for at afvise invitationen. Klik p
 	<notification name="VoiceCallGenericError">
 		En fejl er opstået under forsøget på at koble sig på stemme chatten [VOICE_CHANNEL_NAME].  Pråv venligst senere.
 	</notification>
-	<notification name="ServerVersionChanged">
-		Du er netop ankommet til en region der benytter en anden server version, hvilket kan influere på hastigheden. [[URL] For at se yderligere.]
-	</notification>
 	<notification name="UnsupportedCommandSLURL">
 		Den SLurl du klikkede på understøttes ikke.
 	</notification>
diff --git a/indra/newview/skins/default/xui/de/notifications.xml b/indra/newview/skins/default/xui/de/notifications.xml
index a2d0b5a1702394375b508705f78c376017549bfd..c26b02ec8fbe396f83c2d1e34aa10701e1fc5a16 100644
--- a/indra/newview/skins/default/xui/de/notifications.xml
+++ b/indra/newview/skins/default/xui/de/notifications.xml
@@ -2691,9 +2691,6 @@ Klicken Sie auf  &apos;Akzeptieren &apos;, um dem Chat beizutreten, oder auf  &a
 	<notification name="VoiceCallGenericError">
 		Fehler beim Versuch, eine Voice-Chat-Verbindung zu [VOICE_CHANNEL_NAME] herzustellen.  Bitte versuchen Sie es erneut.
 	</notification>
-	<notification name="ServerVersionChanged">
-		Sie haben eine Region betreten, die eine andere Server-Version verwendet. Dies kann sich auf die Leistung auswirken. [[URL] Versionshinweise anzeigen.]
-	</notification>
 	<notification name="UnsupportedCommandSLURL">
 		Die SLurl, auf die Sie geklickt haben, wird nicht unterstützt.
 	</notification>
diff --git a/indra/newview/skins/default/xui/en/floater_tools.xml b/indra/newview/skins/default/xui/en/floater_tools.xml
index e70e1eb61b3a05db9c45570b418838b72f10e048..1808fea44541ec42ab88fe791c2be08e010ad6fd 100644
--- a/indra/newview/skins/default/xui/en/floater_tools.xml
+++ b/indra/newview/skins/default/xui/en/floater_tools.xml
@@ -872,12 +872,13 @@
              length="1"
              follows="left|top"
              left_pad="0"
-             height="30"
+             height="20"
              layout="topleft"
              name="Creator Name"
              top_delta="0"
              width="190"
-             word_wrap="true">
+             word_wrap="true"
+             use_ellipses="ture">
                 Mrs. Esbee Linden (esbee.linden)
             </text>
             <text
@@ -888,7 +889,7 @@
              height="19"
              layout="topleft"
              name="Owner:"
-             top_pad="3"
+             top_pad="13"
              width="90">
                 Owner:
             </text>
@@ -897,13 +898,14 @@
              type="string"
              length="1"
              follows="left|top"
-             height="30"
+             height="20"
              layout="topleft"
              name="Owner Name"
              left_pad="0"
              top_delta="0"
              width="190"
-             word_wrap="true">
+             word_wrap="true"
+             use_ellipses="true">
                 Mrs. Erica "Moose" Linden (erica.linden)
             </text>
            <text
@@ -914,7 +916,7 @@
              left="10"
              height="18"
              name="Group:"
-             top_pad="7"
+             top_pad="17"
              width="75">
                 Group:
             </text>
diff --git a/indra/newview/skins/default/xui/en/floater_web_content.xml b/indra/newview/skins/default/xui/en/floater_web_content.xml
index d90d0feda9ae58a1d0216db2d3cc6446ecc40498..6ec063cd26df9a1238fd6f4b7b26edec551af0c3 100644
--- a/indra/newview/skins/default/xui/en/floater_web_content.xml
+++ b/indra/newview/skins/default/xui/en/floater_web_content.xml
@@ -2,26 +2,26 @@
 <floater
   legacy_header_height="18"
   can_resize="true"
-  height="440"
+  height="775"
   layout="topleft"
-  min_height="140"
-  min_width="467"
+  min_height="400"
+  min_width="500"
   name="floater_web_content"
   help_topic="floater_web_content"
   save_rect="true"
   auto_tile="true"
   title=""
   initial_mime_type="text/html"
-  width="820">
+  width="735">
   <layout_stack
-    bottom="440"
+    bottom="775"
     follows="left|right|top|bottom"
     layout="topleft"
     left="5"
     name="stack1"
     orientation="vertical"
     top="20"
-    width="810">
+    width="725">
     <layout_panel
       auto_resize="false"
       default_tab_group="1"
@@ -32,14 +32,14 @@
       name="nav_controls"
       top="400"
       user_resize="false"
-      width="800">
+      width="725">
       <button
         image_overlay="Arrow_Left_Off"
-        image_disabled="PushButton_Disabled"
-        image_disabled_selected="PushButton_Disabled"
-        image_selected="PushButton_Selected"
-        image_unselected="PushButton_Off"
-        hover_glow_amount="0.15"
+		    image_disabled="PushButton_Disabled"
+		    image_disabled_selected="PushButton_Disabled"
+		    image_selected="PushButton_Selected"
+		    image_unselected="PushButton_Off"
+		    hover_glow_amount="0.15"
         tool_tip="Navigate back"
         follows="left|top"
         height="22"
@@ -53,10 +53,10 @@
       </button>
       <button
         image_overlay="Arrow_Right_Off"
-        image_disabled="PushButton_Disabled"
-        image_disabled_selected="PushButton_Disabled"
-        image_selected="PushButton_Selected"
-        image_unselected="PushButton_Off"
+		    image_disabled="PushButton_Disabled"
+		    image_disabled_selected="PushButton_Disabled"
+		    image_selected="PushButton_Selected"
+		    image_unselected="PushButton_Off"
         tool_tip="Navigate forward"
         follows="left|top"
         height="22"
@@ -70,10 +70,10 @@
       </button>
       <button
         image_overlay="Stop_Off"
-        image_disabled="PushButton_Disabled"
-        image_disabled_selected="PushButton_Disabled"
-        image_selected="PushButton_Selected"
-        image_unselected="PushButton_Off"
+		    image_disabled="PushButton_Disabled"
+		    image_disabled_selected="PushButton_Disabled"
+		    image_selected="PushButton_Selected"
+		    image_unselected="PushButton_Off"
         tool_tip="Stop navigation"
         enabled="true"
         follows="left|top"
@@ -88,10 +88,10 @@
       </button>
       <button
         image_overlay="Refresh_Off"
-        image_disabled="PushButton_Disabled"
-        image_disabled_selected="PushButton_Disabled"
-        image_selected="PushButton_Selected"
-        image_unselected="PushButton_Off"
+		    image_disabled="PushButton_Disabled"
+		    image_disabled_selected="PushButton_Disabled"
+		    image_selected="PushButton_Selected"
+		    image_unselected="PushButton_Off"
         tool_tip="Reload page"
         follows="left|top"
         height="22"
@@ -115,7 +115,7 @@
         combo_editor.select_on_focus="true"
         tool_tip="Enter URL here"
         top_delta="0"
-        width="702">
+        width="627">
         <combo_box.commit_callback
           function="WebContent.EnterAddress" />
       </combo_box>
@@ -125,24 +125,24 @@
         follows="top|right"
         image_name="Lock2"
         layout="topleft"
-        left_delta="656"
+        left_delta="575"
         top_delta="2"
         visible="false" 
         tool_tip="Secured Browsing"
         width="16" />
       <button
         image_overlay="ExternalBrowser_Off"
-        image_disabled="PushButton_Disabled"
-        image_disabled_selected="PushButton_Disabled"
-        image_selected="PushButton_Selected"
-        image_unselected="PushButton_Off"
+		    image_disabled="PushButton_Disabled"
+		    image_disabled_selected="PushButton_Disabled"
+		    image_selected="PushButton_Selected"
+		    image_unselected="PushButton_Off"
         tool_tip="Open current URL in your desktop browser"
         follows="right|top"
         enabled="true" 
         height="22"
         layout="topleft"
         name="popexternal"
-        right="800"
+        right="725"
         top_delta="-2"
         width="22">
         <button.commit_callback
@@ -166,16 +166,16 @@
         top="0"/>
       <text
         type="string"
-        length="100"
+        length="200"
         follows="bottom|left"
         height="20"
         layout="topleft"
         left_delta="0"
         name="statusbartext"
         parse_urls="false"
-        text_color="0.4 0.4 0.4 1" 
+        text_color="0.4 0.4 0.4 1"
         top_pad="5"
-        width="452"/>
+        width="520"/>
       <progress_bar
         color_bar="0.3 1.0 0.3 1"
         follows="bottom|right"
diff --git a/indra/newview/skins/default/xui/en/menu_places_gear_folder.xml b/indra/newview/skins/default/xui/en/menu_places_gear_folder.xml
index 6f46165883e4ac868caec8df4b2c280a480d99d4..1aeb166e01570aaccb4ead89d93c7a887e3a4cad 100644
--- a/indra/newview/skins/default/xui/en/menu_places_gear_folder.xml
+++ b/indra/newview/skins/default/xui/en/menu_places_gear_folder.xml
@@ -25,6 +25,14 @@
          function="Places.LandmarksGear.Enable"
          parameter="category" />
     </menu_item_call>
+    <menu_item_call
+     label="Restore Item"
+     layout="topleft"
+     name="restore_item">
+        <menu_item_call.on_click
+         function="Places.LandmarksGear.Custom.Action"
+         parameter="restore" />
+    </menu_item_call>
     <menu_item_separator
      layout="topleft" />
     <menu_item_call
diff --git a/indra/newview/skins/default/xui/en/menu_places_gear_landmark.xml b/indra/newview/skins/default/xui/en/menu_places_gear_landmark.xml
index 121e7cc07ac23761271bf7cae52f205501bc3561..ff5fdd3795322d5c3582f0b7ff7d73b3240c6d29 100644
--- a/indra/newview/skins/default/xui/en/menu_places_gear_landmark.xml
+++ b/indra/newview/skins/default/xui/en/menu_places_gear_landmark.xml
@@ -60,6 +60,14 @@
          function="Places.LandmarksGear.Enable"
          parameter="category" />
     </menu_item_call>
+    <menu_item_call
+     label="Restore Item"
+     layout="topleft"
+     name="restore_item">
+        <menu_item_call.on_click
+         function="Places.LandmarksGear.Custom.Action"
+         parameter="restore" />
+    </menu_item_call>
     <menu_item_separator
      layout="topleft" />
     <menu_item_call
diff --git a/indra/newview/skins/default/xui/en/menu_viewer.xml b/indra/newview/skins/default/xui/en/menu_viewer.xml
index 3d500c2371daf44fab9b230efea77770a4170e68..2207e418c8dff036b8e58a3823378bb4cd10abd8 100644
--- a/indra/newview/skins/default/xui/en/menu_viewer.xml
+++ b/indra/newview/skins/default/xui/en/menu_viewer.xml
@@ -2152,6 +2152,16 @@
            function="Advanced.ToggleInfoDisplay"
            parameter="render batches" />
         </menu_item_check>
+        <menu_item_check
+         label="Update Type"
+         name="Update Type">
+          <menu_item_check.on_check
+           function="Advanced.CheckInfoDisplay"
+           parameter="update type" />
+          <menu_item_check.on_click
+           function="Advanced.ToggleInfoDisplay"
+           parameter="update type" />
+        </menu_item_check>
         <menu_item_check
          label="Texture Anim"
          name="Texture Anim">
diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml
index 6f21938bdb0fd21f9543cec2305f3cfdebce4948..f008042a81c4e7d3edb0d355a9440ddf7ba83849 100644
--- a/indra/newview/skins/default/xui/en/notifications.xml
+++ b/indra/newview/skins/default/xui/en/notifications.xml
@@ -6303,15 +6303,6 @@ An error has occurred while trying to connect to voice chat for [VOICE_CHANNEL_N
     </unique>
   </notification>
 
-  <notification
-   duration="10"
-   icon="notifytip.tga"
-   name="ServerVersionChanged"
-   priority="high"
-   type="notifytip">
-You just entered a region using a different server version, which may affect performance. [[URL] View the release notes.]
-  </notification>
-
   <notification
    icon="notifytip.tga"
    name="UnsupportedCommandSLURL"
diff --git a/indra/newview/skins/default/xui/es/notifications.xml b/indra/newview/skins/default/xui/es/notifications.xml
index 14ce39e8fc673c493d4442ebe5cc79db4bf06be5..1c310669625c089f06f782dfc6f3d26ccd7183d3 100644
--- a/indra/newview/skins/default/xui/es/notifications.xml
+++ b/indra/newview/skins/default/xui/es/notifications.xml
@@ -2678,9 +2678,6 @@ Pulsa Aceptar o Rehusar para coger o no la llamada. Pulsa Ignorar para ignorar a
 	<notification name="VoiceCallGenericError">
 		Se ha producido un error al intentar conectarte al [VOICE_CHANNEL_NAME]. Por favor, inténtalo más tarde.
 	</notification>
-	<notification name="ServerVersionChanged">
-		Acabas de entrar en una región que usa un servidor con una versión distinta, y esto puede influir en el funcionamiento. [[URL] Ver las notas de desarrollo].
-	</notification>
 	<notification name="UnsupportedCommandSLURL">
 		No se admite el formato de la SLurl que has pulsado.
 	</notification>
diff --git a/indra/newview/skins/default/xui/fr/notifications.xml b/indra/newview/skins/default/xui/fr/notifications.xml
index f0b0e63af0079ca4bac7786f1bdf29268a68901b..2ccac5c19ae465040a943640cfcd318dce852688 100644
--- a/indra/newview/skins/default/xui/fr/notifications.xml
+++ b/indra/newview/skins/default/xui/fr/notifications.xml
@@ -2674,9 +2674,6 @@ Pour y participer, cliquez sur Accepter. Sinon, cliquez sur Refuser. Pour ignore
 	<notification name="VoiceCallGenericError">
 		Une erreur est survenue pendant la connexion au chat vocal pour [VOICE_CHANNEL_NAME]. Veuillez réessayer ultérieurement.
 	</notification>
-	<notification name="ServerVersionChanged">
-		La région dans laquelle vous avez pénétré utilise une version de serveur différente, ce qui peut avoir un impact sur votre performance. [[URL] Consultez les notes de version.]
-	</notification>
 	<notification name="UnsupportedCommandSLURL">
 		La SLurl que vous avez saisie n&apos;est pas prise en charge.
 	</notification>
diff --git a/indra/newview/skins/default/xui/it/notifications.xml b/indra/newview/skins/default/xui/it/notifications.xml
index 5e53080c77b312a87c8d54e4c31e591aeebc2a8e..cce588859824506c76dd138e61fab1e881d122f2 100644
--- a/indra/newview/skins/default/xui/it/notifications.xml
+++ b/indra/newview/skins/default/xui/it/notifications.xml
@@ -2623,9 +2623,6 @@ Clicca su Accetta per unirti alla chat oppure su Declina per declinare l&apos;in
 	<notification name="VoiceCallGenericError">
 		Si è verificato un errore durante il tentativo di collegarti a una voice chat con [VOICE_CHANNEL_NAME].  Riprova più tardi.
 	</notification>
-	<notification name="ServerVersionChanged">
-		Sei appena entrato in una regione che usa una versione differente del server: ciò potrebbe incidere sule prestazioni. [[URL] Visualizza le note sulla versione.]
-	</notification>
 	<notification name="UnsupportedCommandSLURL">
 		Lo SLurl su cui hai cliccato non è valido.
 	</notification>
diff --git a/indra/newview/skins/default/xui/ja/notifications.xml b/indra/newview/skins/default/xui/ja/notifications.xml
index f133bb361afcaf578764b04fc60c07c0f25f1cad..baec8c073c2d3dc27d17fa4db389cd2ef3522c91 100644
--- a/indra/newview/skins/default/xui/ja/notifications.xml
+++ b/indra/newview/skins/default/xui/ja/notifications.xml
@@ -2675,9 +2675,6 @@ M キーを押して変更します。
 	<notification name="VoiceCallGenericError">
 		[VOICE_CHANNEL_NAME] のボイスチャットに接続中に、エラーが発生しました。後でもう一度お試しください。
 	</notification>
-	<notification name="ServerVersionChanged">
-		サーバーのバージョンが異なるリージョンに来ました。パフォーマンスに影響することがあります。 [[URL] リリースノートを確認]
-	</notification>
 	<notification name="UnsupportedCommandSLURL">
 		クリックした SLurl はサポートされていません。
 	</notification>
diff --git a/indra/newview/skins/default/xui/nl/notifications.xml b/indra/newview/skins/default/xui/nl/notifications.xml
index be0c17d2ff8a7145f51aca577a62311a38bbe875..f27b83d3f92d1eaf7f68f7115276196e207821ef 100644
--- a/indra/newview/skins/default/xui/nl/notifications.xml
+++ b/indra/newview/skins/default/xui/nl/notifications.xml
@@ -3012,9 +3012,6 @@ Klik Accepteren om deel te nemen aan de chat of Afwijzen om de uitnodiging af te
 	<notification name="VoiceCallGenericError">
 		Er is een fout opgetreden tijdens het verbinden met voice chat voor [VOICE_CHANNEL_NAME]. Probeert u het later alstublieft opnieuw.
 	</notification>
-	<notification name="ServerVersionChanged">
-		De regio die u bent binnengetreden wordt onder een andere simulatorversie uitgevoerd. Klik dit bericht voor meer details.
-	</notification>
 	<notification name="UnableToOpenCommandURL">
 		De URL die u heeft geklikt kan niet binnen deze webbrowser worden geopend.
 	</notification>
diff --git a/indra/newview/skins/default/xui/pl/notifications.xml b/indra/newview/skins/default/xui/pl/notifications.xml
index 57a6b8b8ef9e6cfd258dff586746536f8c7d276c..138125ff0b7e65664df7176dc028cd45fed75eb8 100644
--- a/indra/newview/skins/default/xui/pl/notifications.xml
+++ b/indra/newview/skins/default/xui/pl/notifications.xml
@@ -2635,9 +2635,6 @@ Wybierz Zaakceptuj żeby zacząć czat albo Odmów żeby nie przyjąć zaproszen
 	<notification name="VoiceCallGenericError">
 		Błąd podczas łączenia z rozmową [VOICE_CHANNEL_NAME]. Spróbuj póżniej.
 	</notification>
-	<notification name="ServerVersionChanged">
-		Ten region używa innej wersji symulatora. Kliknij na tą wiadomość żeby uzyskać więcej informacji: [[URL] View the release notes.]
-	</notification>
 	<notification name="UnsupportedCommandSLURL">
 		Nie można otworzyć wybranego SLurl.
 	</notification>
diff --git a/indra/newview/skins/default/xui/pt/notifications.xml b/indra/newview/skins/default/xui/pt/notifications.xml
index a1855f2e892ce26b66be0a7b38aa19bf41fd6153..9c3b9386e02bb665bff4e0af6068d72693bddf93 100644
--- a/indra/newview/skins/default/xui/pt/notifications.xml
+++ b/indra/newview/skins/default/xui/pt/notifications.xml
@@ -2658,9 +2658,6 @@ Clique em Aceitar para atender ou em Recusar para recusar este convite.  Clique
 	<notification name="VoiceCallGenericError">
 		Ocorreu um erro enquanto você tentava se conectar à conversa de voz de [VOICE_CHANNEL_NAME].  Favor tentar novamente mais tarde.
 	</notification>
-	<notification name="ServerVersionChanged">
-		Você chegou a uma região com uma versão diferente de servidor, que pode afetar o desempenho.  [[URL] Consultar notas da versão.]
-	</notification>
 	<notification name="UnsupportedCommandSLURL">
 		O SLurl no qual você clicou não é suportado.
 	</notification>
diff --git a/indra/viewer_components/updater/llupdaterservice.cpp b/indra/viewer_components/updater/llupdaterservice.cpp
index aa4983a3b6634984df873f706787e7a4a1c128d9..ea242f45cdad09799eabea2614371cc0e6acffd4 100644
--- a/indra/viewer_components/updater/llupdaterservice.cpp
+++ b/indra/viewer_components/updater/llupdaterservice.cpp
@@ -361,6 +361,7 @@ void LLUpdaterServiceImpl::error(std::string const & message)
 {
 	if(mIsChecking)
 	{
+		setState(LLUpdaterService::TEMPORARY_ERROR);
 		restartTimer(mCheckPeriod);
 	}
 }
diff --git a/indra/viewer_components/updater/llupdaterservice.h b/indra/viewer_components/updater/llupdaterservice.h
index 421481bc43d0adfe44ad6d6bb12dbd8bc22e2d93..450f19c1c6d18cbffc4b4f0c95621f0a6b9717ba 100644
--- a/indra/viewer_components/updater/llupdaterservice.h
+++ b/indra/viewer_components/updater/llupdaterservice.h
@@ -59,6 +59,7 @@ class LLUpdaterService
 	enum eUpdaterState {
 		INITIAL,
 		CHECKING_FOR_UPDATE,
+		TEMPORARY_ERROR,
 		DOWNLOADING,
 		INSTALLING,
 		UP_TO_DATE,
diff --git a/indra/viewer_components/updater/tests/llupdaterservice_test.cpp b/indra/viewer_components/updater/tests/llupdaterservice_test.cpp
index e19d5724f172b5bdc552d2243007611b285076e6..88ab5a22845fe1b774dce553b4eb3c049d918ea6 100644
--- a/indra/viewer_components/updater/tests/llupdaterservice_test.cpp
+++ b/indra/viewer_components/updater/tests/llupdaterservice_test.cpp
@@ -59,6 +59,12 @@ class LLDir_Mock : public LLDir
 		return 0;
 	}
 
+	BOOL getNextFileInDir(const std::string &dirname, 
+						  const std::string &mask, 
+						  std::string &fname) 
+	{
+		return false;
+	}
 	void getRandomFileInDir(const std::string &dirname, 
 							const std::string &mask, 
 							std::string &fname) {}