You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by su...@apache.org on 2016/02/29 19:24:14 UTC
trafficserver git commit: Clang format.
Repository: trafficserver
Updated Branches:
refs/heads/fcollapse d2bdb0bb0 -> e8eb8a6bd
Clang format.
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/e8eb8a6b
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/e8eb8a6b
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/e8eb8a6b
Branch: refs/heads/fcollapse
Commit: e8eb8a6bd695b934de2966b2741a8ebdbef4b4d6
Parents: d2bdb0b
Author: Sudheer Vinukonda <su...@yahoo-inc.com>
Authored: Mon Feb 29 18:23:57 2016 +0000
Committer: Sudheer Vinukonda <su...@yahoo-inc.com>
Committed: Mon Feb 29 18:23:57 2016 +0000
----------------------------------------------------------------------
.../collapsed_forwarding.cc | 106 +++++++++----------
1 file changed, 51 insertions(+), 55 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/e8eb8a6b/plugins/experimental/collapsed_forwarding/collapsed_forwarding.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/collapsed_forwarding/collapsed_forwarding.cc b/plugins/experimental/collapsed_forwarding/collapsed_forwarding.cc
index 5606d6b..9c5acfb 100644
--- a/plugins/experimental/collapsed_forwarding/collapsed_forwarding.cc
+++ b/plugins/experimental/collapsed_forwarding/collapsed_forwarding.cc
@@ -65,7 +65,7 @@ static char UNUSED rcsId__header_normalize_cc[] =
#include <netdb.h>
#include <map>
-const char *DEBUG_TAG = (char*)"collapsed_forwarding";
+const char *DEBUG_TAG = (char *)"collapsed_forwarding";
const char *LOCATION_HEADER = "Location";
const char *REDIRECT_REASON = "See Other";
@@ -76,12 +76,12 @@ int OPEN_WRITE_FAIL_REQ_DELAY_TIMEOUT = 500;
typedef struct _RequestData {
TSHttpTxn txnp;
- int wl_retry; // write lock failure retry count
+ int wl_retry; // write lock failure retry count
std::string req_url;
} RequestData;
int
-add_redirect_header(TSMBuffer& bufp, TSMLoc& hdr_loc, const std::string& location)
+add_redirect_header(TSMBuffer &bufp, TSMLoc &hdr_loc, const std::string &location)
{
// This is needed in case the response already contains a Location header
TSMLoc field_loc = TSMimeHdrFieldFind(bufp, hdr_loc, LOCATION_HEADER, strlen(LOCATION_HEADER));
@@ -103,15 +103,15 @@ add_redirect_header(TSMBuffer& bufp, TSMLoc& hdr_loc, const std::string& locatio
}
bool
-check_internal_message_hdr(TSHttpTxn& txnp)
+check_internal_message_hdr(TSHttpTxn &txnp)
{
TSMBuffer bufp;
TSMLoc hdr_loc;
bool found = false;
if (TSHttpTxnClientRespGet(txnp, &bufp, &hdr_loc) != TS_SUCCESS) {
- TSError("check_internal_message_hdr: couldn't retrieve client response header");
- return false;
+ TSError("check_internal_message_hdr: couldn't retrieve client response header");
+ return false;
}
TSMLoc header_loc = TSMimeHdrFieldFind(bufp, hdr_loc, ATS_INTERNAL_MESSAGE, strlen(ATS_INTERNAL_MESSAGE));
@@ -128,10 +128,10 @@ check_internal_message_hdr(TSHttpTxn& txnp)
}
int
-on_OS_DNS(const RequestData* req, TSHttpTxn& txnp)
+on_OS_DNS(const RequestData *req, TSHttpTxn &txnp)
{
if (req->wl_retry > 0) {
- TSDebug (DEBUG_TAG, "OS_DNS request delayed %d times, block origin req for url: %s", req->wl_retry, req->req_url.c_str());
+ TSDebug(DEBUG_TAG, "OS_DNS request delayed %d times, block origin req for url: %s", req->wl_retry, req->req_url.c_str());
TSHttpTxnReenable(txnp, TS_EVENT_HTTP_ERROR);
return TS_SUCCESS;
}
@@ -141,10 +141,10 @@ on_OS_DNS(const RequestData* req, TSHttpTxn& txnp)
}
int
-on_send_request_header(const RequestData* req, TSHttpTxn& txnp)
+on_send_request_header(const RequestData *req, TSHttpTxn &txnp)
{
if (req->wl_retry > 0) {
- TSDebug (DEBUG_TAG, "Send_Req request delayed %d times, block origin req for url: %s", req->wl_retry, req->req_url.c_str());
+ TSDebug(DEBUG_TAG, "Send_Req request delayed %d times, block origin req for url: %s", req->wl_retry, req->req_url.c_str());
TSHttpTxnReenable(txnp, TS_EVENT_HTTP_ERROR);
return TS_SUCCESS;
}
@@ -154,28 +154,29 @@ on_send_request_header(const RequestData* req, TSHttpTxn& txnp)
}
int
-on_read_response_header(TSHttpTxn& txnp)
+on_read_response_header(TSHttpTxn &txnp)
{
TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE);
return TS_SUCCESS;
}
int
-on_immediate(RequestData* req, TSCont& contp)
+on_immediate(RequestData *req, TSCont &contp)
{
if (!req) {
- TSError ("%s: invalid req_data", DEBUG_TAG);
+ TSError("%s: invalid req_data", DEBUG_TAG);
return TS_SUCCESS;
}
- TSDebug (DEBUG_TAG, "continuation delayed, scheduling now..for url: %s", req->req_url.c_str());
+ TSDebug(DEBUG_TAG, "continuation delayed, scheduling now..for url: %s", req->req_url.c_str());
// add retry_done header to prevent looping
std::string value;
TSMBuffer bufp;
TSMLoc hdr_loc;
if (TSHttpTxnClientRespGet(req->txnp, &bufp, &hdr_loc) != TS_SUCCESS) {
- TSError("plugin=%s, level=error, error_code=could_not_retrieve_client_response_header for url %s", DEBUG_TAG, req->req_url.c_str());
+ TSError("plugin=%s, level=error, error_code=could_not_retrieve_client_response_header for url %s", DEBUG_TAG,
+ req->req_url.c_str());
TSHttpTxnReenable(req->txnp, TS_EVENT_HTTP_ERROR);
return TS_SUCCESS;
}
@@ -187,7 +188,7 @@ on_immediate(RequestData* req, TSCont& contp)
}
int
-on_send_response_header(RequestData* req, TSHttpTxn& txnp, TSCont& contp)
+on_send_response_header(RequestData *req, TSHttpTxn &txnp, TSCont &contp)
{
TSMBuffer bufp;
TSMLoc hdr_loc;
@@ -201,20 +202,21 @@ on_send_response_header(RequestData* req, TSHttpTxn& txnp, TSCont& contp)
if ((status == TS_HTTP_STATUS_BAD_GATEWAY) || (status == TS_HTTP_STATUS_SEE_OTHER)) {
bool is_internal_message_hdr = check_internal_message_hdr(txnp);
- bool delay_request = is_internal_message_hdr ||
- ((req->wl_retry > 0) && (req->wl_retry < OPEN_WRITE_FAIL_MAX_REQ_DELAY_RETRIES));
+ bool delay_request =
+ is_internal_message_hdr || ((req->wl_retry > 0) && (req->wl_retry < OPEN_WRITE_FAIL_MAX_REQ_DELAY_RETRIES));
if (delay_request) {
- req->wl_retry++;
- TSDebug (DEBUG_TAG, "delaying request, url@%p: {{%s}} on retry: %d time", txnp, req->req_url.c_str(), req->wl_retry);
- TSContSchedule(contp, OPEN_WRITE_FAIL_REQ_DELAY_TIMEOUT, TS_THREAD_POOL_TASK);
- TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
- return TS_SUCCESS;
+ req->wl_retry++;
+ TSDebug(DEBUG_TAG, "delaying request, url@%p: {{%s}} on retry: %d time", txnp, req->req_url.c_str(), req->wl_retry);
+ TSContSchedule(contp, OPEN_WRITE_FAIL_REQ_DELAY_TIMEOUT, TS_THREAD_POOL_TASK);
+ TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
+ return TS_SUCCESS;
}
}
if (req->wl_retry > 0) {
- TSDebug (DEBUG_TAG, "request delayed, but unsuccessful, url@%p: {{%s}} on retry: %d time", txnp, req->req_url.c_str(), req->wl_retry);
+ TSDebug(DEBUG_TAG, "request delayed, but unsuccessful, url@%p: {{%s}} on retry: %d time", txnp, req->req_url.c_str(),
+ req->wl_retry);
req->wl_retry = 0;
}
@@ -231,37 +233,31 @@ int
collapsed_cont(TSCont contp, TSEvent event, void *edata)
{
TSHttpTxn txnp = static_cast<TSHttpTxn>(edata);
- RequestData *my_req = static_cast<RequestData*>(TSContDataGet(contp));
+ RequestData *my_req = static_cast<RequestData *>(TSContDataGet(contp));
switch (event) {
- case TS_EVENT_HTTP_OS_DNS:
- {
- return on_OS_DNS(my_req, txnp);
- }
+ case TS_EVENT_HTTP_OS_DNS: {
+ return on_OS_DNS(my_req, txnp);
+ }
- case TS_EVENT_HTTP_SEND_REQUEST_HDR:
- {
- return on_send_request_header(my_req, txnp);
- }
+ case TS_EVENT_HTTP_SEND_REQUEST_HDR: {
+ return on_send_request_header(my_req, txnp);
+ }
- case TS_EVENT_HTTP_READ_RESPONSE_HDR:
- {
- return on_read_response_header(txnp);
- }
- case TSEvent::TS_EVENT_IMMEDIATE:
- case TSEvent::TS_EVENT_TIMEOUT:
- {
- return on_immediate(my_req, contp);
- }
- case TS_EVENT_HTTP_SEND_RESPONSE_HDR:
- {
- return on_send_response_header(my_req, txnp, contp);
- }
- default:
- {
- TSDebug(DEBUG_TAG, "Unexpected event: %d", event);
- break;
- }
+ case TS_EVENT_HTTP_READ_RESPONSE_HDR: {
+ return on_read_response_header(txnp);
+ }
+ case TSEvent::TS_EVENT_IMMEDIATE:
+ case TSEvent::TS_EVENT_TIMEOUT: {
+ return on_immediate(my_req, contp);
+ }
+ case TS_EVENT_HTTP_SEND_RESPONSE_HDR: {
+ return on_send_response_header(my_req, txnp, contp);
+ }
+ default: {
+ TSDebug(DEBUG_TAG, "Unexpected event: %d", event);
+ break;
+ }
}
TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE);
@@ -276,22 +272,22 @@ TSRemapInit(TSRemapInterface * /* api_info */, char * /* errbuf */, int /* errbu
}
TSReturnCode
-TSRemapNewInstance(int argc, char * argv[], void ** /* ih */, char * /* errbuf */, int /* errbuf_size */)
+TSRemapNewInstance(int argc, char *argv[], void ** /* ih */, char * /* errbuf */, int /* errbuf_size */)
{
// basic argv processing..
for (int i = 2; i < argc; ++i) {
if (strncmp(argv[i], "--delay=", 8) == 0) {
OPEN_WRITE_FAIL_REQ_DELAY_TIMEOUT = atoi((char *)(argv[i] + 8));
- } else if (strncmp(argv[i], "--retries=", 10) == 0) {
+ } else if (strncmp(argv[i], "--retries=", 10) == 0) {
OPEN_WRITE_FAIL_MAX_REQ_DELAY_RETRIES = atoi((char *)(argv[i] + 10));
- }
+ }
}
return TS_SUCCESS;
}
TSRemapStatus
-TSRemapDoRemap(void* ih, TSHttpTxn rh, TSRemapRequestInfo *rri)
+TSRemapDoRemap(void *ih, TSHttpTxn rh, TSRemapRequestInfo *rri)
{
TSCont cont = TSContCreate(collapsed_cont, TSMutexCreate());