summaryrefslogtreecommitdiff
path: root/indra/llcorehttp/_httpservice.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llcorehttp/_httpservice.cpp')
-rw-r--r--indra/llcorehttp/_httpservice.cpp716
1 files changed, 358 insertions, 358 deletions
diff --git a/indra/llcorehttp/_httpservice.cpp b/indra/llcorehttp/_httpservice.cpp
index 517076804d..d543512ec4 100644
--- a/indra/llcorehttp/_httpservice.cpp
+++ b/indra/llcorehttp/_httpservice.cpp
@@ -54,145 +54,145 @@ namespace LLCore
const HttpService::OptionDescriptor HttpService::sOptionDesc[] =
{ // isLong isDynamic isGlobal isClass
- { true, true, true, true, false }, // PO_CONNECTION_LIMIT
- { true, true, false, true, false }, // PO_PER_HOST_CONNECTION_LIMIT
- { false, false, true, false, false }, // PO_CA_PATH
- { false, false, true, false, false }, // PO_CA_FILE
- { false, true, true, false, false }, // PO_HTTP_PROXY
- { true, true, true, false, false }, // PO_LLPROXY
- { true, true, true, false, false }, // PO_TRACE
- { true, true, false, true, false }, // PO_ENABLE_PIPELINING
- { true, true, false, true, false }, // PO_THROTTLE_RATE
- { false, false, true, false, true } // PO_SSL_VERIFY_CALLBACK
+ { true, true, true, true, false }, // PO_CONNECTION_LIMIT
+ { true, true, false, true, false }, // PO_PER_HOST_CONNECTION_LIMIT
+ { false, false, true, false, false }, // PO_CA_PATH
+ { false, false, true, false, false }, // PO_CA_FILE
+ { false, true, true, false, false }, // PO_HTTP_PROXY
+ { true, true, true, false, false }, // PO_LLPROXY
+ { true, true, true, false, false }, // PO_TRACE
+ { true, true, false, true, false }, // PO_ENABLE_PIPELINING
+ { true, true, false, true, false }, // PO_THROTTLE_RATE
+ { false, false, true, false, true } // PO_SSL_VERIFY_CALLBACK
};
HttpService * HttpService::sInstance(NULL);
volatile HttpService::EState HttpService::sState(NOT_INITIALIZED);
HttpService::HttpService()
- : mRequestQueue(NULL),
- mExitRequested(0U),
- mThread(NULL),
- mPolicy(NULL),
- mTransport(NULL),
- mLastPolicy(0)
+ : mRequestQueue(NULL),
+ mExitRequested(0U),
+ mThread(NULL),
+ mPolicy(NULL),
+ mTransport(NULL),
+ mLastPolicy(0)
{}
HttpService::~HttpService()
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_NETWORK;
- mExitRequested = 1U;
- if (RUNNING == sState)
- {
- // Trying to kill the service object with a running thread
- // is a bit tricky.
- if (mRequestQueue)
- {
+ mExitRequested = 1U;
+ if (RUNNING == sState)
+ {
+ // Trying to kill the service object with a running thread
+ // is a bit tricky.
+ if (mRequestQueue)
+ {
if (mRequestQueue->stopQueue())
{
// Give mRequestQueue a chance to finish
ms_sleep(10);
}
- }
-
- if (mThread)
- {
- if (! mThread->timedJoin(250))
- {
- // Failed to join, expect problems ahead so do a hard termination.
- LL_WARNS(LOG_CORE) << "Destroying HttpService with running thread. Expect problems." << LL_NEWLINE
- << "State: " << S32(sState)
- << " Last policy: " << U32(mLastPolicy)
- << LL_ENDL;
-
- mThread->cancel();
- }
- }
- }
-
- if (mRequestQueue)
- {
- mRequestQueue->release();
- mRequestQueue = NULL;
- }
-
- delete mTransport;
- mTransport = NULL;
-
- delete mPolicy;
- mPolicy = NULL;
-
- if (mThread)
- {
- mThread->release();
- mThread = NULL;
- }
+ }
+
+ if (mThread)
+ {
+ if (! mThread->timedJoin(250))
+ {
+ // Failed to join, expect problems ahead so do a hard termination.
+ LL_WARNS(LOG_CORE) << "Destroying HttpService with running thread. Expect problems." << LL_NEWLINE
+ << "State: " << S32(sState)
+ << " Last policy: " << U32(mLastPolicy)
+ << LL_ENDL;
+
+ mThread->cancel();
+ }
+ }
+ }
+
+ if (mRequestQueue)
+ {
+ mRequestQueue->release();
+ mRequestQueue = NULL;
+ }
+
+ delete mTransport;
+ mTransport = NULL;
+
+ delete mPolicy;
+ mPolicy = NULL;
+
+ if (mThread)
+ {
+ mThread->release();
+ mThread = NULL;
+ }
}
-
+
void HttpService::init(HttpRequestQueue * queue)
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_NETWORK;
- llassert_always(! sInstance);
- llassert_always(NOT_INITIALIZED == sState);
- sInstance = new HttpService();
-
- queue->addRef();
- sInstance->mRequestQueue = queue;
- sInstance->mPolicy = new HttpPolicy(sInstance);
- sInstance->mTransport = new HttpLibcurl(sInstance);
- sState = INITIALIZED;
+ llassert_always(! sInstance);
+ llassert_always(NOT_INITIALIZED == sState);
+ sInstance = new HttpService();
+
+ queue->addRef();
+ sInstance->mRequestQueue = queue;
+ sInstance->mPolicy = new HttpPolicy(sInstance);
+ sInstance->mTransport = new HttpLibcurl(sInstance);
+ sState = INITIALIZED;
}
void HttpService::term()
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_NETWORK;
- if (sInstance)
- {
- if (RUNNING == sState && sInstance->mThread)
- {
- // Unclean termination. Thread appears to be running. We'll
- // try to give the worker thread a chance to cancel using the
- // exit flag...
- sInstance->mExitRequested = 1U;
- sInstance->mRequestQueue->stopQueue();
-
- // And a little sleep
- for (int i(0); i < 10 && RUNNING == sState; ++i)
- {
- ms_sleep(100);
- }
- }
-
- delete sInstance;
- sInstance = NULL;
- }
- sState = NOT_INITIALIZED;
+ if (sInstance)
+ {
+ if (RUNNING == sState && sInstance->mThread)
+ {
+ // Unclean termination. Thread appears to be running. We'll
+ // try to give the worker thread a chance to cancel using the
+ // exit flag...
+ sInstance->mExitRequested = 1U;
+ sInstance->mRequestQueue->stopQueue();
+
+ // And a little sleep
+ for (int i(0); i < 10 && RUNNING == sState; ++i)
+ {
+ ms_sleep(100);
+ }
+ }
+
+ delete sInstance;
+ sInstance = NULL;
+ }
+ sState = NOT_INITIALIZED;
}
HttpRequest::policy_t HttpService::createPolicyClass()
{
- mLastPolicy = mPolicy->createPolicyClass();
- return mLastPolicy;
+ mLastPolicy = mPolicy->createPolicyClass();
+ return mLastPolicy;
}
bool HttpService::isStopped()
{
- // What is really wanted here is something like:
- //
- // HttpService * service = instanceOf();
- // return STOPPED == sState && (! service || ! service->mThread || ! service->mThread->joinable());
- //
- // But boost::thread is not giving me a consistent story on joinability
- // of a thread after it returns. Debug and non-debug builds are showing
- // different behavior on Linux/Etch so we do a weaker test that may
- // not be globally correct (i.e. thread *is* stopping, may not have
- // stopped but will very soon):
-
- return STOPPED == sState;
+ // What is really wanted here is something like:
+ //
+ // HttpService * service = instanceOf();
+ // return STOPPED == sState && (! service || ! service->mThread || ! service->mThread->joinable());
+ //
+ // But boost::thread is not giving me a consistent story on joinability
+ // of a thread after it returns. Debug and non-debug builds are showing
+ // different behavior on Linux/Etch so we do a weaker test that may
+ // not be globally correct (i.e. thread *is* stopping, may not have
+ // stopped but will very soon):
+
+ return STOPPED == sState;
}
@@ -200,66 +200,66 @@ bool HttpService::isStopped()
void HttpService::startThread()
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_NETWORK;
- llassert_always(! mThread || STOPPED == sState);
- llassert_always(INITIALIZED == sState || STOPPED == sState);
+ llassert_always(! mThread || STOPPED == sState);
+ llassert_always(INITIALIZED == sState || STOPPED == sState);
- if (mThread)
- {
- mThread->release();
- }
+ if (mThread)
+ {
+ mThread->release();
+ }
- // Push current policy definitions, enable policy & transport components
- mPolicy->start();
- mTransport->start(mLastPolicy + 1);
+ // Push current policy definitions, enable policy & transport components
+ mPolicy->start();
+ mTransport->start(mLastPolicy + 1);
- mThread = new LLCoreInt::HttpThread(boost::bind(&HttpService::threadRun, this, _1));
- sState = RUNNING;
+ mThread = new LLCoreInt::HttpThread(boost::bind(&HttpService::threadRun, this, _1));
+ sState = RUNNING;
}
/// Threading: callable by worker thread.
void HttpService::stopRequested()
{
- mExitRequested = 1U;
+ mExitRequested = 1U;
}
/// Try to find the given request handle on any of the request
/// queues and cancel the operation.
///
-/// @return True if the request was canceled.
+/// @return True if the request was canceled.
///
/// Threading: callable by worker thread.
bool HttpService::cancel(HttpHandle handle)
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_NETWORK;
- bool canceled(false);
+ bool canceled(false);
+
+ // Request can't be on request queue so skip that.
- // Request can't be on request queue so skip that.
+ // Check the policy component's queues first
+ canceled = mPolicy->cancel(handle);
- // Check the policy component's queues first
- canceled = mPolicy->cancel(handle);
+ if (! canceled)
+ {
+ // If that didn't work, check transport's.
+ canceled = mTransport->cancel(handle);
+ }
- if (! canceled)
- {
- // If that didn't work, check transport's.
- canceled = mTransport->cancel(handle);
- }
-
- return canceled;
+ return canceled;
}
-
+
/// Threading: callable by worker thread.
void HttpService::shutdown()
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_NETWORK;
- // Disallow future enqueue of requests
- mRequestQueue->stopQueue();
+ // Disallow future enqueue of requests
+ mRequestQueue->stopQueue();
- // Cancel requests already on the request queue
- HttpRequestQueue::OpContainer ops;
- mRequestQueue->fetchAll(false, ops);
+ // Cancel requests already on the request queue
+ HttpRequestQueue::OpContainer ops;
+ mRequestQueue->fetchAll(false, ops);
for (HttpRequestQueue::OpContainer::iterator it = ops.begin();
it != ops.end(); ++it)
@@ -268,11 +268,11 @@ void HttpService::shutdown()
}
ops.clear();
- // Shutdown transport canceling requests, freeing resources
- mTransport->shutdown();
+ // Shutdown transport canceling requests, freeing resources
+ mTransport->shutdown();
- // And now policy
- mPolicy->shutdown();
+ // And now policy
+ mPolicy->shutdown();
}
@@ -285,31 +285,31 @@ void HttpService::threadRun(LLCoreInt::HttpThread * thread)
{
LL_PROFILER_SET_THREAD_NAME("HttpService");
- boost::this_thread::disable_interruption di;
+ boost::this_thread::disable_interruption di;
+
+ LLThread::registerThreadID();
- LLThread::registerThreadID();
-
- ELoopSpeed loop(REQUEST_SLEEP);
- while (! mExitRequested)
- {
+ ELoopSpeed loop(REQUEST_SLEEP);
+ while (! mExitRequested)
+ {
LL_PROFILE_ZONE_SCOPED_CATEGORY_NETWORK;
try
{
- loop = processRequestQueue(loop);
-
- // Process ready queue issuing new requests as needed
- ELoopSpeed new_loop = mPolicy->processReadyQueue();
- loop = (std::min)(loop, new_loop);
-
- // Give libcurl some cycles
- new_loop = mTransport->processTransport();
- loop = (std::min)(loop, new_loop);
-
- // Determine whether to spin, sleep briefly or sleep for next request
- if (REQUEST_SLEEP != loop)
- {
- ms_sleep(HTTP_SERVICE_LOOP_SLEEP_NORMAL_MS);
- }
+ loop = processRequestQueue(loop);
+
+ // Process ready queue issuing new requests as needed
+ ELoopSpeed new_loop = mPolicy->processReadyQueue();
+ loop = (std::min)(loop, new_loop);
+
+ // Give libcurl some cycles
+ new_loop = mTransport->processTransport();
+ loop = (std::min)(loop, new_loop);
+
+ // Determine whether to spin, sleep briefly or sleep for next request
+ if (REQUEST_SLEEP != loop)
+ {
+ ms_sleep(HTTP_SERVICE_LOOP_SLEEP_NORMAL_MS);
+ }
}
catch (const LLContinueError&)
{
@@ -331,250 +331,250 @@ void HttpService::threadRun(LLCoreInt::HttpThread * thread)
}
}
- shutdown();
- sState = STOPPED;
+ shutdown();
+ sState = STOPPED;
}
HttpService::ELoopSpeed HttpService::processRequestQueue(ELoopSpeed loop)
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_NETWORK;
- HttpRequestQueue::OpContainer ops;
- const bool wait_for_req(REQUEST_SLEEP == loop);
-
- mRequestQueue->fetchAll(wait_for_req, ops);
- while (! ops.empty())
- {
- HttpOperation::ptr_t op(ops.front());
- ops.erase(ops.begin());
-
- // Process operation
- if (! mExitRequested)
- {
- // Setup for subsequent tracing
- long tracing(HTTP_TRACE_OFF);
- mPolicy->getGlobalOptions().get(HttpRequest::PO_TRACE, &tracing);
- op->mTracing = (std::max)(op->mTracing, int(tracing));
-
- if (op->mTracing > HTTP_TRACE_OFF)
- {
- LL_INFOS(LOG_CORE) << "TRACE, FromRequestQueue, Handle: "
- << op->getHandle()
- << LL_ENDL;
- }
-
- // Stage
- op->stageFromRequest(this);
- }
-
- // Done with operation
+ HttpRequestQueue::OpContainer ops;
+ const bool wait_for_req(REQUEST_SLEEP == loop);
+
+ mRequestQueue->fetchAll(wait_for_req, ops);
+ while (! ops.empty())
+ {
+ HttpOperation::ptr_t op(ops.front());
+ ops.erase(ops.begin());
+
+ // Process operation
+ if (! mExitRequested)
+ {
+ // Setup for subsequent tracing
+ long tracing(HTTP_TRACE_OFF);
+ mPolicy->getGlobalOptions().get(HttpRequest::PO_TRACE, &tracing);
+ op->mTracing = (std::max)(op->mTracing, int(tracing));
+
+ if (op->mTracing > HTTP_TRACE_OFF)
+ {
+ LL_INFOS(LOG_CORE) << "TRACE, FromRequestQueue, Handle: "
+ << op->getHandle()
+ << LL_ENDL;
+ }
+
+ // Stage
+ op->stageFromRequest(this);
+ }
+
+ // Done with operation
op.reset();
- }
+ }
- // Queue emptied, allow polling loop to sleep
- return REQUEST_SLEEP;
+ // Queue emptied, allow polling loop to sleep
+ return REQUEST_SLEEP;
}
HttpStatus HttpService::getPolicyOption(HttpRequest::EPolicyOption opt, HttpRequest::policy_t pclass,
- long * ret_value)
+ long * ret_value)
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_NETWORK;
- if (opt < HttpRequest::PO_CONNECTION_LIMIT // option must be in range
- || opt >= HttpRequest::PO_LAST // ditto
- || (! sOptionDesc[opt].mIsLong) // datatype is long
- || (pclass != HttpRequest::GLOBAL_POLICY_ID && pclass > mLastPolicy) // pclass in valid range
- || (pclass == HttpRequest::GLOBAL_POLICY_ID && ! sOptionDesc[opt].mIsGlobal) // global setting permitted
- || (pclass != HttpRequest::GLOBAL_POLICY_ID && ! sOptionDesc[opt].mIsClass)) // class setting permitted
- // can always get, no dynamic check
- {
- return HttpStatus(HttpStatus::LLCORE, LLCore::HE_INVALID_ARG);
- }
-
- HttpStatus status;
- if (pclass == HttpRequest::GLOBAL_POLICY_ID)
- {
- HttpPolicyGlobal & opts(mPolicy->getGlobalOptions());
-
- status = opts.get(opt, ret_value);
- }
- else
- {
- HttpPolicyClass & opts(mPolicy->getClassOptions(pclass));
-
- status = opts.get(opt, ret_value);
- }
-
- return status;
+ if (opt < HttpRequest::PO_CONNECTION_LIMIT // option must be in range
+ || opt >= HttpRequest::PO_LAST // ditto
+ || (! sOptionDesc[opt].mIsLong) // datatype is long
+ || (pclass != HttpRequest::GLOBAL_POLICY_ID && pclass > mLastPolicy) // pclass in valid range
+ || (pclass == HttpRequest::GLOBAL_POLICY_ID && ! sOptionDesc[opt].mIsGlobal) // global setting permitted
+ || (pclass != HttpRequest::GLOBAL_POLICY_ID && ! sOptionDesc[opt].mIsClass)) // class setting permitted
+ // can always get, no dynamic check
+ {
+ return HttpStatus(HttpStatus::LLCORE, LLCore::HE_INVALID_ARG);
+ }
+
+ HttpStatus status;
+ if (pclass == HttpRequest::GLOBAL_POLICY_ID)
+ {
+ HttpPolicyGlobal & opts(mPolicy->getGlobalOptions());
+
+ status = opts.get(opt, ret_value);
+ }
+ else
+ {
+ HttpPolicyClass & opts(mPolicy->getClassOptions(pclass));
+
+ status = opts.get(opt, ret_value);
+ }
+
+ return status;
}
HttpStatus HttpService::getPolicyOption(HttpRequest::EPolicyOption opt, HttpRequest::policy_t pclass,
- std::string * ret_value)
+ std::string * ret_value)
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_NETWORK;
- HttpStatus status(HttpStatus::LLCORE, LLCore::HE_INVALID_ARG);
-
- if (opt < HttpRequest::PO_CONNECTION_LIMIT // option must be in range
- || opt >= HttpRequest::PO_LAST // ditto
- || (sOptionDesc[opt].mIsLong) // datatype is string
- || (pclass != HttpRequest::GLOBAL_POLICY_ID && pclass > mLastPolicy) // pclass in valid range
- || (pclass == HttpRequest::GLOBAL_POLICY_ID && ! sOptionDesc[opt].mIsGlobal) // global setting permitted
- || (pclass != HttpRequest::GLOBAL_POLICY_ID && ! sOptionDesc[opt].mIsClass)) // class setting permitted
- // can always get, no dynamic check
- {
- return status;
- }
-
- // Only global has string values
- if (pclass == HttpRequest::GLOBAL_POLICY_ID)
- {
- HttpPolicyGlobal & opts(mPolicy->getGlobalOptions());
-
- status = opts.get(opt, ret_value);
- }
-
- return status;
+ HttpStatus status(HttpStatus::LLCORE, LLCore::HE_INVALID_ARG);
+
+ if (opt < HttpRequest::PO_CONNECTION_LIMIT // option must be in range
+ || opt >= HttpRequest::PO_LAST // ditto
+ || (sOptionDesc[opt].mIsLong) // datatype is string
+ || (pclass != HttpRequest::GLOBAL_POLICY_ID && pclass > mLastPolicy) // pclass in valid range
+ || (pclass == HttpRequest::GLOBAL_POLICY_ID && ! sOptionDesc[opt].mIsGlobal) // global setting permitted
+ || (pclass != HttpRequest::GLOBAL_POLICY_ID && ! sOptionDesc[opt].mIsClass)) // class setting permitted
+ // can always get, no dynamic check
+ {
+ return status;
+ }
+
+ // Only global has string values
+ if (pclass == HttpRequest::GLOBAL_POLICY_ID)
+ {
+ HttpPolicyGlobal & opts(mPolicy->getGlobalOptions());
+
+ status = opts.get(opt, ret_value);
+ }
+
+ return status;
}
HttpStatus HttpService::getPolicyOption(HttpRequest::EPolicyOption opt, HttpRequest::policy_t pclass,
- HttpRequest::policyCallback_t * ret_value)
+ HttpRequest::policyCallback_t * ret_value)
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_NETWORK;
- HttpStatus status(HttpStatus::LLCORE, LLCore::HE_INVALID_ARG);
-
- if (opt < HttpRequest::PO_CONNECTION_LIMIT // option must be in range
- || opt >= HttpRequest::PO_LAST // ditto
- || (sOptionDesc[opt].mIsLong) // datatype is string
- || (pclass != HttpRequest::GLOBAL_POLICY_ID && pclass > mLastPolicy) // pclass in valid range
- || (pclass == HttpRequest::GLOBAL_POLICY_ID && !sOptionDesc[opt].mIsGlobal) // global setting permitted
- || (pclass != HttpRequest::GLOBAL_POLICY_ID && !sOptionDesc[opt].mIsClass)) // class setting permitted
- // can always get, no dynamic check
- {
- return status;
- }
-
- // Only global has callback values
- if (pclass == HttpRequest::GLOBAL_POLICY_ID)
- {
- HttpPolicyGlobal & opts(mPolicy->getGlobalOptions());
-
- status = opts.get(opt, ret_value);
- }
-
- return status;
+ HttpStatus status(HttpStatus::LLCORE, LLCore::HE_INVALID_ARG);
+
+ if (opt < HttpRequest::PO_CONNECTION_LIMIT // option must be in range
+ || opt >= HttpRequest::PO_LAST // ditto
+ || (sOptionDesc[opt].mIsLong) // datatype is string
+ || (pclass != HttpRequest::GLOBAL_POLICY_ID && pclass > mLastPolicy) // pclass in valid range
+ || (pclass == HttpRequest::GLOBAL_POLICY_ID && !sOptionDesc[opt].mIsGlobal) // global setting permitted
+ || (pclass != HttpRequest::GLOBAL_POLICY_ID && !sOptionDesc[opt].mIsClass)) // class setting permitted
+ // can always get, no dynamic check
+ {
+ return status;
+ }
+
+ // Only global has callback values
+ if (pclass == HttpRequest::GLOBAL_POLICY_ID)
+ {
+ HttpPolicyGlobal & opts(mPolicy->getGlobalOptions());
+
+ status = opts.get(opt, ret_value);
+ }
+
+ return status;
}
HttpStatus HttpService::setPolicyOption(HttpRequest::EPolicyOption opt, HttpRequest::policy_t pclass,
- long value, long * ret_value)
+ long value, long * ret_value)
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_NETWORK;
- HttpStatus status(HttpStatus::LLCORE, LLCore::HE_INVALID_ARG);
-
- if (opt < HttpRequest::PO_CONNECTION_LIMIT // option must be in range
- || opt >= HttpRequest::PO_LAST // ditto
- || (! sOptionDesc[opt].mIsLong) // datatype is long
- || (pclass != HttpRequest::GLOBAL_POLICY_ID && pclass > mLastPolicy) // pclass in valid range
- || (pclass == HttpRequest::GLOBAL_POLICY_ID && ! sOptionDesc[opt].mIsGlobal) // global setting permitted
- || (pclass != HttpRequest::GLOBAL_POLICY_ID && ! sOptionDesc[opt].mIsClass) // class setting permitted
- || (RUNNING == sState && ! sOptionDesc[opt].mIsDynamic)) // dynamic setting permitted
- {
- return status;
- }
-
- if (pclass == HttpRequest::GLOBAL_POLICY_ID)
- {
- HttpPolicyGlobal & opts(mPolicy->getGlobalOptions());
-
- status = opts.set(opt, value);
- if (status && ret_value)
- {
- status = opts.get(opt, ret_value);
- }
- }
- else
- {
- HttpPolicyClass & opts(mPolicy->getClassOptions(pclass));
-
- status = opts.set(opt, value);
- if (status)
- {
- mTransport->policyUpdated(pclass);
- if (ret_value)
- {
- status = opts.get(opt, ret_value);
- }
- }
- }
-
- return status;
+ HttpStatus status(HttpStatus::LLCORE, LLCore::HE_INVALID_ARG);
+
+ if (opt < HttpRequest::PO_CONNECTION_LIMIT // option must be in range
+ || opt >= HttpRequest::PO_LAST // ditto
+ || (! sOptionDesc[opt].mIsLong) // datatype is long
+ || (pclass != HttpRequest::GLOBAL_POLICY_ID && pclass > mLastPolicy) // pclass in valid range
+ || (pclass == HttpRequest::GLOBAL_POLICY_ID && ! sOptionDesc[opt].mIsGlobal) // global setting permitted
+ || (pclass != HttpRequest::GLOBAL_POLICY_ID && ! sOptionDesc[opt].mIsClass) // class setting permitted
+ || (RUNNING == sState && ! sOptionDesc[opt].mIsDynamic)) // dynamic setting permitted
+ {
+ return status;
+ }
+
+ if (pclass == HttpRequest::GLOBAL_POLICY_ID)
+ {
+ HttpPolicyGlobal & opts(mPolicy->getGlobalOptions());
+
+ status = opts.set(opt, value);
+ if (status && ret_value)
+ {
+ status = opts.get(opt, ret_value);
+ }
+ }
+ else
+ {
+ HttpPolicyClass & opts(mPolicy->getClassOptions(pclass));
+
+ status = opts.set(opt, value);
+ if (status)
+ {
+ mTransport->policyUpdated(pclass);
+ if (ret_value)
+ {
+ status = opts.get(opt, ret_value);
+ }
+ }
+ }
+
+ return status;
}
HttpStatus HttpService::setPolicyOption(HttpRequest::EPolicyOption opt, HttpRequest::policy_t pclass,
- const std::string & value, std::string * ret_value)
+ const std::string & value, std::string * ret_value)
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_NETWORK;
- HttpStatus status(HttpStatus::LLCORE, LLCore::HE_INVALID_ARG);
-
- if (opt < HttpRequest::PO_CONNECTION_LIMIT // option must be in range
- || opt >= HttpRequest::PO_LAST // ditto
- || (sOptionDesc[opt].mIsLong) // datatype is string
- || (pclass != HttpRequest::GLOBAL_POLICY_ID && pclass > mLastPolicy) // pclass in valid range
- || (pclass == HttpRequest::GLOBAL_POLICY_ID && ! sOptionDesc[opt].mIsGlobal) // global setting permitted
- || (pclass != HttpRequest::GLOBAL_POLICY_ID && ! sOptionDesc[opt].mIsClass) // class setting permitted
- || (RUNNING == sState && ! sOptionDesc[opt].mIsDynamic)) // dynamic setting permitted
- {
- return status;
- }
-
- // String values are always global (at this time).
- if (pclass == HttpRequest::GLOBAL_POLICY_ID)
- {
- HttpPolicyGlobal & opts(mPolicy->getGlobalOptions());
-
- status = opts.set(opt, value);
- if (status && ret_value)
- {
- status = opts.get(opt, ret_value);
- }
- }
-
- return status;
+ HttpStatus status(HttpStatus::LLCORE, LLCore::HE_INVALID_ARG);
+
+ if (opt < HttpRequest::PO_CONNECTION_LIMIT // option must be in range
+ || opt >= HttpRequest::PO_LAST // ditto
+ || (sOptionDesc[opt].mIsLong) // datatype is string
+ || (pclass != HttpRequest::GLOBAL_POLICY_ID && pclass > mLastPolicy) // pclass in valid range
+ || (pclass == HttpRequest::GLOBAL_POLICY_ID && ! sOptionDesc[opt].mIsGlobal) // global setting permitted
+ || (pclass != HttpRequest::GLOBAL_POLICY_ID && ! sOptionDesc[opt].mIsClass) // class setting permitted
+ || (RUNNING == sState && ! sOptionDesc[opt].mIsDynamic)) // dynamic setting permitted
+ {
+ return status;
+ }
+
+ // String values are always global (at this time).
+ if (pclass == HttpRequest::GLOBAL_POLICY_ID)
+ {
+ HttpPolicyGlobal & opts(mPolicy->getGlobalOptions());
+
+ status = opts.set(opt, value);
+ if (status && ret_value)
+ {
+ status = opts.get(opt, ret_value);
+ }
+ }
+
+ return status;
}
HttpStatus HttpService::setPolicyOption(HttpRequest::EPolicyOption opt, HttpRequest::policy_t pclass,
- HttpRequest::policyCallback_t value, HttpRequest::policyCallback_t * ret_value)
+ HttpRequest::policyCallback_t value, HttpRequest::policyCallback_t * ret_value)
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_NETWORK;
- HttpStatus status(HttpStatus::LLCORE, LLCore::HE_INVALID_ARG);
-
- if (opt < HttpRequest::PO_CONNECTION_LIMIT // option must be in range
- || opt >= HttpRequest::PO_LAST // ditto
- || (sOptionDesc[opt].mIsLong) // datatype is string
- || (pclass != HttpRequest::GLOBAL_POLICY_ID && pclass > mLastPolicy) // pclass in valid range
- || (pclass == HttpRequest::GLOBAL_POLICY_ID && !sOptionDesc[opt].mIsGlobal) // global setting permitted
- || (pclass != HttpRequest::GLOBAL_POLICY_ID && !sOptionDesc[opt].mIsClass) // class setting permitted
- || (RUNNING == sState && !sOptionDesc[opt].mIsDynamic)) // dynamic setting permitted
- {
- return status;
- }
-
- // Callbacks values are always global (at this time).
- if (pclass == HttpRequest::GLOBAL_POLICY_ID)
- {
- HttpPolicyGlobal & opts(mPolicy->getGlobalOptions());
-
- status = opts.set(opt, value);
- if (status && ret_value)
- {
- status = opts.get(opt, ret_value);
- }
- }
-
- return status;
+ HttpStatus status(HttpStatus::LLCORE, LLCore::HE_INVALID_ARG);
+
+ if (opt < HttpRequest::PO_CONNECTION_LIMIT // option must be in range
+ || opt >= HttpRequest::PO_LAST // ditto
+ || (sOptionDesc[opt].mIsLong) // datatype is string
+ || (pclass != HttpRequest::GLOBAL_POLICY_ID && pclass > mLastPolicy) // pclass in valid range
+ || (pclass == HttpRequest::GLOBAL_POLICY_ID && !sOptionDesc[opt].mIsGlobal) // global setting permitted
+ || (pclass != HttpRequest::GLOBAL_POLICY_ID && !sOptionDesc[opt].mIsClass) // class setting permitted
+ || (RUNNING == sState && !sOptionDesc[opt].mIsDynamic)) // dynamic setting permitted
+ {
+ return status;
+ }
+
+ // Callbacks values are always global (at this time).
+ if (pclass == HttpRequest::GLOBAL_POLICY_ID)
+ {
+ HttpPolicyGlobal & opts(mPolicy->getGlobalOptions());
+
+ status = opts.set(opt, value);
+ if (status && ret_value)
+ {
+ status = opts.get(opt, ret_value);
+ }
+ }
+
+ return status;
}