Found the memory corruptor. String trimmer didn't have a valid

Mon, 08 Jul 2013 20:31:09 +0000

author
Monty Brandenberg <monty@lindenlab.com>
date
Mon, 08 Jul 2013 20:31:09 +0000
changeset 40693
206b5cdfe4d5
parent 40692
c7519f1e63cf
child 40694
4291c258ebc4

Found the memory corruptor. String trimmer didn't have a valid
termination test. Sheesh. Also get some more numbers out of the
example/load test program which drives traffic. This should
give some useful insights into how the current http throttle
works (or doesn't) with varying client demands.

indra/llcorehttp/_httpoprequest.cpp file | annotate | diff | revisions
indra/llcorehttp/examples/http_texture_load.cpp file | annotate | diff | revisions
     1.1 --- a/indra/llcorehttp/_httpoprequest.cpp	Wed Jul 03 19:35:15 2013 -0400
     1.2 +++ b/indra/llcorehttp/_httpoprequest.cpp	Mon Jul 08 20:31:09 2013 +0000
     1.3 @@ -1025,13 +1025,15 @@
     1.4  	}
     1.5  	if (*lstr)
     1.6  	{
     1.7 -		for (char * rstr(lstr + strlen(lstr)); *--rstr;)
     1.8 +		char * rstr(lstr + strlen(lstr));
     1.9 +		while (lstr < rstr && *--rstr)
    1.10  		{
    1.11  			if (' ' == *rstr || '\t' == *rstr)
    1.12  			{
    1.13  				*rstr = '\0';
    1.14  			}
    1.15  		}
    1.16 +		llassert(lstr <= rstr);
    1.17  	}
    1.18  	return lstr;
    1.19  }
     2.1 --- a/indra/llcorehttp/examples/http_texture_load.cpp	Wed Jul 03 19:35:15 2013 -0400
     2.2 +++ b/indra/llcorehttp/examples/http_texture_load.cpp	Mon Jul 08 20:31:09 2013 +0000
     2.3 @@ -58,6 +58,7 @@
     2.4  
     2.5  // Default command line settings
     2.6  static int concurrency_limit(40);
     2.7 +static int highwater(100);
     2.8  static char url_format[1024] = "http://example.com/some/path?texture_id=%s.texture";
     2.9  
    2.10  #if defined(WIN32)
    2.11 @@ -113,6 +114,8 @@
    2.12  	int							mErrorsHttp416;
    2.13  	int							mErrorsHttp500;
    2.14  	int							mErrorsHttp503;
    2.15 +	int							mRetries;
    2.16 +	int							mRetriesHttp503;
    2.17  	int							mSuccesses;
    2.18  	long						mByteCount;
    2.19  	LLCore::HttpHeaders *		mHeaders;
    2.20 @@ -160,7 +163,7 @@
    2.21  	bool do_verbose(false);
    2.22  	
    2.23  	int option(-1);
    2.24 -	while (-1 != (option = getopt(argc, argv, "u:c:h?Rv")))
    2.25 +	while (-1 != (option = getopt(argc, argv, "u:c:h?RvH:")))
    2.26  	{
    2.27  		switch (option)
    2.28  		{
    2.29 @@ -184,6 +187,21 @@
    2.30  			}
    2.31  			break;
    2.32  
    2.33 +		case 'H':
    2.34 +		    {
    2.35 +				unsigned long value;
    2.36 +				char * end;
    2.37 +
    2.38 +				value = strtoul(optarg, &end, 10);
    2.39 +				if (value < 1 || value > 100 || *end != '\0')
    2.40 +				{
    2.41 +					usage(std::cerr);
    2.42 +					return 1;
    2.43 +				}
    2.44 +				highwater = value;
    2.45 +			}
    2.46 +			break;
    2.47 +
    2.48  		case 'R':
    2.49  			do_random = true;
    2.50  			break;
    2.51 @@ -239,7 +257,7 @@
    2.52  	ws.loadAssetUuids(uuids);
    2.53  	ws.mRandomRange = do_random;
    2.54  	ws.mVerbose = do_verbose;
    2.55 -	ws.mRequestHighWater = 100;
    2.56 +	ws.mRequestHighWater = highwater;
    2.57  	ws.mRequestLowWater = ws.mRequestHighWater / 2;
    2.58  	
    2.59  	if (! ws.mAssets.size())
    2.60 @@ -273,6 +291,8 @@
    2.61  	std::cout << "HTTP 404 errors: " << ws.mErrorsHttp404 << "  HTTP 416 errors: " << ws.mErrorsHttp416
    2.62  			  << "  HTTP 500 errors:  " << ws.mErrorsHttp500 << "  HTTP 503 errors: " << ws.mErrorsHttp503 
    2.63  			  << std::endl;
    2.64 +	std::cout << "Retries: " << ws.mRetries << "  Retries on 503: " << ws.mRetriesHttp503
    2.65 +			  << std::endl;
    2.66  	std::cout << "User CPU: " << (metrics.mEndUTime - metrics.mStartUTime)
    2.67  			  << " uS  System CPU: " << (metrics.mEndSTime - metrics.mStartSTime)
    2.68  			  << " uS  Wall Time: "  << (metrics.mEndWallTime - metrics.mStartWallTime)
    2.69 @@ -310,8 +330,10 @@
    2.70  		" -u <url_format>       printf-style format string for URL generation\n"
    2.71  		"                       Default:  " << url_format << "\n"
    2.72  		" -R                    Issue GETs with random Range: headers\n"
    2.73 -		" -c <limit>            Maximum request concurrency.  Range:  [1..100]\n"
    2.74 +		" -c <limit>            Maximum connection concurrency.  Range:  [1..100]\n"
    2.75  		"                       Default:  " << concurrency_limit << "\n"
    2.76 +		" -H <limit>            HTTP request highwater (requests fed to llcorehttp).\n"
    2.77 +		"                       Range:  [1..100]  Default:  " << highwater << "\n"
    2.78  		" -v                    Verbose mode.  Issue some chatter while running\n"
    2.79  		" -h                    print this help\n"
    2.80  		"\n"
    2.81 @@ -332,6 +354,8 @@
    2.82  	  mErrorsHttp416(0),
    2.83  	  mErrorsHttp500(0),
    2.84  	  mErrorsHttp503(0),
    2.85 +	  mRetries(0),
    2.86 +	  mRetriesHttp503(0),
    2.87  	  mSuccesses(0),
    2.88  	  mByteCount(0L)
    2.89  {
    2.90 @@ -426,7 +450,7 @@
    2.91  		{
    2.92  			// More success
    2.93  			LLCore::BufferArray * data(response->getBody());
    2.94 -			mByteCount += data->size();
    2.95 +			mByteCount += data ? data->size() : 0;
    2.96  			++mSuccesses;
    2.97  		}
    2.98  		else
    2.99 @@ -462,6 +486,10 @@
   2.100  				++mErrorsApi;
   2.101  			}
   2.102  		}
   2.103 +		unsigned int retry(0U), retry_503(0U);
   2.104 +		response->getRetries(&retry, &retry_503);
   2.105 +		mRetries += int(retry);
   2.106 +		mRetriesHttp503 += int(retry_503);
   2.107  		mHandles.erase(it);
   2.108  	}
   2.109  

mercurial