This is an automated email from the ASF dual-hosted git repository.
amc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push:
new 6abe654 TS-4976: Regularize plugins - protocol
6abe654 is described below
commit 6abe654d8864f9436a03b8799256cdfbd4b160da
Author: Alan M. Carroll <[email protected]>
AuthorDate: Wed Mar 22 20:35:26 2017 -0500
TS-4976: Regularize plugins - protocol
---
.../plugins/new-protocol-plugins.en.rst | 186 ++++++++++-----------
example/protocol/Protocol.c | 33 ++--
example/protocol/Protocol.h | 2 +
example/protocol/TxnSM.c | 86 +++++-----
4 files changed, 145 insertions(+), 162 deletions(-)
diff --git a/doc/developer-guide/plugins/new-protocol-plugins.en.rst
b/doc/developer-guide/plugins/new-protocol-plugins.en.rst
index 72c1925..1c825a7 100644
--- a/doc/developer-guide/plugins/new-protocol-plugins.en.rst
+++ b/doc/developer-guide/plugins/new-protocol-plugins.en.rst
@@ -180,10 +180,10 @@ Database event flow, and the thick dashed lines show
Cache event flow.
Notice that this flow of events is independent of the Protocol plugin's
design (i.e., whether you build **accept** or **transaction** state
machines). Any plugin that supports network connections uses the net
-vconnection interfaces (``TSNetAccept``, ``TSNetConnect``) and thus
+vconnection interfaces (:c:func:`TSNetAccept`, :c:func:`TSNetConnect`) and thus
receives events from the Net Processor. Any plugin that performs cache
-lookups or cache writes uses ``TSCacheRead``, ``TSCacheWrite``,
-``TSVConnRead``, and ``TSVConnWrite`` and thus receives events from the
+lookups or cache writes uses :c:func:`TSCacheRead`, :c:func:`TSCacheWrite`,
+:c:func:`TSVConnRead`, and :c:func:`TSVConnWrite` and thus receives events
from the
Cache Processor and Traffic Server event system. Similarly, any plugin
that does DNS lookups receives events from the Host Database Processor.
@@ -269,105 +269,91 @@ The code is contained in the following files:
- ``Protocol.c`` and ``Protocol.h``
-- ``Accept.c`` and ``Accept.h``
-
- ``TxnSM.c`` and ``TxnSM.h``
Below is a step-by-step walk-through of the code that processes a
typical transaction.
-1. The ``TSPluginInit`` function is in the ``Protocol.c`` file. It
- checks the validity of the ``plugin.config`` entries (there must be
- two: a client accept port and a server port) and runs an
- initialization routine, ``init``.
-
-2. The ``init`` function (in ``Protocol.c``) creates the plugin's
- log file using ``TSTextLogObjectCreate``.
-
-3. The ``init`` function creates the accept state machine using
- ``AcceptCreate``. The code for ``AcceptCreate`` is in the
- ``Accept.c`` file.
-
-4. The accept state machine, like the transaction state machine, keeps
- track of its state with a data structure. This data structure,
- ``Accept``, is defined in the ``Accept.h`` file. State data in
- ``AcceptCreate`` is associated with the new accept state machine
- via ``TSContDataSet``.
-
-5. The ``init`` function arranges the callback of the accept state
- machine when there is a network connection by using
- ``TSNetAccept``.
-
-6. The handler for the accept state machine is ``accept_event`` in
- the ``Accept.c`` file. When Traffic Server's Net Processor sends
- ``TS_EVENT_NET_ACCEPT`` to the accept state machine,
- ``accept_event`` creates a transaction state machine
- (``txn_sm``) by calling ``TxnSMCreate``. Notice that
- ``accept_event`` creates a mutex for the transaction state
- machine, since each transaction state machine has its own mutex.
-
-7. The ``TxnSMCreate`` function is in the ``TxnSM.c`` file. The
- first thing it does is initialize the transaction's data, which is
- of type ``TxnSM`` (as defined in ``TxnSM.h``). Notice that the
- current handler (``q_current_handler``) is set to
- ``state_start``.
-
-8. ``TxnSMCreate`` then creates a transaction state machine using
- ``TSContCreate``. The handler for the transaction state machine
- is ``main_handler``, which is in the ``TxnSM.c`` file.
-
-9. When ``accept_event`` receives ``TS_EVENT_NET_ACCEPT``, it
- calls the transaction state machine (
- ``TSContCall (txn_sm, 0, NULL);`` ). The event passed to
- ``main_handler`` is ``0`` (``TS_EVENT_NONE``).
-
-10. The first thing ``main_handler`` does is examine the current
- ``txn_sm`` state by calling ``TSContDataGet``. The state is
- ``state_start``.
-
-11. ``main_handler`` then invokes the handler for
- ``state_start`` by using the function pointer
- ``TxnSMHandler`` (as defined in ``TxnSM.h``).
-
-12. The ``state_start`` handler function (in the ``TxnSM.c`` file)
- is handed an event (at this stage, the event is
- ``TS_EVENT_NET_ACCEPT``) and a client vconnection.
- ``state_start`` checks to see if this client vconnection is
- closed; if it is not, then ``state_start`` attempts to read data
- from the client vconnection into an ``TSIOBuffer``
- (``state_start`` is handling the event it receives).
-
-13. ``state_start`` changes the current handler to
- ``state_interface_with_client`` (that is, it updates the state
- of the transaction to the next state).
-
-14. ``state_start`` initiates a read of the client vconnection
- (arranges for Traffic Server to send
- ``TS_EVENT_VCONN_READ_READY`` events to the TSM) by calling
- ``TSVConnRead``.
-
-15. ``state_interface_with_client`` is activated by the next event
- from Traffic Server. It checks for errors and examines the read VIO
- for the read operation initiated by ``TSVConnRead``.
-
-16. If the read VIO is the ``client_read_VIO`` (which we are
- expecting at this stage in the transaction), then
- ``state_interface_with_client`` updates the state to
- ``state_read_request_from_client`` .
-
-17. ``state_read_request_from_client`` handles actual
- ``TS_EVENT_READ_READY`` events and reads the client request.
-
-18. ``state_read_request_from_client`` parses the client request.
-
-19. ``state_read_request_from_client`` updates the current state to
- the next state, ``state_handle_cache_lookup`` .
-
-20. ``state_read_request_from_client`` arranges for Traffic Server
- to call back the TSM with the next set of events (initiating the
- cache lookup) by calling ``TSCacheRead``.
-
-21. When the ``TSCacheRead`` sends the TSM either
- ``TS_EVENT_OPEN_READ`` (a cache hit) or
- ``TS_EVENT_OPEN_READ_FAILED`` (a cache miss),
- ``main_handler`` calls ``state_handle_cache_lookup``.
+#. The :c:func:`TSPluginInit` function is in the ``Protocol.c`` file. It
+ checks the validity of the :file:`plugin.config` entries (there must be
two: a client accept port
+ and a server port) and runs an initialization routine, ``init``.
+
+#. The ``init`` function (in ``Protocol.c``) creates the plugin's
+ log file using :c:func:`TSTextLogObjectCreate`.
+
+#. The ``init`` function creates the accept state machine using
+ ``AcceptCreate``. The code for ``AcceptCreate`` is in the
+ ``Accept.c`` file.
+
+#. The ``init`` function arranges the callback of the accept state
+ machine when there is a network connection by using
+ :c:func:`TSNetAccept`.
+
+#. The handler for the accept state machine is ``accept_handler`` in
+ the ``Protocol.c`` file. When Traffic Server's Net Processor sends
:c:macro:`TS_EVENT_NET_ACCEPT`
+ to the accept state machine, ``accept_handler`` creates a transaction state
machine (``txn_sm``)
+ by calling ``TxnSMCreate``. Notice that ``accept_event`` creates a mutex
for the transaction
+ state machine, since each transaction state machine has its own mutex.
+
+#. The ``TxnSMCreate`` function is in the ``TxnSM.c`` file. The
+ first thing it does is initialize the transaction's data, which is of type
``TxnSM`` (as defined
+ in ``TxnSM.h``). Notice that the current handler (``q_current_handler``) is
set to
+ ``state_start``.
+
+#. ``TxnSMCreate`` then creates a transaction state machine using
+ :c:func`TSContCreate`. The handler for the transaction state machine
+ is ``main_handler``, which is in the ``TxnSM.c`` file.
+
+#. When ``accept_event`` receives :c:macro`TS_EVENT_NET_ACCEPT`, it
+ calls the transaction state machine (
+ ``TSContCall (txn_sm, 0, NULL);`` ). The event passed to
+ ``main_handler`` is ``0`` (:c:macro`TS_EVENT_NONE`).
+
+#. The first thing ``main_handler`` does is examine the current
+ ``txn_sm`` state by calling :c:func:`TSContDataGet`. The state is
+ ``state_start``.
+
+#. ``main_handler`` then invokes the handler for
+ ``state_start`` by using the function pointer
+ ``TxnSMHandler`` (as defined in ``TxnSM.h``).
+
+#. The ``state_start`` handler function (in the ``TxnSM.c`` file)
+ is handed an event (at this stage, the event is
:c:macro:`TS_EVENT_NET_ACCEPT`) and a client
+ vconnection. ``state_start`` checks to see if this client vconnection is
closed; if it is not,
+ then ``state_start`` attempts to read data from the client vconnection into
an
+ :c:type:`TSIOBuffer` (``state_start`` is handling the event it receives).
+
+#. ``state_start`` changes the current handler to
+ ``state_interface_with_client`` (that is, it updates the state of the
transaction to the next
+ state).
+
+#. ``state_start`` initiates a read of the client vconnection
+ (arranges for Traffic Server to send
+ :c:macro:`TS_EVENT_VCONN_READ_READY` events to the TSM) by calling
+ :c:func:`TSVConnRead`.
+
+#. ``state_interface_with_client`` is activated by the next event
+ from Traffic Server. It checks for errors and examines the read VIO
+ for the read operation initiated by :c:func:`TSVConnRead`.
+
+#. If the read VIO is the ``client_read_VIO`` (which we are
+ expecting at this stage in the transaction), then
+ ``state_interface_with_client`` updates the state to
+ ``state_read_request_from_client`` .
+
+#. ``state_read_request_from_client`` handles actual
+ :c:macro:`TS_EVENT_VCONN_READ_READY` events and reads the client request.
+
+#. ``state_read_request_from_client`` parses the client request.
+
+#. ``state_read_request_from_client`` updates the current state to
+ the next state, ``state_handle_cache_lookup`` .
+
+#. ``state_read_request_from_client`` arranges for Traffic Server
+ to call back the TSM with the next set of events (initiating the
+ cache lookup) by calling :c:func:`TSCacheRead`.
+
+#. When the :c:func:`TSCacheRead` sends the TSM either
+ :c:macro:`TS_EVENT_CACHE_OPEN_READ` (a cache hit) or
+ :c:macro:`TS_EVENT_CACHE_OPEN_READ_FAILED` (a cache miss),
+ ``main_handler`` calls ``state_handle_cache_lookup``.
diff --git a/example/protocol/Protocol.c b/example/protocol/Protocol.c
index 7620350..e6f4cd0 100644
--- a/example/protocol/Protocol.c
+++ b/example/protocol/Protocol.c
@@ -80,15 +80,15 @@ protocol_init(int accept_port, int server_port ATS_UNUSED)
int ret_val;
/* create customized log */
- ret_val = TSTextLogObjectCreate("protocol", TS_LOG_MODE_ADD_TIMESTAMP,
&protocol_plugin_log);
+ ret_val = TSTextLogObjectCreate(PLUGIN_NAME, TS_LOG_MODE_ADD_TIMESTAMP,
&protocol_plugin_log);
if (ret_val != TS_SUCCESS) {
- TSError("[protocol] Failed to create log");
+ TSError("[%s] Failed to create log", PLUGIN_NAME);
}
/* format of the log entries, for caching_status, 1 for HIT and 0 for MISS */
ret_val = TSTextLogObjectWrite(protocol_plugin_log, "timestamp filename
servername caching_status\n\n");
if (ret_val != TS_SUCCESS) {
- TSError("[protocol] Failed to write into log");
+ TSError("[%s] Failed to write into log", PLUGIN_NAME);
}
contp = TSContCreate(accept_handler, TSMutexCreate());
@@ -107,12 +107,12 @@ TSPluginInit(int argc, const char *argv[])
char *end;
int tmp;
- info.plugin_name = "output-header";
- info.vendor_name = "MyCompany";
- info.support_email = "[email protected]";
+ info.plugin_name = PLUGIN_NAME;
+ info.vendor_name = "Apache Software Foundation";
+ info.support_email = "[email protected]";
if (TSPluginRegister(&info) != TS_SUCCESS) {
- TSError("[protocol] Plugin registration failed.");
+ TSError("[%s] Plugin registration failed.", PLUGIN_NAME);
goto error;
}
@@ -122,33 +122,28 @@ TSPluginInit(int argc, const char *argv[])
server_port = 4666;
if (argc < 3) {
- TSDebug("protocol", "Usage: protocol.so accept_port server_port");
- printf("[protocol_plugin] Usage: protocol.so accept_port server_port\n");
- printf("[protocol_plugin] Wrong arguments. Using deafult ports.\n");
+ TSDebug(PLUGIN_NAME, "Usage: protocol.so <accept_port> <server_port>.
Using default ports accept=%d server=%d", accept_port,
+ server_port);
} else {
tmp = strtol(argv[1], &end, 10);
if (*end == '\0') {
accept_port = tmp;
- TSDebug("protocol", "using accept_port %d", accept_port);
- printf("[protocol_plugin] using accept_port %d\n", accept_port);
+ TSDebug(PLUGIN_NAME, "using accept_port %d", accept_port);
} else {
- printf("[protocol_plugin] Wrong argument for accept_port.");
- printf("Using deafult port %d\n", accept_port);
+ TSError("[%s] Wrong argument for accept_port, using default port %d.",
PLUGIN_NAME, accept_port);
}
tmp = strtol(argv[2], &end, 10);
if (*end == '\0') {
server_port = tmp;
- TSDebug("protocol", "using server_port %d", server_port);
- printf("[protocol_plugin] using server_port %d\n", server_port);
+ TSDebug(PLUGIN_NAME, "using server_port %d", server_port);
} else {
- printf("[protocol_plugin] Wrong argument for server_port.");
- printf("Using deafult port %d\n", server_port);
+ TSError("[%s] Wrong argument for server_port, using default port %d.",
PLUGIN_NAME, server_port);
}
}
protocol_init(accept_port, server_port);
error:
- TSError("[protocol] Plugin not initialized");
+ TSError("[%s] Plugin not initialized", PLUGIN_NAME);
}
diff --git a/example/protocol/Protocol.h b/example/protocol/Protocol.h
index 8da3a4a..18e1034 100644
--- a/example/protocol/Protocol.h
+++ b/example/protocol/Protocol.h
@@ -35,6 +35,8 @@
#include <ts/ts.h>
+#define PLUGIN_NAME "protocol"
+
#define MAX_SERVER_NAME_LENGTH 1024
#define MAX_FILE_NAME_LENGTH 1024
diff --git a/example/protocol/TxnSM.c b/example/protocol/TxnSM.c
index d21cee1..7978d31 100644
--- a/example/protocol/TxnSM.c
+++ b/example/protocol/TxnSM.c
@@ -75,7 +75,7 @@ main_handler(TSCont contp, TSEvent event, void *data)
TxnSM *txn_sm = (TxnSM *)TSContDataGet(contp);
TxnSMHandler q_current_handler = txn_sm->q_current_handler;
- TSDebug("protocol", "main_handler (contp %p event %d)", contp, event);
+ TSDebug(PLUGIN_NAME, "main_handler (contp %p event %d)", contp, event);
/* handle common cases errors */
if (event == TS_EVENT_ERROR) {
@@ -88,7 +88,7 @@ main_handler(TSCont contp, TSEvent event, void *data)
}
}
- TSDebug("protocol", "current_handler (%p)", q_current_handler);
+ TSDebug(PLUGIN_NAME, "current_handler (%p)", q_current_handler);
return (*q_current_handler)(contp, event, data);
}
@@ -190,7 +190,7 @@ state_interface_with_client(TSCont contp, TSEvent event,
TSVIO vio)
{
TxnSM *txn_sm = (TxnSM *)TSContDataGet(contp);
- TSDebug("protocol", "enter state_interface_with_client");
+ TSDebug(PLUGIN_NAME, "enter state_interface_with_client");
txn_sm->q_pending_action = NULL;
@@ -212,7 +212,7 @@ state_read_request_from_client(TSCont contp, TSEvent event,
TSVIO vio ATS_UNUSED
TxnSM *txn_sm = (TxnSM *)TSContDataGet(contp);
- TSDebug("protocol", "enter state_read_request_from_client");
+ TSDebug(PLUGIN_NAME, "enter state_read_request_from_client");
switch (event) {
case TS_EVENT_VCONN_READ_READY:
@@ -236,7 +236,7 @@ state_read_request_from_client(TSCont contp, TSEvent event,
TSVIO vio ATS_UNUSED
}
/* Start to do cache lookup */
- TSDebug("protocol", "Key material: file name is %s*****",
txn_sm->q_file_name);
+ TSDebug(PLUGIN_NAME, "Key material: file name is %s*****",
txn_sm->q_file_name);
txn_sm->q_key = (TSCacheKey)CacheKeyCreate(txn_sm->q_file_name);
set_handler(txn_sm->q_current_handler,
(TxnSMHandler)&state_handle_cache_lookup);
@@ -266,17 +266,17 @@ state_handle_cache_lookup(TSCont contp, TSEvent event,
TSVConn vc)
int64_t response_size;
int ret_val;
- TSDebug("protocol", "enter state_handle_cache_lookup");
+ TSDebug(PLUGIN_NAME, "enter state_handle_cache_lookup");
switch (event) {
case TS_EVENT_CACHE_OPEN_READ:
- TSDebug("protocol", "cache hit!!!");
+ TSDebug(PLUGIN_NAME, "cache hit!!!");
/* Cache hit. */
/* Write log */
ret_val = TSTextLogObjectWrite(protocol_plugin_log, "%s %s %d \n",
txn_sm->q_file_name, txn_sm->q_server_name, 1);
if (ret_val != TS_SUCCESS) {
- TSError("[protocol] Fail to write into log");
+ TSError("[%s] Fail to write into log", PLUGIN_NAME);
}
txn_sm->q_cache_vc = vc;
@@ -304,12 +304,12 @@ state_handle_cache_lookup(TSCont contp, TSEvent event,
TSVConn vc)
case TS_EVENT_CACHE_OPEN_READ_FAILED:
/* Cache miss or error, open cache write_vc. */
- TSDebug("protocol", "cache miss or error!!!");
+ TSDebug(PLUGIN_NAME, "cache miss or error!!!");
/* Write log */
ret_val = TSTextLogObjectWrite(protocol_plugin_log, "%s %s %d \n",
txn_sm->q_file_name, txn_sm->q_server_name, 0);
if (ret_val != TS_SUCCESS) {
- TSError("[protocol] Fail to write into log");
+ TSError("[%s] Fail to write into log", PLUGIN_NAME);
}
set_handler(txn_sm->q_current_handler,
(TxnSMHandler)&state_handle_cache_prepare_for_write);
@@ -332,8 +332,8 @@ load_buffer_cache_data(TxnSM *txn_sm)
server response buffer */
int rdr_avail = TSIOBufferReaderAvail(txn_sm->q_cache_read_buffer_reader);
- TSDebug("protocol", "entering buffer_cache_data");
- TSDebug("protocol", "loading %d bytes to buffer reader", rdr_avail);
+ TSDebug(PLUGIN_NAME, "entering buffer_cache_data");
+ TSDebug(PLUGIN_NAME, "loading %d bytes to buffer reader", rdr_avail);
TSAssert(rdr_avail > 0);
@@ -354,7 +354,7 @@ state_handle_cache_read_response(TSCont contp, TSEvent
event, TSVIO vio ATS_UNUS
{
TxnSM *txn_sm = (TxnSM *)TSContDataGet(contp);
- TSDebug("protocol", "enter state_handle_cache_read_response");
+ TSDebug(PLUGIN_NAME, "enter state_handle_cache_read_response");
txn_sm->q_pending_action = NULL;
@@ -404,7 +404,7 @@ state_handle_cache_prepare_for_write(TSCont contp, TSEvent
event, TSVConn vc)
{
TxnSM *txn_sm = (TxnSM *)TSContDataGet(contp);
- TSDebug("protocol", "enter state_handle_cache_prepare_for_write");
+ TSDebug(PLUGIN_NAME, "enter state_handle_cache_prepare_for_write");
txn_sm->q_pending_action = NULL;
@@ -413,7 +413,7 @@ state_handle_cache_prepare_for_write(TSCont contp, TSEvent
event, TSVConn vc)
txn_sm->q_cache_vc = vc;
break;
default:
- TSError("[protocol] Can't open cache write_vc, aborting txn");
+ TSError("[%s] Can't open cache write_vc, aborting txn", PLUGIN_NAME);
txn_sm->q_cache_vc = NULL;
return prepare_to_die(contp);
break;
@@ -428,7 +428,7 @@ state_build_and_send_request(TSCont contp, TSEvent event
ATS_UNUSED, void *data
{
TxnSM *txn_sm = (TxnSM *)TSContDataGet(contp);
- TSDebug("protocol", "enter state_build_and_send_request");
+ TSDebug(PLUGIN_NAME, "enter state_build_and_send_request");
txn_sm->q_pending_action = NULL;
@@ -452,7 +452,7 @@ state_build_and_send_request(TSCont contp, TSEvent event
ATS_UNUSED, void *data
txn_sm->q_pending_action = TSHostLookup(contp, txn_sm->q_server_name,
strlen(txn_sm->q_server_name));
TSAssert(txn_sm->q_pending_action);
- TSDebug("protocol", "initiating host lookup");
+ TSDebug(PLUGIN_NAME, "initiating host lookup");
return TS_SUCCESS;
}
@@ -465,7 +465,7 @@ state_dns_lookup(TSCont contp, TSEvent event,
TSHostLookupResult host_info)
struct sockaddr const *q_server_addr;
struct sockaddr_in ip_addr;
- TSDebug("protocol", "enter state_dns_lookup");
+ TSDebug(PLUGIN_NAME, "enter state_dns_lookup");
/* Can't find the server IP. */
if (event != TS_EVENT_HOST_LOOKUP || !host_info) {
@@ -498,7 +498,7 @@ state_connect_to_server(TSCont contp, TSEvent event,
TSVConn vc)
{
TxnSM *txn_sm = (TxnSM *)TSContDataGet(contp);
- TSDebug("protocol", "enter state_connect_to_server");
+ TSDebug(PLUGIN_NAME, "enter state_connect_to_server");
/* TSNetConnect failed. */
if (event != TS_EVENT_NET_CONNECT) {
@@ -524,7 +524,7 @@ state_send_request_to_server(TSCont contp, TSEvent event,
TSVIO vio)
{
TxnSM *txn_sm = (TxnSM *)TSContDataGet(contp);
- TSDebug("protocol", "enter state_send_request_to_server");
+ TSDebug(PLUGIN_NAME, "enter state_send_request_to_server");
switch (event) {
case TS_EVENT_VCONN_WRITE_READY:
@@ -551,7 +551,7 @@ state_interface_with_server(TSCont contp, TSEvent event,
TSVIO vio)
{
TxnSM *txn_sm = (TxnSM *)TSContDataGet(contp);
- TSDebug("protocol", "enter state_interface_with_server");
+ TSDebug(PLUGIN_NAME, "enter state_interface_with_server");
txn_sm->q_pending_action = NULL;
@@ -569,7 +569,7 @@ state_interface_with_server(TSCont contp, TSEvent event,
TSVIO vio)
/* all data of the response come in. */
case TS_EVENT_VCONN_EOS:
- TSDebug("protocol", "get server eos");
+ TSDebug(PLUGIN_NAME, "get server eos");
/* There is no more use of server_vc, close it. */
if (txn_sm->q_server_vc) {
TSVConnClose(txn_sm->q_server_vc);
@@ -609,7 +609,7 @@ state_interface_with_server(TSCont contp, TSEvent event,
TSVIO vio)
txn_sm->q_pending_action = TSCacheRead(contp, txn_sm->q_key);
} else { /* not done with writing into cache */
- TSDebug("protocol", "cache_response_length is %d, server response length
is %d", txn_sm->q_cache_response_length,
+ TSDebug(PLUGIN_NAME, "cache_response_length is %d, server response
length is %d", txn_sm->q_cache_response_length,
txn_sm->q_server_response_length);
TSVIOReenable(txn_sm->q_cache_write_vio);
}
@@ -633,7 +633,7 @@ state_read_response_from_server(TSCont contp, TSEvent event
ATS_UNUSED, TSVIO vi
TxnSM *txn_sm = (TxnSM *)TSContDataGet(contp);
int bytes_read = 0;
- TSDebug("protocol", "enter state_read_response_from_server");
+ TSDebug(PLUGIN_NAME, "enter state_read_response_from_server");
bytes_read = TSIOBufferReaderAvail(txn_sm->q_cache_response_buffer_reader);
@@ -656,7 +656,7 @@ state_read_response_from_server(TSCont contp, TSEvent event
ATS_UNUSED, TSVIO vi
}
txn_sm->q_server_response_length += bytes_read;
- TSDebug("protocol", "bytes read is %d, total response length is %d",
bytes_read, txn_sm->q_server_response_length);
+ TSDebug(PLUGIN_NAME, "bytes read is %d, total response length is %d",
bytes_read, txn_sm->q_server_response_length);
return TS_SUCCESS;
}
@@ -668,7 +668,7 @@ state_write_to_cache(TSCont contp, TSEvent event, TSVIO vio)
{
TxnSM *txn_sm = (TxnSM *)TSContDataGet(contp);
- TSDebug("protocol", "enter state_write_to_cache");
+ TSDebug(PLUGIN_NAME, "enter state_write_to_cache");
switch (event) {
case TS_EVENT_VCONN_WRITE_READY:
@@ -676,7 +676,7 @@ state_write_to_cache(TSCont contp, TSEvent event, TSVIO vio)
return TS_SUCCESS;
case TS_EVENT_VCONN_WRITE_COMPLETE:
- TSDebug("protocol", "nbytes %" PRId64 ", ndone %" PRId64,
TSVIONBytesGet(vio), TSVIONDoneGet(vio));
+ TSDebug(PLUGIN_NAME, "nbytes %" PRId64 ", ndone %" PRId64,
TSVIONBytesGet(vio), TSVIONDoneGet(vio));
/* Since the first write is through TSVConnWrite, which aleady consume
the data in cache_buffer_reader, don't consume it again. */
if (txn_sm->q_cache_response_length > 0 && txn_sm->q_block_bytes_read > 0)
{
@@ -687,14 +687,14 @@ state_write_to_cache(TSCont contp, TSEvent event, TSVIO
vio)
/* If not all data have been read in, we have to reenable the read_vio */
if (txn_sm->q_server_vc != NULL) {
- TSDebug("protocol", "re-enable server_read_vio");
+ TSDebug(PLUGIN_NAME, "re-enable server_read_vio");
TSVIOReenable(txn_sm->q_server_read_vio);
return TS_SUCCESS;
}
if (txn_sm->q_cache_response_length >= txn_sm->q_server_response_length) {
/* Write is complete, close the cache_vc. */
- TSDebug("protocol", "close cache_vc, cache_response_length is %d,
server_response_lenght is %d",
+ TSDebug(PLUGIN_NAME, "close cache_vc, cache_response_length is %d,
server_response_lenght is %d",
txn_sm->q_cache_response_length,
txn_sm->q_server_response_length);
TSVConnClose(txn_sm->q_cache_vc);
txn_sm->q_cache_vc = NULL;
@@ -706,7 +706,7 @@ state_write_to_cache(TSCont contp, TSEvent event, TSVIO vio)
txn_sm->q_pending_action = TSCacheRead(contp, txn_sm->q_key);
} else { /* not done with writing into cache */
- TSDebug("protocol", "re-enable cache_write_vio");
+ TSDebug(PLUGIN_NAME, "re-enable cache_write_vio");
TSVIOReenable(txn_sm->q_cache_write_vio);
}
return TS_SUCCESS;
@@ -726,18 +726,18 @@ state_send_response_to_client(TSCont contp, TSEvent
event, TSVIO vio)
{
TxnSM *txn_sm = (TxnSM *)TSContDataGet(contp);
- TSDebug("protocol", "enter state_send_response_to_client");
+ TSDebug(PLUGIN_NAME, "enter state_send_response_to_client");
switch (event) {
case TS_EVENT_VCONN_WRITE_READY:
- TSDebug("protocol", " . wr ready");
- TSDebug("protocol", "write_ready: nbytes %" PRId64 ", ndone %" PRId64,
TSVIONBytesGet(vio), TSVIONDoneGet(vio));
+ TSDebug(PLUGIN_NAME, " . wr ready");
+ TSDebug(PLUGIN_NAME, "write_ready: nbytes %" PRId64 ", ndone %" PRId64,
TSVIONBytesGet(vio), TSVIONDoneGet(vio));
TSVIOReenable(txn_sm->q_client_write_vio);
break;
case TS_EVENT_VCONN_WRITE_COMPLETE:
- TSDebug("protocol", " . wr complete");
- TSDebug("protocol", "write_complete: nbytes %" PRId64 ", ndone %" PRId64,
TSVIONBytesGet(vio), TSVIONDoneGet(vio));
+ TSDebug(PLUGIN_NAME, " . wr complete");
+ TSDebug(PLUGIN_NAME, "write_complete: nbytes %" PRId64 ", ndone %" PRId64,
TSVIONBytesGet(vio), TSVIONDoneGet(vio));
/* Finished sending all data to client, close client_vc. */
if (txn_sm->q_client_vc) {
TSVConnClose(txn_sm->q_client_vc);
@@ -749,11 +749,11 @@ state_send_response_to_client(TSCont contp, TSEvent
event, TSVIO vio)
return state_done(contp, 0, NULL);
default:
- TSDebug("protocol", " . default handler");
+ TSDebug(PLUGIN_NAME, " . default handler");
return prepare_to_die(contp);
}
- TSDebug("protocol", "leaving send_response_to_client");
+ TSDebug(PLUGIN_NAME, "leaving send_response_to_client");
return TS_SUCCESS;
}
@@ -765,7 +765,7 @@ prepare_to_die(TSCont contp)
{
TxnSM *txn_sm = (TxnSM *)TSContDataGet(contp);
- TSDebug("protocol", "enter prepare_to_die");
+ TSDebug(PLUGIN_NAME, "enter prepare_to_die");
if (txn_sm->q_client_vc) {
TSVConnAbort(txn_sm->q_client_vc, 1);
txn_sm->q_client_vc = NULL;
@@ -795,13 +795,13 @@ state_done(TSCont contp, TSEvent event ATS_UNUSED, TSVIO
vio ATS_UNUSED)
{
TxnSM *txn_sm = (TxnSM *)TSContDataGet(contp);
- TSDebug("protocol", "enter state_done");
+ TSDebug(PLUGIN_NAME, "enter state_done");
if (txn_sm->q_pending_action && !TSActionDone(txn_sm->q_pending_action)) {
- TSDebug("protocol", "cancelling pending action %p",
txn_sm->q_pending_action);
+ TSDebug(PLUGIN_NAME, "cancelling pending action %p",
txn_sm->q_pending_action);
TSActionCancel(txn_sm->q_pending_action);
} else if (txn_sm->q_pending_action) {
- TSDebug("protocol", "action is done %p", txn_sm->q_pending_action);
+ TSDebug(PLUGIN_NAME, "action is done %p", txn_sm->q_pending_action);
}
txn_sm->q_pending_action = NULL;
@@ -888,12 +888,12 @@ send_response_to_client(TSCont contp)
TxnSM *txn_sm;
int response_len;
- TSDebug("protocol", "enter send_response_to_client");
+ TSDebug(PLUGIN_NAME, "enter send_response_to_client");
txn_sm = (TxnSM *)TSContDataGet(contp);
response_len =
TSIOBufferReaderAvail(txn_sm->q_client_response_buffer_reader);
- TSDebug("protocol", " . resp_len is %d", response_len);
+ TSDebug(PLUGIN_NAME, " . resp_len is %d", response_len);
set_handler(txn_sm->q_current_handler,
(TxnSMHandler)&state_interface_with_client);
txn_sm->q_client_write_vio =
--
To stop receiving notification emails like this one, please contact
['"[email protected]" <[email protected]>'].