You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by am...@apache.org on 2017/03/10 23:55:23 UTC

[trafficserver] branch master updated: TS-4976: Regularize plugins - null transform.

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  c590774   TS-4976: Regularize plugins - null transform.
c590774 is described below

commit c5907743819d8cd868922762a3b1d946dc73ecbd
Author: Alan M. Carroll <am...@apache.org>
AuthorDate: Fri Mar 10 07:32:52 2017 -0600

    TS-4976: Regularize plugins - null transform.
---
 doc/developer-guide/introduction/index.en.rst      |  4 +-
 .../append-transform-plugin.en.rst                 |  2 +-
 ...mple-buffered-null-transformation-plugin.en.rst |  2 +-
 .../plugins/io/transformations.en.rst              |  2 +-
 example/Makefile.am                                |  8 ++--
 .../bnull_transform.c}                             | 12 +++---
 .../null_transform.c}                              | 46 +++++++++++-----------
 .../{null-transform => null_transform}/readme.txt  |  4 +-
 8 files changed, 40 insertions(+), 40 deletions(-)

diff --git a/doc/developer-guide/introduction/index.en.rst b/doc/developer-guide/introduction/index.en.rst
index 00ec7c9..3c3609e 100644
--- a/doc/developer-guide/introduction/index.en.rst
+++ b/doc/developer-guide/introduction/index.en.rst
@@ -62,7 +62,7 @@ Below is a section-by-section breakdown of this guide:
    plugins.
 
 :ref:`developer-plugins-http-transformations`
-   Detailed explanation of the null-transform example; also discusses
+   Detailed explanation of the null_transform example; also discusses
    ``VConnections``, ``VIOs``, and IO buffers.
 
 :ref:`developer-plugins-new-protocol-plugins`
@@ -113,5 +113,3 @@ function type:
 
 :ref:`developer-api-ref-functions`
    Traffic Server API Function Documentation.
-
-
diff --git a/doc/developer-guide/plugins/http-transformations/append-transform-plugin.en.rst b/doc/developer-guide/plugins/http-transformations/append-transform-plugin.en.rst
index 5494b44..e3cfc57 100644
--- a/doc/developer-guide/plugins/http-transformations/append-transform-plugin.en.rst
+++ b/doc/developer-guide/plugins/http-transformations/append-transform-plugin.en.rst
@@ -31,7 +31,7 @@ containing the append text is a parameter you specify in
 
     append_transform.so path/to/file
 
-The append_transform plugin is based on ``null-transform.c``. The only
+The append_transform plugin is based on ``null_transform.c``. The only
 difference is that after the plugin feeds the document through the
 transformation, it adds text to the response.
 
diff --git a/doc/developer-guide/plugins/http-transformations/sample-buffered-null-transformation-plugin.en.rst b/doc/developer-guide/plugins/http-transformations/sample-buffered-null-transformation-plugin.en.rst
index 2e7c18e..55cd3a5 100644
--- a/doc/developer-guide/plugins/http-transformations/sample-buffered-null-transformation-plugin.en.rst
+++ b/doc/developer-guide/plugins/http-transformations/sample-buffered-null-transformation-plugin.en.rst
@@ -22,7 +22,7 @@
 Sample Buffered Null Transform Plugin
 *************************************
 
-The buffered null transform, ``bnull-transform.c``, reads the response
+The buffered null transform, ``bnull_transform.c``, reads the response
 content into a buffer and then writes the full buffer out to the client.
 Many examples of transformations, such as compression, require you to
 gather the full response content in order to perform the transformation.
diff --git a/doc/developer-guide/plugins/io/transformations.en.rst b/doc/developer-guide/plugins/io/transformations.en.rst
index baa613e..826259e 100644
--- a/doc/developer-guide/plugins/io/transformations.en.rst
+++ b/doc/developer-guide/plugins/io/transformations.en.rst
@@ -142,7 +142,7 @@ Here's how to make sure that all incoming data is consumed:
 
 -  After reading or copying data, make sure that you consume the data
    and increase the value of ndone for the input VIO, as in the
-   following example taken from ``null-transform.c``:
+   following example taken from ``null_transform.c``:
 
    .. code-block:: c
 
diff --git a/example/Makefile.am b/example/Makefile.am
index db9eca0..82cfa33 100644
--- a/example/Makefile.am
+++ b/example/Makefile.am
@@ -28,13 +28,13 @@ example_Plugins = \
 	basic_auth.la \
 	blacklist_0.la \
 	blacklist_1.la \
-	bnull-transform.la \
+	bnull_transform.la \
 	cache-scan.la \
 	file-1.la \
 	hello.la \
 	intercept.la \
 	lifecycle-plugin.la \
-	null-transform.la \
+	null_transform.la \
 	output-header.la \
 	passthru.la \
 	protocol-stack.la \
@@ -92,13 +92,13 @@ append_transform_la_SOURCES = append_transform/append_transform.c
 basic_auth_la_SOURCES = basic_auth/basic_auth.c
 blacklist_0_la_SOURCES = blacklist_0/blacklist_0.c
 blacklist_1_la_SOURCES = blacklist_1/blacklist_1.c
-bnull_transform_la_SOURCES = bnull-transform/bnull-transform.c
+bnull_transform_la_SOURCES = bnull_transform/bnull_transform.c
 cache_scan_la_SOURCES = cache-scan/cache-scan.cc
 file_1_la_SOURCES = file-1/file-1.c
 hello_la_SOURCES = hello/hello.c
 intercept_la_SOURCES = intercept/intercept.cc
 lifecycle_plugin_la_SOURCES = lifecycle-plugin/lifecycle-plugin.c
-null_transform_la_SOURCES = null-transform/null-transform.c
+null_transform_la_SOURCES = null_transform/null_transform.c
 output_header_la_SOURCES = output-header/output-header.c
 passthru_la_SOURCES = passthru/passthru.cc
 protocol_la_SOURCES = protocol/Protocol.c protocol/TxnSM.c
diff --git a/example/bnull-transform/bnull-transform.c b/example/bnull_transform/bnull_transform.c
similarity index 96%
rename from example/bnull-transform/bnull-transform.c
rename to example/bnull_transform/bnull_transform.c
index c73fefe..589aa55 100644
--- a/example/bnull-transform/bnull-transform.c
+++ b/example/bnull_transform/bnull_transform.c
@@ -39,6 +39,8 @@
 #include "ts/ts.h"
 #include "ts/ink_defs.h"
 
+#define PLUGIN_NAME "bnull_transform"
+
 #define TS_NULL_MUTEX NULL
 #define STATE_BUFFER_DATA 0
 #define STATE_OUTPUT_DATA 1
@@ -303,12 +305,12 @@ TSPluginInit(int argc ATS_UNUSED, const char *argv[] ATS_UNUSED)
   TSPluginRegistrationInfo info;
   TSMutex mutex = TS_NULL_MUTEX;
 
-  info.plugin_name   = "buffered-null-transform";
-  info.vendor_name   = "MyCompany";
-  info.support_email = "ts-api-support@MyCompany.com";
+  info.plugin_name   = PLUGIN_NAME;
+  info.vendor_name   = "Apache Software Foundation";
+  info.support_email = "dev@trafficserver.apache.org";
 
   if (TSPluginRegister(&info) != TS_SUCCESS) {
-    TSError("[bnull-transform] Plugin registration failed.");
+    TSError("[%s] Plugin registration failed.", PLUGIN_NAME);
 
     goto Lerror;
   }
@@ -320,5 +322,5 @@ TSPluginInit(int argc ATS_UNUSED, const char *argv[] ATS_UNUSED)
   return;
 
 Lerror:
-  TSError("[bnull-transform] Plugin disabled");
+  TSError("[%s] Plugin disabled", PLUGIN_NAME);
 }
diff --git a/example/null-transform/null-transform.c b/example/null_transform/null_transform.c
similarity index 86%
rename from example/null-transform/null-transform.c
rename to example/null_transform/null_transform.c
index e3d6928..7a55525 100644
--- a/example/null-transform/null-transform.c
+++ b/example/null_transform/null_transform.c
@@ -21,13 +21,13 @@
   limitations under the License.
  */
 
-/* null-transform.c:  an example program that does a null transform
+/* null_transform.c:  an example program that does a null transform
  *                    of response body content
  *
  *
  *
  *	Usage:
- *	  null-transform.so
+ *	  null_transform.so
  *
  *
  */
@@ -38,6 +38,8 @@
 #include "ts/ts.h"
 #include "ts/ink_defs.h"
 
+#define PLUGIN_NAME "null_transform"
+
 typedef struct {
   TSVIO output_vio;
   TSIOBuffer output_buffer;
@@ -78,7 +80,7 @@ handle_transform(TSCont contp)
   int64_t towrite;
   int64_t avail;
 
-  TSDebug("null-transform", "Entering handle_transform()");
+  TSDebug(PLUGIN_NAME, "Entering handle_transform()");
   /* Get the output (downstream) vconnection where we'll write data to. */
 
   output_conn = TSTransformOutputVConnGet(contp);
@@ -101,7 +103,7 @@ handle_transform(TSCont contp)
     data                = my_data_alloc();
     data->output_buffer = TSIOBufferCreate();
     data->output_reader = TSIOBufferReaderAlloc(data->output_buffer);
-    TSDebug("null-transform", "\tWriting %" PRId64 " bytes on VConn", TSVIONBytesGet(input_vio));
+    TSDebug(PLUGIN_NAME, "\tWriting %" PRId64 " bytes on VConn", TSVIONBytesGet(input_vio));
     // data->output_vio = TSVConnWrite(output_conn, contp, data->output_reader, INT32_MAX);
     data->output_vio = TSVConnWrite(output_conn, contp, data->output_reader, INT64_MAX);
     // data->output_vio = TSVConnWrite(output_conn, contp, data->output_reader, TSVIONBytesGet(input_vio));
@@ -129,14 +131,14 @@ handle_transform(TSCont contp)
    * to write to the output connection.
    */
   towrite = TSVIONTodoGet(input_vio);
-  TSDebug("null-transform", "\ttoWrite is %" PRId64 "", towrite);
+  TSDebug(PLUGIN_NAME, "\ttoWrite is %" PRId64 "", towrite);
 
   if (towrite > 0) {
     /* The amount of data left to read needs to be truncated by
      * the amount of data actually in the read buffer.
      */
     avail = TSIOBufferReaderAvail(TSVIOReaderGet(input_vio));
-    TSDebug("null-transform", "\tavail is %" PRId64 "", avail);
+    TSDebug(PLUGIN_NAME, "\tavail is %" PRId64 "", avail);
     if (towrite > avail) {
       towrite = avail;
     }
@@ -197,10 +199,10 @@ null_transform(TSCont contp, TSEvent event, void *edata ATS_UNUSED)
   /* Check to see if the transformation has been closed by a call to
    * TSVConnClose.
    */
-  TSDebug("null-transform", "Entering null_transform()");
+  TSDebug(PLUGIN_NAME, "Entering null_transform()");
 
   if (TSVConnClosedGet(contp)) {
-    TSDebug("null-transform", "\tVConn is closed");
+    TSDebug(PLUGIN_NAME, "\tVConn is closed");
     my_data_destroy(TSContDataGet(contp));
     TSContDestroy(contp);
     return 0;
@@ -209,7 +211,7 @@ null_transform(TSCont contp, TSEvent event, void *edata ATS_UNUSED)
     case TS_EVENT_ERROR: {
       TSVIO input_vio;
 
-      TSDebug("null-transform", "\tEvent is TS_EVENT_ERROR");
+      TSDebug(PLUGIN_NAME, "\tEvent is TS_EVENT_ERROR");
       /* Get the write VIO for the write operation that was
        * performed on ourself. This VIO contains the continuation of
        * our parent transformation. This is the input VIO.
@@ -222,7 +224,7 @@ null_transform(TSCont contp, TSEvent event, void *edata ATS_UNUSED)
       TSContCall(TSVIOContGet(input_vio), TS_EVENT_ERROR, input_vio);
     } break;
     case TS_EVENT_VCONN_WRITE_COMPLETE:
-      TSDebug("null-transform", "\tEvent is TS_EVENT_VCONN_WRITE_COMPLETE");
+      TSDebug(PLUGIN_NAME, "\tEvent is TS_EVENT_VCONN_WRITE_COMPLETE");
       /* When our output connection says that it has finished
        * reading all the data we've written to it then we should
        * shutdown the write portion of its connection to
@@ -231,9 +233,9 @@ null_transform(TSCont contp, TSEvent event, void *edata ATS_UNUSED)
       TSVConnShutdown(TSTransformOutputVConnGet(contp), 0, 1);
       break;
     case TS_EVENT_VCONN_WRITE_READY:
-      TSDebug("null-transform", "\tEvent is TS_EVENT_VCONN_WRITE_READY");
+      TSDebug(PLUGIN_NAME, "\tEvent is TS_EVENT_VCONN_WRITE_READY");
     default:
-      TSDebug("null-transform", "\t(event is %d)", event);
+      TSDebug(PLUGIN_NAME, "\t(event is %d)", event);
       /* If we get a WRITE_READY event or any other type of
        * event (sent, perhaps, because we were reenabled) then
        * we'll attempt to transform more data.
@@ -258,7 +260,7 @@ transformable(TSHttpTxn txnp)
   TSHttpStatus resp_status;
   int retv = 0;
 
-  TSDebug("null-transform", "Entering transformable()");
+  TSDebug(PLUGIN_NAME, "Entering transformable()");
 
   if (TS_SUCCESS == TSHttpTxnServerRespGet(txnp, &bufp, &hdr_loc)) {
     resp_status = TSHttpHdrStatusGet(bufp, hdr_loc);
@@ -266,7 +268,7 @@ transformable(TSHttpTxn txnp)
     TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
   }
 
-  TSDebug("null-transform", "Exiting transformable with return %d", retv);
+  TSDebug(PLUGIN_NAME, "Exiting transformable with return %d", retv);
   return retv;
 }
 
@@ -275,7 +277,7 @@ transform_add(TSHttpTxn txnp)
 {
   TSVConn connp;
 
-  TSDebug("null-transform", "Entering transform_add()");
+  TSDebug(PLUGIN_NAME, "Entering transform_add()");
   connp = TSTransformCreate(null_transform, txnp);
   TSHttpTxnHookAdd(txnp, TS_HTTP_RESPONSE_TRANSFORM_HOOK, connp);
 }
@@ -285,10 +287,10 @@ transform_plugin(TSCont contp ATS_UNUSED, TSEvent event, void *edata)
 {
   TSHttpTxn txnp = (TSHttpTxn)edata;
 
-  TSDebug("null-transform", "Entering transform_plugin()");
+  TSDebug(PLUGIN_NAME, "Entering transform_plugin()");
   switch (event) {
   case TS_EVENT_HTTP_READ_RESPONSE_HDR:
-    TSDebug("null-transform", "\tEvent is TS_EVENT_HTTP_READ_RESPONSE_HDR");
+    TSDebug(PLUGIN_NAME, "\tEvent is TS_EVENT_HTTP_READ_RESPONSE_HDR");
     if (transformable(txnp)) {
       transform_add(txnp);
     }
@@ -307,12 +309,12 @@ TSPluginInit(int argc ATS_UNUSED, const char *argv[] ATS_UNUSED)
 {
   TSPluginRegistrationInfo info;
 
-  info.plugin_name   = "null-transform";
-  info.vendor_name   = "MyCompany";
-  info.support_email = "ts-api-support@MyCompany.com";
+  info.plugin_name   = PLUGIN_NAME;
+  info.vendor_name   = "Apache Software Foundation";
+  info.support_email = "dev@trafficserver.apache.org";
 
   if (TSPluginRegister(&info) != TS_SUCCESS) {
-    TSError("[null-transform] Plugin registration failed.");
+    TSError("[%s] Plugin registration failed.", PLUGIN_NAME);
 
     goto Lerror;
   }
@@ -321,5 +323,5 @@ TSPluginInit(int argc ATS_UNUSED, const char *argv[] ATS_UNUSED)
   return;
 
 Lerror:
-  TSError("[null-transform] Unable to initialize plugin (disabled).");
+  TSError("[%s] Unable to initialize plugin (disabled).", PLUGIN_NAME);
 }
diff --git a/example/null-transform/readme.txt b/example/null_transform/readme.txt
similarity index 98%
rename from example/null-transform/readme.txt
rename to example/null_transform/readme.txt
index d873cbe..3ab9e0c 100644
--- a/example/null-transform/readme.txt
+++ b/example/null_transform/readme.txt
@@ -1,4 +1,4 @@
-The null-transform.c plugin performs a null transformation
+The null_transform.c plugin performs a null transformation
 on response content.
 
 The plugin is called each time Traffic Server reads an HTTP
@@ -108,5 +108,3 @@ This is how the transformation receives the WRITE_COMPLETE event:
 when the downstream vconnection learns through the downstream
 (output) vio that there is no more data left to read (nbytes=ndone),
 the downstream vconnection sends WRITE_COMPLETE upstream.
-
-

-- 
To stop receiving notification emails like this one, please contact
['"commits@trafficserver.apache.org" <co...@trafficserver.apache.org>'].