You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by ig...@apache.org on 2013/08/09 01:09:22 UTC
[10/13] git commit: transform rfc5861 to new logging non-API
transform rfc5861 to new logging non-API
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/e68e0c88
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/e68e0c88
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/e68e0c88
Branch: refs/heads/consistent-gzip-error-msgs
Commit: e68e0c880286748a49c163dbce16496ea3dbbc47
Parents: ff043e1
Author: Igor Galić <i....@brainsware.org>
Authored: Fri Aug 9 00:03:08 2013 +0200
Committer: Igor Galić <i....@brainsware.org>
Committed: Fri Aug 9 00:03:08 2013 +0200
----------------------------------------------------------------------
plugins/experimental/rfc5861/rfc5861.c | 186 ++++++++++++++--------------
1 file changed, 94 insertions(+), 92 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/e68e0c88/plugins/experimental/rfc5861/rfc5861.c
----------------------------------------------------------------------
diff --git a/plugins/experimental/rfc5861/rfc5861.c b/plugins/experimental/rfc5861/rfc5861.c
index 384aa91..3646faa 100644
--- a/plugins/experimental/rfc5861/rfc5861.c
+++ b/plugins/experimental/rfc5861/rfc5861.c
@@ -36,7 +36,8 @@
#include "ts/ts.h"
#include "ts/experimental.h"
-#define LOG_PREFIX "rfc5861"
+#define PLUGIN_NAME "rfc5861"
+#include <ts/debug.h>
//#define ENABLE_SAVE_ORIGINAL_REQUEST
@@ -96,7 +97,7 @@ create_response_info(void)
{
ResponseInfo *resp_info;
- TSDebug(LOG_PREFIX, "Entering create_response_info");
+ TSLogDebug("Entering create_response_info");
resp_info = (ResponseInfo *) TSmalloc(sizeof(ResponseInfo));
@@ -105,7 +106,7 @@ create_response_info(void)
resp_info->parser = TSHttpParserCreate();
resp_info->parsed = false;
- TSDebug(LOG_PREFIX, "Leaving create_reseponse_info");
+ TSLogDebug("Leaving create_reseponse_info");
return resp_info;
}
@@ -113,14 +114,14 @@ create_response_info(void)
static void
free_response_info(ResponseInfo *resp_info)
{
- TSDebug(LOG_PREFIX, "Entering free_response_info");
+ TSLogDebug("Entering free_response_info");
TSHandleMLocRelease(resp_info->buf, TS_NULL_MLOC, resp_info->http_hdr_loc);
TSMBufferDestroy(resp_info->buf);
TSHttpParserDestroy(resp_info->parser);
TSfree(resp_info);
- TSDebug(LOG_PREFIX, "Leaving free_response_info");
+ TSLogDebug("Leaving free_response_info");
}
static RequestInfo*
@@ -132,14 +133,14 @@ create_request_info(TSHttpTxn txn)
TSMBuffer buf;
TSMLoc loc;
- TSDebug(LOG_PREFIX, "Entering create_request_info");
+ TSLogDebug("Entering create_request_info");
req_info = (RequestInfo *) TSmalloc(sizeof(RequestInfo));
url = TSHttpTxnEffectiveUrlStringGet(txn, &url_len);
req_info->effective_url = TSstrndup(url, url_len);
TSfree(url);
- //TSDebug(LOG_PREFIX, "URL: %s", req_info->effective_url);
+ //TSLogDebug("URL: %s", req_info->effective_url);
TSHttpTxnClientReqGet(txn, &buf, &loc);
req_info->buf = TSMBufferCreate();
@@ -149,7 +150,7 @@ create_request_info(TSHttpTxn txn)
req_info->client_addr = TSmalloc(sizeof(struct sockaddr));
memmove((void *) req_info->client_addr, (void *) TSHttpTxnClientAddrGet(txn), sizeof(struct sockaddr));
- TSDebug(LOG_PREFIX, "Leaving create_request_info");
+ TSLogDebug("Leaving create_request_info");
return req_info;
}
@@ -157,20 +158,20 @@ create_request_info(TSHttpTxn txn)
static void
free_request_info(RequestInfo *req_info)
{
- TSDebug(LOG_PREFIX, "Entering free_request_info");
- TSDebug(LOG_PREFIX, "Free effective URL");
- //TSDebug(LOG_PREFIX, "URL: %s", req_info->effective_url);
+ TSLogDebug("Entering free_request_info");
+ TSLogDebug("Free effective URL");
+ //TSLogDebug("URL: %s", req_info->effective_url);
TSfree(req_info->effective_url);
- TSDebug(LOG_PREFIX, "Release Http Header");
+ TSLogDebug("Release Http Header");
TSHandleMLocRelease(req_info->buf, TS_NULL_MLOC, req_info->http_hdr_loc);
- TSDebug(LOG_PREFIX, "Destroy Buffer");
+ TSLogDebug("Destroy Buffer");
TSMBufferDestroy(req_info->buf);
- TSDebug(LOG_PREFIX, "Free Client Addr");
+ TSLogDebug("Free Client Addr");
TSfree(req_info->client_addr);
- TSDebug(LOG_PREFIX, "Free Request Info");
+ TSLogDebug("Free Request Info");
TSfree(req_info);
- TSDebug(LOG_PREFIX, "Leaving free_request_info");
+ TSLogDebug("Leaving free_request_info");
}
static CachedHeaderInfo*
@@ -188,14 +189,14 @@ get_cached_header_info(TSHttpTxn txn)
chi->stale_while_revalidate = 0;
chi->stale_on_error = 0;
- TSDebug(LOG_PREFIX, "Inside get_cached_header_info");
+ TSLogDebug("Inside get_cached_header_info");
if (TSHttpTxnCachedRespGet(txn, &cr_buf, &cr_hdr_loc) == TS_SUCCESS)
{
cr_date_loc = TSMimeHdrFieldFind(cr_buf, cr_hdr_loc, TS_MIME_FIELD_DATE, TS_MIME_LEN_DATE);
if (cr_date_loc != TS_NULL_MLOC)
{
- TSDebug(LOG_PREFIX, "Found a date");
+ TSLogDebug("Found a date");
chi->date = TSMimeHdrFieldValueDateGet(cr_buf, cr_hdr_loc, cr_date_loc);
TSHandleMLocRelease(cr_buf, cr_hdr_loc, cr_date_loc);
}
@@ -204,7 +205,7 @@ get_cached_header_info(TSHttpTxn txn)
while(cr_cache_control_loc != TS_NULL_MLOC)
{
- TSDebug(LOG_PREFIX, "Found cache-control");
+ TSLogDebug("Found cache-control");
cr_cache_control_count = TSMimeHdrFieldValuesCount(cr_buf, cr_hdr_loc, cr_cache_control_loc);
for (i = 0; i < cr_cache_control_count; i++)
@@ -214,7 +215,7 @@ get_cached_header_info(TSHttpTxn txn)
if (strncmp(value, TS_HTTP_VALUE_MAX_AGE, TS_HTTP_LEN_MAX_AGE) == 0)
{
- TSDebug(LOG_PREFIX, "Found max-age");
+ TSLogDebug("Found max-age");
ptr += TS_HTTP_LEN_MAX_AGE;
if (*ptr == '=')
{
@@ -224,13 +225,13 @@ get_cached_header_info(TSHttpTxn txn)
else
{
ptr = TSstrndup(value, TS_HTTP_LEN_MAX_AGE + 2);
- TSDebug(LOG_PREFIX, "This is what I found: %s", ptr);
+ TSLogDebug("This is what I found: %s", ptr);
TSfree(ptr);
}
}
else if (strncmp(value, HTTP_VALUE_STALE_WHILE_REVALIDATE, strlen(HTTP_VALUE_STALE_WHILE_REVALIDATE)) == 0)
{
- TSDebug(LOG_PREFIX, "Found stale-while-revalidate");
+ TSLogDebug("Found stale-while-revalidate");
ptr += strlen(HTTP_VALUE_STALE_WHILE_REVALIDATE);
if (*ptr == '=')
{
@@ -240,7 +241,7 @@ get_cached_header_info(TSHttpTxn txn)
}
else if (strncmp(value, HTTP_VALUE_STALE_IF_ERROR, strlen(HTTP_VALUE_STALE_IF_ERROR)) == 0)
{
- TSDebug(LOG_PREFIX, "Found stale-on-error");
+ TSLogDebug("Found stale-on-error");
ptr += strlen(HTTP_VALUE_STALE_IF_ERROR);
if (*ptr == '=')
{
@@ -250,7 +251,7 @@ get_cached_header_info(TSHttpTxn txn)
}
else
{
- TSDebug(LOG_PREFIX, "Unknown field value");
+ TSLogDebug("Unknown field value");
}
}
@@ -261,7 +262,7 @@ get_cached_header_info(TSHttpTxn txn)
TSHandleMLocRelease(cr_buf, TS_NULL_MLOC, cr_hdr_loc);
}
- TSDebug(LOG_PREFIX, "Leaving get_cached_header_info");
+ TSLogDebug("Leaving get_cached_header_info");
return chi;
}
@@ -279,7 +280,7 @@ parse_response(StateInfo *state)
int64_t avail;
char *start;
- TSDebug(LOG_PREFIX, "Entering parse_response");
+ TSLogDebug("Entering parse_response");
block = TSIOBufferReaderStart(state->resp_io_buf_reader);
@@ -297,10 +298,10 @@ parse_response(StateInfo *state)
{
state->resp_info->status = TSHttpHdrStatusGet(state->resp_info->buf, state->resp_info->http_hdr_loc);
state->resp_info->parsed = true;
- TSDebug(LOG_PREFIX, "HTTP Status: %d", state->resp_info->status);
+ TSLogDebug("HTTP Status: %d", state->resp_info->status);
}
- TSDebug(LOG_PREFIX, "Leaving parse_response");
+ TSLogDebug("Leaving parse_response");
}
static int
@@ -312,7 +313,7 @@ consume_resource(TSCont cont, TSEvent event ATS_UNUSED, void *edata ATS_UNUSED)
TSMLoc url_loc;
int lookup_count;
- TSDebug(LOG_PREFIX, "Entering consume_resource");
+ TSLogDebug("Entering consume_resource");
vconn = (TSVConn) edata;
state = (StateInfo *) TSContDataGet(cont);
@@ -321,15 +322,15 @@ consume_resource(TSCont cont, TSEvent event ATS_UNUSED, void *edata ATS_UNUSED)
{
case TS_EVENT_VCONN_WRITE_READY:
// We shouldn't get here because we specify the exact size of the buffer.
- TSDebug(LOG_PREFIX, "Write Ready");
+ TSLogDebug("Write Ready");
case TS_EVENT_VCONN_WRITE_COMPLETE:
- TSDebug(LOG_PREFIX, "Write Complete");
- //TSDebug(LOG_PREFIX, "TSVConnShutdown()");
+ TSLogDebug("Write Complete");
+ //TSLogDebug("TSVConnShutdown()");
//TSVConnShutdown(state->vconn, 0, 1);
//TSVIOReenable(state->w_vio);
break;
case TS_EVENT_VCONN_READ_READY:
- TSDebug(LOG_PREFIX, "Read Ready");
+ TSLogDebug("Read Ready");
avail = TSIOBufferReaderAvail(state->resp_io_buf_reader);
@@ -349,21 +350,21 @@ consume_resource(TSCont cont, TSEvent event ATS_UNUSED, void *edata ATS_UNUSED)
case TS_EVENT_VCONN_INACTIVITY_TIMEOUT:
if (event == TS_EVENT_VCONN_INACTIVITY_TIMEOUT)
{
- TSDebug(LOG_PREFIX, "Inactivity Timeout");
- TSDebug(LOG_PREFIX, "TSVConnAbort()");
+ TSLogDebug("Inactivity Timeout");
+ TSLogDebug("TSVConnAbort()");
TSVConnAbort(vconn, TS_VC_CLOSE_ABORT);
}
else
{
if (event == TS_EVENT_VCONN_READ_COMPLETE)
{
- TSDebug(LOG_PREFIX, "Read Complete");
+ TSLogDebug("Read Complete");
}
else if (event == TS_EVENT_VCONN_EOS)
{
- TSDebug(LOG_PREFIX, "EOS");
+ TSLogDebug("EOS");
}
- TSDebug(LOG_PREFIX, "TSVConnClose()");
+ TSLogDebug("TSVConnClose()");
TSVConnClose(state->vconn);
}
@@ -380,18 +381,18 @@ consume_resource(TSCont cont, TSEvent event ATS_UNUSED, void *edata ATS_UNUSED)
TSVIONDoneSet(state->r_vio, TSVIONDoneGet(state->r_vio) + avail);
if (state->async_req)
{
- TSDebug(LOG_PREFIX, "Unlock URL");
+ TSLogDebug("Unlock URL");
TSMutexLock(troot_mutex);
tdelete(state->req_info->effective_url, &troot, xstrcmp);
TSMutexUnlock(troot_mutex);
}
else
{
- TSDebug(LOG_PREFIX, "In sync path. setting fresh and re-enabling");
+ TSLogDebug("In sync path. setting fresh and re-enabling");
TSHttpTxnCacheLookupCountGet(state->txn, &lookup_count);
if ((state->resp_info->status == 500) || ((state->resp_info->status >= 502) && (state->resp_info->status <= 504)) || lookup_count > 2)
{
- TSDebug(LOG_PREFIX, "Sending stale data as fresh");
+ TSLogDebug("Sending stale data as fresh");
if (log_info.object && (log_info.all || log_info.stale_if_error))
{
CachedHeaderInfo *chi = get_cached_header_info(state->txn);
@@ -403,7 +404,7 @@ consume_resource(TSCont cont, TSEvent event ATS_UNUSED, void *edata ATS_UNUSED)
}
else
{
- TSDebug(LOG_PREFIX, "Attempting new cache lookup");
+ TSLogDebug("Attempting new cache lookup");
TSHttpHdrUrlGet(state->req_info->buf, state->req_info->http_hdr_loc, &url_loc);
TSHttpTxnNewCacheLookupDo(state->txn, state->req_info->buf, url_loc);
TSHandleMLocRelease(state->req_info->buf, state->req_info->http_hdr_loc, url_loc);
@@ -422,15 +423,15 @@ consume_resource(TSCont cont, TSEvent event ATS_UNUSED, void *edata ATS_UNUSED)
TSIOBufferReaderFree(state->resp_io_buf_reader);
TSIOBufferDestroy(state->resp_io_buf);
TSfree(state);
- TSDebug(LOG_PREFIX, "Destroying Cont");
+ TSLogDebug("Destroying Cont");
TSContDestroy(cont);
break;
default:
- TSError("Unknown event %d.", event);
+ TSLogError("Unknown event %d.", event);
break;
}
- TSDebug(LOG_PREFIX, "Leaving consume_resource");
+ TSLogDebug("Leaving consume_resource");
return 0;
}
@@ -442,18 +443,18 @@ fetch_resource(TSCont cont, TSEvent event ATS_UNUSED, void *edata ATS_UNUSED)
//struct sockaddr_in client_addr;
TSMLoc connection_hdr_loc, connection_hdr_dup_loc;
- TSDebug(LOG_PREFIX, "Entering fetch_resource");
+ TSLogDebug("Entering fetch_resource");
state = (StateInfo *) TSContDataGet(cont);
- TSDebug(LOG_PREFIX, "state: %p", state);
+ TSLogDebug("state: %p", state);
//li = (RequestInfo *) edata;
TSMutexLock(troot_mutex);
// If already doing async lookup lets just close shop and go home
if (state->async_req && (tfind(state->req_info->effective_url, &troot, xstrcmp) != NULL))
{
- TSDebug(LOG_PREFIX, "Looks like an async is already in progress");
+ TSLogDebug("Looks like an async is already in progress");
TSMutexUnlock(troot_mutex);
free_request_info(state->req_info);
TSfree(state);
@@ -461,11 +462,11 @@ fetch_resource(TSCont cont, TSEvent event ATS_UNUSED, void *edata ATS_UNUSED)
// Otherwise lets do the lookup!
else
{
- TSDebug(LOG_PREFIX, "Lets do the lookup");
+ TSLogDebug("Lets do the lookup");
if (state->async_req)
{
// Lock in tree
- TSDebug(LOG_PREFIX, "Locking URL");
+ TSLogDebug("Locking URL");
tsearch(state->req_info->effective_url, &troot, xstrcmp);
}
TSMutexUnlock(troot_mutex);
@@ -481,12 +482,12 @@ fetch_resource(TSCont cont, TSEvent event ATS_UNUSED, void *edata ATS_UNUSED)
state->resp_info = create_response_info();
}
- TSDebug(LOG_PREFIX, "Set Connection: close");
+ TSLogDebug("Set Connection: close");
connection_hdr_loc = TSMimeHdrFieldFind(state->req_info->buf, state->req_info->http_hdr_loc, TS_MIME_FIELD_CONNECTION, TS_MIME_LEN_CONNECTION);
while(connection_hdr_loc != TS_NULL_MLOC)
{
- TSDebug(LOG_PREFIX, "Found old Connection hdr");
+ TSLogDebug("Found old Connection hdr");
connection_hdr_dup_loc = TSMimeHdrFieldNextDup(state->req_info->buf, state->req_info->http_hdr_loc, connection_hdr_loc);
TSMimeHdrFieldRemove(state->req_info->buf, state->req_info->http_hdr_loc, connection_hdr_loc);
@@ -496,43 +497,43 @@ fetch_resource(TSCont cont, TSEvent event ATS_UNUSED, void *edata ATS_UNUSED)
}
// This seems to have little effect
- TSDebug(LOG_PREFIX, "Creating Connection hdr");
+ TSLogDebug("Creating Connection hdr");
TSMimeHdrFieldCreateNamed(state->req_info->buf, state->req_info->http_hdr_loc, TS_MIME_FIELD_CONNECTION, TS_MIME_LEN_CONNECTION, &connection_hdr_loc);
TSMimeHdrFieldValueStringInsert(state->req_info->buf, state->req_info->http_hdr_loc, connection_hdr_loc, -1, TS_HTTP_VALUE_CLOSE, TS_HTTP_LEN_CLOSE);
TSMimeHdrFieldAppend(state->req_info->buf, state->req_info->http_hdr_loc, connection_hdr_loc);
TSHandleMLocRelease(state->req_info->buf, state->req_info->http_hdr_loc, connection_hdr_loc);
/*
- TSDebug(LOG_PREFIX, "Creating @RFC5861 header");
+ TSLogDebug("Creating @RFC5861 header");
TSMimeHdrFieldCreateNamed(state->req_info->buf, state->req_info->http_hdr_loc, TS_MIME_FIELD_CONNECTION, TS_MIME_LEN_CONNECTION, &connection_hdr_loc);
TSMimeHdrFieldValueStringInsert(state->req_info->buf, state->req_info->http_hdr_loc, connection_hdr_loc, -1, TS_HTTP_VALUE_CLOSE, TS_HTTP_LEN_CLOSE);
TSMimeHdrFieldAppend(state->req_info->buf, state->req_info->http_hdr_loc, connection_hdr_loc);
TSHandleMLocRelease(state->req_info->buf, state->req_info->http_hdr_loc, connection_hdr_loc);
*/
- TSDebug(LOG_PREFIX, "Create Buffers");
+ TSLogDebug("Create Buffers");
state->req_io_buf = TSIOBufferCreate();
state->req_io_buf_reader = TSIOBufferReaderAlloc(state->req_io_buf);
state->resp_io_buf = TSIOBufferCreate();
state->resp_io_buf_reader = TSIOBufferReaderAlloc(state->resp_io_buf);
- TSDebug(LOG_PREFIX, "HdrPrint()");
+ TSLogDebug("HdrPrint()");
TSHttpHdrPrint(state->req_info->buf, state->req_info->http_hdr_loc, state->req_io_buf);
TSIOBufferWrite(state->req_io_buf, "\r\n", 2);
- TSDebug(LOG_PREFIX, "TSHttpConnect()");
+ TSLogDebug("TSHttpConnect()");
//memmove((void *) &client_addr, (void *) state->req_info->client_addr, sizeof(struct sockaddr));
- //TSDebug(LOG_PREFIX, "client_addr: %s:%d", inet_ntoa(client_addr.sin_addr), client_addr.sin_port);
+ //TSLogDebug("client_addr: %s:%d", inet_ntoa(client_addr.sin_addr), client_addr.sin_port);
state->vconn = TSHttpConnect((struct sockaddr const *) state->req_info->client_addr);
- TSDebug(LOG_PREFIX, "TSVConnRead()");
+ TSLogDebug("TSVConnRead()");
state->r_vio = TSVConnRead(state->vconn, consume_cont, state->resp_io_buf, INT64_MAX);
- TSDebug(LOG_PREFIX, "TSVConnWrite()");
+ TSLogDebug("TSVConnWrite()");
state->w_vio = TSVConnWrite(state->vconn, consume_cont, state->req_io_buf_reader, TSIOBufferReaderAvail(state->req_io_buf_reader));
}
TSContDestroy(cont);
- TSDebug(LOG_PREFIX, "Leaving fetch_resource");
+ TSLogDebug("Leaving fetch_resource");
return 0;
}
@@ -549,26 +550,26 @@ rfc5861_plugin(TSCont cont, TSEvent event, void *edata)
TSMLoc loc,warn_loc;
TSHttpStatus http_status;
- TSDebug(LOG_PREFIX, "Entering rfc5861_plugin");
+ TSLogDebug("Entering rfc5861_plugin");
switch (event)
{
// Is this the proper event?
case TS_EVENT_HTTP_READ_REQUEST_HDR:
- TSDebug(LOG_PREFIX, "Event: TS_EVENT_HTTP_READ_REQUEST_HDR");
+ TSLogDebug("Event: TS_EVENT_HTTP_READ_REQUEST_HDR");
if (TSHttpIsInternalRequest(txn) != TS_SUCCESS)
{
- TSDebug(LOG_PREFIX, "External Request");
+ TSLogDebug("External Request");
state = TSmalloc(sizeof(StateInfo));
time(&state->txn_start);
state->req_info = create_request_info(txn);
- TSDebug(LOG_PREFIX, "state after TSmalloc: %p", state);
+ TSLogDebug("state after TSmalloc: %p", state);
TSHttpTxnArgSet(txn, txn_slot, (void *) state);
TSHttpTxnHookAdd(txn, TS_HTTP_CACHE_LOOKUP_COMPLETE_HOOK, cont);
}
else
{
- TSDebug(LOG_PREFIX, "Internal Request"); // This is insufficient if there are other plugins using TSHttpConnect
+ TSLogDebug("Internal Request"); // This is insufficient if there are other plugins using TSHttpConnect
//TSHttpTxnHookAdd(txn, TS_HTTP_CACHE_LOOKUP_COMPLETE_HOOK, cont);
TSHttpTxnHookAdd(txn, TS_HTTP_READ_RESPONSE_HDR_HOOK, cont);
// This might be needed in 3.2.0 to fix a timeout issue
@@ -577,25 +578,25 @@ rfc5861_plugin(TSCont cont, TSEvent event, void *edata)
}
TSHttpTxnReenable(txn, TS_EVENT_HTTP_CONTINUE);
- TSDebug(LOG_PREFIX, "TS_EVENT_HTTP_READ_REQUEST_HDR Event Handler End");
+ TSLogDebug("TS_EVENT_HTTP_READ_REQUEST_HDR Event Handler End");
break;
case TS_EVENT_HTTP_CACHE_LOOKUP_COMPLETE:
- TSDebug(LOG_PREFIX, "Event: TS_EVENT_HTTP_CACHE_LOOKUP_COMPLETE");
+ TSLogDebug("Event: TS_EVENT_HTTP_CACHE_LOOKUP_COMPLETE");
state = (StateInfo *) TSHttpTxnArgGet(txn, txn_slot);
TSHttpTxnCacheLookupCountGet(txn, &lookup_count);
- TSDebug(LOG_PREFIX, "state after arg get: %p", state);
+ TSLogDebug("state after arg get: %p", state);
if (TSHttpTxnCacheLookupStatusGet(txn, &status) == TS_SUCCESS)
{
// Are we stale?
if (status == TS_CACHE_LOOKUP_HIT_STALE)
{
- TSDebug(LOG_PREFIX, "CacheLookupStatus is STALE");
+ TSLogDebug("CacheLookupStatus is STALE");
// Get headers
chi = get_cached_header_info(txn);
if ((state->txn_start - chi->date) < (chi->max_age + chi->stale_while_revalidate))
{
- TSDebug(LOG_PREFIX, "Looks like we can return fresh info and validate in the background");
+ TSLogDebug("Looks like we can return fresh info and validate in the background");
if (log_info.object && (log_info.all || log_info.stale_while_revalidate))
TSTextLogObjectWrite(log_info.object, "stale-while-revalidate: %d - %d < %d + %d %s", (int) state->txn_start, (int) chi->date, (int) chi->max_age, (int) chi->stale_while_revalidate, state->req_info->effective_url);
// lookup async
@@ -606,23 +607,23 @@ rfc5861_plugin(TSCont cont, TSEvent event, void *edata)
// Set warning header
TSHttpTxnHookAdd(txn, TS_HTTP_SEND_RESPONSE_HDR_HOOK, cont);
- TSDebug(LOG_PREFIX, "set state as async");
+ TSLogDebug("set state as async");
state->async_req = true;
- TSDebug(LOG_PREFIX, "TSHttpTxnCacheLookupStatusSet()");
+ TSLogDebug("TSHttpTxnCacheLookupStatusSet()");
TSHttpTxnCacheLookupStatusSet(txn, TS_CACHE_LOOKUP_HIT_FRESH);
//TSHttpTxnReenable(txn, TS_EVENT_HTTP_CONTINUE);
- TSDebug(LOG_PREFIX, "TSContCreate()");
+ TSLogDebug("TSContCreate()");
fetch_cont = TSContCreate(fetch_resource, NULL);
- TSDebug(LOG_PREFIX, "TSContDataSet()");
+ TSLogDebug("TSContDataSet()");
TSContDataSet(fetch_cont, (void *) state);
- TSDebug(LOG_PREFIX, "state: %p", state);
+ TSLogDebug("state: %p", state);
TSContSchedule(fetch_cont, 0, TS_THREAD_POOL_TASK);
- TSDebug(LOG_PREFIX, "TSHttpTxnReenable()");
+ TSLogDebug("TSHttpTxnReenable()");
TSHttpTxnReenable(txn, TS_EVENT_HTTP_CONTINUE);
}
else if ((state->txn_start - chi->date) < (chi->max_age + chi->stale_on_error))
{
- TSDebug(LOG_PREFIX, "Looks like we can return fresh data on 500 error");
+ TSLogDebug("Looks like we can return fresh data on 500 error");
#if (TS_VERSION_NUMBER >= 3003000)
TSHttpTxnConfigIntSet(txn, TS_CONFIG_HTTP_INSERT_AGE_IN_RESPONSE, 1);
#endif
@@ -636,7 +637,8 @@ rfc5861_plugin(TSCont cont, TSEvent event, void *edata)
}
else
{
- TSDebug(LOG_PREFIX, "No love? now: %d date: %d max-age: %d swr: %d soe: %d", (int) state->txn_start, (int) chi->date, (int) chi->max_age, (int) chi->stale_while_revalidate, (int) chi->stale_on_error);
+ TSLogDebug("No love? now: %d date: %d max-age: %d swr: %d soe: %d", (int) state->txn_start,
+ (int) chi->date, (int) chi->max_age, (int) chi->stale_while_revalidate, (int) chi->stale_on_error);
if (lookup_count == 1)
{
free_request_info(state->req_info);
@@ -649,7 +651,7 @@ rfc5861_plugin(TSCont cont, TSEvent event, void *edata)
}
else
{
- TSDebug(LOG_PREFIX, "Not Stale!");
+ TSLogDebug("Not Stale!");
if (lookup_count == 1)
{
free_request_info(state->req_info);
@@ -660,7 +662,7 @@ rfc5861_plugin(TSCont cont, TSEvent event, void *edata)
}
else
{
- TSDebug(LOG_PREFIX, "Could not get CacheLookupStatus");
+ TSLogDebug("Could not get CacheLookupStatus");
if (lookup_count == 1)
{
free_request_info(state->req_info);
@@ -668,15 +670,15 @@ rfc5861_plugin(TSCont cont, TSEvent event, void *edata)
}
TSHttpTxnReenable(txn, TS_EVENT_HTTP_CONTINUE);
}
- TSDebug(LOG_PREFIX, "TS_EVENT_HTTP_CACHE_LOOKUP_COMPLETE Event Handler End");
+ TSLogDebug("TS_EVENT_HTTP_CACHE_LOOKUP_COMPLETE Event Handler End");
break;
case TS_EVENT_HTTP_READ_RESPONSE_HDR:
- TSDebug(LOG_PREFIX, "Event: TS_EVENT_HTTP_READ_RESPONSE_HDR");
+ TSLogDebug("Event: TS_EVENT_HTTP_READ_RESPONSE_HDR");
TSHttpTxnServerRespGet(txn, &buf, &loc);
http_status = TSHttpHdrStatusGet(buf, loc);
if ((http_status == 500) || ((http_status >= 502) && (http_status <= 504))) // 500, 502, 503, or 504
{
- TSDebug(LOG_PREFIX, "Set non-cachable");
+ TSLogDebug("Set non-cachable");
#if (TS_VERSION_NUMBER >= 3003000)
TSHttpTxnServerRespNoStoreSet(txn,1);
#else
@@ -685,11 +687,11 @@ rfc5861_plugin(TSCont cont, TSEvent event, void *edata)
}
TSHandleMLocRelease(buf, TS_NULL_MLOC, loc);
TSHttpTxnReenable(txn, TS_EVENT_HTTP_CONTINUE);
- TSDebug(LOG_PREFIX, "TS_EVENT_HTTP_READ_RESPONSE_HDR Event Handler End");
+ TSLogDebug("TS_EVENT_HTTP_READ_RESPONSE_HDR Event Handler End");
break;
case TS_EVENT_HTTP_SEND_RESPONSE_HDR:
- TSDebug(LOG_PREFIX, "Event: TS_EVENT_HTTP_SEND_RESPONSE_HDR");
- TSDebug(LOG_PREFIX, "set warning header");
+ TSLogDebug("Event: TS_EVENT_HTTP_SEND_RESPONSE_HDR");
+ TSLogDebug("set warning header");
TSHttpTxnClientRespGet(txn, &buf, &loc);
TSMimeHdrFieldCreateNamed(buf, loc, TS_MIME_FIELD_WARNING, TS_MIME_LEN_WARNING, &warn_loc);
TSMimeHdrFieldValueStringInsert(buf, loc, warn_loc, -1, HTTP_VALUE_STALE_WARNING, strlen(HTTP_VALUE_STALE_WARNING));
@@ -697,14 +699,14 @@ rfc5861_plugin(TSCont cont, TSEvent event, void *edata)
TSHandleMLocRelease(buf, loc, warn_loc);
TSHandleMLocRelease(buf, TS_NULL_MLOC, loc);
TSHttpTxnReenable(txn, TS_EVENT_HTTP_CONTINUE);
- TSDebug(LOG_PREFIX, "TS_EVENT_HTTP_SEND_RESPONSE_HDR Event Handler End");
+ TSLogDebug("TS_EVENT_HTTP_SEND_RESPONSE_HDR Event Handler End");
break;
default:
TSHttpTxnReenable(txn, TS_EVENT_HTTP_CONTINUE);
break;
}
- TSDebug(LOG_PREFIX, "Leaving rfc5861_plugin");
+ TSLogDebug("Leaving rfc5861_plugin");
return 0;
}
@@ -721,12 +723,12 @@ TSPluginInit (int argc, const char *argv[])
if (TSPluginRegister(TS_SDK_VERSION_3_0 , &info) != TS_SUCCESS)
{
- TSError("Plugin registration failed.\n");
+ TSLogError("Plugin registration failed.\n");
return;
}
else
{
- TSDebug(LOG_PREFIX, "Plugin registration succeeded.\n");
+ TSLogDebug("Plugin registration succeeded.\n");
}
if (argc > 1)
@@ -771,5 +773,5 @@ TSPluginInit (int argc, const char *argv[])
main_cont = TSContCreate(rfc5861_plugin, NULL);
TSHttpHookAdd(TS_HTTP_READ_REQUEST_HDR_HOOK, main_cont);
- TSDebug(LOG_PREFIX, "Plugin Init Complete.\n");
+ TSLogDebug("Plugin Init Complete.\n");
}