diff options
author | Kelly Washington <kelly@lindenlab.com> | 2009-02-24 19:29:36 +0000 |
---|---|---|
committer | Kelly Washington <kelly@lindenlab.com> | 2009-02-24 19:29:36 +0000 |
commit | aa2b978bf59dd74083bec86c61a29fefb4ebb14c (patch) | |
tree | 63d0e55a524208eb2bdad1a1a6f0d03af1b39de2 /indra/lscript/lscript_execute | |
parent | f5242719b628efb148f05ba44ce78f9818ec617a (diff) |
merge -r 112783:112799 linden/branches/kelly/lsl-http-in-merge to linden/trunk
Diffstat (limited to 'indra/lscript/lscript_execute')
-rw-r--r-- | indra/lscript/lscript_execute/CMakeLists.txt | 6 | ||||
-rw-r--r-- | indra/lscript/lscript_execute/llscriptresource.cpp | 86 | ||||
-rw-r--r-- | indra/lscript/lscript_execute/llscriptresourceconsumer.cpp | 101 | ||||
-rw-r--r-- | indra/lscript/lscript_execute/llscriptresourcepool.cpp | 39 | ||||
-rw-r--r-- | indra/lscript/lscript_execute/lscript_execute.cpp | 6 | ||||
-rw-r--r-- | indra/lscript/lscript_execute/lscript_readlso.cpp | 10 |
6 files changed, 248 insertions, 0 deletions
diff --git a/indra/lscript/lscript_execute/CMakeLists.txt b/indra/lscript/lscript_execute/CMakeLists.txt index f30915bab0..3a16ffdc01 100644 --- a/indra/lscript/lscript_execute/CMakeLists.txt +++ b/indra/lscript/lscript_execute/CMakeLists.txt @@ -12,6 +12,9 @@ include_directories( ) set(lscript_execute_SOURCE_FILES + llscriptresource.cpp + llscriptresourceconsumer.cpp + llscriptresourcepool.cpp lscript_execute.cpp lscript_heapruntime.cpp lscript_readlso.cpp @@ -20,6 +23,9 @@ set(lscript_execute_SOURCE_FILES set(lscript_execute_HEADER_FILES CMakeLists.txt + ../llscriptresource.h + ../llscriptresourceconsumer.h + ../llscriptresourcepool.h ../lscript_execute.h ../lscript_rt_interface.h lscript_heapruntime.h diff --git a/indra/lscript/lscript_execute/llscriptresource.cpp b/indra/lscript/lscript_execute/llscriptresource.cpp new file mode 100644 index 0000000000..cc802987b9 --- /dev/null +++ b/indra/lscript/lscript_execute/llscriptresource.cpp @@ -0,0 +1,86 @@ +/** + * @file llscriptresource.cpp + * @brief LLScriptResource class implementation for managing limited resources + * + * $LicenseInfo:firstyear=2008&license=internal$ + * + * Copyright (c) 2008, Linden Research, Inc. + * + * The following source code is PROPRIETARY AND CONFIDENTIAL. Use of + * this source code is governed by the Linden Lab Source Code Disclosure + * Agreement ("Agreement") previously entered between you and Linden + * Lab. By accessing, using, copying, modifying or distributing this + * software, you acknowledge that you have been informed of your + * obligations under the Agreement and agree to abide by those obligations. + * + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. + * $/LicenseInfo$ + */ + +#include "llscriptresource.h" +#include "llerror.h" + +LLScriptResource::LLScriptResource() +: mTotal(0), + mUsed(0) +{ +} + +bool LLScriptResource::request(S32 amount /* = 1 */) +{ + if (mUsed + amount <= mTotal) + { + mUsed += amount; + return true; + } + + return false; +} + +bool LLScriptResource::release(S32 amount /* = 1 */) +{ + if (mUsed >= amount) + { + mUsed -= amount; + return true; + } + + return false; +} + +S32 LLScriptResource::getAvailable() const +{ + if (mUsed > mTotal) + { + // It is possible after a parcel ownership change for more than total to be used + // In this case the user of this class just wants to know + // whether or not they can use a resource + return 0; + } + return (mTotal - mUsed); +} + +void LLScriptResource::setTotal(S32 amount) +{ + // This may cause this resource to be over spent + // such that more are in use than total allowed + // Until those resources are released getAvailable will return 0. + mTotal = amount; +} + +S32 LLScriptResource::getTotal() const +{ + return mTotal; +} + +S32 LLScriptResource::getUsed() const +{ + return mUsed; +} + +bool LLScriptResource::isOverLimit() const +{ + return (mUsed > mTotal); +} diff --git a/indra/lscript/lscript_execute/llscriptresourceconsumer.cpp b/indra/lscript/lscript_execute/llscriptresourceconsumer.cpp new file mode 100644 index 0000000000..6a5b28e257 --- /dev/null +++ b/indra/lscript/lscript_execute/llscriptresourceconsumer.cpp @@ -0,0 +1,101 @@ +/** + * @file llscriptresourceconsumer.cpp + * @brief An interface for a script resource consumer. + * + * $LicenseInfo:firstyear=2008&license=internal$ + * + * Copyright (c) 2008, Linden Research, Inc. + * + * The following source code is PROPRIETARY AND CONFIDENTIAL. Use of + * this source code is governed by the Linden Lab Source Code Disclosure + * Agreement ("Agreement") previously entered between you and Linden + * Lab. By accessing, using, copying, modifying or distributing this + * software, you acknowledge that you have been informed of your + * obligations under the Agreement and agree to abide by those obligations. + * + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. + * $/LicenseInfo$ + */ + +#include "llscriptresourceconsumer.h" + +#include "llscriptresourcepool.h" + +LLScriptResourceConsumer::LLScriptResourceConsumer() + : mScriptResourcePool(&LLScriptResourcePool::null) +{ } + +// Get the resource pool this consumer is currently using. +// virtual +LLScriptResourcePool& LLScriptResourceConsumer::getScriptResourcePool() +{ + return *mScriptResourcePool; +} + +// Get the resource pool this consumer is currently using. +// virtual +const LLScriptResourcePool& LLScriptResourceConsumer::getScriptResourcePool() const +{ + return *mScriptResourcePool; +} + +// virtual +void LLScriptResourceConsumer::setScriptResourcePool(LLScriptResourcePool& new_pool) +{ + mScriptResourcePool = &new_pool; +} + +bool LLScriptResourceConsumer::switchScriptResourcePools(LLScriptResourcePool& new_pool) +{ + if (&new_pool == &LLScriptResourcePool::null) + { + llwarns << "New pool is null" << llendl; + } + + if (isInPool(new_pool)) + { + return true; + } + + if (!canUseScriptResourcePool(new_pool)) + { + return false; + } + + S32 used_urls = getUsedPublicURLs(); + + getScriptResourcePool().getPublicURLResource().release( used_urls ); + setScriptResourcePool(new_pool); + getScriptResourcePool().getPublicURLResource().request( used_urls ); + + return true; +} + +bool LLScriptResourceConsumer::canUseScriptResourcePool(const LLScriptResourcePool& resource_pool) +{ + if (isInPool(resource_pool)) + { + return true; + } + + if (resource_pool.getPublicURLResource().getAvailable() < getUsedPublicURLs()) + { + return false; + } + + return true; +} + +bool LLScriptResourceConsumer::isInPool(const LLScriptResourcePool& resource_pool) +{ + const LLScriptResourcePool& current_pool = getScriptResourcePool(); + if ( &resource_pool == ¤t_pool ) + { + // This consumer is already in this pool + return true; + } + return false; +} + diff --git a/indra/lscript/lscript_execute/llscriptresourcepool.cpp b/indra/lscript/lscript_execute/llscriptresourcepool.cpp new file mode 100644 index 0000000000..2ec67c87dd --- /dev/null +++ b/indra/lscript/lscript_execute/llscriptresourcepool.cpp @@ -0,0 +1,39 @@ +/** + * @file llscriptresourcepool.cpp + * @brief Collection of limited script resources + * + * $LicenseInfo:firstyear=2002&license=internal$ + * + * Copyright (c) 2002-2007, Linden Research, Inc. + * + * The following source code is PROPRIETARY AND CONFIDENTIAL. Use of + * this source code is governed by the Linden Lab Source Code Disclosure + * Agreement ("Agreement") previously entered between you and Linden + * Lab. By accessing, using, copying, modifying or distributing this + * software, you acknowledge that you have been informed of your + * obligations under the Agreement and agree to abide by those obligations. + * + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. + * $/LicenseInfo$ + */ + +#include "llscriptresourcepool.h" + +LLScriptResourcePool LLScriptResourcePool::null; + +LLScriptResourcePool::LLScriptResourcePool() +{ + +} + +LLScriptResource& LLScriptResourcePool::getPublicURLResource() +{ + return mLSLPublicURLs; +} + +const LLScriptResource& LLScriptResourcePool::getPublicURLResource() const +{ + return mLSLPublicURLs; +} diff --git a/indra/lscript/lscript_execute/lscript_execute.cpp b/indra/lscript/lscript_execute/lscript_execute.cpp index daa17f371c..b2b54cdd7a 100644 --- a/indra/lscript/lscript_execute/lscript_execute.cpp +++ b/indra/lscript/lscript_execute/lscript_execute.cpp @@ -68,6 +68,12 @@ const char* LSCRIPTRunTimeFaultStrings[LSRF_EOF] = /*Flawfinder: ignore*/ void LLScriptExecuteLSL2::startRunning() {} void LLScriptExecuteLSL2::stopRunning() {} +const char* URL_REQUEST_GRANTED = "URL_REQUEST_GRANTED"; +const char* URL_REQUEST_DENIED = "URL_REQUEST_DENIED"; + +// HTTP Requests to LSL scripts will time out after 25 seconds. +const U64 LSL_HTTP_REQUEST_TIMEOUT = 25 * USEC_PER_SEC; + LLScriptExecuteLSL2::LLScriptExecuteLSL2(LLFILE *fp) { U8 sizearray[4]; diff --git a/indra/lscript/lscript_execute/lscript_readlso.cpp b/indra/lscript/lscript_execute/lscript_readlso.cpp index f45e64e5de..3b10cc67c1 100644 --- a/indra/lscript/lscript_execute/lscript_readlso.cpp +++ b/indra/lscript/lscript_execute/lscript_readlso.cpp @@ -625,6 +625,16 @@ void LLScriptLSOParse::printStates(LLFILE *fp) bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "\t\tstring %s\n", name); break; + case LSTT_HTTP_REQUEST: // LSTT_HTTP_REQUEST + bytestream2char(name, mRawData, event_offset, sizeof(name)); + fprintf(fp, "%s\n", name); + bytestream2char(name, mRawData, event_offset, sizeof(name)); + fprintf(fp, "\t\tkey %s\n", name); + bytestream2char(name, mRawData, event_offset, sizeof(name)); + fprintf(fp, "\t\tstring %s\n", name); + bytestream2char(name, mRawData, event_offset, sizeof(name)); + fprintf(fp, "\t\tstring %s\n", name); + break; default: break; } |