Author: zwoop
Date: Thu Feb 17 03:12:32 2011
New Revision: 1071491
URL: http://svn.apache.org/viewvc?rev=1071491&view=rev
Log:
TS-590 Checkpoint 5, many changes, still passes regression
Modified:
trafficserver/traffic/trunk/example/add-header/add-header.c
trafficserver/traffic/trunk/example/append-transform/append-transform.c
trafficserver/traffic/trunk/example/basic-auth/basic-auth.c
trafficserver/traffic/trunk/example/blacklist-0/blacklist-0.c
trafficserver/traffic/trunk/example/blacklist-1/blacklist-1.c
trafficserver/traffic/trunk/example/bnull-transform/bnull-transform.c
trafficserver/traffic/trunk/example/cache_scan/cache_scan.cc
trafficserver/traffic/trunk/example/gzip-transform/gunzip.c
trafficserver/traffic/trunk/example/gzip-transform/gzip.c
trafficserver/traffic/trunk/example/null-transform/null-transform.c
trafficserver/traffic/trunk/example/output-header/output-header.c
trafficserver/traffic/trunk/example/redirect-1/redirect-1.c
trafficserver/traffic/trunk/example/remap/remap.cc
trafficserver/traffic/trunk/example/response-header-1/response-header-1.c
trafficserver/traffic/trunk/example/server-transform/server-transform.c
trafficserver/traffic/trunk/example/thread-pool/psi.c
trafficserver/traffic/trunk/iocore/cache/Cache.cc
trafficserver/traffic/trunk/proxy/FetchSM.cc
trafficserver/traffic/trunk/proxy/InkAPI.cc
trafficserver/traffic/trunk/proxy/InkAPITest.cc
trafficserver/traffic/trunk/proxy/InkAPITestTool.cc
trafficserver/traffic/trunk/proxy/InkIOCoreAPI.cc
trafficserver/traffic/trunk/proxy/ProxyConfig.cc
trafficserver/traffic/trunk/proxy/api/ts/experimental.h
trafficserver/traffic/trunk/proxy/api/ts/ts.h.in
Modified: trafficserver/traffic/trunk/example/add-header/add-header.c
URL:
http://svn.apache.org/viewvc/trafficserver/traffic/trunk/example/add-header/add-header.c?rev=1071491&r1=1071490&r2=1071491&view=diff
==============================================================================
--- trafficserver/traffic/trunk/example/add-header/add-header.c (original)
+++ trafficserver/traffic/trunk/example/add-header/add-header.c Thu Feb 17
03:12:32 2011
@@ -51,7 +51,7 @@ add_header(TSHttpTxn txnp, TSCont contp)
TSMLoc new_field_loc;
int retval;
- if (!TSHttpTxnClientReqGet(txnp, &req_bufp, &req_loc)) {
+ if (TSHttpTxnClientReqGet(txnp, &req_bufp, &req_loc) != TS_SUCCESS) {
TSError("[add_header] Error while retrieving client request header\n");
goto done;
}
@@ -222,12 +222,7 @@ TSPluginInit(int argc, const char *argv[
/* Create a continuation with a mutex as there is a shared global structure
containing the headers to add */
- retval = TSHttpHookAdd(TS_HTTP_READ_REQUEST_HDR_HOOK,
TSContCreate(add_header_plugin, TSMutexCreate()));
- if (retval == TS_ERROR) {
- TSError("[PluginInit] Error while registering to hook");
- goto error;
- }
-
+ TSHttpHookAdd(TS_HTTP_READ_REQUEST_HDR_HOOK, TSContCreate(add_header_plugin,
TSMutexCreate()));
goto done;
error:
Modified:
trafficserver/traffic/trunk/example/append-transform/append-transform.c
URL:
http://svn.apache.org/viewvc/trafficserver/traffic/trunk/example/append-transform/append-transform.c?rev=1071491&r1=1071490&r2=1071491&view=diff
==============================================================================
--- trafficserver/traffic/trunk/example/append-transform/append-transform.c
(original)
+++ trafficserver/traffic/trunk/example/append-transform/append-transform.c Thu
Feb 17 03:12:32 2011
@@ -99,7 +99,7 @@ handle_transform(TSCont contp)
ourself. This VIO contains the buffer that we are to read from
as well as the continuation we are to call when the buffer is
empty. */
- write_vio = TSVConnWriteVIOGet(contp);
+ TSVConnWriteVIOGet(contp, &write_vio); /* Should check for errors ... */
/* Get our data structure for this operation. The private data
structure contains the output VIO and output buffer. If the
@@ -115,7 +115,7 @@ handle_transform(TSCont contp)
data->output_buffer = TSIOBufferCreate();
data->output_reader = TSIOBufferReaderAlloc(data->output_buffer);
data->output_vio = TSVConnWrite(output_conn, contp, data->output_reader,
towrite);
- ASSERT_SUCCESS(TSContDataSet(contp, data));
+ TSContDataSet(contp, data);
}
/* We also check to see if the write VIO's buffer is non-NULL. A
@@ -205,7 +205,7 @@ append_transform(TSCont contp, TSEvent e
TSVConnClose. */
if (TSVConnClosedGet(contp)) {
my_data_destroy(TSContDataGet(contp));
- ASSERT_SUCCESS(TSContDestroy(contp));
+ TSContDestroy(contp);
return 0;
} else {
switch (event) {
@@ -216,7 +216,7 @@ append_transform(TSCont contp, TSEvent e
/* Get the write VIO for the write operation that was
performed on ourself. This VIO contains the continuation of
our parent transformation. */
- write_vio = TSVConnWriteVIOGet(contp);
+ TSVConnWriteVIOGet(contp, &write_vio); /* Should check for errors ...
*/
/* Call back the write VIO continuation to let it know that we
have completed the write operation. */
@@ -295,10 +295,7 @@ transform_add(TSHttpTxn txnp)
TSVConn connp;
connp = TSTransformCreate(append_transform, txnp);
-
- if (TSHttpTxnHookAdd(txnp, TS_HTTP_RESPONSE_TRANSFORM_HOOK, connp) ==
TS_ERROR) {
- TSError("[append-transform] Unable to attach plugin to http
transaction\n");
- }
+ TSHttpTxnHookAdd(txnp, TS_HTTP_RESPONSE_TRANSFORM_HOOK, connp);
}
static int
@@ -311,7 +308,7 @@ transform_plugin(TSCont contp, TSEvent e
if (transformable(txnp)) {
transform_add(txnp);
}
- ASSERT_SUCCESS(TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE));
+ TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE);
return 0;
default:
break;
@@ -411,11 +408,7 @@ TSPluginInit(int argc, const char *argv[
goto Lerror;
}
- if (TSHttpHookAdd(TS_HTTP_READ_RESPONSE_HDR_HOOK,
TSContCreate(transform_plugin, NULL)) == TS_ERROR) {
- TSError("[append-transform] Unable to set read response header\n");
- goto Lerror;
- }
-
+ TSHttpHookAdd(TS_HTTP_READ_RESPONSE_HDR_HOOK, TSContCreate(transform_plugin,
NULL));
return;
Lerror:
Modified: trafficserver/traffic/trunk/example/basic-auth/basic-auth.c
URL:
http://svn.apache.org/viewvc/trafficserver/traffic/trunk/example/basic-auth/basic-auth.c?rev=1071491&r1=1071490&r2=1071491&view=diff
==============================================================================
--- trafficserver/traffic/trunk/example/basic-auth/basic-auth.c (original)
+++ trafficserver/traffic/trunk/example/basic-auth/basic-auth.c Thu Feb 17
03:12:32 2011
@@ -119,7 +119,7 @@ handle_dns(TSHttpTxn txnp, TSCont contp)
char *user, *password;
int authval_length;
- if (!TSHttpTxnClientReqGet(txnp, &bufp, &hdr_loc)) {
+ if (TSHttpTxnClientReqGet(txnp, &bufp, &hdr_loc) != TS_SUCCESS) {
TSError("couldn't retrieve client request header\n");
goto done;
}
@@ -192,7 +192,7 @@ handle_response(TSHttpTxn txnp)
const char *insert = "Basic realm=\"proxy\"";
int len = strlen(insert);
- if (!TSHttpTxnClientRespGet(txnp, &bufp, &hdr_loc)) {
+ if (TSHttpTxnClientRespGet(txnp, &bufp, &hdr_loc) != TS_SUCCESS) {
TSError("couldn't retrieve client response header\n");
goto done;
}
Modified: trafficserver/traffic/trunk/example/blacklist-0/blacklist-0.c
URL:
http://svn.apache.org/viewvc/trafficserver/traffic/trunk/example/blacklist-0/blacklist-0.c?rev=1071491&r1=1071490&r2=1071491&view=diff
==============================================================================
--- trafficserver/traffic/trunk/example/blacklist-0/blacklist-0.c (original)
+++ trafficserver/traffic/trunk/example/blacklist-0/blacklist-0.c Thu Feb 17
03:12:32 2011
@@ -47,7 +47,7 @@ handle_dns(TSHttpTxn txnp, TSCont contp)
int i;
int host_length;
- if (!TSHttpTxnClientReqGet(txnp, &bufp, &hdr_loc)) {
+ if (TSHttpTxnClientReqGet(txnp, &bufp, &hdr_loc) != TS_SUCCESS) {
TSError("couldn't retrieve client request header\n");
goto done;
}
@@ -92,7 +92,7 @@ handle_response(TSHttpTxn txnp)
char *buf;
int url_length;
- if (!TSHttpTxnClientRespGet(txnp, &bufp, &hdr_loc)) {
+ if (TSHttpTxnClientRespGet(txnp, &bufp, &hdr_loc) != TS_SUCCESS) {
TSError("couldn't retrieve client response header\n");
goto done;
}
@@ -102,7 +102,7 @@ handle_response(TSHttpTxn txnp)
TSHttpHdrReasonLookup(TS_HTTP_STATUS_FORBIDDEN),
strlen(TSHttpHdrReasonLookup(TS_HTTP_STATUS_FORBIDDEN)));
- if (!TSHttpTxnClientReqGet(txnp, &bufp, &hdr_loc)) {
+ if (TSHttpTxnClientReqGet(txnp, &bufp, &hdr_loc) != TS_SUCCESS) {
TSError("couldn't retrieve client request header\n");
TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
goto done;
Modified: trafficserver/traffic/trunk/example/blacklist-1/blacklist-1.c
URL:
http://svn.apache.org/viewvc/trafficserver/traffic/trunk/example/blacklist-1/blacklist-1.c?rev=1071491&r1=1071490&r2=1071491&view=diff
==============================================================================
--- trafficserver/traffic/trunk/example/blacklist-1/blacklist-1.c (original)
+++ trafficserver/traffic/trunk/example/blacklist-1/blacklist-1.c Thu Feb 17
03:12:32 2011
@@ -77,7 +77,7 @@ handle_dns(TSHttpTxn txnp, TSCont contp)
int lock;
TSReturnCode ret_code;
- if (!TSHttpTxnClientReqGet(txnp, &bufp, &hdr_loc)) {
+ if (TSHttpTxnClientReqGet(txnp, &bufp, &hdr_loc) != TS_SUCCESS) {
TSError("couldn't retrieve client request header\n");
goto done;
}
@@ -149,7 +149,7 @@ handle_response(TSHttpTxn txnp, TSCont c
char *buf;
int url_length;
- if (!TSHttpTxnClientRespGet(txnp, &bufp, &hdr_loc)) {
+ if (TSHttpTxnClientRespGet(txnp, &bufp, &hdr_loc) != TS_SUCCESS) {
TSError("couldn't retrieve client response header\n");
goto done;
}
@@ -159,7 +159,7 @@ handle_response(TSHttpTxn txnp, TSCont c
TSHttpHdrReasonLookup(TS_HTTP_STATUS_FORBIDDEN),
strlen(TSHttpHdrReasonLookup(TS_HTTP_STATUS_FORBIDDEN)));
- if (!TSHttpTxnClientReqGet(txnp, &bufp, &hdr_loc)) {
+ if (TSHttpTxnClientReqGet(txnp, &bufp, &hdr_loc) != TS_SUCCESS) {
TSError("couldn't retrieve client request header\n");
TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
goto done;
Modified: trafficserver/traffic/trunk/example/bnull-transform/bnull-transform.c
URL:
http://svn.apache.org/viewvc/trafficserver/traffic/trunk/example/bnull-transform/bnull-transform.c?rev=1071491&r1=1071490&r2=1071491&view=diff
==============================================================================
--- trafficserver/traffic/trunk/example/bnull-transform/bnull-transform.c
(original)
+++ trafficserver/traffic/trunk/example/bnull-transform/bnull-transform.c Thu
Feb 17 03:12:32 2011
@@ -86,7 +86,7 @@ handle_buffering(TSCont contp, MyData *
ourself. This VIO contains the buffer that we are to read from
as well as the continuation we are to call when the buffer is
empty. */
- write_vio = TSVConnWriteVIOGet(contp);
+ TSVConnWriteVIOGet(contp, &write_vio); /* Should check for errors ... */
/* Create the output buffer and its associated reader */
if (!data->output_buffer) {
@@ -228,7 +228,7 @@ bnull_transform(TSCont contp, TSEvent ev
if (TSVConnClosedGet(contp)) {
my_data_destroy(TSContDataGet(contp));
- TSAssert(TSContDestroy(contp) == TS_SUCCESS);
+ TSContDestroy(contp);
} else {
switch (event) {
case TS_EVENT_ERROR:{
@@ -237,7 +237,7 @@ bnull_transform(TSCont contp, TSEvent ev
/* Get the write VIO for the write operation that was
performed on ourself. This VIO contains the continuation of
our parent transformation. */
- write_vio = TSVConnWriteVIOGet(contp);
+ TSVConnWriteVIOGet(contp, &write_vio); /* Should check for errors ...
*/
/* Call back the write VIO continuation to let it know that we
have completed the write operation. */
@@ -294,12 +294,7 @@ transform_add(TSHttpTxn txnp)
TSVConn connp;
connp = TSTransformCreate(bnull_transform, txnp);
- if (TSHttpTxnHookAdd(txnp, TS_HTTP_RESPONSE_TRANSFORM_HOOK, connp)
- == TS_ERROR) {
- /* this should not happen */
- TSError("[bnull-transform] Error adding transform to transaction\n");
- }
-
+ TSHttpTxnHookAdd(txnp, TS_HTTP_RESPONSE_TRANSFORM_HOOK, connp);
return;
}
@@ -371,11 +366,7 @@ TSPluginInit(int argc, const char *argv[
/* This is call we could use if we need to protect global data */
/* TSReleaseAssert ((mutex = TSMutexCreate()) != TS_NULL_MUTEX); */
- if (TSHttpHookAdd(TS_HTTP_READ_RESPONSE_HDR_HOOK,
TSContCreate(transform_plugin, mutex)) == TS_ERROR) {
- TSError("[bnull-transform] Unable to add READ_RESPONSE_HDR_HOOK\n");
- goto Lerror;
- }
-
+ TSHttpHookAdd(TS_HTTP_READ_RESPONSE_HDR_HOOK, TSContCreate(transform_plugin,
mutex));
return;
Lerror:
Modified: trafficserver/traffic/trunk/example/cache_scan/cache_scan.cc
URL:
http://svn.apache.org/viewvc/trafficserver/traffic/trunk/example/cache_scan/cache_scan.cc?rev=1071491&r1=1071490&r2=1071491&view=diff
==============================================================================
--- trafficserver/traffic/trunk/example/cache_scan/cache_scan.cc (original)
+++ trafficserver/traffic/trunk/example/cache_scan/cache_scan.cc Thu Feb 17
03:12:32 2011
@@ -222,13 +222,11 @@ cleanup(TSCont contp)
if (cstate) {
// cancel any pending cache scan actions, since we will be destroying the
// continuation
- if (cstate->pending_action) {
+ if (cstate->pending_action)
TSActionCancel(cstate->pending_action);
- }
- if (cstate->net_vc) {
+ if (cstate->net_vc)
TSVConnShutdown(cstate->net_vc, 1, 1);
- }
if (cstate->req_buffer) {
if (TSIOBufferDestroy(cstate->req_buffer) == TS_ERROR) {
@@ -416,15 +414,17 @@ setup_request(TSCont contp, TSHttpTxn tx
TSAssert(contp == global_contp);
- if (!TSHttpTxnClientReqGet(txnp, &bufp, &hdr_loc)) {
+ if (TSHttpTxnClientReqGet(txnp, &bufp, &hdr_loc) != TS_SUCCESS) {
TSError("couldn't retrieve client request header");
- return TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE);
+ TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE);
+ return TS_SUCCESS;
}
if (TSHttpHdrUrlGet(bufp, hdr_loc, &url_loc) != TS_SUCCESS) {
TSError("couldn't retrieve request url");
TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
- return TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE);
+ TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE);
+ return TS_SUCCESS;
}
path = TSUrlPathGet(bufp, url_loc, &path_len);
@@ -432,7 +432,8 @@ setup_request(TSCont contp, TSHttpTxn tx
TSError("couldn't retrieve request path");
TSHandleMLocRelease(bufp, hdr_loc, url_loc);
TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
- return TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE);
+ TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE);
+ return TS_SUCCESS;
}
query = TSUrlHttpQueryGet(bufp, url_loc, &query_len);
@@ -487,11 +488,7 @@ setup_request(TSCont contp, TSHttpTxn tx
}
}
- if (TSContDataSet(scan_contp, cstate) != TS_SUCCESS) {
- TSError("ContDataSet failed");
- TSfree(cstate);
- goto Ldone;
- }
+ TSContDataSet(scan_contp, cstate);
TSDebug("cache_iter", "setup cache intercept");
} else {
TSDebug("cache_iter", "not a cache iter request");
@@ -500,8 +497,8 @@ setup_request(TSCont contp, TSHttpTxn tx
Ldone:
TSHandleMLocRelease(bufp, hdr_loc, url_loc);
TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
-
- return TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE);
+ TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE);
+ return TS_SUCCESS;
}
//----------------------------------------------------------------------------
@@ -515,7 +512,8 @@ cache_print_plugin(TSCont contp, TSEvent
default:
break;
}
- return TSHttpTxnReenable((TSHttpTxn) edata, TS_EVENT_HTTP_CONTINUE);
+ TSHttpTxnReenable((TSHttpTxn) edata, TS_EVENT_HTTP_CONTINUE);
+ return TS_SUCCESS;
}
//----------------------------------------------------------------------------
Modified: trafficserver/traffic/trunk/example/gzip-transform/gunzip.c
URL:
http://svn.apache.org/viewvc/trafficserver/traffic/trunk/example/gzip-transform/gunzip.c?rev=1071491&r1=1071490&r2=1071491&view=diff
==============================================================================
--- trafficserver/traffic/trunk/example/gzip-transform/gunzip.c (original)
+++ trafficserver/traffic/trunk/example/gzip-transform/gunzip.c Thu Feb 17
03:12:32 2011
@@ -295,7 +295,7 @@ gzip_transform_do(TSCont contp)
ourself. This vio contains the buffer that we are to read from
as well as the continuation we are to call when the buffer is
empty. */
- write_vio = TSVConnWriteVIOGet(contp);
+ TSVConnWriteVIOGet(contp, &write_vio); /* Should check for errors... */
length = data->output_length;
@@ -392,7 +392,7 @@ gzip_transform(TSCont contp, TSEvent eve
/* Get the write vio for the write operation that was
performed on ourself. This vio contains the continuation of
our parent transformation. */
- write_vio = TSVConnWriteVIOGet(contp);
+ TSVConnWriteVIOGet(contp, &write_vio); /* Should check for errors ...
*/
/* Call back the write vio continuation to let it know that we
have completed the write operation. */
Modified: trafficserver/traffic/trunk/example/gzip-transform/gzip.c
URL:
http://svn.apache.org/viewvc/trafficserver/traffic/trunk/example/gzip-transform/gzip.c?rev=1071491&r1=1071490&r2=1071491&view=diff
==============================================================================
--- trafficserver/traffic/trunk/example/gzip-transform/gzip.c (original)
+++ trafficserver/traffic/trunk/example/gzip-transform/gzip.c Thu Feb 17
03:12:32 2011
@@ -344,7 +344,7 @@ gzip_transform_do(TSCont contp)
ourself. This vio contains the buffer that we are to read from
as well as the continuation we are to call when the buffer is
empty. */
- write_vio = TSVConnWriteVIOGet(contp);
+ TSVConnWriteVIOGet(contp, &write_vio); /* Should check for errors ... */
length = data->output_length;
@@ -444,7 +444,7 @@ gzip_transform(TSCont contp, TSEvent eve
/* Get the write vio for the write operation that was
performed on ourself. This vio contains the continuation of
our parent transformation. */
- write_vio = TSVConnWriteVIOGet(contp);
+ TSVConnWriteVIOGet(contp, &write_vio); /* Should check for errors ...
*/
/* Call back the write vio continuation to let it know that we
have completed the write operation. */
Modified: trafficserver/traffic/trunk/example/null-transform/null-transform.c
URL:
http://svn.apache.org/viewvc/trafficserver/traffic/trunk/example/null-transform/null-transform.c?rev=1071491&r1=1071490&r2=1071491&view=diff
==============================================================================
--- trafficserver/traffic/trunk/example/null-transform/null-transform.c
(original)
+++ trafficserver/traffic/trunk/example/null-transform/null-transform.c Thu Feb
17 03:12:32 2011
@@ -93,8 +93,7 @@ handle_transform(TSCont contp)
* empty. This is the input VIO (the write VIO for the upstream
* vconnection).
*/
- input_vio = TSVConnWriteVIOGet(contp);
- if (input_vio == TS_ERROR_PTR) {
+ if (TSVConnWriteVIOGet(contp, &input_vio) != TS_SUCCESS) {
TSError("[null-transform] Unable to fetching input VIO\n");
goto Lerror;
}
@@ -113,10 +112,7 @@ handle_transform(TSCont contp)
//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));
- if (TSContDataSet(contp, data) == TS_ERROR) {
- TSError("[null-transform] unable to set continuation " "data!\n");
- goto Lerror;
- }
+ TSContDataSet(contp, data);
}
/* We also check to see if the input VIO's buffer is non-NULL. A
@@ -247,7 +243,7 @@ null_transform(TSCont contp, TSEvent eve
if (TSVConnClosedGet(contp)) {
TSDebug("null-transform", "\tVConn is closed");
my_data_destroy(TSContDataGet(contp));
- TSAssert(TSContDestroy(contp) == TS_SUCCESS);
+ TSContDestroy(contp);
return 0;
} else {
switch (event) {
@@ -260,7 +256,7 @@ null_transform(TSCont contp, TSEvent eve
* performed on ourself. This VIO contains the continuation of
* our parent transformation. This is the input VIO.
*/
- input_vio = TSVConnWriteVIOGet(contp);
+ TSVConnWriteVIOGet(contp, &input_vio); /* Should check for errors ...
*/
/* Call back the write VIO continuation to let it know that we
* have completed the write operation.
@@ -326,9 +322,7 @@ transform_add(TSHttpTxn txnp)
TSDebug("null-transform", "Entering transform_add()");
connp = TSTransformCreate(null_transform, txnp);
- if (TSHttpTxnHookAdd(txnp, TS_HTTP_RESPONSE_TRANSFORM_HOOK, connp) ==
TS_ERROR) {
- TSError("[null-plugin] Unable to attach plugin to transaction\n");
- }
+ TSHttpTxnHookAdd(txnp, TS_HTTP_RESPONSE_TRANSFORM_HOOK, connp);
}
static int
@@ -344,10 +338,7 @@ transform_plugin(TSCont contp, TSEvent e
transform_add(txnp);
}
- if (TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE) == TS_ERROR) {
- TSError("[null-plugin] Alert! unable to continue " "the HTTP
transaction\n");
- return -1;
- }
+ TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE);
return 0;
default:
break;
@@ -401,11 +392,7 @@ TSPluginInit(int argc, const char *argv[
goto Lerror;
}
- if (TSHttpHookAdd(TS_HTTP_READ_RESPONSE_HDR_HOOK,
TSContCreate(transform_plugin, NULL)) == TS_ERROR) {
- TSError("[null-transform] Unable to set READ_RESPONSE_HDR_HOOK\n");
- goto Lerror;
- }
-
+ TSHttpHookAdd(TS_HTTP_READ_RESPONSE_HDR_HOOK, TSContCreate(transform_plugin,
NULL));
return;
Lerror:
Modified: trafficserver/traffic/trunk/example/output-header/output-header.c
URL:
http://svn.apache.org/viewvc/trafficserver/traffic/trunk/example/output-header/output-header.c?rev=1071491&r1=1071490&r2=1071491&view=diff
==============================================================================
--- trafficserver/traffic/trunk/example/output-header/output-header.c (original)
+++ trafficserver/traffic/trunk/example/output-header/output-header.c Thu Feb
17 03:12:32 2011
@@ -64,7 +64,7 @@ handle_dns(TSHttpTxn txnp, TSCont contp)
char *output_string;
int64_t output_len;
- if (!TSHttpTxnClientReqGet(txnp, &bufp, &hdr_loc)) {
+ if (TSHttpTxnClientReqGet(txnp, &bufp, &hdr_loc) != TS_SUCCESS) {
TSDebug(DEBUG_TAG, "couldn't retrieve client request header");
TSError("couldn't retrieve client request header\n");
goto done;
Modified: trafficserver/traffic/trunk/example/redirect-1/redirect-1.c
URL:
http://svn.apache.org/viewvc/trafficserver/traffic/trunk/example/redirect-1/redirect-1.c?rev=1071491&r1=1071490&r2=1071491&view=diff
==============================================================================
--- trafficserver/traffic/trunk/example/redirect-1/redirect-1.c (original)
+++ trafficserver/traffic/trunk/example/redirect-1/redirect-1.c Thu Feb 17
03:12:32 2011
@@ -148,7 +148,7 @@ handle_client_lookup(TSHttpTxn txnp, TSC
clientstring = inet_ntoa(tempstruct);
TSDebug("redirect", "clientip is %s and block_ip is %s", clientstring,
block_ip);
- if (!TSHttpTxnClientReqGet(txnp, &bufp, &hdr_loc)) {
+ if (TSHttpTxnClientReqGet(txnp, &bufp, &hdr_loc) != TS_SUCCESS) {
TSError("couldn't retrieve client request header\n");
goto done;
}
@@ -216,7 +216,7 @@ handle_response(TSHttpTxn txnp)
char *errormsg_body = "All requests from this IP address are redirected.\n";
char *tmp_body;
- if (!TSHttpTxnClientRespGet(txnp, &bufp, &hdr_loc)) {
+ if (TSHttpTxnClientRespGet(txnp, &bufp, &hdr_loc) != TS_SUCCESS) {
TSError("couldn't retrieve client response header\n");
goto done;
}
Modified: trafficserver/traffic/trunk/example/remap/remap.cc
URL:
http://svn.apache.org/viewvc/trafficserver/traffic/trunk/example/remap/remap.cc?rev=1071491&r1=1071490&r2=1071491&view=diff
==============================================================================
--- trafficserver/traffic/trunk/example/remap/remap.cc (original)
+++ trafficserver/traffic/trunk/example/remap/remap.cc Thu Feb 17 03:12:32 2011
@@ -327,7 +327,7 @@ tsremap_remap(ihandle ih, rhandle rh, TS
// InkAPI usage case
- if (TSHttpTxnClientReqGet((TSHttpTxn) rh, &cbuf, &chdr)) {
+ if (TSHttpTxnClientReqGet((TSHttpTxn) rh, &cbuf, &chdr) == TS_SUCCESS) {
const char *value;
if ((cfield = TSMimeHdrFieldFind(cbuf, chdr, TS_MIME_FIELD_DATE, -1)) !=
TS_NULL_MLOC) {
fprintf(stderr, "We have \"Date\" header in request\n");
@@ -384,8 +384,11 @@ tsremap_remap(ihandle ih, rhandle rh, TS
void
tsremap_os_response(ihandle ih, rhandle rh, int os_response_type)
{
- int request_id;
- TSHttpTxnArgGet((TSHttpTxn) rh, arg_index, (void **) &request_id); // read
counter (we store it in tsremap_remap function call)
+ int request_id = -1;
+ void *data = TSHttpTxnArgGet((TSHttpTxn) rh, arg_index); // read counter
(we store it in tsremap_remap function call)
+
+ if (data)
+ request_id = *((int*)data);
fprintf(stderr, "[tsremap_os_response] Read processing counter %d from
request processing block\n", request_id);
fprintf(stderr, "[tsremap_os_response] OS response status: %d\n",
os_response_type);
}
Modified:
trafficserver/traffic/trunk/example/response-header-1/response-header-1.c
URL:
http://svn.apache.org/viewvc/trafficserver/traffic/trunk/example/response-header-1/response-header-1.c?rev=1071491&r1=1071490&r2=1071491&view=diff
==============================================================================
--- trafficserver/traffic/trunk/example/response-header-1/response-header-1.c
(original)
+++ trafficserver/traffic/trunk/example/response-header-1/response-header-1.c
Thu Feb 17 03:12:32 2011
@@ -85,7 +85,7 @@ modify_header(TSHttpTxn txnp, TSCont con
if (!init_buffer_status)
return; /* caller reenables */
- if (!TSHttpTxnServerRespGet(txnp, &resp_bufp, &resp_loc)) {
+ if (TSHttpTxnServerRespGet(txnp, &resp_bufp, &resp_loc) != TS_SUCCESS) {
TSError("couldn't retrieve server response header\n");
return; /* caller reenables */
}
@@ -137,7 +137,7 @@ modify_header(TSHttpTxn txnp, TSCont con
/* N.B.: Protect writes to data (hash on URL + mutex: (ies)) */
/* Get the cached HTTP header */
- if (!TSHttpTxnCachedRespGet(txnp, &cached_bufp, &cached_loc)) {
+ if (TSHttpTxnCachedRespGet(txnp, &cached_bufp, &cached_loc) != TS_SUCCESS)
{
TSError("STATUS 304, TSHttpTxnCachedRespGet():");
TSError("couldn't retrieve cached response header\n");
TSHandleMLocRelease(resp_bufp, TS_NULL_MLOC, resp_loc);
Modified:
trafficserver/traffic/trunk/example/server-transform/server-transform.c
URL:
http://svn.apache.org/viewvc/trafficserver/traffic/trunk/example/server-transform/server-transform.c?rev=1071491&r1=1071490&r2=1071491&view=diff
==============================================================================
--- trafficserver/traffic/trunk/example/server-transform/server-transform.c
(original)
+++ trafficserver/traffic/trunk/example/server-transform/server-transform.c Thu
Feb 17 03:12:32 2011
@@ -138,10 +138,7 @@ transform_create(TSHttpTxn txnp)
data->server_vio = NULL;
data->content_length = 0;
- if (TSContDataSet(contp, data) != TS_SUCCESS) {
- TSError("Error in setting continuation's data. TSContDataSet doesn't
return TS_SUCCESS");
- }
-
+ TSContDataSet(contp, data);
return contp;
}
@@ -164,11 +161,8 @@ transform_destroy(TSCont contp)
}
}
- if (data->pending_action) {
- if (TSActionCancel(data->pending_action) != TS_SUCCESS) {
- TSError("Unable to cancel the pending action");
- }
- }
+ if (data->pending_action)
+ TSActionCancel(data->pending_action);
if (data->server_vc) {
if (TSVConnAbort(data->server_vc, 1) != TS_SUCCESS) {
@@ -181,9 +175,7 @@ transform_destroy(TSCont contp)
TSError("Unable to get Continuation's Data. TSContDataGet returns
TS_ERROR_PTR or NULL");
}
- if (TSContDestroy(contp) != TS_SUCCESS) {
- TSError("Error in Destroying the continuation");
- }
+ TSContDestroy(contp);
}
static int
@@ -414,10 +406,8 @@ transform_buffer_event(TSCont contp, Tra
ourself. This VIO contains the buffer that we are to read from
as well as the continuation we are to call when the buffer is
empty. */
- write_vio = TSVConnWriteVIOGet(contp);
- if (write_vio == TS_ERROR_PTR) {
+ if (TSVConnWriteVIOGet(contp, &write_vio) != TS_SUCCESS)
TSError("Corrupted write VIO received.");
- }
/* We also check to see if the write VIO's buffer is non-NULL. A
NULL buffer indicates that the write operation has been
@@ -739,7 +729,7 @@ server_response_ok(TSHttpTxn txnp)
TSMLoc hdr_loc;
TSHttpStatus resp_status;
- if (TSHttpTxnServerRespGet(txnp, &bufp, &hdr_loc) == 0) {
+ if (TSHttpTxnServerRespGet(txnp, &bufp, &hdr_loc) != TS_SUCCESS) {
TSError("Unable to get handle to Server Response");
return 0;
}
@@ -773,36 +763,22 @@ transform_plugin(TSCont contp, TSEvent e
switch (event) {
case TS_EVENT_HTTP_READ_REQUEST_HDR:
if (request_ok(txnp)) {
- if (TSHttpTxnHookAdd(txnp, TS_HTTP_READ_CACHE_HDR_HOOK, contp) !=
TS_SUCCESS) {
- TSError("Unable to add continuation to hook "
"TS_HTTP_READ_CACHE_HDR_HOOK for this transaction");
- }
- if (TSHttpTxnHookAdd(txnp, TS_HTTP_READ_RESPONSE_HDR_HOOK, contp) !=
TS_SUCCESS) {
- TSError("Unable to add continuation to hook "
"TS_HTTP_READ_RESPONSE_HDR_HOOK for this transaction");
- }
- }
- if (TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE) != TS_SUCCESS) {
- TSError("Error in re-enabling transaction at
TS_HTTP_READ_REQUEST_HDR_HOOK");
+ TSHttpTxnHookAdd(txnp, TS_HTTP_READ_CACHE_HDR_HOOK, contp);
+ TSHttpTxnHookAdd(txnp, TS_HTTP_READ_RESPONSE_HDR_HOOK, contp);
}
+ TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE);
break;
case TS_EVENT_HTTP_READ_CACHE_HDR:
if (cache_response_ok(txnp)) {
- if (TSHttpTxnHookAdd(txnp, TS_HTTP_RESPONSE_TRANSFORM_HOOK,
transform_create(txnp)) != TS_SUCCESS) {
- TSError("Unable to add continuation to tranformation hook " "for this
transaction");
- }
- }
- if (TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE) != TS_SUCCESS) {
- TSError("Error in re-enabling transaction at
TS_HTTP_READ_CACHE_HDR_HOOK");
+ TSHttpTxnHookAdd(txnp, TS_HTTP_RESPONSE_TRANSFORM_HOOK,
transform_create(txnp));
}
+ TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE);
break;
case TS_EVENT_HTTP_READ_RESPONSE_HDR:
if (server_response_ok(txnp)) {
- if (TSHttpTxnHookAdd(txnp, TS_HTTP_RESPONSE_TRANSFORM_HOOK,
transform_create(txnp)) != TS_SUCCESS) {
- TSError("Unable to add continuation to tranformation hook " "for this
transaction");
- }
- }
- if (TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE) != TS_SUCCESS) {
- TSError("Error in re-enabling transaction at
TS_HTTP_READ_RESPONSE_HDR_HOOK");
+ TSHttpTxnHookAdd(txnp, TS_HTTP_RESPONSE_TRANSFORM_HOOK,
transform_create(txnp));
}
+ TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE);
break;
default:
break;
@@ -865,10 +841,5 @@ TSPluginInit(int argc, const char *argv[
return;
}
- if (TSHttpHookAdd(TS_HTTP_READ_REQUEST_HDR_HOOK, cont) == TS_ERROR) {
- TSError("Unable to add the continuation to the hook. Aborting...");
- if (TSContDestroy(cont) == TS_ERROR) {
- TSError("Error in Destroying the continuation.");
- }
- }
+ TSHttpHookAdd(TS_HTTP_READ_REQUEST_HDR_HOOK, cont);
}
Modified: trafficserver/traffic/trunk/example/thread-pool/psi.c
URL:
http://svn.apache.org/viewvc/trafficserver/traffic/trunk/example/thread-pool/psi.c?rev=1071491&r1=1071490&r2=1071491&view=diff
==============================================================================
--- trafficserver/traffic/trunk/example/thread-pool/psi.c (original)
+++ trafficserver/traffic/trunk/example/thread-pool/psi.c Thu Feb 17 03:12:32
2011
@@ -628,8 +628,7 @@ wake_up_streams(TSCont contp)
data = TSContDataGet(contp);
TSAssert(data->magic == MAGIC_ALIVE);
- input_vio = TSVConnWriteVIOGet(contp);
- if (input_vio == TS_ERROR_PTR) {
+ if (TSVConnWriteVIOGet(contp, &input_vio) != TS_SUCCESS) {
TSError("[wake_up_streams] Error while getting input_vio");
return 0;
}
@@ -699,8 +698,7 @@ handle_transform(TSCont contp)
}
/* Get upstream vio */
- input_vio = TSVConnWriteVIOGet(contp);
- if (input_vio == TS_ERROR_PTR) {
+ if (TSVConnWriteVIOGet(contp, &input_vio) != TS_SUCCESS) {
TSError("[handle_transform] Error while getting input vio");
return 1;
}
@@ -834,8 +832,7 @@ dump_psi(TSCont contp)
TSVIO input_vio;
TSReturnCode retval;
- input_vio = TSVConnWriteVIOGet(contp);
- if (input_vio == TS_ERROR_PTR) {
+ if (TSVConnWriteVIOGet(contp, &input_vio) != TS_SUCCESS) {
TSError("[dump_psi] Error while getting input vio");
return 1;
}
@@ -942,8 +939,7 @@ transform_handler(TSCont contp, TSEvent
} else {
switch (event) {
case TS_EVENT_ERROR:
- input_vio = TSVConnWriteVIOGet(contp);
- if (input_vio == TS_ERROR_PTR) {
+ if (TSVConnWriteVIOGet(contp, &input_vio) != TS_SUCCESS) {
TSError("[transform_handler] Error while getting upstream vio");
} else {
TSContCall(TSVIOContGet(input_vio), TS_EVENT_ERROR, input_vio);
@@ -1085,7 +1081,6 @@ transform_add(TSHttpTxn txnp)
{
TSCont contp;
ContData *data;
- TSReturnCode retval;
contp = TSTransformCreate(transform_handler, txnp);
if (contp == TS_ERROR_PTR) {
@@ -1096,11 +1091,7 @@ transform_add(TSHttpTxn txnp)
data = cont_data_alloc();
TSContDataSet(contp, data);
- retval = TSHttpTxnHookAdd(txnp, TS_HTTP_RESPONSE_TRANSFORM_HOOK, contp);
- if (retval == TS_ERROR) {
- TSError("[transform_add] Error registering to transform hook");
- return 0;
- }
+ TSHttpTxnHookAdd(txnp, TS_HTTP_RESPONSE_TRANSFORM_HOOK, contp);
return 1;
}
@@ -1225,11 +1216,6 @@ TSPluginInit(int argc, const char *argv[
}
}
- retval = TSHttpHookAdd(TS_HTTP_READ_RESPONSE_HDR_HOOK,
TSContCreate(read_response_handler, TSMutexCreate()));
- if (retval == TS_ERROR) {
- TSError("[TSPluginInit] Error while registering to read response hook");
- return;
- }
-
+ TSHttpHookAdd(TS_HTTP_READ_RESPONSE_HDR_HOOK,
TSContCreate(read_response_handler, TSMutexCreate()));
TSDebug(DBG_TAG, "Plugin started");
}
Modified: trafficserver/traffic/trunk/iocore/cache/Cache.cc
URL:
http://svn.apache.org/viewvc/trafficserver/traffic/trunk/iocore/cache/Cache.cc?rev=1071491&r1=1071490&r2=1071491&view=diff
==============================================================================
--- trafficserver/traffic/trunk/iocore/cache/Cache.cc (original)
+++ trafficserver/traffic/trunk/iocore/cache/Cache.cc Thu Feb 17 03:12:32 2011
@@ -340,7 +340,8 @@ CacheVC::reenable_re(VIO *avio)
}
}
-bool CacheVC::get_data(int i, void *data)
+bool
+CacheVC::get_data(int i, void *data)
{
switch (i) {
case CACHE_DATA_SIZE:
Modified: trafficserver/traffic/trunk/proxy/FetchSM.cc
URL:
http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/FetchSM.cc?rev=1071491&r1=1071490&r2=1071491&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/FetchSM.cc (original)
+++ trafficserver/traffic/trunk/proxy/FetchSM.cc Thu Feb 17 03:12:32 2011
@@ -41,7 +41,9 @@ FetchSM::cleanUp()
http_parser_clear(&http_parser);
client_response_hdr.destroy();
xfree(client_response);
+
PluginVC *vc = (PluginVC *) http_vc;
+
vc->do_io_close();
FetchSMAllocator.free(this);
}
@@ -50,24 +52,30 @@ void
FetchSM::httpConnect()
{
Debug(DEBUG_TAG, "[%s] calling httpconnect write", __FUNCTION__);
- TSHttpConnect(_ip, _port, &(http_vc));
+ http_vc = TSHttpConnect(_ip, _port);
+
PluginVC *vc = (PluginVC *) http_vc;
+
read_vio = vc->do_io_read(this, INT64_MAX, resp_buffer);
write_vio = vc->do_io_write(this, getReqLen(), req_reader);
}
char* FetchSM::resp_get(int *length) {
-*length = client_bytes;
-return client_response;
+ *length = client_bytes;
+ return client_response;
}
int FetchSM::InvokePlugin(int event, void *data)
{
Continuation *cont = (Continuation*) contp;
EThread *mythread = this_ethread();
+
MUTEX_TAKE_LOCK(cont->mutex,mythread);
+
int ret = cont->handleEvent(event,data);
+
MUTEX_UNTAKE_LOCK(cont->mutex,mythread);
+
return ret;
}
void