You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2010/11/16 21:22:08 UTC
svn commit: r1035782 [27/29] - in /trafficserver/traffic/trunk:
example/add-header/ example/append-transform/ example/basic-auth/
example/blacklist-0/ example/blacklist-1/ example/bnull-transform/
example/cache_plugin/ example/cache_scan/ example/file-...
Modified: trafficserver/traffic/trunk/test/plugin/plugin_as_origin/net_bridge.c
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/test/plugin/plugin_as_origin/net_bridge.c?rev=1035782&r1=1035781&r2=1035782&view=diff
==============================================================================
--- trafficserver/traffic/trunk/test/plugin/plugin_as_origin/net_bridge.c (original)
+++ trafficserver/traffic/trunk/test/plugin/plugin_as_origin/net_bridge.c Tue Nov 16 20:22:02 2010
@@ -45,14 +45,14 @@
Log macros for error code return verification
**************************************************/
#define PLUGIN_NAME "net_bridge"
-#define VALID_POINTER(X) ((X != NULL) && (X != INK_ERROR_PTR))
+#define VALID_POINTER(X) ((X != NULL) && (X != TS_ERROR_PTR))
#define LOG_SET_FUNCTION_NAME(NAME) const char * FUNCTION_NAME = NAME
#define LOG_ERROR(API_NAME) { \
- INKDebug(PLUGIN_NAME, "%s: %s %s %s File %s, line number %d", PLUGIN_NAME, API_NAME, "APIFAIL", \
+ TSDebug(PLUGIN_NAME, "%s: %s %s %s File %s, line number %d", PLUGIN_NAME, API_NAME, "APIFAIL", \
FUNCTION_NAME, __FILE__, __LINE__); \
}
#define LOG_ERROR_NEG(API_NAME) { \
- INKDebug(PLUGIN_NAME, "%s: %s %s %s File %s, line number %d", PLUGIN_NAME, API_NAME, "NEGAPIFAIL", \
+ TSDebug(PLUGIN_NAME, "%s: %s %s %s File %s, line number %d", PLUGIN_NAME, API_NAME, "NEGAPIFAIL", \
FUNCTION_NAME, __FILE__, __LINE__); \
}
#define LOG_ERROR_AND_RETURN(API_NAME) { \
@@ -65,10 +65,10 @@
}
#define LOG_ERROR_AND_REENABLE(API_NAME) { \
LOG_ERROR(API_NAME); \
- INKHttpTxnReenable(txnp, INK_EVENT_HTTP_CONTINUE); \
+ TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE); \
}
-static INKStat pvc_count;
+static TSStat pvc_count;
#ifdef USE_PVC_HISTORY
struct pvc_hist_t
@@ -92,26 +92,26 @@ typedef struct pvc_hist_t pvc_hist;
struct pvc_state_t
{
- INKVConn p_vc;
- INKVIO p_read_vio;
- INKVIO p_write_vio;
-
- INKVConn net_vc;
- INKVIO n_read_vio;
- INKVIO n_write_vio;
+ TSVConn p_vc;
+ TSVIO p_read_vio;
+ TSVIO p_write_vio;
+
+ TSVConn net_vc;
+ TSVIO n_read_vio;
+ TSVIO n_write_vio;
- INKIOBuffer req_buffer;
- INKIOBufferReader req_reader;
+ TSIOBuffer req_buffer;
+ TSIOBufferReader req_reader;
- INKIOBuffer resp_buffer;
- INKIOBufferReader resp_reader;
+ TSIOBuffer resp_buffer;
+ TSIOBufferReader resp_reader;
int req_finished;
int resp_finished;
- INKAction connect_timeout_event;
+ TSAction connect_timeout_event;
- INKHttpTxn http_txnp;
+ TSHttpTxn http_txnp;
unsigned int dest_ip;
int dest_port;
@@ -133,52 +133,52 @@ typedef struct pvc_state_t pvc_state;
#ifdef USE_PVC_DEBUG_LIST
static pvc_state *debug_list_head = NULL;
static pvc_state *debug_list_tail = NULL;
-static INKMutex debug_list_mutex = NULL;
+static TSMutex debug_list_mutex = NULL;
static void
pvc_add_to_debug_list(pvc_state * to_add)
{
- INKMutexLock(debug_list_mutex);
+ TSMutexLock(debug_list_mutex);
- INKAssert(to_add->flink == NULL);
- INKAssert(to_add->blink == NULL);
+ TSAssert(to_add->flink == NULL);
+ TSAssert(to_add->blink == NULL);
if (debug_list_head == NULL) {
- INKAssert(debug_list_tail == NULL);
+ TSAssert(debug_list_tail == NULL);
debug_list_head = debug_list_tail = to_add;
} else {
- INKAssert(debug_list_tail->flink == NULL);
+ TSAssert(debug_list_tail->flink == NULL);
to_add->blink = debug_list_tail;
debug_list_tail->flink = to_add;
debug_list_tail = to_add;
}
- INKMutexUnlock(debug_list_mutex);
+ TSMutexUnlock(debug_list_mutex);
}
static void
pvc_remove_from_debug_list(pvc_state * to_remove)
{
- INKMutexLock(debug_list_mutex);
+ TSMutexLock(debug_list_mutex);
if (debug_list_head == to_remove) {
- INKAssert(to_remove->blink == NULL);
+ TSAssert(to_remove->blink == NULL);
debug_list_head = to_remove->flink;
if (debug_list_head) {
- INKAssert(debug_list_head->blink == to_remove);
- INKAssert(debug_list_tail != to_remove);
+ TSAssert(debug_list_head->blink == to_remove);
+ TSAssert(debug_list_tail != to_remove);
debug_list_head->blink = NULL;
} else {
- INKAssert(debug_list_tail == to_remove);
+ TSAssert(debug_list_tail == to_remove);
debug_list_tail = NULL;
}
} else if (debug_list_tail == to_remove) {
debug_list_tail = to_remove->blink;
- INKAssert(debug_list_tail->flink == to_remove);
+ TSAssert(debug_list_tail->flink == to_remove);
debug_list_tail->flink = NULL;
} else {
- INKAssert(to_remove->flink != NULL);
- INKAssert(to_remove->blink != NULL);
+ TSAssert(to_remove->flink != NULL);
+ TSAssert(to_remove->blink != NULL);
to_remove->blink->flink = to_remove->flink;
to_remove->flink->blink = to_remove->blink;
}
@@ -186,33 +186,33 @@ pvc_remove_from_debug_list(pvc_state * t
to_remove->flink = NULL;
to_remove->blink = NULL;
- INKMutexUnlock(debug_list_mutex);
+ TSMutexUnlock(debug_list_mutex);
}
#endif /* USE_PVC_DEBUG_LIST */
static void
-pvc_cleanup(INKCont contp, pvc_state * my_state)
+pvc_cleanup(TSCont contp, pvc_state * my_state)
{
LOG_SET_FUNCTION_NAME("pvc_cleanup");
PVC_ADD_HISTORY_ENTRY(0xdeadbeef);
if (my_state->req_buffer) {
- if (INKIOBufferDestroy(my_state->req_buffer) == INK_ERROR) {
- LOG_ERROR("INKIOBufferDestroy");
+ if (TSIOBufferDestroy(my_state->req_buffer) == TS_ERROR) {
+ LOG_ERROR("TSIOBufferDestroy");
}
my_state->req_buffer = NULL;
}
if (my_state->resp_buffer) {
- if (INKIOBufferDestroy(my_state->resp_buffer) == INK_ERROR) {
- LOG_ERROR("INKIOBufferDestroy");
+ if (TSIOBufferDestroy(my_state->resp_buffer) == TS_ERROR) {
+ LOG_ERROR("TSIOBufferDestroy");
}
my_state->resp_buffer = NULL;
}
if (my_state->connect_timeout_event) {
- INKActionCancel(my_state->connect_timeout_event);
+ TSActionCancel(my_state->connect_timeout_event);
my_state->connect_timeout_event = NULL;
}
#ifdef USE_PVC_DEBUG_LIST
@@ -220,350 +220,350 @@ pvc_cleanup(INKCont contp, pvc_state * m
pvc_remove_from_debug_list(my_state);
#endif
- INKfree(my_state);
- if (INKContDestroy(contp) == INK_ERROR) {
- LOG_ERROR("INKContDestroy");
+ TSfree(my_state);
+ if (TSContDestroy(contp) == TS_ERROR) {
+ LOG_ERROR("TSContDestroy");
}
/* Decrement pvc_count */
- INKStatDecrement(pvc_count);
+ TSStatDecrement(pvc_count);
}
static void
-pvc_check_done(INKCont contp, pvc_state * my_state)
+pvc_check_done(TSCont contp, pvc_state * my_state)
{
LOG_SET_FUNCTION_NAME("pvc_check_done");
if (my_state->req_finished && my_state->resp_finished) {
- if (INKVConnClose(my_state->p_vc) == INK_ERROR) {
- LOG_ERROR("INKVConnClose");
+ if (TSVConnClose(my_state->p_vc) == TS_ERROR) {
+ LOG_ERROR("TSVConnClose");
}
- if (INKVConnClose(my_state->net_vc) == INK_ERROR) {
- LOG_ERROR("INKVConnClose");
+ if (TSVConnClose(my_state->net_vc) == TS_ERROR) {
+ LOG_ERROR("TSVConnClose");
}
pvc_cleanup(contp, my_state);
}
}
static void
-pvc_process_accept(INKCont contp, int event, void *edata, pvc_state * my_state)
+pvc_process_accept(TSCont contp, int event, void *edata, pvc_state * my_state)
{
LOG_SET_FUNCTION_NAME("pvc_process_accept");
PVC_ADD_HISTORY_ENTRY(event);
- INKDebug(DEBUG_TAG, "plugin called: pvc_process_accept with event %d", event);
+ TSDebug(DEBUG_TAG, "plugin called: pvc_process_accept with event %d", event);
- if (event == INK_EVENT_NET_ACCEPT) {
- my_state->p_vc = (INKVConn) edata;
+ if (event == TS_EVENT_NET_ACCEPT) {
+ my_state->p_vc = (TSVConn) edata;
- my_state->dest_ip = INKHttpTxnNextHopIPGet(my_state->http_txnp);
+ my_state->dest_ip = TSHttpTxnNextHopIPGet(my_state->http_txnp);
if (!my_state->dest_ip) {
- LOG_ERROR("INKHttpTxnNextHopIPGet");
+ LOG_ERROR("TSHttpTxnNextHopIPGet");
return;
}
- my_state->dest_port = INKHttpTxnNextHopPortGet(my_state->http_txnp);
+ my_state->dest_port = TSHttpTxnNextHopPortGet(my_state->http_txnp);
if (!my_state->dest_port) {
- LOG_ERROR("INKHttpTxnNextHopPortGet");
+ LOG_ERROR("TSHttpTxnNextHopPortGet");
return;
}
- my_state->req_buffer = INKIOBufferCreate();
- my_state->req_reader = INKIOBufferReaderAlloc(my_state->req_buffer);
- my_state->resp_buffer = INKIOBufferCreate();
- my_state->resp_reader = INKIOBufferReaderAlloc(my_state->resp_buffer);
- if ((my_state->req_buffer == INK_ERROR_PTR) || (my_state->req_reader == INK_ERROR_PTR)
- || (my_state->resp_buffer == INK_ERROR_PTR) || (my_state->resp_reader == INK_ERROR_PTR)) {
- LOG_ERROR("INKIOBufferCreate || INKIOBufferReaderAlloc");
- if (INKVConnClose(my_state->net_vc) == INK_ERROR) {
- LOG_ERROR("INKVConnClose");
+ my_state->req_buffer = TSIOBufferCreate();
+ my_state->req_reader = TSIOBufferReaderAlloc(my_state->req_buffer);
+ my_state->resp_buffer = TSIOBufferCreate();
+ my_state->resp_reader = TSIOBufferReaderAlloc(my_state->resp_buffer);
+ if ((my_state->req_buffer == TS_ERROR_PTR) || (my_state->req_reader == TS_ERROR_PTR)
+ || (my_state->resp_buffer == TS_ERROR_PTR) || (my_state->resp_reader == TS_ERROR_PTR)) {
+ LOG_ERROR("TSIOBufferCreate || TSIOBufferReaderAlloc");
+ if (TSVConnClose(my_state->net_vc) == TS_ERROR) {
+ LOG_ERROR("TSVConnClose");
}
pvc_cleanup(contp, my_state);
} else {
- INKNetConnect(contp, my_state->dest_ip, my_state->dest_port);
+ TSNetConnect(contp, my_state->dest_ip, my_state->dest_port);
}
- } else if (event == INK_EVENT_NET_ACCEPT_FAILED) {
+ } else if (event == TS_EVENT_NET_ACCEPT_FAILED) {
pvc_cleanup(contp, my_state);
} else {
- INKReleaseAssert(!"Unexpected Event");
+ TSReleaseAssert(!"Unexpected Event");
}
}
static void
-pvc_process_connect(INKCont contp, int event, void *data, pvc_state * my_state)
+pvc_process_connect(TSCont contp, int event, void *data, pvc_state * my_state)
{
LOG_SET_FUNCTION_NAME("pvc_process_connect");
PVC_ADD_HISTORY_ENTRY(event);
- INKDebug(DEBUG_TAG, "plugin called: pvc_process_connect with event %d", event);
+ TSDebug(DEBUG_TAG, "plugin called: pvc_process_connect with event %d", event);
- if (event == INK_EVENT_NET_CONNECT_FAILED) {
- LOG_ERROR("INK_EVENT_NET_CONNECT_FAILED");
- if (INKVConnClose(my_state->p_vc) == INK_ERROR) {
- LOG_ERROR("INKVConnClose");
+ if (event == TS_EVENT_NET_CONNECT_FAILED) {
+ LOG_ERROR("TS_EVENT_NET_CONNECT_FAILED");
+ if (TSVConnClose(my_state->p_vc) == TS_ERROR) {
+ LOG_ERROR("TSVConnClose");
}
pvc_cleanup(contp, my_state);
- } else if (event == INK_EVENT_NET_CONNECT) {
- my_state->net_vc = (INKVConn *) data;
+ } else if (event == TS_EVENT_NET_CONNECT) {
+ my_state->net_vc = (TSVConn *) data;
- /* INKqa12967 - the IO Core has a bug where if the connect fails, we
+ /* TSqa12967 - the IO Core has a bug where if the connect fails, we
do not always get VC_EVENT_ERROR on write side of the connection.
Timeout if we do not reach the host after 30 seconds to prevent leaks.
*/
- my_state->connect_timeout_event = INKContSchedule(contp, 30 * 1000);
+ my_state->connect_timeout_event = TSContSchedule(contp, 30 * 1000);
- my_state->p_read_vio = INKVConnRead(my_state->p_vc, contp, my_state->req_buffer, INT_MAX);
- if (my_state->p_read_vio == INK_ERROR_PTR) {
- LOG_ERROR("INKVConnRead");
+ my_state->p_read_vio = TSVConnRead(my_state->p_vc, contp, my_state->req_buffer, INT_MAX);
+ if (my_state->p_read_vio == TS_ERROR_PTR) {
+ LOG_ERROR("TSVConnRead");
return;
}
- my_state->p_write_vio = INKVConnWrite(my_state->p_vc, contp, my_state->resp_reader, INT_MAX);
- if (my_state->p_write_vio == INK_ERROR_PTR) {
- LOG_ERROR("INKVConnWrite");
+ my_state->p_write_vio = TSVConnWrite(my_state->p_vc, contp, my_state->resp_reader, INT_MAX);
+ if (my_state->p_write_vio == TS_ERROR_PTR) {
+ LOG_ERROR("TSVConnWrite");
return;
}
- my_state->n_read_vio = INKVConnRead(my_state->net_vc, contp, my_state->resp_buffer, INT_MAX);
- if (my_state->n_read_vio == INK_ERROR_PTR) {
- LOG_ERROR("INKVConnRead");
+ my_state->n_read_vio = TSVConnRead(my_state->net_vc, contp, my_state->resp_buffer, INT_MAX);
+ if (my_state->n_read_vio == TS_ERROR_PTR) {
+ LOG_ERROR("TSVConnRead");
return;
}
- my_state->n_write_vio = INKVConnWrite(my_state->net_vc, contp, my_state->req_reader, INT_MAX);
- if (my_state->n_write_vio == INK_ERROR_PTR) {
- LOG_ERROR("INKVConnWrite");
+ my_state->n_write_vio = TSVConnWrite(my_state->net_vc, contp, my_state->req_reader, INT_MAX);
+ if (my_state->n_write_vio == TS_ERROR_PTR) {
+ LOG_ERROR("TSVConnWrite");
return;
}
} else {
- INKReleaseAssert(!"Unexpected Event");
+ TSReleaseAssert(!"Unexpected Event");
}
}
static void
-pvc_process_p_read(INKCont contp, INKEvent event, pvc_state * my_state)
+pvc_process_p_read(TSCont contp, TSEvent event, pvc_state * my_state)
{
LOG_SET_FUNCTION_NAME("pvc_process_p_read");
int bytes;
PVC_ADD_HISTORY_ENTRY(event);
- INKDebug(DEBUG_TAG, "plugin called: pvc_process_p_read with event %d", event);
+ TSDebug(DEBUG_TAG, "plugin called: pvc_process_p_read with event %d", event);
switch (event) {
- case INK_EVENT_VCONN_READ_READY:
- if (INKVIOReenable(my_state->n_write_vio) == INK_ERROR) {
- LOG_ERROR("INKVIOReenable");
+ case TS_EVENT_VCONN_READ_READY:
+ if (TSVIOReenable(my_state->n_write_vio) == TS_ERROR) {
+ LOG_ERROR("TSVIOReenable");
}
break;
- case INK_EVENT_VCONN_READ_COMPLETE:
- case INK_EVENT_VCONN_EOS:
- case INK_EVENT_ERROR:
+ case TS_EVENT_VCONN_READ_COMPLETE:
+ case TS_EVENT_VCONN_EOS:
+ case TS_EVENT_ERROR:
{
/* We're finished reading from the plugin vc */
int ndone;
int todo;
- ndone = INKVIONDoneGet(my_state->p_read_vio);
- if (ndone == INK_ERROR) {
- LOG_ERROR("INKVIODoneGet");
+ ndone = TSVIONDoneGet(my_state->p_read_vio);
+ if (ndone == TS_ERROR) {
+ LOG_ERROR("TSVIODoneGet");
}
my_state->p_read_vio = NULL;
- if (INKVIONBytesSet(my_state->n_write_vio, ndone) == INK_ERROR) {
- LOG_ERROR("INKVIONBytesSet");
+ if (TSVIONBytesSet(my_state->n_write_vio, ndone) == TS_ERROR) {
+ LOG_ERROR("TSVIONBytesSet");
}
- if (INKVConnShutdown(my_state->p_vc, 1, 0) == INK_ERROR) {
- LOG_ERROR("INKVConnShutdown");
+ if (TSVConnShutdown(my_state->p_vc, 1, 0) == TS_ERROR) {
+ LOG_ERROR("TSVConnShutdown");
}
- todo = INKVIONTodoGet(my_state->n_write_vio);
- if (todo == INK_ERROR) {
- LOG_ERROR("INKVIONTodoGet");
+ todo = TSVIONTodoGet(my_state->n_write_vio);
+ if (todo == TS_ERROR) {
+ LOG_ERROR("TSVIONTodoGet");
todo = 0;
}
if (todo == 0) {
my_state->req_finished = 1;
- if (INKVConnShutdown(my_state->net_vc, 0, 1) == INK_ERROR) {
- LOG_ERROR("INKVConnShutdown");
+ if (TSVConnShutdown(my_state->net_vc, 0, 1) == TS_ERROR) {
+ LOG_ERROR("TSVConnShutdown");
}
pvc_check_done(contp, my_state);
} else {
- if (INKVIOReenable(my_state->n_write_vio) == INK_ERROR) {
- LOG_ERROR("INKVIOReenable");
+ if (TSVIOReenable(my_state->n_write_vio) == TS_ERROR) {
+ LOG_ERROR("TSVIOReenable");
}
}
break;
}
default:
- INKReleaseAssert(!"Unexpected Event");
+ TSReleaseAssert(!"Unexpected Event");
break;
}
}
static void
-pvc_process_n_write(INKCont contp, INKEvent event, pvc_state * my_state)
+pvc_process_n_write(TSCont contp, TSEvent event, pvc_state * my_state)
{
LOG_SET_FUNCTION_NAME("pvc_process_n_write");
int bytes;
PVC_ADD_HISTORY_ENTRY(event);
- INKDebug(DEBUG_TAG, "plugin called: pvc_process_n_write with event %d", event);
+ TSDebug(DEBUG_TAG, "plugin called: pvc_process_n_write with event %d", event);
/* Any event from the write side of the connection means that either
the connect completed successfully or we already know about the
error. Either way cancel the timeout event */
if (my_state->connect_timeout_event) {
- INKActionCancel(my_state->connect_timeout_event);
+ TSActionCancel(my_state->connect_timeout_event);
my_state->connect_timeout_event = NULL;
}
switch (event) {
- case INK_EVENT_VCONN_WRITE_READY:
+ case TS_EVENT_VCONN_WRITE_READY:
if (my_state->p_read_vio) {
- if (INKVIOReenable(my_state->p_read_vio) == INK_ERROR) {
- LOG_ERROR("INKVIOReenable");
+ if (TSVIOReenable(my_state->p_read_vio) == TS_ERROR) {
+ LOG_ERROR("TSVIOReenable");
}
}
break;
- case INK_EVENT_ERROR:
+ case TS_EVENT_ERROR:
if (my_state->p_read_vio) {
- if (INKVConnShutdown(my_state->p_vc, 1, 0) == INK_ERROR) {
- LOG_ERROR("INKVConnShutdown");
+ if (TSVConnShutdown(my_state->p_vc, 1, 0) == TS_ERROR) {
+ LOG_ERROR("TSVConnShutdown");
}
my_state->p_read_vio = NULL;
}
/* FALL THROUGH */
- case INK_EVENT_VCONN_WRITE_COMPLETE:
+ case TS_EVENT_VCONN_WRITE_COMPLETE:
/* We should have already shutdown read pvc side */
- INKAssert(my_state->p_read_vio == NULL);
- if (INKVConnShutdown(my_state->net_vc, 0, 1) == INK_ERROR) {
- LOG_ERROR("INKVConnShutdown");
+ TSAssert(my_state->p_read_vio == NULL);
+ if (TSVConnShutdown(my_state->net_vc, 0, 1) == TS_ERROR) {
+ LOG_ERROR("TSVConnShutdown");
}
my_state->req_finished = 1;
pvc_check_done(contp, my_state);
break;
default:
- INKReleaseAssert(!"Unexpected Event");
+ TSReleaseAssert(!"Unexpected Event");
break;
}
}
static void
-pvc_process_n_read(INKCont contp, INKEvent event, pvc_state * my_state)
+pvc_process_n_read(TSCont contp, TSEvent event, pvc_state * my_state)
{
LOG_SET_FUNCTION_NAME("pvc_process_n_read");
int bytes;
PVC_ADD_HISTORY_ENTRY(event);
- INKDebug("pvc", "plugin called: pvc_process_n_read with event %d", event);
+ TSDebug("pvc", "plugin called: pvc_process_n_read with event %d", event);
switch (event) {
- case INK_EVENT_VCONN_READ_READY:
- if (INKVIOReenable(my_state->p_write_vio) == INK_ERROR) {
- LOG_ERROR("INKVIOReenable");
+ case TS_EVENT_VCONN_READ_READY:
+ if (TSVIOReenable(my_state->p_write_vio) == TS_ERROR) {
+ LOG_ERROR("TSVIOReenable");
}
break;
- case INK_EVENT_VCONN_READ_COMPLETE:
- case INK_EVENT_VCONN_EOS:
- case INK_EVENT_ERROR:
+ case TS_EVENT_VCONN_READ_COMPLETE:
+ case TS_EVENT_VCONN_EOS:
+ case TS_EVENT_ERROR:
{
/* We're finished reading from the plugin vc */
int ndone;
int todo;
- ndone = INKVIONDoneGet(my_state->n_read_vio);
- if (ndone == INK_ERROR) {
- LOG_ERROR("INKVIODoneGet");
+ ndone = TSVIONDoneGet(my_state->n_read_vio);
+ if (ndone == TS_ERROR) {
+ LOG_ERROR("TSVIODoneGet");
}
my_state->n_read_vio = NULL;
- if (INKVIONBytesSet(my_state->p_write_vio, ndone) == INK_ERROR) {
- LOG_ERROR("INKVIONBytesSet");
+ if (TSVIONBytesSet(my_state->p_write_vio, ndone) == TS_ERROR) {
+ LOG_ERROR("TSVIONBytesSet");
}
- if (INKVConnShutdown(my_state->net_vc, 1, 0) == INK_ERROR) {
- LOG_ERROR("INKVConnShutdown");
+ if (TSVConnShutdown(my_state->net_vc, 1, 0) == TS_ERROR) {
+ LOG_ERROR("TSVConnShutdown");
}
- todo = INKVIONTodoGet(my_state->p_write_vio);
- if (todo == INK_ERROR) {
- LOG_ERROR("INKVIOTodoGet");
+ todo = TSVIONTodoGet(my_state->p_write_vio);
+ if (todo == TS_ERROR) {
+ LOG_ERROR("TSVIOTodoGet");
/* Error so set it to 0 to cleanup */
todo = 0;
}
if (todo == 0) {
my_state->resp_finished = 1;
- if (INKVConnShutdown(my_state->p_vc, 0, 1) == INK_ERROR) {
- LOG_ERROR("INKVConnShutdown");
+ if (TSVConnShutdown(my_state->p_vc, 0, 1) == TS_ERROR) {
+ LOG_ERROR("TSVConnShutdown");
}
pvc_check_done(contp, my_state);
} else {
- if (INKVIOReenable(my_state->p_write_vio) == INK_ERROR) {
- LOG_ERROR("INKVIOReenable");
+ if (TSVIOReenable(my_state->p_write_vio) == TS_ERROR) {
+ LOG_ERROR("TSVIOReenable");
}
}
break;
}
default:
- INKReleaseAssert(!"Unexpected Event");
+ TSReleaseAssert(!"Unexpected Event");
break;
}
}
static void
-pvc_process_p_write(INKCont contp, INKEvent event, pvc_state * my_state)
+pvc_process_p_write(TSCont contp, TSEvent event, pvc_state * my_state)
{
LOG_SET_FUNCTION_NAME("pvc_process_p_write");
int bytes;
PVC_ADD_HISTORY_ENTRY(event);
- INKDebug(DEBUG_TAG, "plugin called: pvc_process_p_write with event %d", event);
+ TSDebug(DEBUG_TAG, "plugin called: pvc_process_p_write with event %d", event);
switch (event) {
- case INK_EVENT_VCONN_WRITE_READY:
+ case TS_EVENT_VCONN_WRITE_READY:
if (my_state->n_read_vio) {
- if (INKVIOReenable(my_state->n_read_vio) == INK_ERROR) {
- LOG_ERROR("INKVIOReenable");
+ if (TSVIOReenable(my_state->n_read_vio) == TS_ERROR) {
+ LOG_ERROR("TSVIOReenable");
}
}
break;
- case INK_EVENT_ERROR:
+ case TS_EVENT_ERROR:
if (my_state->n_read_vio) {
- if (INKVConnShutdown(my_state->net_vc, 1, 0) == INK_ERROR) {
+ if (TSVConnShutdown(my_state->net_vc, 1, 0) == TS_ERROR) {
LOG_ERROR("INVConnShutdown");
}
my_state->n_read_vio = NULL;
}
/* FALL THROUGH */
- case INK_EVENT_VCONN_WRITE_COMPLETE:
+ case TS_EVENT_VCONN_WRITE_COMPLETE:
/* We should have already shutdown read net side */
- INKAssert(my_state->n_read_vio == NULL);
- if (INKVConnShutdown(my_state->p_vc, 0, 1) == INK_ERROR) {
- LOG_ERROR("INKVConnShutdown");
+ TSAssert(my_state->n_read_vio == NULL);
+ if (TSVConnShutdown(my_state->p_vc, 0, 1) == TS_ERROR) {
+ LOG_ERROR("TSVConnShutdown");
}
my_state->resp_finished = 1;
pvc_check_done(contp, my_state);
break;
default:
- INKReleaseAssert(!"Unexpected Event");
+ TSReleaseAssert(!"Unexpected Event");
break;
}
}
static void
-pvc_process_connect_timeout(INKCont contp, int event, pvc_state * my_state)
+pvc_process_connect_timeout(TSCont contp, int event, pvc_state * my_state)
{
PVC_ADD_HISTORY_ENTRY(event);
- INKDebug(DEBUG_TAG, "plugin called: pvc_process_conect_time with event %d", event);
- INKDebug(DEBUG_TAG "-connect", "Timing out connect to %u.%u.%u.%u:%d",
+ TSDebug(DEBUG_TAG, "plugin called: pvc_process_conect_time with event %d", event);
+ TSDebug(DEBUG_TAG "-connect", "Timing out connect to %u.%u.%u.%u:%d",
((unsigned char *) &my_state->dest_ip)[0],
((unsigned char *) &my_state->dest_ip)[1],
((unsigned char *) &my_state->dest_ip)[2],
@@ -572,17 +572,17 @@ pvc_process_connect_timeout(INKCont cont
my_state->connect_timeout_event = NULL;
/* Simulate an error event which is what we should gotten anyway */
- pvc_process_n_write(contp, INK_EVENT_ERROR, my_state);
+ pvc_process_n_write(contp, TS_EVENT_ERROR, my_state);
}
static int
-pvc_plugin(INKCont contp, INKEvent event, void *edata)
+pvc_plugin(TSCont contp, TSEvent event, void *edata)
{
- pvc_state *my_state = INKContDataGet(contp);
+ pvc_state *my_state = TSContDataGet(contp);
- if (event == INK_EVENT_NET_ACCEPT || event == INK_EVENT_NET_ACCEPT_FAILED) {
+ if (event == TS_EVENT_NET_ACCEPT || event == TS_EVENT_NET_ACCEPT_FAILED) {
pvc_process_accept(contp, event, edata, my_state);
- } else if (event == INK_EVENT_NET_CONNECT || event == INK_EVENT_NET_CONNECT_FAILED) {
+ } else if (event == TS_EVENT_NET_CONNECT || event == TS_EVENT_NET_CONNECT_FAILED) {
pvc_process_connect(contp, event, edata, my_state);
} else if (edata == my_state->p_read_vio) {
pvc_process_p_read(contp, event, my_state);
@@ -592,42 +592,42 @@ pvc_plugin(INKCont contp, INKEvent event
pvc_process_n_read(contp, event, my_state);
} else if (edata == my_state->n_write_vio) {
pvc_process_n_write(contp, event, my_state);
- } else if (event == INK_EVENT_TIMEOUT &&
- ((INKAction) (((unsigned long) edata) | 0x1)) == my_state->connect_timeout_event) {
+ } else if (event == TS_EVENT_TIMEOUT &&
+ ((TSAction) (((unsigned long) edata) | 0x1)) == my_state->connect_timeout_event) {
/* FIX ME - SDK should have a function to compare the Action received from
- InkContSchedule and edata on INK_EVENT_TIMEOUT */
+ InkContSchedule and edata on TS_EVENT_TIMEOUT */
pvc_process_connect_timeout(contp, event, my_state);
} else {
- INKReleaseAssert(!"Unexpected Event");
+ TSReleaseAssert(!"Unexpected Event");
}
return 0;
}
static int
-attach_pvc_plugin(INKCont contp, INKEvent event, void *edata)
+attach_pvc_plugin(TSCont contp, TSEvent event, void *edata)
{
LOG_SET_FUNCTION_NAME("attach_pvc_plugin");
- INKHttpTxn txnp = (INKHttpTxn) edata;
- INKMutex mutex;
- INKCont new_cont;
+ TSHttpTxn txnp = (TSHttpTxn) edata;
+ TSMutex mutex;
+ TSCont new_cont;
pvc_state *my_state;
switch (event) {
- case INK_EVENT_HTTP_READ_REQUEST_HDR:
- mutex = INKMutexCreate();
- if (mutex == INK_ERROR_PTR) {
- LOG_ERROR("INKMutexCreate");
+ case TS_EVENT_HTTP_READ_REQUEST_HDR:
+ mutex = TSMutexCreate();
+ if (mutex == TS_ERROR_PTR) {
+ LOG_ERROR("TSMutexCreate");
break;
}
- new_cont = INKContCreate(pvc_plugin, mutex);
- if (new_cont == INK_ERROR_PTR) {
- LOG_ERROR("INKContCreate");
+ new_cont = TSContCreate(pvc_plugin, mutex);
+ if (new_cont == TS_ERROR_PTR) {
+ LOG_ERROR("TSContCreate");
break;
}
- my_state = (pvc_state *) INKmalloc(sizeof(pvc_state));
+ my_state = (pvc_state *) TSmalloc(sizeof(pvc_state));
my_state->p_vc = NULL;
my_state->p_read_vio = NULL;
my_state->p_write_vio = NULL;
@@ -650,7 +650,7 @@ attach_pvc_plugin(INKCont contp, INKEven
my_state->resp_finished = 0;
/* Increment pvc_count */
- INKStatIncrement(pvc_count);
+ TSStatIncrement(pvc_count);
#ifdef USE_PVC_HISTORY
my_state->history_index = 0;
@@ -664,29 +664,29 @@ attach_pvc_plugin(INKCont contp, INKEven
pvc_add_to_debug_list(my_state);
#endif
- if (INKContDataSet(new_cont, my_state) == INK_ERROR) {
- LOG_ERROR("INKContDataSet");
+ if (TSContDataSet(new_cont, my_state) == TS_ERROR) {
+ LOG_ERROR("TSContDataSet");
break;
}
- if (INKHttpTxnServerIntercept(new_cont, txnp) == INK_ERROR) {
- LOG_ERROR("INKHttpTxnServerIntercept");
+ if (TSHttpTxnServerIntercept(new_cont, txnp) == TS_ERROR) {
+ LOG_ERROR("TSHttpTxnServerIntercept");
break;
}
#ifdef DEBUG
- if (INKHttpTxnServerIntercept(NULL, NULL) != INK_ERROR) {
- LOG_ERROR_NEG("INKHttpTxnServerIntercept");
+ if (TSHttpTxnServerIntercept(NULL, NULL) != TS_ERROR) {
+ LOG_ERROR_NEG("TSHttpTxnServerIntercept");
}
#endif
break;
default:
- INKReleaseAssert(!"Unexpected Event");
+ TSReleaseAssert(!"Unexpected Event");
break;
}
- if (INKHttpTxnReenable(txnp, INK_EVENT_HTTP_CONTINUE) == INK_ERROR) {
- LOG_ERROR_AND_RETURN("INKHttpTxnReenable");
+ if (TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE) == TS_ERROR) {
+ LOG_ERROR_AND_RETURN("TSHttpTxnReenable");
}
return 0;
@@ -696,7 +696,7 @@ int
check_ts_version()
{
- const char *ts_version = INKTrafficServerVersionGet();
+ const char *ts_version = TSTrafficServerVersionGet();
int result = 0;
if (ts_version) {
@@ -719,48 +719,48 @@ check_ts_version()
}
void
-INKPluginInit(int argc, const char *argv[])
+TSPluginInit(int argc, const char *argv[])
{
- LOG_SET_FUNCTION_NAME("INKPluginInit");
+ LOG_SET_FUNCTION_NAME("TSPluginInit");
- INKMLoc field_loc;
+ TSMLoc field_loc;
const char *p;
int i;
- INKPluginRegistrationInfo info;
- INKCont contp;
+ TSPluginRegistrationInfo info;
+ TSCont contp;
info.plugin_name = "test-pos";
info.vendor_name = "MyCompany";
info.support_email = "ts-api-support@MyCompany.com";
- if (!INKPluginRegister(INK_SDK_VERSION_2_0, &info)) {
- INKError("Plugin registration failed.\n");
+ if (!TSPluginRegister(TS_SDK_VERSION_2_0, &info)) {
+ TSError("Plugin registration failed.\n");
}
if (!check_ts_version()) {
- INKError("Plugin requires Traffic Server 2.0 or later\n");
+ TSError("Plugin requires Traffic Server 2.0 or later\n");
return;
}
/* create the statistic variables */
- pvc_count = INKStatCreate("pvc.count", INKSTAT_TYPE_INT64);
- if (pvc_count == INK_ERROR_PTR) {
- LOG_ERROR("INKStatsCreate");
+ pvc_count = TSStatCreate("pvc.count", TSSTAT_TYPE_INT64);
+ if (pvc_count == TS_ERROR_PTR) {
+ LOG_ERROR("TSStatsCreate");
}
#ifdef USE_PVC_DEBUG_LIST
/* create our debug list mutx */
- debug_list_mutex = INKMutexCreate();
+ debug_list_mutex = TSMutexCreate();
if (debug_list_mutex == NULL) {
- LOG_ERROR("INKMutexCreate");
+ LOG_ERROR("TSMutexCreate");
}
#endif
- contp = INKContCreate(attach_pvc_plugin, NULL);
- if (contp == INK_ERROR_PTR) {
- LOG_ERROR("INKContCreate");
+ contp = TSContCreate(attach_pvc_plugin, NULL);
+ if (contp == TS_ERROR_PTR) {
+ LOG_ERROR("TSContCreate");
} else {
- if (INKHttpHookAdd(INK_HTTP_READ_REQUEST_HDR_HOOK, contp) == INK_ERROR) {
- LOG_ERROR("INKHttpHookAdd");
+ if (TSHttpHookAdd(TS_HTTP_READ_REQUEST_HDR_HOOK, contp) == TS_ERROR) {
+ LOG_ERROR("TSHttpHookAdd");
}
}
Modified: trafficserver/traffic/trunk/test/plugin/plugin_as_origin/serve_file.c
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/test/plugin/plugin_as_origin/serve_file.c?rev=1035782&r1=1035781&r2=1035782&view=diff
==============================================================================
--- trafficserver/traffic/trunk/test/plugin/plugin_as_origin/serve_file.c (original)
+++ trafficserver/traffic/trunk/test/plugin/plugin_as_origin/serve_file.c Tue Nov 16 20:22:02 2010
@@ -45,14 +45,14 @@
Log macros for error code return verification
**************************************************/
#define PLUGIN_NAME "serve_file"
-#define VALID_POINTER(X) ((X != NULL) && (X != INK_ERROR_PTR))
+#define VALID_POINTER(X) ((X != NULL) && (X != TS_ERROR_PTR))
#define LOG_SET_FUNCTION_NAME(NAME) const char * FUNCTION_NAME = NAME
#define LOG_ERROR(API_NAME) { \
- INKDebug(PLUGIN_NAME, "%s: %s %s %s File %s, line number %d", PLUGIN_NAME, API_NAME, "APIFAIL", \
+ TSDebug(PLUGIN_NAME, "%s: %s %s %s File %s, line number %d", PLUGIN_NAME, API_NAME, "APIFAIL", \
FUNCTION_NAME, __FILE__, __LINE__); \
}
#define LOG_ERROR_NEG(API_NAME) { \
- INKDebug(PLUGIN_NAME, "%s: %s %s %s File %s, line number %d", PLUGIN_NAME, API_NAME, "NEGAPIFAIL", \
+ TSDebug(PLUGIN_NAME, "%s: %s %s %s File %s, line number %d", PLUGIN_NAME, API_NAME, "NEGAPIFAIL", \
FUNCTION_NAME, __FILE__, __LINE__); \
}
#define LOG_ERROR_AND_RETURN(API_NAME) { \
@@ -65,7 +65,7 @@
}
#define LOG_ERROR_AND_REENABLE(API_NAME) { \
LOG_ERROR(API_NAME); \
- INKHttpTxnReenable(txnp, INK_EVENT_HTTP_CONTINUE); \
+ TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE); \
}
static char *doc_buf = NULL;
@@ -73,17 +73,17 @@ static int doc_size;
struct pvc_state_t
{
- INKVConn net_vc;
- INKVIO read_vio;
- INKVIO write_vio;
+ TSVConn net_vc;
+ TSVIO read_vio;
+ TSVIO write_vio;
- INKIOBuffer req_buffer;
- INKIOBufferReader req_reader;
+ TSIOBuffer req_buffer;
+ TSIOBufferReader req_reader;
- INKIOBuffer resp_buffer;
- INKIOBufferReader resp_reader;
+ TSIOBuffer resp_buffer;
+ TSIOBufferReader resp_reader;
- INKHttpTxn http_txnp;
+ TSHttpTxn http_txnp;
int output_bytes;
int body_written;
@@ -91,36 +91,36 @@ struct pvc_state_t
typedef struct pvc_state_t pvc_state;
static void
-pvc_cleanup(INKCont contp, pvc_state * my_state)
+pvc_cleanup(TSCont contp, pvc_state * my_state)
{
LOG_SET_FUNCTION_NAME("pvc_cleanup");
- /* Fix for INKqa12401: need to destroy req_buffer */
+ /* Fix for TSqa12401: need to destroy req_buffer */
if (my_state->req_buffer) {
- if (INKIOBufferDestroy(my_state->req_buffer) == INK_ERROR) {
- LOG_ERROR("INKIOBufferDestroy");
+ if (TSIOBufferDestroy(my_state->req_buffer) == TS_ERROR) {
+ LOG_ERROR("TSIOBufferDestroy");
}
my_state->req_buffer = NULL;
}
- /* Fix for INKqa12401: need to destroy resp_buffer */
+ /* Fix for TSqa12401: need to destroy resp_buffer */
if (my_state->resp_buffer) {
- if (INKIOBufferDestroy(my_state->resp_buffer) == INK_ERROR) {
- LOG_ERROR("INKIOBufferDestroy");
+ if (TSIOBufferDestroy(my_state->resp_buffer) == TS_ERROR) {
+ LOG_ERROR("TSIOBufferDestroy");
}
my_state->resp_buffer = NULL;
}
/* Close net_vc */
- if (INKVConnClose(my_state->net_vc) == INK_ERROR) {
- LOG_ERROR("INKVConnClose");
+ if (TSVConnClose(my_state->net_vc) == TS_ERROR) {
+ LOG_ERROR("TSVConnClose");
}
- /* Fix for INKqa12401: need to free the continuation data */
- INKfree(my_state);
+ /* Fix for TSqa12401: need to free the continuation data */
+ TSfree(my_state);
- /* Fix for INKqa12401: need to destroy the continuation */
- INKContDestroy(contp);
+ /* Fix for TSqa12401: need to destroy the continuation */
+ TSContDestroy(contp);
}
@@ -130,12 +130,12 @@ pvc_add_data_to_resp_buffer(const char *
LOG_SET_FUNCTION_NAME("pvc_add_data_to_resp_buffer");
int s_len = strlen(s);
- char *buf = (char *) INKmalloc(s_len);
+ char *buf = (char *) TSmalloc(s_len);
memcpy(buf, s, s_len);
- INKIOBufferWrite(my_state->resp_buffer, buf, s_len);
+ TSIOBufferWrite(my_state->resp_buffer, buf, s_len);
- INKfree(buf);
+ TSfree(buf);
buf = NULL;
return s_len;
}
@@ -150,185 +150,185 @@ pvc_add_resp_header(pvc_state * my_state
}
static void
-pvc_process_accept(INKCont contp, pvc_state * my_state)
+pvc_process_accept(TSCont contp, pvc_state * my_state)
{
LOG_SET_FUNCTION_NAME("pvc_process_accept");
- my_state->req_buffer = INKIOBufferCreate();
- if (my_state->req_buffer == INK_ERROR_PTR) {
- LOG_ERROR("INKIOBufferCreate");
+ my_state->req_buffer = TSIOBufferCreate();
+ if (my_state->req_buffer == TS_ERROR_PTR) {
+ LOG_ERROR("TSIOBufferCreate");
return;
}
- my_state->req_reader = INKIOBufferReaderAlloc(my_state->req_buffer);
- if (my_state->req_reader == INK_ERROR_PTR) {
- LOG_ERROR("INKIOBufferReaderAlloc");
+ my_state->req_reader = TSIOBufferReaderAlloc(my_state->req_buffer);
+ if (my_state->req_reader == TS_ERROR_PTR) {
+ LOG_ERROR("TSIOBufferReaderAlloc");
return;
}
- my_state->resp_buffer = INKIOBufferCreate();
- if (my_state->resp_buffer == INK_ERROR_PTR) {
- LOG_ERROR("INKIOBufferCreate");
+ my_state->resp_buffer = TSIOBufferCreate();
+ if (my_state->resp_buffer == TS_ERROR_PTR) {
+ LOG_ERROR("TSIOBufferCreate");
return;
}
- my_state->resp_reader = INKIOBufferReaderAlloc(my_state->resp_buffer);
- if (my_state->resp_reader == INK_ERROR_PTR) {
- LOG_ERROR("INKIOBufferReaderAlloc");
+ my_state->resp_reader = TSIOBufferReaderAlloc(my_state->resp_buffer);
+ if (my_state->resp_reader == TS_ERROR_PTR) {
+ LOG_ERROR("TSIOBufferReaderAlloc");
return;
}
- my_state->read_vio = INKVConnRead(my_state->net_vc, contp, my_state->req_buffer, INT_MAX);
- if (my_state->read_vio == INK_ERROR_PTR) {
- LOG_ERROR("INKVConnRead");
+ my_state->read_vio = TSVConnRead(my_state->net_vc, contp, my_state->req_buffer, INT_MAX);
+ if (my_state->read_vio == TS_ERROR_PTR) {
+ LOG_ERROR("TSVConnRead");
return;
}
}
static void
-pvc_process_read(INKCont contp, INKEvent event, pvc_state * my_state)
+pvc_process_read(TSCont contp, TSEvent event, pvc_state * my_state)
{
LOG_SET_FUNCTION_NAME("pvc_process_read");
/* int bytes; */
- INKDebug(DEBUG_TAG, "plugin called: pvc_process_read with event %d", event);
+ TSDebug(DEBUG_TAG, "plugin called: pvc_process_read with event %d", event);
- if (event == INK_EVENT_VCONN_READ_READY) {
-/* if (INKVIOReenable(my_state->read_vio) == INK_ERROR) { */
-/* LOG_ERROR("INKVIOReenable"); */
+ if (event == TS_EVENT_VCONN_READ_READY) {
+/* if (TSVIOReenable(my_state->read_vio) == TS_ERROR) { */
+/* LOG_ERROR("TSVIOReenable"); */
/* return; */
/* } */
-/* } else if (event == INK_EVENT_VCONN_READ_COMPLETE) { */
- INKDebug(DEBUG_TAG, "writing response header and shutting down read side");
+/* } else if (event == TS_EVENT_VCONN_READ_COMPLETE) { */
+ TSDebug(DEBUG_TAG, "writing response header and shutting down read side");
my_state->output_bytes = pvc_add_resp_header(my_state);
- if (INKVConnShutdown(my_state->net_vc, 1, 0) == INK_ERROR) {
- LOG_ERROR("INKVConnShutdown");
+ if (TSVConnShutdown(my_state->net_vc, 1, 0) == TS_ERROR) {
+ LOG_ERROR("TSVConnShutdown");
return;
}
#ifdef DEBUG
- if (INKVConnShutdown(NULL, 0, 0) != INK_ERROR) {
- LOG_ERROR_NEG("INKVConnShutdown");
+ if (TSVConnShutdown(NULL, 0, 0) != TS_ERROR) {
+ LOG_ERROR_NEG("TSVConnShutdown");
} else
- INKDebug(NEG_DEBUG_TAG, "Negative Test INKVConnShutdown 1 passed");
+ TSDebug(NEG_DEBUG_TAG, "Negative Test TSVConnShutdown 1 passed");
#endif
- my_state->write_vio = INKVConnWrite(my_state->net_vc, contp, my_state->resp_reader, INT_MAX);
- if (my_state->write_vio == INK_ERROR_PTR) {
- LOG_ERROR("INKVConnWrite");
+ my_state->write_vio = TSVConnWrite(my_state->net_vc, contp, my_state->resp_reader, INT_MAX);
+ if (my_state->write_vio == TS_ERROR_PTR) {
+ LOG_ERROR("TSVConnWrite");
return;
}
- } else if (event == INK_EVENT_ERROR) {
- INKError("pvc_process_read: Received INK_EVENT_ERROR\n");
- } else if (event == INK_EVENT_VCONN_EOS) {
+ } else if (event == TS_EVENT_ERROR) {
+ TSError("pvc_process_read: Received TS_EVENT_ERROR\n");
+ } else if (event == TS_EVENT_VCONN_EOS) {
/* client may end the connection, simply return */
return;
} else {
printf("Unexpected Event %d\n", event);
- INKReleaseAssert(!"Unexpected Event");
+ TSReleaseAssert(!"Unexpected Event");
}
}
static void
-pvc_process_write(INKCont contp, INKEvent event, pvc_state * my_state)
+pvc_process_write(TSCont contp, TSEvent event, pvc_state * my_state)
{
LOG_SET_FUNCTION_NAME("pvc_process_write");
char body[] = "This is a test\n";
- int nbytes = INKVIONBytesGet(my_state->write_vio);
- int ndone = INKVIONDoneGet(my_state->write_vio);
+ int nbytes = TSVIONBytesGet(my_state->write_vio);
+ int ndone = TSVIONDoneGet(my_state->write_vio);
#ifdef DEBUG
- if (INKVIONBytesGet(NULL) != INK_ERROR) {
- LOG_ERROR_NEG("INKVIONBytesGet");
+ if (TSVIONBytesGet(NULL) != TS_ERROR) {
+ LOG_ERROR_NEG("TSVIONBytesGet");
} else
- INKDebug(NEG_DEBUG_TAG, "Negative Test INKVIONBytesGet 1 passed");
+ TSDebug(NEG_DEBUG_TAG, "Negative Test TSVIONBytesGet 1 passed");
#endif
- INKDebug(DEBUG_TAG, "plugin called: pvc_process_write with event %d", event);
+ TSDebug(DEBUG_TAG, "plugin called: pvc_process_write with event %d", event);
- if (event == INK_EVENT_VCONN_WRITE_READY) {
+ if (event == TS_EVENT_VCONN_WRITE_READY) {
if (my_state->body_written == 0) {
- INKDebug(DEBUG_TAG, "plugin adding response body");
+ TSDebug(DEBUG_TAG, "plugin adding response body");
my_state->body_written = 1;
my_state->output_bytes += pvc_add_data_to_resp_buffer(doc_buf, my_state);
- if (INKVIONBytesSet(my_state->write_vio, my_state->output_bytes) == INK_ERROR) {
- LOG_ERROR("INKVIONBytesSet");
+ if (TSVIONBytesSet(my_state->write_vio, my_state->output_bytes) == TS_ERROR) {
+ LOG_ERROR("TSVIONBytesSet");
return;
}
}
- if (INKVIOReenable(my_state->write_vio) == INK_ERROR) {
- LOG_ERROR("INKVIOReenable");
+ if (TSVIOReenable(my_state->write_vio) == TS_ERROR) {
+ LOG_ERROR("TSVIOReenable");
return;
}
- } else if (INK_EVENT_VCONN_WRITE_COMPLETE) {
+ } else if (TS_EVENT_VCONN_WRITE_COMPLETE) {
pvc_cleanup(contp, my_state);
- } else if (event == INK_EVENT_ERROR) {
- INKError("pvc_process_write: Received INK_EVENT_ERROR\n");
+ } else if (event == TS_EVENT_ERROR) {
+ TSError("pvc_process_write: Received TS_EVENT_ERROR\n");
} else {
- INKReleaseAssert(!"Unexpected Event");
+ TSReleaseAssert(!"Unexpected Event");
}
}
static int
-pvc_plugin(INKCont contp, INKEvent event, void *edata)
+pvc_plugin(TSCont contp, TSEvent event, void *edata)
{
- pvc_state *my_state = INKContDataGet(contp);
+ pvc_state *my_state = TSContDataGet(contp);
- if (event == INK_EVENT_NET_ACCEPT) {
- my_state->net_vc = (INKVConn) edata;
+ if (event == TS_EVENT_NET_ACCEPT) {
+ my_state->net_vc = (TSVConn) edata;
pvc_process_accept(contp, my_state);
} else if (edata == my_state->read_vio) {
pvc_process_read(contp, event, my_state);
} else if (edata == my_state->write_vio) {
pvc_process_write(contp, event, my_state);
} else {
- INKReleaseAssert(!"Unexpected Event");
+ TSReleaseAssert(!"Unexpected Event");
}
return 0;
}
static int
-attach_pvc_plugin(INKCont contp, INKEvent event, void *edata)
+attach_pvc_plugin(TSCont contp, TSEvent event, void *edata)
{
LOG_SET_FUNCTION_NAME("attach_pvc_plugin");
- INKHttpTxn txnp = (INKHttpTxn) edata;
- INKCont new_cont;
+ TSHttpTxn txnp = (TSHttpTxn) edata;
+ TSCont new_cont;
pvc_state *my_state;
switch (event) {
- case INK_EVENT_HTTP_READ_REQUEST_HDR:
- new_cont = INKContCreate(pvc_plugin, INKMutexCreate());
- /* INKqa12409 */
-/* new_cont = INKContCreate (pvc_plugin, NULL); */
- if (new_cont == INK_ERROR_PTR) {
- LOG_ERROR_AND_REENABLE("INKContCreate");
+ case TS_EVENT_HTTP_READ_REQUEST_HDR:
+ new_cont = TSContCreate(pvc_plugin, TSMutexCreate());
+ /* TSqa12409 */
+/* new_cont = TSContCreate (pvc_plugin, NULL); */
+ if (new_cont == TS_ERROR_PTR) {
+ LOG_ERROR_AND_REENABLE("TSContCreate");
}
- my_state = (pvc_state *) INKmalloc(sizeof(pvc_state));
+ my_state = (pvc_state *) TSmalloc(sizeof(pvc_state));
my_state->net_vc = NULL;
my_state->read_vio = NULL;
my_state->write_vio = NULL;
my_state->http_txnp = txnp;
my_state->body_written = 0;
- if (INKContDataSet(new_cont, my_state) == INK_ERROR) {
- LOG_ERROR_AND_REENABLE("INKContDataSet");
+ if (TSContDataSet(new_cont, my_state) == TS_ERROR) {
+ LOG_ERROR_AND_REENABLE("TSContDataSet");
return -1;
}
- if (INKHttpTxnIntercept(new_cont, txnp) == INK_ERROR) {
- LOG_ERROR_AND_REENABLE("INKHttpTxnIntercept");
+ if (TSHttpTxnIntercept(new_cont, txnp) == TS_ERROR) {
+ LOG_ERROR_AND_REENABLE("TSHttpTxnIntercept");
return -1;
}
#ifdef DEBUG
- if (INKHttpTxnIntercept(NULL, NULL) != INK_ERROR) {
- LOG_ERROR_NEG("INKHttpTxnIntercept");
+ if (TSHttpTxnIntercept(NULL, NULL) != TS_ERROR) {
+ LOG_ERROR_NEG("TSHttpTxnIntercept");
} else
- INKDebug(NEG_DEBUG_TAG, "Negative Test INKHttpTxnIntercept 1 passed");
+ TSDebug(NEG_DEBUG_TAG, "Negative Test TSHttpTxnIntercept 1 passed");
#endif
-/* INKHttpTxnServerIntercept(new_cont, txnp); */
- if (INKHttpTxnReenable(txnp, INK_EVENT_HTTP_CONTINUE) == INK_ERROR) {
- LOG_ERROR("INKHttpTxnReenable");
+/* TSHttpTxnServerIntercept(new_cont, txnp); */
+ if (TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE) == TS_ERROR) {
+ LOG_ERROR("TSHttpTxnReenable");
return -1;
}
return 0;
@@ -342,7 +342,7 @@ int
check_ts_version()
{
- const char *ts_version = INKTrafficServerVersionGet();
+ const char *ts_version = TSTrafficServerVersionGet();
int result = 0;
if (ts_version) {
@@ -375,7 +375,7 @@ load_file(char *file_name)
fd = open(file_name, O_RDONLY);
if (fd < 0) {
- INKError("Failed to open file %s : (%d)", file_name, errno);
+ TSError("Failed to open file %s : (%d)", file_name, errno);
return 0;
}
@@ -384,7 +384,7 @@ load_file(char *file_name)
return 0;
}
- buf = (char *) INKmalloc(finfo.st_size + 1);
+ buf = (char *) TSmalloc(finfo.st_size + 1);
r = read(fd, buf, finfo.st_size);
if (r < 0) {
@@ -400,58 +400,58 @@ load_file(char *file_name)
}
void
-INKPluginInit(int argc, const char *argv[])
+TSPluginInit(int argc, const char *argv[])
{
- LOG_SET_FUNCTION_NAME("INKPluginInit");
+ LOG_SET_FUNCTION_NAME("TSPluginInit");
- INKMLoc field_loc;
+ TSMLoc field_loc;
const char *p;
int i;
- INKPluginRegistrationInfo info;
- INKCont contp;
+ TSPluginRegistrationInfo info;
+ TSCont contp;
info.plugin_name = "test-pos";
info.vendor_name = "MyCompany";
info.support_email = "ts-api-support@MyCompany.com";
-/* NEGATIVE TEST for INKPluginRegister */
+/* NEGATIVE TEST for TSPluginRegister */
#ifdef DEBUG
- if (INKPluginRegister(INK_SDK_VERSION_2_0, NULL) != 0) {
- LOG_ERROR_NEG("INKPluginRegister");
+ if (TSPluginRegister(TS_SDK_VERSION_2_0, NULL) != 0) {
+ LOG_ERROR_NEG("TSPluginRegister");
} else
- INKDebug(NEG_DEBUG_TAG, "Negative Test INKPluginRegister 1 passed");
+ TSDebug(NEG_DEBUG_TAG, "Negative Test TSPluginRegister 1 passed");
#endif
- if (!INKPluginRegister(INK_SDK_VERSION_2_0, &info)) {
- INKError("Plugin registration failed.\n");
+ if (!TSPluginRegister(TS_SDK_VERSION_2_0, &info)) {
+ TSError("Plugin registration failed.\n");
}
if (!check_ts_version()) {
- INKError("Plugin requires Traffic Server 2.0 or later\n");
+ TSError("Plugin requires Traffic Server 2.0 or later\n");
return;
}
if (argc != 2) {
- INKError("Need file name arguement");
+ TSError("Need file name arguement");
}
if (load_file((char *) argv[1]) > 0) {
- contp = INKContCreate(attach_pvc_plugin, NULL);
- if (contp == INK_ERROR_PTR) {
- LOG_ERROR("INKContCreate");
+ contp = TSContCreate(attach_pvc_plugin, NULL);
+ if (contp == TS_ERROR_PTR) {
+ LOG_ERROR("TSContCreate");
} else {
- if (INKHttpHookAdd(INK_HTTP_READ_REQUEST_HDR_HOOK, contp) == INK_ERROR) {
- LOG_ERROR("INKHttpHookAdd");
+ if (TSHttpHookAdd(TS_HTTP_READ_REQUEST_HDR_HOOK, contp) == TS_ERROR) {
+ LOG_ERROR("TSHttpHookAdd");
}
}
} else {
fprintf(stderr, "Failed to load file %s\n", argv[1]);
- INKError("Failed to load file %s", argv[1]);
+ TSError("Failed to load file %s", argv[1]);
}
}
/* Plugin needs license in order to be loaded */
int
-INKPluginLicenseRequired(void)
+TSPluginLicenseRequired(void)
{
return 1;
}
Modified: trafficserver/traffic/trunk/test/plugin/plugin_as_origin/test_dealloc.c
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/test/plugin/plugin_as_origin/test_dealloc.c?rev=1035782&r1=1035781&r2=1035782&view=diff
==============================================================================
--- trafficserver/traffic/trunk/test/plugin/plugin_as_origin/test_dealloc.c (original)
+++ trafficserver/traffic/trunk/test/plugin/plugin_as_origin/test_dealloc.c Tue Nov 16 20:22:02 2010
@@ -35,40 +35,40 @@
#include "ts.h"
static int
-test_destroy_plugin(INKCont contp, INKEvent event, void *edata)
+test_destroy_plugin(TSCont contp, TSEvent event, void *edata)
{
- INKHttpTxn txnp = (INKHttpTxn) edata;
+ TSHttpTxn txnp = (TSHttpTxn) edata;
- if (event == INK_EVENT_HTTP_TXN_CLOSE) {
- INKContDestroy(contp);
- INKHttpTxnReenable(txnp, INK_EVENT_HTTP_CONTINUE);
+ if (event == TS_EVENT_HTTP_TXN_CLOSE) {
+ TSContDestroy(contp);
+ TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE);
} else {
- INKAssert(0);
+ TSAssert(0);
}
return 0;
}
static int
-attach_test(INKCont contp, INKEvent event, void *edata)
+attach_test(TSCont contp, TSEvent event, void *edata)
{
- INKHttpTxn txnp = (INKHttpTxn) edata;
- INKCont new_cont;
+ TSHttpTxn txnp = (TSHttpTxn) edata;
+ TSCont new_cont;
switch (event) {
- case INK_EVENT_HTTP_READ_REQUEST_HDR:
- new_cont = INKContCreate(test_destroy_plugin, INKMutexCreate());
- INKHttpTxnHookAdd(txnp, INK_HTTP_TXN_CLOSE_HOOK, new_cont);
- INKHttpTxnReenable(txnp, INK_EVENT_HTTP_CONTINUE);
+ case TS_EVENT_HTTP_READ_REQUEST_HDR:
+ new_cont = TSContCreate(test_destroy_plugin, TSMutexCreate());
+ TSHttpTxnHookAdd(txnp, TS_HTTP_TXN_CLOSE_HOOK, new_cont);
+ TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE);
break;
default:
- INKAssert(0);
+ TSAssert(0);
}
return 0;
}
void
-INKPluginInit(int argc, const char *argv[])
+TSPluginInit(int argc, const char *argv[])
{
- INKHttpHookAdd(INK_HTTP_READ_REQUEST_HDR_HOOK, INKContCreate(attach_test, NULL));
+ TSHttpHookAdd(TS_HTTP_READ_REQUEST_HDR_HOOK, TSContCreate(attach_test, NULL));
}
Modified: trafficserver/traffic/trunk/test/plugin/redirect-1-neg/redirect-1-neg.c
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/test/plugin/redirect-1-neg/redirect-1-neg.c?rev=1035782&r1=1035781&r2=1035782&view=diff
==============================================================================
--- trafficserver/traffic/trunk/test/plugin/redirect-1-neg/redirect-1-neg.c (original)
+++ trafficserver/traffic/trunk/test/plugin/redirect-1-neg/redirect-1-neg.c Tue Nov 16 20:22:02 2010
@@ -54,17 +54,17 @@ static unsigned int ip_deny;
/*
* uncoupled statistics variables:
*/
-static INKStat method_count_redirected_connect;
-static INKStat method_count_redirected_delete;
-static INKStat method_count_redirected_get;
-static INKStat method_count_redirected_head;
-static INKStat method_count_redirected_icp_query;
-static INKStat method_count_redirected_options;
-static INKStat method_count_redirected_post;
-static INKStat method_count_redirected_purge;
-static INKStat method_count_redirected_put;
-static INKStat method_count_redirected_trace;
-static INKStat method_count_redirected_unknown;
+static TSStat method_count_redirected_connect;
+static TSStat method_count_redirected_delete;
+static TSStat method_count_redirected_get;
+static TSStat method_count_redirected_head;
+static TSStat method_count_redirected_icp_query;
+static TSStat method_count_redirected_options;
+static TSStat method_count_redirected_post;
+static TSStat method_count_redirected_purge;
+static TSStat method_count_redirected_put;
+static TSStat method_count_redirected_trace;
+static TSStat method_count_redirected_unknown;
/*
@@ -73,13 +73,13 @@ static INKStat method_count_redirected_u
* is request_outcomes. The relationship among the stats is:
* requests_all = requests_redirects + requests_unchanged
*/
-static INKCoupledStat request_outcomes;
-static INKStat requests_all;
-static INKStat requests_redirects;
-static INKStat requests_unchanged;
+static TSCoupledStat request_outcomes;
+static TSStat requests_all;
+static TSStat requests_redirects;
+static TSStat requests_unchanged;
-void update_redirected_method_stats(INKMBuffer bufp, INKMLoc hdr_loc);
+void update_redirected_method_stats(TSMBuffer bufp, TSMLoc hdr_loc);
static char *url_redirect;
static char *uri_redirect;
@@ -89,15 +89,15 @@ static char *block_ip;
#define LOG_SET_FUNCTION_NAME(NAME) const char * FUNCTION_NAME = NAME
#define LOG_ERROR_NEG(API_NAME) { \
- INKDebug(PLUGIN_NAME, "%s: %s %s %s File %s, line number %d",PLUGIN_NAME, API_NAME, "NEGAPIFAIL", \
+ TSDebug(PLUGIN_NAME, "%s: %s %s %s File %s, line number %d",PLUGIN_NAME, API_NAME, "NEGAPIFAIL", \
FUNCTION_NAME, __FILE__, __LINE__); \
}
static void
-handle_client_lookup(INKHttpTxn txnp, INKCont contp)
+handle_client_lookup(TSHttpTxn txnp, TSCont contp)
{
- INKMBuffer bufp;
- INKMLoc hdr_loc, url_loc;
+ TSMBuffer bufp;
+ TSMLoc hdr_loc, url_loc;
int host_length;
#if !defined (_WIN32)
@@ -113,27 +113,27 @@ handle_client_lookup(INKHttpTxn txnp, IN
/*
* Here we declare local coupled statistics variables:
*/
- INKCoupledStat local_request_outcomes;
- INKStat local_requests_all;
- INKStat local_requests_redirects;
- INKStat local_requests_unchanged;
+ TSCoupledStat local_request_outcomes;
+ TSStat local_requests_all;
+ TSStat local_requests_redirects;
+ TSStat local_requests_unchanged;
LOG_SET_FUNCTION_NAME("handle_client_lookup");
/*
* Create local copy of the global coupled stat category:
*/
- local_request_outcomes = INKStatCoupledLocalCopyCreate("local_request_outcomes", request_outcomes);
+ local_request_outcomes = TSStatCoupledLocalCopyCreate("local_request_outcomes", request_outcomes);
/*
* Create the local copies of the global coupled stats:
*/
- local_requests_all = INKStatCoupledLocalAdd(local_request_outcomes, "requests.all.local", INKSTAT_TYPE_FLOAT);
- local_requests_redirects = INKStatCoupledLocalAdd(local_request_outcomes,
- "requests.redirects.local", INKSTAT_TYPE_INT64);
- local_requests_unchanged = INKStatCoupledLocalAdd(local_request_outcomes,
- "requests.unchanged.local", INKSTAT_TYPE_INT64);
+ local_requests_all = TSStatCoupledLocalAdd(local_request_outcomes, "requests.all.local", TSSTAT_TYPE_FLOAT);
+ local_requests_redirects = TSStatCoupledLocalAdd(local_request_outcomes,
+ "requests.redirects.local", TSSTAT_TYPE_INT64);
+ local_requests_unchanged = TSStatCoupledLocalAdd(local_request_outcomes,
+ "requests.unchanged.local", TSSTAT_TYPE_INT64);
/*
@@ -142,60 +142,60 @@ handle_client_lookup(INKHttpTxn txnp, IN
* integer, but we declare this a FLOAT in order to demonstrate
* how to increment coupled FLOAT stats)
*/
- INKStatFloatAddTo(local_requests_all, 1.0);
+ TSStatFloatAddTo(local_requests_all, 1.0);
/* negative test */
#ifdef DEBUG
- if (INKStatCoupledLocalCopyCreate(NULL, request_outcomes) != INK_ERROR_PTR) {
- LOG_ERROR_NEG("INKStatCoupledLocalCopyCreate");
+ if (TSStatCoupledLocalCopyCreate(NULL, request_outcomes) != TS_ERROR_PTR) {
+ LOG_ERROR_NEG("TSStatCoupledLocalCopyCreate");
}
- if (INKStatCoupledLocalCopyCreate("my_local_copy", NULL) != INK_ERROR_PTR) {
- LOG_ERROR_NEG("INKStatCoupledLocalCopyCreate");
+ if (TSStatCoupledLocalCopyCreate("my_local_copy", NULL) != TS_ERROR_PTR) {
+ LOG_ERROR_NEG("TSStatCoupledLocalCopyCreate");
}
- if (INKStatCoupledLocalAdd(NULL, "requests.negtest", INKSTAT_TYPE_INT64) != INK_ERROR_PTR) {
- LOG_ERROR_NEG("INKStatCoupledLocalAdd");
+ if (TSStatCoupledLocalAdd(NULL, "requests.negtest", TSSTAT_TYPE_INT64) != TS_ERROR_PTR) {
+ LOG_ERROR_NEG("TSStatCoupledLocalAdd");
}
- if (INKStatCoupledLocalAdd(local_request_outcomes, NULL, INKSTAT_TYPE_INT64) != INK_ERROR_PTR) {
- LOG_ERROR_NEG("INKStatCoupledLocalAdd");
+ if (TSStatCoupledLocalAdd(local_request_outcomes, NULL, TSSTAT_TYPE_INT64) != TS_ERROR_PTR) {
+ LOG_ERROR_NEG("TSStatCoupledLocalAdd");
}
- if (INKStatFloatAddTo(NULL, 1.0) != INK_ERROR) {
- LOG_ERROR_NEG("INKStatFloatAddTo");
+ if (TSStatFloatAddTo(NULL, 1.0) != TS_ERROR) {
+ LOG_ERROR_NEG("TSStatFloatAddTo");
}
- if (INKHttpTxnClientIPGet(NULL) != 0) {
- LOG_ERROR_NEG("INKHttpTxnClientIPGet");
+ if (TSHttpTxnClientIPGet(NULL) != 0) {
+ LOG_ERROR_NEG("TSHttpTxnClientIPGet");
}
#endif
#if !defined (_WIN32)
- clientip = (in_addr_t) INKHttpTxnClientIPGet(txnp);
+ clientip = (in_addr_t) TSHttpTxnClientIPGet(txnp);
#else
- clientip = INKHttpTxnClientIPGet(txnp);
+ clientip = TSHttpTxnClientIPGet(txnp);
#endif
tempstruct.s_addr = clientip;
clientstring = inet_ntoa(tempstruct);
- INKDebug("redirect", "clientip is %s and block_ip is %s", clientstring, block_ip);
+ TSDebug("redirect", "clientip is %s and block_ip is %s", clientstring, block_ip);
- if (!INKHttpTxnClientReqGet(txnp, &bufp, &hdr_loc)) {
- INKError("couldn't retrieve client request header\n");
+ if (!TSHttpTxnClientReqGet(txnp, &bufp, &hdr_loc)) {
+ TSError("couldn't retrieve client request header\n");
goto done;
}
- url_loc = INKHttpHdrUrlGet(bufp, hdr_loc);
+ url_loc = TSHttpHdrUrlGet(bufp, hdr_loc);
if (!url_loc) {
- INKError("couldn't retrieve request url\n");
- INKHandleMLocRelease(bufp, INK_NULL_MLOC, hdr_loc);
+ TSError("couldn't retrieve request url\n");
+ TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
goto done;
}
- host = INKUrlHostGet(bufp, url_loc, &host_length);
+ host = TSUrlHostGet(bufp, url_loc, &host_length);
if (!host) {
- INKError("couldn't retrieve request hostname\n");
- INKHandleMLocRelease(bufp, hdr_loc, url_loc);
- INKHandleMLocRelease(bufp, INK_NULL_MLOC, hdr_loc);
+ TSError("couldn't retrieve request hostname\n");
+ TSHandleMLocRelease(bufp, hdr_loc, url_loc);
+ TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
goto done;
}
@@ -203,30 +203,30 @@ handle_client_lookup(INKHttpTxn txnp, IN
* Check to see if the client is already headed to the redirect site.
*/
if (strncmp(host, url_redirect, host_length) == 0) {
- INKHandleStringRelease(bufp, url_loc, host);
- INKHandleMLocRelease(bufp, hdr_loc, url_loc);
- INKHandleMLocRelease(bufp, INK_NULL_MLOC, hdr_loc);
+ TSHandleStringRelease(bufp, url_loc, host);
+ TSHandleMLocRelease(bufp, hdr_loc, url_loc);
+ TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
goto done;
}
if (ip_deny == clientip) {
- INKHttpTxnHookAdd(txnp, INK_HTTP_SEND_RESPONSE_HDR_HOOK, contp);
- INKHandleStringRelease(bufp, url_loc, host);
+ TSHttpTxnHookAdd(txnp, TS_HTTP_SEND_RESPONSE_HDR_HOOK, contp);
+ TSHandleStringRelease(bufp, url_loc, host);
update_redirected_method_stats(bufp, hdr_loc);
- INKHandleMLocRelease(bufp, hdr_loc, url_loc);
- INKHandleMLocRelease(bufp, INK_NULL_MLOC, hdr_loc);
+ TSHandleMLocRelease(bufp, hdr_loc, url_loc);
+ TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
/*
* Increment the local redirect stat and do global update:
*/
- INKStatIncrement(local_requests_redirects);
- INKStatsCoupledUpdate(local_request_outcomes);
- INKStatCoupledLocalCopyDestroy(local_request_outcomes);
+ TSStatIncrement(local_requests_redirects);
+ TSStatsCoupledUpdate(local_request_outcomes);
+ TSStatCoupledLocalCopyDestroy(local_request_outcomes);
- INKHttpTxnReenable(txnp, INK_EVENT_HTTP_ERROR);
+ TSHttpTxnReenable(txnp, TS_EVENT_HTTP_ERROR);
return;
}
@@ -234,81 +234,81 @@ done:
/*
* Increment the local number unchanged stat and do global update:
*/
- INKStatIncrement(local_requests_unchanged);
- INKStatsCoupledUpdate(local_request_outcomes);
- INKStatCoupledLocalCopyDestroy(local_request_outcomes);
+ TSStatIncrement(local_requests_unchanged);
+ TSStatsCoupledUpdate(local_request_outcomes);
+ TSStatCoupledLocalCopyDestroy(local_request_outcomes);
/* negative test */
#ifdef DEBUG
- if (INKStatsCoupledUpdate(NULL) != INK_ERROR) {
- LOG_ERROR_NEG("INKStatsCoupledUpdate");
+ if (TSStatsCoupledUpdate(NULL) != TS_ERROR) {
+ LOG_ERROR_NEG("TSStatsCoupledUpdate");
}
- if (INKStatCoupledLocalCopyDestroy(NULL) != INK_ERROR) {
- LOG_ERROR_NEG("INKStatCoupledLocalCopyDestroy");
+ if (TSStatCoupledLocalCopyDestroy(NULL) != TS_ERROR) {
+ LOG_ERROR_NEG("TSStatCoupledLocalCopyDestroy");
}
#endif
- INKHttpTxnReenable(txnp, INK_EVENT_HTTP_CONTINUE);
+ TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE);
}
static void
-handle_response(INKHttpTxn txnp)
+handle_response(TSHttpTxn txnp)
{
- INKMBuffer bufp;
- INKMLoc hdr_loc, newfield_loc;
- INKMLoc url_loc;
+ TSMBuffer bufp;
+ TSMLoc hdr_loc, newfield_loc;
+ TSMLoc url_loc;
char *url_str;
char *buf;
char *errormsg_body = "All requests from this IP address are redirected.\n";
char *tmp_body;
- if (!INKHttpTxnClientRespGet(txnp, &bufp, &hdr_loc)) {
- INKError("couldn't retrieve client response header\n");
+ if (!TSHttpTxnClientRespGet(txnp, &bufp, &hdr_loc)) {
+ TSError("couldn't retrieve client response header\n");
goto done;
}
- INKHttpHdrStatusSet(bufp, hdr_loc, INK_HTTP_STATUS_MOVED_PERMANENTLY);
- INKHttpHdrReasonSet(bufp, hdr_loc,
- INKHttpHdrReasonLookup(INK_HTTP_STATUS_MOVED_PERMANENTLY),
- strlen(INKHttpHdrReasonLookup(INK_HTTP_STATUS_MOVED_PERMANENTLY)));
-
- newfield_loc = INKMimeHdrFieldCreate(bufp, hdr_loc);
- INKMimeHdrFieldNameSet(bufp, hdr_loc, newfield_loc, INK_MIME_FIELD_LOCATION, INK_MIME_LEN_LOCATION);
- INKMimeHdrFieldValueStringInsert(bufp, hdr_loc, newfield_loc, uri_redirect, strlen(uri_redirect), -1);
- INKMimeHdrFieldAppend(bufp, hdr_loc, newfield_loc);
+ TSHttpHdrStatusSet(bufp, hdr_loc, TS_HTTP_STATUS_MOVED_PERMANENTLY);
+ TSHttpHdrReasonSet(bufp, hdr_loc,
+ TSHttpHdrReasonLookup(TS_HTTP_STATUS_MOVED_PERMANENTLY),
+ strlen(TSHttpHdrReasonLookup(TS_HTTP_STATUS_MOVED_PERMANENTLY)));
+
+ newfield_loc = TSMimeHdrFieldCreate(bufp, hdr_loc);
+ TSMimeHdrFieldNameSet(bufp, hdr_loc, newfield_loc, TS_MIME_FIELD_LOCATION, TS_MIME_LEN_LOCATION);
+ TSMimeHdrFieldValueStringInsert(bufp, hdr_loc, newfield_loc, uri_redirect, strlen(uri_redirect), -1);
+ TSMimeHdrFieldAppend(bufp, hdr_loc, newfield_loc);
/*
- * Note that we can't directly use errormsg_body, as INKHttpTxnErrorBodySet()
- * will try to free the passed buffer with INKfree().
+ * Note that we can't directly use errormsg_body, as TSHttpTxnErrorBodySet()
+ * will try to free the passed buffer with TSfree().
*/
- tmp_body = INKstrdup(errormsg_body);
- INKHttpTxnErrorBodySet(txnp, tmp_body, strlen(tmp_body), NULL);
- INKHandleMLocRelease(bufp, hdr_loc, newfield_loc);
- INKHandleMLocRelease(bufp, INK_NULL_MLOC, hdr_loc);
+ tmp_body = TSstrdup(errormsg_body);
+ TSHttpTxnErrorBodySet(txnp, tmp_body, strlen(tmp_body), NULL);
+ TSHandleMLocRelease(bufp, hdr_loc, newfield_loc);
+ TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
done:
- INKHttpTxnReenable(txnp, INK_EVENT_HTTP_CONTINUE);
+ TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE);
}
static int
-redirect_plugin(INKCont contp, INKEvent event, void *edata)
+redirect_plugin(TSCont contp, TSEvent event, void *edata)
{
- INKHttpTxn txnp = (INKHttpTxn) edata;
+ TSHttpTxn txnp = (TSHttpTxn) edata;
switch (event) {
- case INK_EVENT_HTTP_READ_REQUEST_HDR:
+ case TS_EVENT_HTTP_READ_REQUEST_HDR:
handle_client_lookup(txnp, contp);
return 0;
- case INK_EVENT_HTTP_SEND_RESPONSE_HDR:
+ case TS_EVENT_HTTP_SEND_RESPONSE_HDR:
handle_response(txnp);
return 0;
@@ -332,35 +332,35 @@ init_stats(void)
LOG_SET_FUNCTION_NAME("init_stats");
/* noncoupled: */
- method_count_redirected_connect = INKStatCreate("method.count.redirected.connect", INKSTAT_TYPE_INT64);
- method_count_redirected_delete = INKStatCreate("method.count.redirected.delete", INKSTAT_TYPE_INT64);
- method_count_redirected_get = INKStatCreate("method.count.redirected.get", INKSTAT_TYPE_INT64);
- method_count_redirected_head = INKStatCreate("method.count.redirected.head", INKSTAT_TYPE_FLOAT);
- method_count_redirected_icp_query = INKStatCreate("method.count.redirected.icp_query", INKSTAT_TYPE_FLOAT);
- method_count_redirected_options = INKStatCreate("method.count.redirected.options", INKSTAT_TYPE_INT64);
- method_count_redirected_post = INKStatCreate("method.count.redirected.post", INKSTAT_TYPE_INT64);
- method_count_redirected_purge = INKStatCreate("method.count.redirected.purge", INKSTAT_TYPE_INT64);
- method_count_redirected_put = INKStatCreate("method.count.redirected.put", INKSTAT_TYPE_INT64);
- method_count_redirected_trace = INKStatCreate("method.count.redirected.trace", INKSTAT_TYPE_INT64);
- method_count_redirected_unknown = INKStatCreate("method.count.redirected.unknown", INKSTAT_TYPE_INT64);
+ method_count_redirected_connect = TSStatCreate("method.count.redirected.connect", TSSTAT_TYPE_INT64);
+ method_count_redirected_delete = TSStatCreate("method.count.redirected.delete", TSSTAT_TYPE_INT64);
+ method_count_redirected_get = TSStatCreate("method.count.redirected.get", TSSTAT_TYPE_INT64);
+ method_count_redirected_head = TSStatCreate("method.count.redirected.head", TSSTAT_TYPE_FLOAT);
+ method_count_redirected_icp_query = TSStatCreate("method.count.redirected.icp_query", TSSTAT_TYPE_FLOAT);
+ method_count_redirected_options = TSStatCreate("method.count.redirected.options", TSSTAT_TYPE_INT64);
+ method_count_redirected_post = TSStatCreate("method.count.redirected.post", TSSTAT_TYPE_INT64);
+ method_count_redirected_purge = TSStatCreate("method.count.redirected.purge", TSSTAT_TYPE_INT64);
+ method_count_redirected_put = TSStatCreate("method.count.redirected.put", TSSTAT_TYPE_INT64);
+ method_count_redirected_trace = TSStatCreate("method.count.redirected.trace", TSSTAT_TYPE_INT64);
+ method_count_redirected_unknown = TSStatCreate("method.count.redirected.unknown", TSSTAT_TYPE_INT64);
/* coupled: */
- request_outcomes = INKStatCoupledGlobalCategoryCreate("request_outcomes");
- requests_all = INKStatCoupledGlobalAdd(request_outcomes, "requests.all", INKSTAT_TYPE_FLOAT);
- requests_redirects = INKStatCoupledGlobalAdd(request_outcomes, "requests.redirects", INKSTAT_TYPE_INT64);
- requests_unchanged = INKStatCoupledGlobalAdd(request_outcomes, "requests.unchanged", INKSTAT_TYPE_INT64);
+ request_outcomes = TSStatCoupledGlobalCategoryCreate("request_outcomes");
+ requests_all = TSStatCoupledGlobalAdd(request_outcomes, "requests.all", TSSTAT_TYPE_FLOAT);
+ requests_redirects = TSStatCoupledGlobalAdd(request_outcomes, "requests.redirects", TSSTAT_TYPE_INT64);
+ requests_unchanged = TSStatCoupledGlobalAdd(request_outcomes, "requests.unchanged", TSSTAT_TYPE_INT64);
/* negative test */
#ifdef DEBUG
- if (INKStatCoupledGlobalCategoryCreate(NULL) != INK_ERROR_PTR) {
- LOG_ERROR_NEG("INKStatCoupledGlobalCategoryCreate");
+ if (TSStatCoupledGlobalCategoryCreate(NULL) != TS_ERROR_PTR) {
+ LOG_ERROR_NEG("TSStatCoupledGlobalCategoryCreate");
}
- if (INKStatCoupledGlobalAdd(NULL, "requests.mytest", INKSTAT_TYPE_INT64) != INK_ERROR_PTR) {
- LOG_ERROR_NEG("INKStatCoupledGlobalAdd");
+ if (TSStatCoupledGlobalAdd(NULL, "requests.mytest", TSSTAT_TYPE_INT64) != TS_ERROR_PTR) {
+ LOG_ERROR_NEG("TSStatCoupledGlobalAdd");
}
- if (INKStatCoupledGlobalAdd(request_outcomes, NULL, INKSTAT_TYPE_INT64) != INK_ERROR_PTR) {
- LOG_ERROR_NEG("INKStatCoupledGlobalAdd");
+ if (TSStatCoupledGlobalAdd(request_outcomes, NULL, TSSTAT_TYPE_INT64) != TS_ERROR_PTR) {
+ LOG_ERROR_NEG("TSStatCoupledGlobalAdd");
}
#endif
}
@@ -368,61 +368,61 @@ init_stats(void)
/*
* This function is only called for redirected requests. It illustrates
* several different ways of updating INT64 stats. Some may consider
- * the particular use of INKDecrementStat() shown below somewhat contrived.
+ * the particular use of TSDecrementStat() shown below somewhat contrived.
*/
void
-update_redirected_method_stats(INKMBuffer bufp, INKMLoc hdr_loc)
+update_redirected_method_stats(TSMBuffer bufp, TSMLoc hdr_loc)
{
const char *txn_method;
int length;
- INK64 tempint;
+ TS64 tempint;
LOG_SET_FUNCTION_NAME("update_redirected_method_stats");
- txn_method = INKHttpHdrMethodGet(bufp, hdr_loc, &length);
+ txn_method = TSHttpHdrMethodGet(bufp, hdr_loc, &length);
if (NULL != txn_method) {
- if (0 == strncmp(txn_method, INK_HTTP_METHOD_CONNECT, length))
- INKStatIncrement(method_count_redirected_connect);
- else if (0 == strncmp(txn_method, INK_HTTP_METHOD_DELETE, length))
- INKStatIncrement(method_count_redirected_delete);
- else if (0 == strncmp(txn_method, INK_HTTP_METHOD_GET, length))
- INKStatIncrement(method_count_redirected_get);
-
- else if (0 == strncmp(txn_method, INK_HTTP_METHOD_HEAD, length))
- INKStatFloatAddTo(method_count_redirected_head, 1);
- else if (0 == strncmp(txn_method, INK_HTTP_METHOD_ICP_QUERY, length))
- INKStatFloatAddTo(method_count_redirected_icp_query, 1);
+ if (0 == strncmp(txn_method, TS_HTTP_METHOD_CONNECT, length))
+ TSStatIncrement(method_count_redirected_connect);
+ else if (0 == strncmp(txn_method, TS_HTTP_METHOD_DELETE, length))
+ TSStatIncrement(method_count_redirected_delete);
+ else if (0 == strncmp(txn_method, TS_HTTP_METHOD_GET, length))
+ TSStatIncrement(method_count_redirected_get);
+
+ else if (0 == strncmp(txn_method, TS_HTTP_METHOD_HEAD, length))
+ TSStatFloatAddTo(method_count_redirected_head, 1);
+ else if (0 == strncmp(txn_method, TS_HTTP_METHOD_ICP_QUERY, length))
+ TSStatFloatAddTo(method_count_redirected_icp_query, 1);
- else if (0 == strncmp(txn_method, INK_HTTP_METHOD_OPTIONS, length)) {
- INKStatIntGet(method_count_redirected_options, tempint);
+ else if (0 == strncmp(txn_method, TS_HTTP_METHOD_OPTIONS, length)) {
+ TSStatIntGet(method_count_redirected_options, tempint);
tempint++;
- INKStatIntSet(method_count_redirected_options, tempint);
- } else if (0 == strncmp(txn_method, INK_HTTP_METHOD_POST, length)) {
- INKStatDecrement(method_count_redirected_post);
- INKStatIncrement(method_count_redirected_post);
- INKStatIncrement(method_count_redirected_post);
+ TSStatIntSet(method_count_redirected_options, tempint);
+ } else if (0 == strncmp(txn_method, TS_HTTP_METHOD_POST, length)) {
+ TSStatDecrement(method_count_redirected_post);
+ TSStatIncrement(method_count_redirected_post);
+ TSStatIncrement(method_count_redirected_post);
}
- else if (0 == strncmp(txn_method, INK_HTTP_METHOD_PURGE, length))
- INKStatIncrement(method_count_redirected_purge);
- else if (0 == strncmp(txn_method, INK_HTTP_METHOD_PUT, length))
- INKStatIncrement(method_count_redirected_put);
- else if (0 == strncmp(txn_method, INK_HTTP_METHOD_TRACE, length))
- INKStatIncrement(method_count_redirected_trace);
+ else if (0 == strncmp(txn_method, TS_HTTP_METHOD_PURGE, length))
+ TSStatIncrement(method_count_redirected_purge);
+ else if (0 == strncmp(txn_method, TS_HTTP_METHOD_PUT, length))
+ TSStatIncrement(method_count_redirected_put);
+ else if (0 == strncmp(txn_method, TS_HTTP_METHOD_TRACE, length))
+ TSStatIncrement(method_count_redirected_trace);
else
- INKStatIncrement(method_count_redirected_unknown);
+ TSStatIncrement(method_count_redirected_unknown);
}
- INKHandleStringRelease(bufp, hdr_loc, txn_method);
+ TSHandleStringRelease(bufp, hdr_loc, txn_method);
/* negative test */
#ifdef DEBUG
- if (INKStatIntSet(NULL, 0) != INK_ERROR) {
- LOG_ERROR_NEG("INKStatIntSet");
+ if (TSStatIntSet(NULL, 0) != TS_ERROR) {
+ LOG_ERROR_NEG("TSStatIntSet");
}
- if (INKStatDecrement(NULL) != INK_ERROR) {
- LOG_ERROR_NEG("INKStatDecrement");
+ if (TSStatDecrement(NULL) != TS_ERROR) {
+ LOG_ERROR_NEG("TSStatDecrement");
}
#endif
@@ -432,7 +432,7 @@ int
check_ts_version()
{
- const char *ts_version = INKTrafficServerVersionGet();
+ const char *ts_version = TSTrafficServerVersionGet();
int result = 0;
if (ts_version) {
@@ -455,52 +455,52 @@ check_ts_version()
}
void
-INKPluginInit(int argc, const char *argv[])
+TSPluginInit(int argc, const char *argv[])
{
const char prefix[] = "http://";
int uri_len;
- INKPluginRegistrationInfo info;
+ TSPluginRegistrationInfo info;
info.plugin_name = "redirect-1";
info.vendor_name = "MyCompany";
info.support_email = "ts-api-support@MyCompany.com";
- if (!INKPluginRegister(INK_SDK_VERSION_2_0, &info)) {
- INKError("Plugin registration failed.\n");
+ if (!TSPluginRegister(TS_SDK_VERSION_2_0, &info)) {
+ TSError("Plugin registration failed.\n");
}
if (!check_ts_version()) {
- INKError("Plugin requires Traffic Server 2.0 or later\n");
+ TSError("Plugin requires Traffic Server 2.0 or later\n");
return;
}
if (argc == 3) {
- block_ip = INKstrdup(argv[1]);
+ block_ip = TSstrdup(argv[1]);
/*
* The Location header must contain an absolute URI:
*/
- url_redirect = INKstrdup(argv[2]);
+ url_redirect = TSstrdup(argv[2]);
uri_len = strlen(prefix) + strlen(url_redirect) + 1;
- uri_redirect = INKmalloc(uri_len);
+ uri_redirect = TSmalloc(uri_len);
strcpy(uri_redirect, prefix);
strcat(uri_redirect, url_redirect);
} else {
- INKError("Incorrect syntax in plugin.conf: correct usage is" "redirect-1.so ip_deny url_redirect");
+ TSError("Incorrect syntax in plugin.conf: correct usage is" "redirect-1.so ip_deny url_redirect");
return;
}
ip_deny = inet_addr(block_ip);
- INKHttpHookAdd(INK_HTTP_READ_REQUEST_HDR_HOOK, INKContCreate(redirect_plugin, NULL));
+ TSHttpHookAdd(TS_HTTP_READ_REQUEST_HDR_HOOK, TSContCreate(redirect_plugin, NULL));
- INKDebug("redirect_init", "block_ip is %s, url_redirect is %s, and uri_redirect is %s",
+ TSDebug("redirect_init", "block_ip is %s, url_redirect is %s, and uri_redirect is %s",
block_ip, url_redirect, uri_redirect);
- INKDebug("redirect_init", "ip_deny is %ld\n", ip_deny);
+ TSDebug("redirect_init", "ip_deny is %ld\n", ip_deny);
- INKDebug("redirect_init", "initializing stats...");
+ TSDebug("redirect_init", "initializing stats...");
init_stats();
@@ -510,8 +510,8 @@ INKPluginInit(int argc, const char *argv
* be done in debug mode.
*/
- if (INKIsDebugTagSet("redirect_demo"))
- INKDebug("redirect_init", "The redirect_demo tag is set");
+ if (TSIsDebugTagSet("redirect_demo"))
+ TSDebug("redirect_init", "The redirect_demo tag is set");
else
- INKDebug("redirect_init", "The redirect_demo tag is not set");
+ TSDebug("redirect_init", "The redirect_demo tag is not set");
}
Modified: trafficserver/traffic/trunk/test/plugin/session-2/session-2.c
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/test/plugin/session-2/session-2.c?rev=1035782&r1=1035781&r2=1035782&view=diff
==============================================================================
--- trafficserver/traffic/trunk/test/plugin/session-2/session-2.c (original)
+++ trafficserver/traffic/trunk/test/plugin/session-2/session-2.c Tue Nov 16 20:22:02 2010
@@ -23,16 +23,16 @@
/********************************************************************************
* This plugin tries to cover the APIs in the following categories:
-* -- INKHttpSsn*
-* -- INKConfig*
-* -- INKStat*
-* -- INKThread*
+* -- TSHttpSsn*
+* -- TSConfig*
+* -- TSStat*
+* -- TSThread*
*
* It does the following things:
-* 1. Create a thread and destroy it in INKPluginInit()
-* 2. Create three INKStat statistic variables transaction_count, session_count
+* 1. Create a thread and destroy it in TSPluginInit()
+* 2. Create three TSStat statistic variables transaction_count, session_count
* and avg_transactions and update them at every new session or transaction.
-* 3. Play with INKConfig family of functions to set and get config data.
+* 3. Play with TSConfig family of functions to set and get config data.
******************************************************************************/
#include <stdio.h>
#include <pthread.h>
@@ -42,10 +42,10 @@
#define SLEEP_TIME 10
#define PLUGIN_NAME "session-2"
-#define VALID_POINTER(X) ((X != NULL) && (X != INK_ERROR_PTR))
+#define VALID_POINTER(X) ((X != NULL) && (X != TS_ERROR_PTR))
#define LOG_SET_FUNCTION_NAME(NAME) const char * FUNCTION_NAME = NAME
#define LOG_ERROR(API_NAME) { \
- INKDebug(PLUGIN_NAME, "%s: %s %s %s File %s, line number %d", PLUGIN_NAME, API_NAME, "APIFAIL", \
+ TSDebug(PLUGIN_NAME, "%s: %s %s %s File %s, line number %d", PLUGIN_NAME, API_NAME, "APIFAIL", \
FUNCTION_NAME, __FILE__, __LINE__); \
}
#define LOG_ERROR_AND_RETURN(API_NAME) { \
@@ -58,26 +58,26 @@
}
#define LOG_ERROR_AND_REENABLE(API_NAME) { \
LOG_ERROR(API_NAME); \
- INKHttpTxnReenable(txnp, INK_EVENT_HTTP_CONTINUE); \
+ TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE); \
}
#define LOG_ERROR_NEG(API_NAME) { \
- INKDebug(PLUGIN_NAME, "%s: %s %s %s File %s, line number %d",PLUGIN_NAME, API_NAME, "NEGAPIFAIL", \
+ TSDebug(PLUGIN_NAME, "%s: %s %s %s File %s, line number %d",PLUGIN_NAME, API_NAME, "NEGAPIFAIL", \
FUNCTION_NAME, __FILE__, __LINE__); \
}
-INKThread ink_tid;
+TSThread ink_tid;
typedef struct
{
- INK64 num_ssns;
+ TS64 num_ssns;
} ConfigData;
static unsigned int my_id = 0;
-static INKStat transaction_count;
-static INKStat session_count;
-static INKStat avg_transactions;
+static TSStat transaction_count;
+static TSStat session_count;
+static TSStat avg_transactions;
/*********************************************************************
* constructor for plugin config data
@@ -87,7 +87,7 @@ plugin_config_constructor()
{
ConfigData *data;
- data = (ConfigData *) INKmalloc(sizeof(ConfigData));
+ data = (ConfigData *) TSmalloc(sizeof(ConfigData));
data->num_ssns = 0;
return data;
}
@@ -98,100 +98,100 @@ plugin_config_constructor()
static void
plugin_config_destructor(void *data)
{
- INKfree((ConfigData *) data);
+ TSfree((ConfigData *) data);
}
/**********************************************************************
- * Update the statistic variables using the INKStat family of functions
+ * Update the statistic variables using the TSStat family of functions
*********************************************************************/
static void
-txn_handler(INKHttpTxn txnp, INKCont contp)
+txn_handler(TSHttpTxn txnp, TSCont contp)
{
LOG_SET_FUNCTION_NAME("txn_handler");
- INK64 num_txns;
- INK64 num_ssns;
+ TS64 num_txns;
+ TS64 num_ssns;
float old_avg_txns, new_avg_txns;
- /* negative test for INKStatIncrement */
+ /* negative test for TSStatIncrement */
#ifdef DEBUG
- if (INKStatIncrement(NULL) != INK_ERROR)
- LOG_ERROR_NEG("INKStatIncrement");
+ if (TSStatIncrement(NULL) != TS_ERROR)
+ LOG_ERROR_NEG("TSStatIncrement");
#endif
- if (INKStatIncrement(transaction_count) == INK_ERROR)
- LOG_ERROR("INKStatIncrement");
+ if (TSStatIncrement(transaction_count) == TS_ERROR)
+ LOG_ERROR("TSStatIncrement");
- if (INKStatIntGet(transaction_count, &num_txns) == INK_ERROR)
- LOG_ERROR("INKStatIntGet");
- if (INKStatIntGet(session_count, &num_ssns) == INK_ERROR)
- LOG_ERROR("INKStatIntGet");
- if (INKStatFloatGet(avg_transactions, &old_avg_txns) == INK_ERROR)
- LOG_ERROR("INKStatFloatGet");
+ if (TSStatIntGet(transaction_count, &num_txns) == TS_ERROR)
+ LOG_ERROR("TSStatIntGet");
+ if (TSStatIntGet(session_count, &num_ssns) == TS_ERROR)
+ LOG_ERROR("TSStatIntGet");
+ if (TSStatFloatGet(avg_transactions, &old_avg_txns) == TS_ERROR)
+ LOG_ERROR("TSStatFloatGet");
if (num_ssns > 0) {
new_avg_txns = (float) num_txns / num_ssns;
} else {
new_avg_txns = 0;
}
- if (INKStatFloatSet(avg_transactions, new_avg_txns) == INK_ERROR)
- LOG_ERROR("INKStatFloatSet");
+ if (TSStatFloatSet(avg_transactions, new_avg_txns) == TS_ERROR)
+ LOG_ERROR("TSStatFloatSet");
- /*negative test for INKStatFloatSet */
+ /*negative test for TSStatFloatSet */
#ifdef DEBUG
- if (INKStatFloatSet(NULL, new_avg_txns) != INK_ERROR)
- LOG_ERROR_NEG("INKStatFloatSet");
+ if (TSStatFloatSet(NULL, new_avg_txns) != TS_ERROR)
+ LOG_ERROR_NEG("TSStatFloatSet");
#endif
- INKDebug(DEBUG_TAG, "The number of transactions is %ld\n", (long) num_txns);
- INKDebug(DEBUG_TAG, "The previous number of average transactions per session is %.2f\n", old_avg_txns);
- INKDebug(DEBUG_TAG, "The current number of average transactions per session is %.2f\n", new_avg_txns);
+ TSDebug(DEBUG_TAG, "The number of transactions is %ld\n", (long) num_txns);
+ TSDebug(DEBUG_TAG, "The previous number of average transactions per session is %.2f\n", old_avg_txns);
+ TSDebug(DEBUG_TAG, "The current number of average transactions per session is %.2f\n", new_avg_txns);
}
/**********************************************************************
- * Update session_count with both INKStat* and INKConfig* functions
+ * Update session_count with both TSStat* and TSConfig* functions
*********************************************************************/
static void
-handle_session(INKHttpSsn ssnp, INKCont contp)
+handle_session(TSHttpSsn ssnp, TSCont contp)
{
LOG_SET_FUNCTION_NAME("handle_session");
- INK64 num_ssns;
- INKConfig config_ptr;
+ TS64 num_ssns;
+ TSConfig config_ptr;
ConfigData *config_data;
- /* negative test for INKStatIntAddTo */
+ /* negative test for TSStatIntAddTo */
#ifdef DEBUG
- if (INKStatIntAddTo(NULL, 1) != INK_ERROR)
- LOG_ERROR_NEG("INKStatIntAddTo");
+ if (TSStatIntAddTo(NULL, 1) != TS_ERROR)
+ LOG_ERROR_NEG("TSStatIntAddTo");
#endif
- /* update the session_count with INKStat functions */
- if (INKStatIntAddTo(session_count, 1) == INK_ERROR)
- LOG_ERROR("INKStatIntAddTo");
- if (INKStatIntGet(session_count, &num_ssns) == INK_ERROR)
- LOG_ERROR("INKStatIntGet");
- INKDebug(DEBUG_TAG, "The number of sessions from INKStat is %ld\n", (long) num_ssns);
+ /* update the session_count with TSStat functions */
+ if (TSStatIntAddTo(session_count, 1) == TS_ERROR)
+ LOG_ERROR("TSStatIntAddTo");
+ if (TSStatIntGet(session_count, &num_ssns) == TS_ERROR)
+ LOG_ERROR("TSStatIntGet");
+ TSDebug(DEBUG_TAG, "The number of sessions from TSStat is %ld\n", (long) num_ssns);
/* get the config data and update it */
- config_ptr = INKConfigGet(my_id);
- config_data = (ConfigData *) INKConfigDataGet(config_ptr);
+ config_ptr = TSConfigGet(my_id);
+ config_data = (ConfigData *) TSConfigDataGet(config_ptr);
config_data->num_ssns++;
- INKDebug(DEBUG_TAG, "The number of sessions from INKConfig is %ld\n", (long) config_data->num_ssns);
- INKConfigRelease(my_id, config_ptr);
+ TSDebug(DEBUG_TAG, "The number of sessions from TSConfig is %ld\n", (long) config_data->num_ssns);
+ TSConfigRelease(my_id, config_ptr);
/* add the session hook */
- if (INKHttpSsnHookAdd(ssnp, INK_HTTP_TXN_START_HOOK, contp) == INK_ERROR)
- LOG_ERROR("INKHttpSsnHookAdd");
+ if (TSHttpSsnHookAdd(ssnp, TS_HTTP_TXN_START_HOOK, contp) == TS_ERROR)
+ LOG_ERROR("TSHttpSsnHookAdd");
- /* negative test for INKHttpSsnHookAdd */
+ /* negative test for TSHttpSsnHookAdd */
#ifdef DEBUG
- if (INKHttpSsnHookAdd(NULL, INK_HTTP_TXN_START_HOOK, contp) != INK_ERROR)
- LOG_ERROR_NEG("INKHttpSsnHookAdd");
- if (INKHttpSsnHookAdd(ssnp, INK_HTTP_TXN_START_HOOK, NULL) != INK_ERROR)
- LOG_ERROR_NEG("INKHttpSsnHookAdd");
+ if (TSHttpSsnHookAdd(NULL, TS_HTTP_TXN_START_HOOK, contp) != TS_ERROR)
+ LOG_ERROR_NEG("TSHttpSsnHookAdd");
+ if (TSHttpSsnHookAdd(ssnp, TS_HTTP_TXN_START_HOOK, NULL) != TS_ERROR)
+ LOG_ERROR_NEG("TSHttpSsnHookAdd");
#endif
}
@@ -203,12 +203,12 @@ thread_func(void *arg)
{
LOG_SET_FUNCTION_NAME("thread_func");
int sleep_time = (int) arg;
- INKThread self;
+ TSThread self;
- if ((ink_tid = INKThreadInit()) == INK_ERROR_PTR || ink_tid == NULL)
- LOG_ERROR("INKThreadInit");
- if ((self = INKThreadSelf()) == INK_ERROR_PTR || self == NULL)
- LOG_ERROR("INKThreadSelf");
+ if ((ink_tid = TSThreadInit()) == TS_ERROR_PTR || ink_tid == NULL)
+ LOG_ERROR("TSThreadInit");
+ if ((self = TSThreadSelf()) == TS_ERROR_PTR || self == NULL)
+ LOG_ERROR("TSThreadSelf");
sleep(sleep_time);
return NULL;
}
@@ -224,81 +224,81 @@ thread_handler()
pthread_create(&tid, NULL, thread_func, (void *) SLEEP_TIME);
sleep(5);
- if (INKThreadDestroy(ink_tid) == INK_ERROR)
- LOG_ERROR("INKThreadDestroy");
+ if (TSThreadDestroy(ink_tid) == TS_ERROR)
+ LOG_ERROR("TSThreadDestroy");
}
static int
-ssn_handler(INKCont contp, INKEvent event, void *edata)
+ssn_handler(TSCont contp, TSEvent event, void *edata)
{
LOG_SET_FUNCTION_NAME("ssn_handler");
- INKHttpSsn ssnp;
- INKHttpTxn txnp;
+ TSHttpSsn ssnp;
+ TSHttpTxn txnp;
switch (event) {
- case INK_EVENT_HTTP_SSN_START:
- ssnp = (INKHttpSsn) edata;
+ case TS_EVENT_HTTP_SSN_START:
+ ssnp = (TSHttpSsn) edata;
handle_session(ssnp, contp);
- if (INKHttpSsnReenable(ssnp, INK_EVENT_HTTP_CONTINUE) == INK_ERROR)
- LOG_ERROR("INKHttpSsnReenable");
+ if (TSHttpSsnReenable(ssnp, TS_EVENT_HTTP_CONTINUE) == TS_ERROR)
+ LOG_ERROR("TSHttpSsnReenable");
- /* negative test for INKHttpSsnReenable */
+ /* negative test for TSHttpSsnReenable */
#ifdef DEBUG
- if (INKHttpSsnReenable(NULL, INK_EVENT_HTTP_CONTINUE) != INK_ERROR)
- LOG_ERROR_NEG("INKHttpSsnReenable");
+ if (TSHttpSsnReenable(NULL, TS_EVENT_HTTP_CONTINUE) != TS_ERROR)
+ LOG_ERROR_NEG("TSHttpSsnReenable");
#endif
return 0;
- case INK_EVENT_HTTP_TXN_START:
- txnp = (INKHttpTxn) edata;
+ case TS_EVENT_HTTP_TXN_START:
+ txnp = (TSHttpTxn) edata;
txn_handler(txnp, contp);
- if (INKHttpTxnReenable(txnp, INK_EVENT_HTTP_CONTINUE) == INK_ERROR)
- LOG_ERROR("INKHttpTxnReenable");
+ if (TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE) == TS_ERROR)
+ LOG_ERROR("TSHttpTxnReenable");
return 0;
default:
- INKDebug(DEBUG_TAG, "In the default case: event = %d\n", event);
+ TSDebug(DEBUG_TAG, "In the default case: event = %d\n", event);
break;
}
return 0;
}
void
-INKPluginInit(int argc, const char *argv[])
+TSPluginInit(int argc, const char *argv[])
{
- LOG_SET_FUNCTION_NAME("INKPluginInit");
- INKCont contp;
+ LOG_SET_FUNCTION_NAME("TSPluginInit");
+ TSCont contp;
ConfigData *config_data;
thread_handler();
/* create the statistic variables */
- transaction_count = INKStatCreate("transaction.count", INKSTAT_TYPE_INT64);
- session_count = INKStatCreate("session.count", INKSTAT_TYPE_INT64);
- avg_transactions = INKStatCreate("avg.transactions", INKSTAT_TYPE_FLOAT);
- if ((transaction_count == INK_ERROR_PTR) || (session_count == INK_ERROR_PTR) || (avg_transactions == INK_ERROR_PTR)) {
- LOG_ERROR("INKStatCreate");
+ transaction_count = TSStatCreate("transaction.count", TSSTAT_TYPE_INT64);
+ session_count = TSStatCreate("session.count", TSSTAT_TYPE_INT64);
+ avg_transactions = TSStatCreate("avg.transactions", TSSTAT_TYPE_FLOAT);
+ if ((transaction_count == TS_ERROR_PTR) || (session_count == TS_ERROR_PTR) || (avg_transactions == TS_ERROR_PTR)) {
+ LOG_ERROR("TSStatCreate");
return;
}
- /* negative test for INKStatCreate */
+ /* negative test for TSStatCreate */
#ifdef DEBUG
- if (INKStatCreate(NULL, INKSTAT_TYPE_INT64) != INK_ERROR_PTR) {
- LOG_ERROR_NEG("INKStatCreate");
+ if (TSStatCreate(NULL, TSSTAT_TYPE_INT64) != TS_ERROR_PTR) {
+ LOG_ERROR_NEG("TSStatCreate");
}
- if (INKStatCreate("transaction.negtest", -1) != INK_ERROR_PTR) {
- LOG_ERROR_NEG("INKStatCreate");
+ if (TSStatCreate("transaction.negtest", -1) != TS_ERROR_PTR) {
+ LOG_ERROR_NEG("TSStatCreate");
}
#endif
- /* create config data for plugin and assign it an identifier with INKConfigSet */
+ /* create config data for plugin and assign it an identifier with TSConfigSet */
config_data = plugin_config_constructor();
- my_id = INKConfigSet(my_id, config_data, plugin_config_destructor);
+ my_id = TSConfigSet(my_id, config_data, plugin_config_destructor);
/* create the continuation */
- if ((contp = INKContCreate(ssn_handler, NULL)) == INK_ERROR_PTR)
- LOG_ERROR("INKContCreate")
+ if ((contp = TSContCreate(ssn_handler, NULL)) == TS_ERROR_PTR)
+ LOG_ERROR("TSContCreate")
else
- INKHttpHookAdd(INK_HTTP_SSN_START_HOOK, contp);
+ TSHttpHookAdd(TS_HTTP_SSN_START_HOOK, contp);
}