Commits

Scott Lawrence committed e85aea7 Draft Merge

merge changes for DRTVWR-269

Comments (0)

Files changed (4)

 44e764a6ac9e672a4f3bce821a4b6a218590c374 DRTVWR-258
 c23d734065ed593b2413385aecd8366d8e0ee96b DRTVWR-257
 452ce96d4046dc05a3ecaecc203e2cc8ddd72e76 DRTVWR-259
-5cba5f39d0a81d659f24ebc4b5efd025a39e3db1 3.4.3-release
 9aa1aa9f1fe13c194695a0b8f0af298296241dc2 DRTVWR-260
 daca610d840625b5bebb966a57cb49581852c417 DRTVWR-265
 9afbdc4e24cc04feacfb2b7a10b78a64f780901a DRTVWR-266
 73280db02501f5ad041fc18b1eba68e73a81996c DRTVWR-267
 870e2d79e0063fda87187f17bbc2747766733194 3.4.3-beta3
-18c5f76ac07937e0b64bb874edba0d60a28cec56 DRTVWR-244
+0a2ca6546b499239afeb66d17b2fadbcdbe36ab1 3.4.3-release
+84fbaf2d4141bd161731430e760949dc787ca206 DRTVWR-244
 083d2d36b5bb1c54fc3dd7caac0e7ac381a9cef0 3.4.4-beta1
 391a8c74cec7275c5d26c85ad108d4782a3e3dd9 DRTVWR-268
 b634dec987c16e8c9c938e11e52591d9ead8fa9b DRTVWR-270
 2f8a3ef687bc55828abcb17ac1ad7cde70536d7e 3.4.4-beta3
 35cfd4cf5b895fa776592f2e630e330be7f0604e DRTVWR-273
 a36f1f354b02aa6e448ca13685de167d0a0a3d03 DRTVWR-272
+37dba00ad820de3a808d4039396b162a9c275b3e DRTVWR-269

indra/llcommon/lluuid.cpp

 #include "llmd5.h"
 #include "llstring.h"
 #include "lltimer.h"
+#include "llthread.h"
 
 const LLUUID LLUUID::null;
 const LLTransactionID LLTransactionID::tnull;
 
+// static 
+LLMutex * LLUUID::mMutex = NULL;
+
+
+
 /*
 
 NOT DONE YET!!!
       getSystemTime(&time_last);
       uuids_this_tick = uuids_per_tick;
       init = TRUE;
+	  mMutex = new LLMutex(NULL);
    }
 
    uuid_time_t time_now = {0,0};
 #endif
 	if (!has_init) 
 	{
+		has_init = 1;
 		if (getNodeID(node_id) <= 0) 
 		{
 			get_random_bytes(node_id, 6);
 #else
 		clock_seq = (U16)ll_rand(65536);
 #endif
-		has_init = 1;
 	}
 
 	// get current time
 	getCurrentTime(&timestamp);
+	U16 our_clock_seq = clock_seq;
 
-	// if clock went backward change clockseq
-	if (cmpTime(&timestamp, &time_last) == -1) {
+	// if clock hasn't changed or went backward, change clockseq
+	if (cmpTime(&timestamp, &time_last) != 1) 
+	{
+		LLMutexLock	lock(mMutex);
 		clock_seq = (clock_seq + 1) & 0x3FFF;
-		if (clock_seq == 0) clock_seq++;
+		if (clock_seq == 0) 
+			clock_seq++;
+		our_clock_seq = clock_seq;	// Ensure we're using a different clock_seq value from previous time
 	}
 
+    time_last = timestamp;
+
 	memcpy(mData+10, node_id, 6);		/* Flawfinder: ignore */
 	U32 tmp;
 	tmp = timestamp.low;
 	tmp >>= 8;
 	mData[6] = (unsigned char) tmp;
 
-	tmp = clock_seq;
+	tmp = our_clock_seq;
+
 	mData[9] = (unsigned char) tmp;
 	tmp >>= 8;
 	mData[8] = (unsigned char) tmp;
 	md5_uuid.update(mData,16);
 	md5_uuid.finalize();
 	md5_uuid.raw_digest(mData);
-
-    time_last = timestamp;
 }
 
 void LLUUID::generate(const std::string& hash_string)
    static unsigned char seed[16];		/* Flawfinder: ignore */
    
    getNodeID(&seed[0]);
-   seed[6]='\0';
-   seed[7]='\0';
+
+   // Incorporate the pid into the seed to prevent
+   // processes that start on the same host at the same
+   // time from generating the same seed.
+   pid_t pid = LLApp::getPid();
+
+   seed[6]=(unsigned char)(pid >> 8);
+   seed[7]=(unsigned char)(pid);
    getSystemTime((uuid_time_t *)(&seed[8]));
 
    LLMD5 md5_seed;

indra/llcommon/lluuid.h

 #include "stdtypes.h"
 #include "llpreprocessor.h"
 
+class LLMutex;
+
 const S32 UUID_BYTES = 16;
 const S32 UUID_WORDS = 4;
 const S32 UUID_STR_LENGTH = 37;	// actually wrong, should be 36 and use size below
 	static BOOL validate(const std::string& in_string); // Validate that the UUID string is legal.
 
 	static const LLUUID null;
+	static LLMutex * mMutex;
 
 	static U32 getRandomSeed();
 	static S32 getNodeID(unsigned char * node_id);

indra/test/lluuidhashmap_tut.cpp

 		std::string savefile(gDirUtilp->add(tempdir, "lluuidhashmap_tut.save.txt"));
 		const int numElementsToCheck = 32*256*32;
 		std::vector<LLUUID> idList;
-		if (gDirUtilp->fileExists(savefile))
+		if ((! getenv("TEAMCITY_PROJECT_NAME")) && gDirUtilp->fileExists(savefile))
 		{
-			// We have saved data from a previous failed run. Reload that data.
+			// This is not a TeamCity build, and we have saved data from a
+			// previous failed run. Reload that data.
 			std::ifstream inf(savefile.c_str());
 			if (! inf.is_open())
 			{
 		}
 		else
 		{
-			// savefile does not exist (normal case): regenerate idList from
-			// scratch.
+			// This is a TeamCity build, or (normal case) savefile does not
+			// exist: regenerate idList from scratch.
 			for (int i = 0; i < numElementsToCheck; ++i)
 			{
 				LLUUID id;