From 398d78a77348fb4c5ee4e96b7ed6f981b1042627 Mon Sep 17 00:00:00 2001
From: Monty Brandenberg <monty@lindenlab.com>
Date: Mon, 9 Jul 2012 13:28:50 -0400
Subject: [PATCH] Rework the 'sleep' logic in the test HTTP server so that the
 30-second hang doesn't break subsequent tests.  Did this by introducing
 threads into the HTTP server as I can't find the magic to detect that my
 client has gone away.

---
 indra/llcorehttp/tests/test_httprequest.hpp    | 5 -----
 indra/llcorehttp/tests/test_llcorehttp_peer.py | 6 ++++--
 2 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/indra/llcorehttp/tests/test_httprequest.hpp b/indra/llcorehttp/tests/test_httprequest.hpp
index ed4e239fe79..914f35ec3db 100644
--- a/indra/llcorehttp/tests/test_httprequest.hpp
+++ b/indra/llcorehttp/tests/test_httprequest.hpp
@@ -1381,8 +1381,6 @@ void HttpRequestTestObjectType::test<13>()
 }
 
 
-// *NB:  This test must be last.  The sleeping webserver
-// won't respond for a long time.
 template <> template <>
 void HttpRequestTestObjectType::test<14>()
 {
@@ -1503,9 +1501,6 @@ void HttpRequestTestObjectType::test<14>()
 		throw;
 	}
 }
-// *NOTE:  This test ^^^^^^^^ must be the last one in the set.  It uses a
-// sleeping service that interferes with other HTTP tests.  Keep it
-// last until that little HTTP server can get some attention...
 
 }  // end namespace tut
 
diff --git a/indra/llcorehttp/tests/test_llcorehttp_peer.py b/indra/llcorehttp/tests/test_llcorehttp_peer.py
index 0e38e5a87fc..9e1847c66ec 100644
--- a/indra/llcorehttp/tests/test_llcorehttp_peer.py
+++ b/indra/llcorehttp/tests/test_llcorehttp_peer.py
@@ -32,10 +32,12 @@
 import os
 import sys
 import time
+import select
 from threading import Thread
 from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler
+from SocketServer import ThreadingMixIn
 
-mydir = os.path.dirname(__file__)       # expected to be .../indra/llmessage/tests/
+mydir = os.path.dirname(__file__)       # expected to be .../indra/llcorehttp/tests/
 sys.path.insert(0, os.path.join(mydir, os.pardir, os.pardir, "lib", "python"))
 from indra.util.fastest_elementtree import parse as xml_parse
 from indra.base import llsd
@@ -144,7 +146,7 @@ def log_error(self, format, *args):
             # Suppress error output as well
             pass
 
-class Server(HTTPServer):
+class Server(ThreadingMixIn, HTTPServer):
     # This pernicious flag is on by default in HTTPServer. But proper
     # operation of freeport() absolutely depends on it being off.
     allow_reuse_address = False
-- 
GitLab