You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by br...@apache.org on 2014/03/27 19:43:06 UTC
[1/6] git commit: Patch for TS-2652: Allowing cancelation of
AsyncProviders
Repository: trafficserver
Updated Branches:
refs/heads/master 5d38019f2 -> 006ede8cf
Patch for TS-2652: Allowing cancelation of AsyncProviders
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/af12e778
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/af12e778
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/af12e778
Branch: refs/heads/master
Commit: af12e778714f6950316d2752339be178df43d7f1
Parents: 79dd503
Author: Manjesh Nilange <ma...@yahoo.com>
Authored: Thu Mar 20 15:22:52 2014 -0700
Committer: Manjesh Nilange <ma...@yahoo.com>
Committed: Thu Mar 20 15:22:52 2014 -0700
----------------------------------------------------------------------
.../examples/async_http_fetch/AsyncHttpFetch.cc | 42 +++++++++++++++++-
lib/atscppapi/src/AsyncHttpFetch.cc | 4 +-
lib/atscppapi/src/AsyncTimer.cc | 4 +-
lib/atscppapi/src/include/atscppapi/Async.h | 46 +++++++++++++++++---
.../src/include/atscppapi/AsyncHttpFetch.h | 2 +-
.../src/include/atscppapi/AsyncTimer.h | 2 +-
6 files changed, 87 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/af12e778/lib/atscppapi/examples/async_http_fetch/AsyncHttpFetch.cc
----------------------------------------------------------------------
diff --git a/lib/atscppapi/examples/async_http_fetch/AsyncHttpFetch.cc b/lib/atscppapi/examples/async_http_fetch/AsyncHttpFetch.cc
index 0535786..14ff9cc 100644
--- a/lib/atscppapi/examples/async_http_fetch/AsyncHttpFetch.cc
+++ b/lib/atscppapi/examples/async_http_fetch/AsyncHttpFetch.cc
@@ -22,6 +22,7 @@
#include <atscppapi/Logger.h>
#include <atscppapi/Async.h>
#include <atscppapi/AsyncHttpFetch.h>
+#include <atscppapi/AsyncTimer.h>
#include <atscppapi/PluginInit.h>
#include <cstring>
#include <cassert>
@@ -43,8 +44,31 @@ public:
AsyncHttpFetch3(string request, HttpMethod method) : AsyncHttpFetch(request, method) { };
};
+class DelayedAsyncHttpFetch : public AsyncHttpFetch, public AsyncReceiver<AsyncTimer> {
+public:
+ DelayedAsyncHttpFetch(string request, HttpMethod method, shared_ptr<Mutex> mutex)
+ : AsyncHttpFetch(request, method), mutex_(mutex), timer_(NULL) { };
+ void run() {
+ timer_ = new AsyncTimer(AsyncTimer::TYPE_ONE_OFF, 1000 /* 1s */);
+ Async::execute(this, timer_, mutex_);
+ }
+ void handleAsyncComplete(AsyncTimer &/*timer ATS_UNUSED */) {
+ TS_DEBUG(TAG, "Receiver should not be reachable");
+ assert(!getDispatchController()->dispatch());
+ delete this;
+ }
+ bool isAlive() {
+ return getDispatchController()->isEnabled();
+ }
+ ~DelayedAsyncHttpFetch() { delete timer_; }
+private:
+ shared_ptr<Mutex> mutex_;
+ AsyncTimer *timer_;
+};
+
class TransactionHookPlugin : public TransactionPlugin, public AsyncReceiver<AsyncHttpFetch>,
- public AsyncReceiver<AsyncHttpFetch2>, public AsyncReceiver<AsyncHttpFetch3> {
+ public AsyncReceiver<AsyncHttpFetch2>, public AsyncReceiver<AsyncHttpFetch3>,
+ public AsyncReceiver<DelayedAsyncHttpFetch> {
public:
TransactionHookPlugin(Transaction &transaction) :
TransactionPlugin(transaction), transaction_(transaction), num_fetches_pending_(0) {
@@ -70,6 +94,15 @@ public:
request_headers.set("Header2", "Value2");
Async::execute<AsyncHttpFetch2>(this, provider2, getMutex());
++num_fetches_pending_;
+
+ DelayedAsyncHttpFetch *delayed_provider = new DelayedAsyncHttpFetch("url", HTTP_METHOD_GET, getMutex());
+ Async::execute<DelayedAsyncHttpFetch>(this, delayed_provider, getMutex());
+
+ // canceling right after starting in this case, but cancel() can be called any time
+ TS_DEBUG(TAG, "Will cancel delayed fetch");
+ assert(delayed_provider->isAlive());
+ delayed_provider->cancel();
+ assert(!delayed_provider->isAlive());
}
void handleAsyncComplete(AsyncHttpFetch &async_http_fetch) {
@@ -94,6 +127,10 @@ public:
assert(!"AsyncHttpFetch3 shouldn't have completed!");
}
+ void handleAsyncComplete(DelayedAsyncHttpFetch &/*async_http_fetch ATS_UNUSED */) {
+ assert(!"Should've been canceled!");
+ }
+
private:
Transaction &transaction_;
int num_fetches_pending_;
@@ -139,6 +176,9 @@ public:
if (!transaction.isInternalRequest()) {
transaction.addPlugin(new TransactionHookPlugin(transaction));
}
+ else {
+ TS_DEBUG(TAG, "Ignoring internal transaction");
+ }
transaction.resume();
}
};
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/af12e778/lib/atscppapi/src/AsyncHttpFetch.cc
----------------------------------------------------------------------
diff --git a/lib/atscppapi/src/AsyncHttpFetch.cc b/lib/atscppapi/src/AsyncHttpFetch.cc
index 19dbe58..ff374a9 100644
--- a/lib/atscppapi/src/AsyncHttpFetch.cc
+++ b/lib/atscppapi/src/AsyncHttpFetch.cc
@@ -118,8 +118,8 @@ void AsyncHttpFetch::init(const string &url_str, HttpMethod http_method, const s
state_ = new AsyncHttpFetchState(url_str, http_method, request_body);
}
-void AsyncHttpFetch::run(shared_ptr<AsyncDispatchControllerBase> sender) {
- state_->dispatch_controller_ = sender;
+void AsyncHttpFetch::run() {
+ state_->dispatch_controller_ = getDispatchController(); // keep a copy in state so that cont handler can use it
TSCont fetchCont = TSContCreate(handleFetchEvents, TSMutexCreate());
TSContDataSet(fetchCont, static_cast<void *>(this)); // Providers have to clean themselves up when they are done.
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/af12e778/lib/atscppapi/src/AsyncTimer.cc
----------------------------------------------------------------------
diff --git a/lib/atscppapi/src/AsyncTimer.cc b/lib/atscppapi/src/AsyncTimer.cc
index 995cc48..c7548ce 100644
--- a/lib/atscppapi/src/AsyncTimer.cc
+++ b/lib/atscppapi/src/AsyncTimer.cc
@@ -67,7 +67,8 @@ AsyncTimer::AsyncTimer(Type type, int period_in_ms, int initial_period_in_ms) {
TSContDataSet(state_->cont_, static_cast<void *>(state_));
}
-void AsyncTimer::run(shared_ptr<AsyncDispatchControllerBase> dispatch_controller) {
+void AsyncTimer::run() {
+ state_->dispatch_controller_ = getDispatchController(); // keep a copy in state so that cont handler can use it
int one_off_timeout_in_ms = 0;
int regular_timeout_in_ms = 0;
if (state_->type_ == AsyncTimer::TYPE_ONE_OFF) {
@@ -87,7 +88,6 @@ void AsyncTimer::run(shared_ptr<AsyncDispatchControllerBase> dispatch_controller
state_->periodic_timer_action_ = TSContScheduleEvery(state_->cont_, regular_timeout_in_ms,
TS_THREAD_POOL_DEFAULT);
}
- state_->dispatch_controller_ = dispatch_controller;
}
AsyncTimer::~AsyncTimer() {
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/af12e778/lib/atscppapi/src/include/atscppapi/Async.h
----------------------------------------------------------------------
diff --git a/lib/atscppapi/src/include/atscppapi/Async.h b/lib/atscppapi/src/include/atscppapi/Async.h
index 39a24d0..3bfa2f4 100644
--- a/lib/atscppapi/src/include/atscppapi/Async.h
+++ b/lib/atscppapi/src/include/atscppapi/Async.h
@@ -46,6 +46,13 @@ public:
* @return True if the receiver was still alive.
*/
virtual bool dispatch() = 0;
+
+ /** Renders dispatch unusable to communicate to receiver */
+ virtual void disable() = 0;
+
+ /** Returns true if receiver can be communicated with */
+ virtual bool isEnabled() = 0;
+
virtual ~AsyncDispatchControllerBase() { }
};
@@ -60,13 +67,31 @@ class AsyncProvider {
public:
/**
* This method is invoked when the async operation is requested. This call should be used
- * to just start the async operation and *not* block this thread.
- *
- * @param dispatch_controller provides a way to dispatch an "async complete" event to the
- * requester.
+ * to just start the async operation and *not* block this thread. On completion,
+ * getDispatchController() can be used to invoke the receiver.
*/
- virtual void run(shared_ptr<AsyncDispatchControllerBase> dispatch_controller) = 0;
+ virtual void run() = 0;
+
+ /** Base implementation just breaks communication channel with receiver. Implementations
+ * should add business logic here. */
+ virtual void cancel() {
+ if (dispatch_controller_) {
+ dispatch_controller_->disable();
+ }
+ }
+
virtual ~AsyncProvider() { }
+
+protected:
+ shared_ptr<AsyncDispatchControllerBase> getDispatchController() { return dispatch_controller_; }
+
+private:
+ shared_ptr<AsyncDispatchControllerBase> dispatch_controller_;
+ void doRun(shared_ptr<AsyncDispatchControllerBase> dispatch_controller) {
+ dispatch_controller_ = dispatch_controller;
+ run();
+ }
+ friend class Async;
};
/**
@@ -88,6 +113,15 @@ public:
return ret;
}
+ void disable() {
+ ScopedSharedMutexLock scopedLock(dispatch_mutex_);
+ event_receiver_ = NULL;
+ }
+
+ bool isEnabled() {
+ return (event_receiver_ != NULL);
+ }
+
/**
* Constructor
*
@@ -177,7 +211,7 @@ public:
shared_ptr<AsyncReceiverPromise<AsyncReceiver<AsyncProviderType>, AsyncProviderType > > receiver_promise(
new AsyncReceiverPromise<AsyncReceiver<AsyncProviderType>, AsyncProviderType >(dispatcher));
event_receiver->receiver_promises_.push_back(receiver_promise); // now if the event receiver dies, we're safe.
- provider->run(dispatcher);
+ provider->doRun(dispatcher);
}
};
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/af12e778/lib/atscppapi/src/include/atscppapi/AsyncHttpFetch.h
----------------------------------------------------------------------
diff --git a/lib/atscppapi/src/include/atscppapi/AsyncHttpFetch.h b/lib/atscppapi/src/include/atscppapi/AsyncHttpFetch.h
index 42118fa..1ddd235 100644
--- a/lib/atscppapi/src/include/atscppapi/AsyncHttpFetch.h
+++ b/lib/atscppapi/src/include/atscppapi/AsyncHttpFetch.h
@@ -90,7 +90,7 @@ public:
/**
* Starts a HTTP fetch of the Request contained.
*/
- virtual void run(shared_ptr<AsyncDispatchControllerBase> dispatch_controller);
+ virtual void run();
protected:
virtual ~AsyncHttpFetch();
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/af12e778/lib/atscppapi/src/include/atscppapi/AsyncTimer.h
----------------------------------------------------------------------
diff --git a/lib/atscppapi/src/include/atscppapi/AsyncTimer.h b/lib/atscppapi/src/include/atscppapi/AsyncTimer.h
index 10da3e9..5e61e1d 100644
--- a/lib/atscppapi/src/include/atscppapi/AsyncTimer.h
+++ b/lib/atscppapi/src/include/atscppapi/AsyncTimer.h
@@ -67,7 +67,7 @@ public:
/**
* Starts the timer.
*/
- void run(shared_ptr<AsyncDispatchControllerBase> dispatch_controller);
+ void run();
private:
AsyncTimerState *state_;
[4/6] git commit: Merge branch 'master' of
https://github.com/manjeshnilange/trafficserver
Posted by br...@apache.org.
Merge branch 'master' of https://github.com/manjeshnilange/trafficserver
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/3adb279f
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/3adb279f
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/3adb279f
Branch: refs/heads/master
Commit: 3adb279fe706c16d7310b57ab42a40efa2553696
Parents: 5d38019 5994228
Author: Brian Geffon <br...@apache.org>
Authored: Thu Mar 27 11:31:27 2014 -0700
Committer: Brian Geffon <br...@apache.org>
Committed: Thu Mar 27 11:31:27 2014 -0700
----------------------------------------------------------------------
.../examples/async_http_fetch/AsyncHttpFetch.cc | 42 +++++++++++++++++-
.../examples/async_timer/AsyncTimer.cc | 17 ++++++--
lib/atscppapi/src/AsyncHttpFetch.cc | 4 +-
lib/atscppapi/src/AsyncTimer.cc | 12 +++--
lib/atscppapi/src/InterceptPlugin.cc | 6 +++
lib/atscppapi/src/include/atscppapi/Async.h | 46 +++++++++++++++++---
.../src/include/atscppapi/AsyncHttpFetch.h | 2 +-
.../src/include/atscppapi/AsyncTimer.h | 4 +-
.../src/include/atscppapi/InterceptPlugin.h | 3 ++
9 files changed, 118 insertions(+), 18 deletions(-)
----------------------------------------------------------------------
[6/6] git commit: [TS-2652] Allowing cancelation of AsyncProviders.
This closes #65.
Posted by br...@apache.org.
[TS-2652] Allowing cancelation of AsyncProviders. This closes #65.
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/006ede8c
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/006ede8c
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/006ede8c
Branch: refs/heads/master
Commit: 006ede8cf25962cf5f291dadb37490ed4082ac8a
Parents: 98d85f2
Author: Brian Geffon <br...@apache.org>
Authored: Thu Mar 27 11:43:00 2014 -0700
Committer: Brian Geffon <br...@apache.org>
Committed: Thu Mar 27 11:43:00 2014 -0700
----------------------------------------------------------------------
CHANGES | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/006ede8c/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index d979ec4..8a23115 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,9 +1,9 @@
-*- coding: utf-8 -*-
Changes with Apache Traffic Server 5.0.0
- *) [TS-2652] Providing a cancel() in AsyncTimer
+ *) [TS-2652] atscppapi: Providing a cancel() in asyncproviders
- *) [TS-2667] Allow intercept plugins to access request headers object
+ *) [TS-2667] atscppapi: Allow intercept plugins to access request headers object
*) [TS-2672] TSMimeHdrFieldDestroy should not assert on removed fields.
[5/6] git commit: [TS-2652] Allowing cancelation of AsyncProviders
Posted by br...@apache.org.
[TS-2652] Allowing cancelation of AsyncProviders
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/98d85f24
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/98d85f24
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/98d85f24
Branch: refs/heads/master
Commit: 98d85f242683a4d21c80e218775e5b068f9534f6
Parents: 3adb279
Author: Brian Geffon <br...@apache.org>
Authored: Thu Mar 27 11:41:51 2014 -0700
Committer: Brian Geffon <br...@apache.org>
Committed: Thu Mar 27 11:41:51 2014 -0700
----------------------------------------------------------------------
CHANGES | 4 ++++
1 file changed, 4 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/98d85f24/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 5e6e208..d979ec4 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,10 @@
-*- coding: utf-8 -*-
Changes with Apache Traffic Server 5.0.0
+ *) [TS-2652] Providing a cancel() in AsyncTimer
+
+ *) [TS-2667] Allow intercept plugins to access request headers object
+
*) [TS-2672] TSMimeHdrFieldDestroy should not assert on removed fields.
*) [TS-2554] New plugin: background_fetch, which under certain conditions
[2/6] git commit: TS-2652: Providing a true cancel() in AsyncTimer
Posted by br...@apache.org.
TS-2652: Providing a true cancel() in AsyncTimer
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/521b6e11
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/521b6e11
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/521b6e11
Branch: refs/heads/master
Commit: 521b6e11d4357ccaae348c4714b1084b39a199d0
Parents: af12e77
Author: Manjesh Nilange <ma...@yahoo.com>
Authored: Wed Mar 26 11:22:23 2014 -0700
Committer: Manjesh Nilange <ma...@yahoo.com>
Committed: Wed Mar 26 11:22:23 2014 -0700
----------------------------------------------------------------------
lib/atscppapi/examples/async_timer/AsyncTimer.cc | 17 ++++++++++++++---
lib/atscppapi/src/AsyncTimer.cc | 8 ++++++--
lib/atscppapi/src/include/atscppapi/AsyncTimer.h | 2 ++
3 files changed, 22 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/521b6e11/lib/atscppapi/examples/async_timer/AsyncTimer.cc
----------------------------------------------------------------------
diff --git a/lib/atscppapi/examples/async_timer/AsyncTimer.cc b/lib/atscppapi/examples/async_timer/AsyncTimer.cc
index 738a536..c802462 100644
--- a/lib/atscppapi/examples/async_timer/AsyncTimer.cc
+++ b/lib/atscppapi/examples/async_timer/AsyncTimer.cc
@@ -28,8 +28,9 @@ using std::string;
class TimerEventReceiver : public AsyncReceiver<AsyncTimer> {
public:
- TimerEventReceiver(AsyncTimer::Type type, int period_in_ms, int initial_period_in_ms = 0, int max_instances = 0)
- : max_instances_(max_instances), instance_count_(0), type_(type) {
+ TimerEventReceiver(AsyncTimer::Type type, int period_in_ms, int initial_period_in_ms = 0, int max_instances = 0,
+ bool cancel = false)
+ : max_instances_(max_instances), instance_count_(0), type_(type), cancel_(cancel) {
timer_ = new AsyncTimer(type, period_in_ms, initial_period_in_ms);
Async::execute<AsyncTimer>(this, timer_, shared_ptr<Mutex>()); // letting the system create the mutex
}
@@ -38,7 +39,7 @@ public:
TS_DEBUG(TAG, "Got timer event in object %p!", this);
if ((type_ == AsyncTimer::TYPE_ONE_OFF) || (max_instances_ && (++instance_count_ == max_instances_))) {
TS_DEBUG(TAG, "Stopping timer in object %p!", this);
- delete this;
+ cancel_ ? timer_->cancel() : delete this;
}
}
@@ -51,6 +52,7 @@ private:
int instance_count_;
AsyncTimer::Type type_;
AsyncTimer *timer_;
+ bool cancel_;
};
void TSPluginInit(int argc ATSCPPAPI_UNUSED, const char *argv[] ATSCPPAPI_UNUSED) {
@@ -58,11 +60,13 @@ void TSPluginInit(int argc ATSCPPAPI_UNUSED, const char *argv[] ATSCPPAPI_UNUSED
TimerEventReceiver *timer1 = new TimerEventReceiver(AsyncTimer::TYPE_PERIODIC, period_in_ms);
TS_DEBUG(TAG, "Created periodic timer %p with initial period 0, regular period %d and max instances 0", timer1,
period_in_ms);
+
int initial_period_in_ms = 100;
TimerEventReceiver *timer2 = new TimerEventReceiver(AsyncTimer::TYPE_PERIODIC, period_in_ms,
initial_period_in_ms);
TS_DEBUG(TAG, "Created periodic timer %p with initial period %d, regular period %d and max instances 0", timer2,
initial_period_in_ms, period_in_ms);
+
initial_period_in_ms = 200;
int max_instances = 10;
TimerEventReceiver *timer3 = new TimerEventReceiver(AsyncTimer::TYPE_PERIODIC, period_in_ms, initial_period_in_ms,
@@ -72,4 +76,11 @@ void TSPluginInit(int argc ATSCPPAPI_UNUSED, const char *argv[] ATSCPPAPI_UNUSED
TimerEventReceiver *timer4 = new TimerEventReceiver(AsyncTimer::TYPE_ONE_OFF, period_in_ms);
TS_DEBUG(TAG, "Created one-off timer %p with period %d", timer4, period_in_ms);
+
+ initial_period_in_ms = 0;
+ max_instances = 5;
+ TimerEventReceiver *timer5 = new TimerEventReceiver(AsyncTimer::TYPE_PERIODIC, period_in_ms, initial_period_in_ms,
+ max_instances, true /* cancel */);
+ TS_DEBUG(TAG, "Created canceling timer %p with initial period %d, regular period %d and max instances %d", timer5,
+ initial_period_in_ms, period_in_ms, max_instances);
}
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/521b6e11/lib/atscppapi/src/AsyncTimer.cc
----------------------------------------------------------------------
diff --git a/lib/atscppapi/src/AsyncTimer.cc b/lib/atscppapi/src/AsyncTimer.cc
index c7548ce..d07b617 100644
--- a/lib/atscppapi/src/AsyncTimer.cc
+++ b/lib/atscppapi/src/AsyncTimer.cc
@@ -90,8 +90,8 @@ void AsyncTimer::run() {
}
}
-AsyncTimer::~AsyncTimer() {
- TSMutexLock(TSContMutexGet(state_->cont_));
+void AsyncTimer::cancel() {
+ TSMutexLock(TSContMutexGet(state_->cont_)); // mutex will be unlocked in destroy
if (state_->initial_timer_action_) {
LOG_DEBUG("Canceling initial timer action");
TSActionCancel(state_->initial_timer_action_);
@@ -102,5 +102,9 @@ AsyncTimer::~AsyncTimer() {
}
LOG_DEBUG("Destroying cont");
TSContDestroy(state_->cont_);
+}
+
+AsyncTimer::~AsyncTimer() {
+ cancel();
delete state_;
}
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/521b6e11/lib/atscppapi/src/include/atscppapi/AsyncTimer.h
----------------------------------------------------------------------
diff --git a/lib/atscppapi/src/include/atscppapi/AsyncTimer.h b/lib/atscppapi/src/include/atscppapi/AsyncTimer.h
index 5e61e1d..5b5f6d5 100644
--- a/lib/atscppapi/src/include/atscppapi/AsyncTimer.h
+++ b/lib/atscppapi/src/include/atscppapi/AsyncTimer.h
@@ -69,6 +69,8 @@ public:
*/
void run();
+ void cancel();
+
private:
AsyncTimerState *state_;
};
[3/6] git commit: Patch for TS-2667 atscppapi: Allow intercept
plugins to access request headers object
Posted by br...@apache.org.
Patch for TS-2667 atscppapi: Allow intercept plugins to access request headers object
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/5994228b
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/5994228b
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/5994228b
Branch: refs/heads/master
Commit: 5994228bdab3fa704eb74fc5e26896166254ca88
Parents: 521b6e1
Author: Manjesh Nilange <ma...@yahoo.com>
Authored: Wed Mar 26 17:21:46 2014 -0700
Committer: Manjesh Nilange <ma...@yahoo.com>
Committed: Wed Mar 26 17:21:46 2014 -0700
----------------------------------------------------------------------
lib/atscppapi/src/InterceptPlugin.cc | 6 ++++++
lib/atscppapi/src/include/atscppapi/InterceptPlugin.h | 3 +++
2 files changed, 9 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/5994228b/lib/atscppapi/src/InterceptPlugin.cc
----------------------------------------------------------------------
diff --git a/lib/atscppapi/src/InterceptPlugin.cc b/lib/atscppapi/src/InterceptPlugin.cc
index c06e494..b9aaa7c 100644
--- a/lib/atscppapi/src/InterceptPlugin.cc
+++ b/lib/atscppapi/src/InterceptPlugin.cc
@@ -85,6 +85,7 @@ struct InterceptPlugin::State {
int num_bytes_written_;
PluginHandle *plugin_handle_;
bool shut_down_;
+ Headers request_headers_;
State(TSCont cont) : cont_(cont), net_vc_(NULL), expected_body_size_(0), num_body_bytes_read_(0),
hdr_parsed_(false), hdr_buf_(NULL), hdr_loc_(NULL), num_bytes_written_(0),
@@ -197,6 +198,10 @@ bool InterceptPlugin::setOutputComplete() {
return true;
}
+Headers &InterceptPlugin::getRequestHeaders() {
+ return state_->request_headers_;
+}
+
bool InterceptPlugin::doRead() {
int avail = TSIOBufferReaderAvail(state_->input_.reader_);
if (avail == TS_ERROR) {
@@ -273,6 +278,7 @@ void InterceptPlugin::handleEvent(int abstract_event, void *edata) {
state_->hdr_buf_ = TSMBufferCreate();
state_->hdr_loc_ = TSHttpHdrCreate(state_->hdr_buf_);
+ state_->request_headers_.reset(state_->hdr_buf_, state_->hdr_loc_);
TSHttpHdrTypeSet(state_->hdr_buf_, state_->hdr_loc_, TS_HTTP_TYPE_REQUEST);
break;
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/5994228b/lib/atscppapi/src/include/atscppapi/InterceptPlugin.h
----------------------------------------------------------------------
diff --git a/lib/atscppapi/src/include/atscppapi/InterceptPlugin.h b/lib/atscppapi/src/include/atscppapi/InterceptPlugin.h
index 5160c8d..da8d5a4 100644
--- a/lib/atscppapi/src/include/atscppapi/InterceptPlugin.h
+++ b/lib/atscppapi/src/include/atscppapi/InterceptPlugin.h
@@ -68,6 +68,9 @@ public:
*/
virtual void handleInputComplete() = 0;
+ /** Should be called only after request header has completely been consumed */
+ Headers &getRequestHeaders();
+
virtual ~InterceptPlugin();
struct State; /** Internal use only */