From a8a62201ba762e98dff92cf49033e577fc34d8d4 Mon Sep 17 00:00:00 2001 From: Jacek Antonelli Date: Fri, 15 Aug 2008 23:45:27 -0500 Subject: Second Life viewer sources 1.19.0.0 --- linden/indra/test/io.cpp | 68 +++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 65 insertions(+), 3 deletions(-) (limited to 'linden/indra/test/io.cpp') diff --git a/linden/indra/test/io.cpp b/linden/indra/test/io.cpp index 0a31e3a..facf98d 100644 --- a/linden/indra/test/io.cpp +++ b/linden/indra/test/io.cpp @@ -14,12 +14,12 @@ * ("GPL"), unless you have obtained a separate licensing agreement * ("Other License"), formally executed by you and Linden Lab. Terms of * the GPL can be found in doc/GPL-license.txt in this distribution, or - * online at http://secondlife.com/developers/opensource/gplv2 + * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 * * There are special exceptions to the terms and conditions of the GPL as * it is applied to this Source Code. View the full text of the exception * in the file doc/FLOSS-exception.txt in this software distribution, or - * online at http://secondlife.com/developers/opensource/flossexception + * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception * * By copying, modifying or distributing this software, you acknowledge * that you have read and understood your obligations described above, @@ -1080,7 +1080,7 @@ namespace tut mPool, mSocket, factory); - server->setResponseTimeout(SHORT_CHAIN_EXPIRY_SECS + 2.0f); + server->setResponseTimeout(SHORT_CHAIN_EXPIRY_SECS + 1.80f); chain.push_back(LLIOPipe::ptr_t(server)); mPump->addChain(chain, NEVER_CHAIN_EXPIRY_SECS); @@ -1108,6 +1108,68 @@ namespace tut F32 elapsed = pump_loop(mPump, SHORT_CHAIN_EXPIRY_SECS + 3.0f); ensure("Did not take too long", (elapsed < DEFAULT_CHAIN_EXPIRY_SECS)); } + + template<> template<> + void fitness_test_object::test<5>() + { + // Set up the server + LLPumpIO::chain_t chain; + typedef LLCloneIOFactory sleeper_t; + sleeper_t* sleeper = new sleeper_t(new LLIOSleeper); + boost::shared_ptr factory(sleeper); + LLIOServerSocket* server = new LLIOServerSocket( + mPool, + mSocket, + factory); + server->setResponseTimeout(1.0); + chain.push_back(LLIOPipe::ptr_t(server)); + mPump->addChain(chain, NEVER_CHAIN_EXPIRY_SECS); + // We need to tickle the pump a little to set up the listen() + pump_loop(mPump, 0.1f); + U32 count = mPump->runningChains(); + ensure_equals("server chain onboard", count, 1); + lldebugs << "** Server is up." << llendl; + + // Set up the client + LLSocket::ptr_t client = LLSocket::create(mPool, LLSocket::STREAM_TCP); + LLHost server_host("127.0.0.1", SERVER_LISTEN_PORT); + bool connected = client->blockingConnect(server_host); + ensure("Connected to server", connected); + lldebugs << "connected" << llendl; + F32 elapsed = pump_loop(mPump,0.1f); + count = mPump->runningChains(); + ensure_equals("server chain onboard", count, 2); + lldebugs << "** Client is connected." << llendl; + + // We have connected, since the socket reader does not block, + // the first call to read data will return EAGAIN, so we need + // to write something. + chain.clear(); + chain.push_back(LLIOPipe::ptr_t(new LLPipeStringInjector("hi"))); + chain.push_back(LLIOPipe::ptr_t(new LLIOSocketWriter(client))); + chain.push_back(LLIOPipe::ptr_t(new LLIONull)); + mPump->addChain(chain, 0.2); + chain.clear(); + + // pump for a bit and make sure all 3 chains are running + elapsed = pump_loop(mPump,0.1f); + count = mPump->runningChains(); + ensure_equals("client chain onboard", count, 3); + lldebugs << "** request should have been sent." << llendl; + + // pump for long enough the the client socket closes, and the + // server socket should not be closed yet. + elapsed = pump_loop(mPump,0.2f); + count = mPump->runningChains(); + ensure_equals("client chain timed out ", count, 2); + lldebugs << "** client chain should be closed." << llendl; + + // At this point, the socket should be closed by the timeout + elapsed = pump_loop(mPump,1.0f); + count = mPump->runningChains(); + ensure_equals("accepted socked close", count, 1); + lldebugs << "** Sleeper should have timed out.." << llendl; + } } namespace tut -- cgit v1.1