Updated Branches: refs/heads/master cd6eb8f62 -> 999a3a6ba
TS-1102 More Diags cleanup, and performance improvements. I also added some fixes to get the examples plugins to compile. //leif Author: Uri Shachar Review: Leif Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/999a3a6b Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/999a3a6b Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/999a3a6b Branch: refs/heads/master Commit: 999a3a6ba5f624755b32618ab63ccb640d8c36a3 Parents: cd6eb8f Author: Uri Shachar <ushachar> Authored: Thu Feb 23 14:49:55 2012 -0700 Committer: Leif Hedstrom <[email protected]> Committed: Thu Feb 23 14:49:55 2012 -0700 ---------------------------------------------------------------------- example/blacklist-1/blacklist-1.c | 2 +- example/cache_scan/cache_scan.cc | 6 +- example/null-transform/null-transform.c | 2 +- example/protocol/TxnSM.c | 16 ++- example/redirect-1/redirect-1.c | 3 +- example/response-header-1/response-header-1.c | 10 +- example/session-1/session-1.c | 8 +- lib/ts/Diags.h | 11 +- proxy/http/HttpSM.cc | 6 +- proxy/http/HttpTransact.cc | 124 +++++++------------ proxy/http/HttpTransactCache.cc | 80 ++++++------- proxy/http/HttpTransactHeaders.cc | 24 ++-- 12 files changed, 129 insertions(+), 163 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/999a3a6b/example/blacklist-1/blacklist-1.c ---------------------------------------------------------------------- diff --git a/example/blacklist-1/blacklist-1.c b/example/blacklist-1/blacklist-1.c index e470d94..a1a09b0 100644 --- a/example/blacklist-1/blacklist-1.c +++ b/example/blacklist-1/blacklist-1.c @@ -214,7 +214,7 @@ read_blacklist(TSCont contp) TSfclose(file); } else { TSError("unable to open %s\n", blacklist_file); - TSError("all sites will be allowed\n", blacklist_file); + TSError("all sites will be allowed\n"); } TSMutexUnlock(sites_mutex); http://git-wip-us.apache.org/repos/asf/trafficserver/blob/999a3a6b/example/cache_scan/cache_scan.cc ---------------------------------------------------------------------- diff --git a/example/cache_scan/cache_scan.cc b/example/cache_scan/cache_scan.cc index ac842aa..0873a9f 100644 --- a/example/cache_scan/cache_scan.cc +++ b/example/cache_scan/cache_scan.cc @@ -33,6 +33,10 @@ #include <ts/ts.h> #include <ts/experimental.h> +// This gets the PRI*64 types +#define __STDC_FORMAT_MACROS 1 +#include <inttypes.h> + static TSCont global_contp; struct cache_scan_state_t @@ -286,7 +290,7 @@ handle_io(TSCont contp, TSEvent event, void *edata) } case TS_EVENT_VCONN_WRITE_READY: { - TSDebug("cache_iter", "ndone: %d total_bytes: %d", TSVIONDoneGet(cstate->write_vio), cstate->total_bytes); + TSDebug("cache_iter", "ndone: %" PRId64 " total_bytes: % " PRId64, TSVIONDoneGet(cstate->write_vio), cstate->total_bytes); cstate->write_pending = 0; // the cache scan handler should call vio reenable when there is // available data http://git-wip-us.apache.org/repos/asf/trafficserver/blob/999a3a6b/example/null-transform/null-transform.c ---------------------------------------------------------------------- diff --git a/example/null-transform/null-transform.c b/example/null-transform/null-transform.c index cc7897a..0ca98d7 100644 --- a/example/null-transform/null-transform.c +++ b/example/null-transform/null-transform.c @@ -104,7 +104,7 @@ handle_transform(TSCont contp) data = my_data_alloc(); data->output_buffer = TSIOBufferCreate(); data->output_reader = TSIOBufferReaderAlloc(data->output_buffer); - TSDebug("null-transform", "\tWriting %d bytes on VConn", TSVIONBytesGet(input_vio)); + TSDebug("null-transform", "\tWriting %" PRId64 " bytes on VConn", TSVIONBytesGet(input_vio)); //data->output_vio = TSVConnWrite(output_conn, contp, data->output_reader, INT32_MAX); data->output_vio = TSVConnWrite(output_conn, contp, data->output_reader, INT64_MAX); // data->output_vio = TSVConnWrite(output_conn, contp, data->output_reader, TSVIONBytesGet(input_vio)); http://git-wip-us.apache.org/repos/asf/trafficserver/blob/999a3a6b/example/protocol/TxnSM.c ---------------------------------------------------------------------- diff --git a/example/protocol/TxnSM.c b/example/protocol/TxnSM.c index 92e6f8b..78bfccc 100644 --- a/example/protocol/TxnSM.c +++ b/example/protocol/TxnSM.c @@ -25,6 +25,10 @@ #include <netinet/in.h> #include "TxnSM.h" +// This gets the PRI*64 types +# define __STDC_FORMAT_MACROS 1 +# include <inttypes.h> + extern TSTextLogObject protocol_plugin_log; /* Fix me: currently, tunnelling server_response from OS to both cache and @@ -73,7 +77,7 @@ main_handler(TSCont contp, TSEvent event, void *data) TxnSM *txn_sm = (TxnSM *) TSContDataGet(contp); TxnSMHandler q_current_handler = txn_sm->q_current_handler; - TSDebug("protocol", "main_handler (contp %X event %d)", contp, event); + TSDebug("protocol", "main_handler (contp %p event %d)", contp, event); /* handle common cases errors */ if (event == TS_EVENT_ERROR) { @@ -232,7 +236,7 @@ state_read_request_from_client(TSCont contp, TSEvent event, TSVIO vio) return prepare_to_die(contp); /* Start to do cache lookup */ - TSDebug("protocol", "Key material: file name is %d, %s*****", txn_sm->q_file_name, txn_sm->q_file_name); + TSDebug("protocol", "Key material: file name is %s*****", txn_sm->q_file_name); txn_sm->q_key = (TSCacheKey)CacheKeyCreate(txn_sm->q_file_name); set_handler(txn_sm->q_current_handler, (TxnSMHandler)&state_handle_cache_lookup); @@ -675,7 +679,7 @@ state_write_to_cache(TSCont contp, TSEvent event, TSVIO vio) return TS_SUCCESS; case TS_EVENT_VCONN_WRITE_COMPLETE: - TSDebug("protocol", "nbytes %d, ndone %d", TSVIONBytesGet(vio), TSVIONDoneGet(vio)); + TSDebug("protocol", "nbytes %" PRId64 ", ndone %" PRId64, TSVIONBytesGet(vio), TSVIONDoneGet(vio)); /* Since the first write is through TSVConnWrite, which aleady consume the data in cache_buffer_reader, don't consume it again. */ if (txn_sm->q_cache_response_length > 0 && txn_sm->q_block_bytes_read > 0) @@ -729,13 +733,13 @@ state_send_response_to_client(TSCont contp, TSEvent event, TSVIO vio) switch (event) { case TS_EVENT_VCONN_WRITE_READY: TSDebug("protocol", " . wr ready"); - TSDebug("protocol", "write_ready: nbytes %d, ndone %d", TSVIONBytesGet(vio), TSVIONDoneGet(vio)); + TSDebug("protocol", "write_ready: nbytes %" PRId64", ndone %" PRId64, TSVIONBytesGet(vio), TSVIONDoneGet(vio)); TSVIOReenable(txn_sm->q_client_write_vio); break; case TS_EVENT_VCONN_WRITE_COMPLETE: TSDebug("protocol", " . wr complete"); - TSDebug("protocol", "write_complete: nbytes %d, ndone %d", TSVIONBytesGet(vio), TSVIONDoneGet(vio)); + TSDebug("protocol", "write_complete: nbytes %" PRId64 ", ndone %" PRId64, TSVIONBytesGet(vio), TSVIONDoneGet(vio)); /* Finished sending all data to client, close client_vc. */ if (txn_sm->q_client_vc) { TSVConnClose(txn_sm->q_client_vc); @@ -888,7 +892,7 @@ send_response_to_client(TSCont contp) txn_sm = (TxnSM *) TSContDataGet(contp); response_len = TSIOBufferReaderAvail(txn_sm->q_client_response_buffer_reader); - TSDebug("protocol", " . resp_len is %d, response_len"); + TSDebug("protocol", " . resp_len is %d", response_len); set_handler(txn_sm->q_current_handler, (TxnSMHandler)&state_interface_with_client); txn_sm->q_client_write_vio = TSVConnWrite(txn_sm->q_client_vc, (TSCont) contp, http://git-wip-us.apache.org/repos/asf/trafficserver/blob/999a3a6b/example/redirect-1/redirect-1.c ---------------------------------------------------------------------- diff --git a/example/redirect-1/redirect-1.c b/example/redirect-1/redirect-1.c index 4a09c4d..579b2f7 100644 --- a/example/redirect-1/redirect-1.c +++ b/example/redirect-1/redirect-1.c @@ -427,7 +427,8 @@ TSPluginInit(int argc, const char *argv[]) TSDebug("redirect_init", "block_ip is %s, url_redirect is %s, and uri_redirect is %s", block_ip, url_redirect, uri_redirect); - TSDebug("redirect_init", "ip_deny is %ld\n", ip_deny); + // ToDo: Should figure out how to print IPs which are IPv4 / v6. + // TSDebug("redirect_init", "ip_deny is %ld\n", ip_deny); /* * Demonstrate another tracing function. This can be used to http://git-wip-us.apache.org/repos/asf/trafficserver/blob/999a3a6b/example/response-header-1/response-header-1.c ---------------------------------------------------------------------- diff --git a/example/response-header-1/response-header-1.c b/example/response-header-1/response-header-1.c index fb85eae..30f93f4 100644 --- a/example/response-header-1/response-header-1.c +++ b/example/response-header-1/response-header-1.c @@ -97,7 +97,7 @@ modify_header(TSHttpTxn txnp, TSCont contp) TSDebug("resphdr", "Processing 200 OK"); TSMimeHdrFieldCreate(resp_bufp, resp_loc, &new_field_loc); /* Probably should check for errors */ - TSDebug("resphdr", "Created new resp field with loc %d", new_field_loc); + TSDebug("resphdr", "Created new resp field with loc %p", new_field_loc); /* copy name/values created at init * ( "x-num-served-from-cache" ) : ( "0" ) @@ -110,7 +110,7 @@ modify_header(TSHttpTxn txnp, TSCont contp) /* Cache-Control: Public */ TSMimeHdrFieldCreate(resp_bufp, resp_loc, &new_field_loc); /* Probably should check for errors */ - TSDebug("resphdr", "Created new resp field with loc %d", new_field_loc); + TSDebug("resphdr", "Created new resp field with loc %p", new_field_loc); TSMimeHdrFieldAppend(resp_bufp, resp_loc, new_field_loc); TSMimeHdrFieldNameSet(resp_bufp, resp_loc, new_field_loc, TS_MIME_FIELD_CACHE_CONTROL, TS_MIME_LEN_CACHE_CONTROL); @@ -121,7 +121,7 @@ modify_header(TSHttpTxn txnp, TSCont contp) * mimehdr2_name = TSstrdup( "x-date-200-recvd" ) : CurrentDateTime */ TSMimeHdrFieldCreate(resp_bufp, resp_loc, &new_field_loc); /* Probably should check for errors */ - TSDebug("resphdr", "Created new resp field with loc %d", new_field_loc); + TSDebug("resphdr", "Created new resp field with loc %p", new_field_loc); TSMimeHdrFieldAppend(resp_bufp, resp_loc, new_field_loc); TSMimeHdrFieldNameSet(resp_bufp, resp_loc, new_field_loc, mimehdr2_name, strlen(mimehdr2_name)); recvd_time = time(NULL); @@ -309,7 +309,7 @@ TSPluginInit(int argc, const char *argv[]) TSMimeHdrFieldAppend(hdr_bufp, hdr_loc, field_loc); TSMimeHdrFieldNameSet(hdr_bufp, hdr_loc, field_loc, mimehdr1_name, strlen(mimehdr1_name)); TSMimeHdrFieldValueStringInsert(hdr_bufp, hdr_loc, field_loc, -1, mimehdr1_value, strlen(mimehdr1_value)); - TSDebug("resphdr", "init buffer hdr, field and value locs are %d, %d and %d", hdr_loc, field_loc, value_loc); + TSDebug("resphdr", "init buffer hdr, field and value locs are %p, %p and %p", hdr_loc, field_loc, value_loc); init_buffer_status = 1; @@ -328,6 +328,6 @@ TSPluginInit(int argc, const char *argv[]) /* bail out here and reenable transaction */ } else { if (field_loc != chk_field_loc) - TSError("retrieved buffer field loc is %d when it should be %d", chk_field_loc, field_loc); + TSError("retrieved buffer field loc is %p when it should be %p", chk_field_loc, field_loc); } } http://git-wip-us.apache.org/repos/asf/trafficserver/blob/999a3a6b/example/session-1/session-1.c ---------------------------------------------------------------------- diff --git a/example/session-1/session-1.c b/example/session-1/session-1.c index 63269b3..ff2417a 100644 --- a/example/session-1/session-1.c +++ b/example/session-1/session-1.c @@ -32,6 +32,10 @@ #include <stdio.h> #include <ts/ts.h> +// This gets the PRI*64 types +# define __STDC_FORMAT_MACROS 1 +# include <inttypes.h> + static INKStat transaction_count; static INKStat session_count; static INKStat av_transaction; @@ -44,7 +48,7 @@ txn_handler(TSHttpTxn txnp, TSCont contp) INKStatIncrement(transaction_count); num_txns = INKStatIntGet(transaction_count); - TSDebug("tag_session", "The number of transactions is %d\n", num_txns); + TSDebug("tag_session", "The number of transactions is %" PRId64, num_txns); } @@ -55,7 +59,7 @@ handle_session(TSHttpSsn ssnp, TSCont contp) INKStatIncrement(session_count); num_ssn = INKStatIntGet(session_count); - TSDebug("tag_session", "The number of sessions is %d\n", num_ssn); + TSDebug("tag_session", "The number of sessions is %" PRId64, num_ssn); TSHttpSsnHookAdd(ssnp, TS_HTTP_TXN_START_HOOK, contp); } http://git-wip-us.apache.org/repos/asf/trafficserver/blob/999a3a6b/lib/ts/Diags.h ---------------------------------------------------------------------- diff --git a/lib/ts/Diags.h b/lib/ts/Diags.h index 98a43ea..eb14afc 100644 --- a/lib/ts/Diags.h +++ b/lib/ts/Diags.h @@ -273,10 +273,8 @@ dummy_debug(const char *tag, const char *fmt, ...) } -#define Diag(tag, ...) diags->log(tag, DTA(DL_Diag), __VA_ARGS__) -#define Debug(tag, ...) diags->log(tag, DTA(DL_Debug), __VA_ARGS__) -#define Debug(tag, ...) diags->log(tag, DTA(DL_Debug), __VA_ARGS__) -#define DebugOn(tag, ...) diags->log(tag, DTA(DL_Debug), __VA_ARGS__) +#define Diag(tag, ...) if (diags->on()) diags->log(tag, DTA(DL_Diag), __VA_ARGS__) +#define Debug(tag, ...) if (diags->on()) diags->log(tag, DTA(DL_Debug), __VA_ARGS__) #define Status(...) diags->error(DTA(DL_Status), __VA_ARGS__) #define Note(...) diags->error(DTA(DL_Note), __VA_ARGS__) @@ -327,9 +325,8 @@ dummy_debug(const char *tag, const char *fmt, ...) (void)fmt; } -#define Diag(tag, fmt, ...) if (0) dummy_debug(tag, fmt, ##__VA_ARGS__) -#define Debug(tag, fmt, ...) if (0) dummy_debug(tag, fmt, ##__VA_ARGS__) -#define DebugOn(tag, fmt, ...) if (0) dummy_debug(tag, fmt, ##__VA_ARGS__) +#define Diag(tag, fmt, ...) if (0) dummy_debug(tag, __VA_ARGS__) +#define Debug(tag, fmt, ...) if (0) dummy_debug(tag, __VA_ARGS__) #define is_debug_tag_set(_t) 0 #define is_action_tag_set(_t) 0 http://git-wip-us.apache.org/repos/asf/trafficserver/blob/999a3a6b/proxy/http/HttpSM.cc ---------------------------------------------------------------------- diff --git a/proxy/http/HttpSM.cc b/proxy/http/HttpSM.cc index 00d1b76..2f069ef 100644 --- a/proxy/http/HttpSM.cc +++ b/proxy/http/HttpSM.cc @@ -2384,10 +2384,8 @@ HttpSM::state_cache_open_read(int event, void *data) case CACHE_EVENT_OPEN_READ_FAILED: pending_action = NULL; - if (diags->on()) { - DebugOn("http", "[%" PRId64 "] cache_open_read - " "CACHE_EVENT_OPEN_READ_FAILED", sm_id); - DebugOn("http", "[state_cache_open_read] open read failed."); - } + Debug("http", "[%" PRId64 "] cache_open_read - " "CACHE_EVENT_OPEN_READ_FAILED", sm_id); + Debug("http", "[state_cache_open_read] open read failed."); // Inform HttpTransact somebody else is updating the document // HttpCacheSM already waited so transact should go ahead. if (data == (void *) -ECACHE_DOC_BUSY) http://git-wip-us.apache.org/repos/asf/trafficserver/blob/999a3a6b/proxy/http/HttpTransact.cc ---------------------------------------------------------------------- diff --git a/proxy/http/HttpTransact.cc b/proxy/http/HttpTransact.cc index 5f888e0..b10930b 100644 --- a/proxy/http/HttpTransact.cc +++ b/proxy/http/HttpTransact.cc @@ -1614,10 +1614,8 @@ HttpTransact::OSDNSLookup(State* s) // On the other hand, if the lookup succeeded on a www.<hostname>.com // expansion, return a 302 response. if (s->dns_info.attempts == max_dns_lookups && s->dns_info.looking_up == ORIGIN_SERVER) { - if (diags->on()) { - DebugOn("http_trans", "[OSDNSLookup] DNS name resolution on expansion"); - DebugOn("http_seq", "[OSDNSLookup] DNS name resolution on expansion - returning"); - } + Debug("http_trans", "[OSDNSLookup] DNS name resolution on expansion"); + Debug("http_seq", "[OSDNSLookup] DNS name resolution on expansion - returning"); build_redirect_response(s); // s->cache_info.action = CACHE_DO_NO_ACTION; TRANSACT_RETURN(PROXY_INTERNAL_CACHE_NOOP, NULL); @@ -1719,10 +1717,8 @@ HttpTransact::HandleFiltering(State* s) if (s->method == HTTP_WKSIDX_PUSH && s->http_config_param->push_method_enabled == 0) { // config file says this request is not authorized. // send back error response to client. - if (diags->on()) { - DebugOn("http_trans", "[HandleFiltering] access denied."); - DebugOn("http_seq", "[HttpTransact::HandleFiltering] Access Denied."); - } + Debug("http_trans", "[HandleFiltering] access denied."); + Debug("http_seq", "[HttpTransact::HandleFiltering] Access Denied."); SET_VIA_STRING(VIA_DETAIL_TUNNEL, VIA_DETAIL_TUNNEL_NO_FORWARD); // adding a comment so that cvs recognizes that I added a space in the text below @@ -1772,10 +1768,8 @@ HttpTransact::DecideCacheLookup(State* s) // now decide whether the cache can even be looked up. if (s->cache_info.action == CACHE_DO_LOOKUP) { - if (diags->on()) { - DebugOn("http_trans", "[DecideCacheLookup] Will do cache lookup."); - DebugOn("http_seq", "[DecideCacheLookup] Will do cache lookup"); - } + Debug("http_trans", "[DecideCacheLookup] Will do cache lookup."); + Debug("http_seq", "[DecideCacheLookup] Will do cache lookup"); ink_debug_assert(s->current.mode != TUNNELLING_PROXY); if (s->cache_info.lookup_url == NULL) { @@ -1825,10 +1819,8 @@ HttpTransact::DecideCacheLookup(State* s) } else { ink_assert(s->cache_info.action != CACHE_DO_LOOKUP && s->cache_info.action != CACHE_DO_SERVE); - if (diags->on()) { - DebugOn("http_trans", "[DecideCacheLookup] Will NOT do cache lookup."); - DebugOn("http_seq", "[DecideCacheLookup] Will NOT do cache lookup"); - } + Debug("http_trans", "[DecideCacheLookup] Will NOT do cache lookup."); + Debug("http_seq", "[DecideCacheLookup] Will NOT do cache lookup"); // If this is a push request, we need send an error because // since what ever was sent is not cachable if (s->method == HTTP_WKSIDX_PUSH) { @@ -2250,12 +2242,10 @@ HttpTransact::HandleCacheOpenReadHitFreshness(State* s) ink_debug_assert(s->request_sent_time <= s->response_received_time); - if (diags->on()) { - DebugOn("http_trans", "[HandleCacheOpenReadHitFreshness] request_sent_time : %lld", - (long long)s->request_sent_time); - DebugOn("http_trans", "[HandleCacheOpenReadHitFreshness] response_received_time : %lld", - (long long)s->response_received_time); - } + Debug("http_trans", "[HandleCacheOpenReadHitFreshness] request_sent_time : %lld", + (long long)s->request_sent_time); + Debug("http_trans", "[HandleCacheOpenReadHitFreshness] response_received_time : %lld", + (long long)s->response_received_time); // if the plugin has already decided the freshness, we don't need to // do it again if (s->cache_lookup_result == HttpTransact::CACHE_LOOKUP_NONE) { @@ -2494,13 +2484,11 @@ HttpTransact::HandleCacheOpenReadHit(State* s) s->range_setup = RANGE_REVALIDATE; } - if (diags->on()) { - DebugOn("http_trans", "CacheOpenRead --- needs_auth = %d", needs_authenticate); - DebugOn("http_trans", "CacheOpenRead --- needs_revalidate = %d", needs_revalidate); - DebugOn("http_trans", "CacheOpenRead --- response_returnable = %d", response_returnable); - DebugOn("http_trans", "CacheOpenRead --- needs_cache_auth = %d", needs_cache_auth); - DebugOn("http_trans", "CacheOpenRead --- send_revalidate = %d", send_revalidate); - } + Debug("http_trans", "CacheOpenRead --- needs_auth = %d", needs_authenticate); + Debug("http_trans", "CacheOpenRead --- needs_revalidate = %d", needs_revalidate); + Debug("http_trans", "CacheOpenRead --- response_returnable = %d", response_returnable); + Debug("http_trans", "CacheOpenRead --- needs_cache_auth = %d", needs_cache_auth); + Debug("http_trans", "CacheOpenRead --- send_revalidate = %d", send_revalidate); if (send_revalidate) { Debug("http_trans", "CacheOpenRead --- HIT-STALE"); s->dns_info.attempts = 0; @@ -2612,10 +2600,8 @@ HttpTransact::HandleCacheOpenReadHit(State* s) // ink_debug_assert((send_revalidate == true && server_up == false) || (send_revalidate == false && server_up == true)); - if (diags->on()) { - DebugOn("http_trans", "CacheOpenRead --- HIT-FRESH"); - DebugOn("http_seq", "[HttpTransact::HandleCacheOpenReadHit] " "Serve from cache"); - } + Debug("http_trans", "CacheOpenRead --- HIT-FRESH"); + Debug("http_seq", "[HttpTransact::HandleCacheOpenReadHit] " "Serve from cache"); if (s->cache_info.is_ram_cache_hit) { SET_VIA_STRING(VIA_CACHE_RESULT, VIA_IN_RAM_CACHE_FRESH); @@ -2879,10 +2865,8 @@ HttpTransact::handle_cache_write_lock(State* s) void HttpTransact::HandleCacheOpenReadMiss(State* s) { - if (diags->on()) { - DebugOn("http_trans", "[HandleCacheOpenReadMiss] --- MISS"); - DebugOn("http_seq", "[HttpTransact::HandleCacheOpenReadMiss] " "Miss in cache"); - } + Debug("http_trans", "[HandleCacheOpenReadMiss] --- MISS"); + Debug("http_seq", "[HttpTransact::HandleCacheOpenReadMiss] " "Miss in cache"); if (delete_all_document_alternates_and_return(s, FALSE)) { Debug("http_trans", "[HandleCacheOpenReadMiss] Delete and return"); @@ -3115,10 +3099,8 @@ HttpTransact::OriginServerRawOpen(State* s) void HttpTransact::HandleResponse(State* s) { - if (diags->on()) { - DebugOn("http_trans", "[HttpTransact::HandleResponse]"); - DebugOn("http_seq", "[HttpTransact::HandleResponse] Response received"); - } + Debug("http_trans", "[HttpTransact::HandleResponse]"); + Debug("http_seq", "[HttpTransact::HandleResponse] Response received"); s->source = SOURCE_HTTP_ORIGIN_SERVER; s->response_received_time = ink_cluster_time(); @@ -3688,11 +3670,9 @@ HttpTransact::delete_server_rr_entry(State* s, int max_retries) { char addrbuf[INET6_ADDRSTRLEN]; - if (diags->on()) { - DebugOn("http_trans", "[%d] failed to connect to %s", s->current.attempts, - ats_ip_ntop(&s->current.server->addr.sa, addrbuf, sizeof(addrbuf))); - DebugOn("http_trans", "[delete_server_rr_entry] marking rr entry " "down and finding next one"); - } + Debug("http_trans", "[%d] failed to connect to %s", s->current.attempts, + ats_ip_ntop(&s->current.server->addr.sa, addrbuf, sizeof(addrbuf))); + Debug("http_trans", "[delete_server_rr_entry] marking rr entry " "down and finding next one"); ink_debug_assert(s->current.server->connect_failure); ink_debug_assert(s->current.request_to == ORIGIN_SERVER); ink_debug_assert(s->current.server == &s->server_info); @@ -3768,10 +3748,8 @@ HttpTransact::handle_server_connection_not_open(State* s) { bool serve_from_cache = false; - if (diags->on()) { - DebugOn("http_trans", "[handle_server_connection_not_open] (hscno)"); - DebugOn("http_seq", "[HttpTransact::handle_server_connection_not_open] "); - } + Debug("http_trans", "[handle_server_connection_not_open] (hscno)"); + Debug("http_seq", "[HttpTransact::handle_server_connection_not_open] "); ink_debug_assert(s->current.state != CONNECTION_ALIVE); ink_debug_assert(s->current.server->connect_failure != 0); @@ -3851,10 +3829,8 @@ HttpTransact::handle_server_connection_not_open(State* s) void HttpTransact::handle_forward_server_connection_open(State* s) { - if (diags->on()) { - DebugOn("http_trans", "[handle_forward_server_connection_open] (hfsco)"); - DebugOn("http_seq", "[HttpTransact::handle_server_connection_open] "); - } + Debug("http_trans", "[handle_forward_server_connection_open] (hfsco)"); + Debug("http_seq", "[HttpTransact::handle_server_connection_open] "); ink_release_assert(s->current.state == CONNECTION_ALIVE); if (s->hdr_info.server_response.version_get() == HTTPVersion(0, 9)) { @@ -4040,10 +4016,8 @@ HttpTransact::build_response_copy(State* s, HTTPHdr* base_response,HTTPHdr* outg void HttpTransact::handle_cache_operation_on_forward_server_response(State* s) { - if (diags->on()) { - DebugOn("http_trans", "[handle_cache_operation_on_forward_server_response] (hcoofsr)"); - DebugOn("http_seq", "[handle_cache_operation_on_forward_server_response]"); - } + Debug("http_trans", "[handle_cache_operation_on_forward_server_response] (hcoofsr)"); + Debug("http_seq", "[handle_cache_operation_on_forward_server_response]"); HTTPHdr *base_response = NULL; HTTPStatus server_response_code = HTTP_STATUS_NONE; @@ -4052,10 +4026,8 @@ HttpTransact::handle_cache_operation_on_forward_server_response(State* s) bool cacheable = false; cacheable = is_response_cacheable(s, &s->hdr_info.client_request, &s->hdr_info.server_response); - if (diags->on()) { - if (cacheable) { - DebugOn("http_trans", "[hcoofsr] response cacheable"); - } + if (cacheable) { + Debug("http_trans", "[hcoofsr] response cacheable"); } // set the correct next action, cache action, response code, and base response @@ -4501,10 +4473,8 @@ HttpTransact::handle_cache_operation_on_forward_server_response(State* s) void HttpTransact::handle_no_cache_operation_on_forward_server_response(State* s) { - if (diags->on()) { - DebugOn("http_trans", "[handle_no_cache_operation_on_forward_server_response] (hncoofsr)"); - DebugOn("http_seq", "[handle_no_cache_operation_on_forward_server_response]"); - } + Debug("http_trans", "[handle_no_cache_operation_on_forward_server_response] (hncoofsr)"); + Debug("http_seq", "[handle_no_cache_operation_on_forward_server_response]"); bool keep_alive = true; keep_alive = ((s->current.server->keep_alive == HTTP_KEEPALIVE) || (s->current.server->keep_alive == HTTP_PIPELINE)); @@ -7508,33 +7478,31 @@ HttpTransact::what_is_document_freshness(State *s, HTTPHdr* client_request, HTTP Debug("http_match", "[..._document_freshness] revalidate_after set, age limit: %d", age_limit); } - if (diags->on()) { - DebugOn("http_match", "document_freshness --- current_age = %lld", (long long)current_age); - DebugOn("http_match", "document_freshness --- age_limit = %d", age_limit); - DebugOn("http_match", "document_freshness --- fresh_limit = %d", fresh_limit); - DebugOn("http_seq", "document_freshness --- current_age = %lld", (long long)current_age); - DebugOn("http_seq", "document_freshness --- age_limit = %d", age_limit); - DebugOn("http_seq", "document_freshness --- fresh_limit = %d", fresh_limit); - } + Debug("http_match", "document_freshness --- current_age = %lld", (long long)current_age); + Debug("http_match", "document_freshness --- age_limit = %d", age_limit); + Debug("http_match", "document_freshness --- fresh_limit = %d", fresh_limit); + Debug("http_seq", "document_freshness --- current_age = %lld", (long long)current_age); + Debug("http_seq", "document_freshness --- age_limit = %d", age_limit); + Debug("http_seq", "document_freshness --- fresh_limit = %d", fresh_limit); /////////////////////////////////////////// // now, see if the age is "fresh enough" // /////////////////////////////////////////// if (do_revalidate || current_age > age_limit) { // client-modified limit - DebugOn("http_match", "[..._document_freshness] document needs revalidate/too old; " + Debug("http_match", "[..._document_freshness] document needs revalidate/too old; " "returning FRESHNESS_STALE"); return (FRESHNESS_STALE); } else if (current_age > fresh_limit) { // original limit if (os_specifies_revalidate) { - DebugOn("http_match", "[..._document_freshness] document is stale and OS specifies revalidation; " + Debug("http_match", "[..._document_freshness] document is stale and OS specifies revalidation; " "returning FRESHNESS_STALE"); return (FRESHNESS_STALE); } - DebugOn("http_match", "[..._document_freshness] document is stale but no revalidation explicitly required; " + Debug("http_match", "[..._document_freshness] document is stale but no revalidation explicitly required; " "returning FRESHNESS_WARNING"); return (FRESHNESS_WARNING); } else { - DebugOn("http_match", "[..._document_freshness] document is fresh; returning FRESHNESS_FRESH"); + Debug("http_match", "[..._document_freshness] document is fresh; returning FRESHNESS_FRESH"); return (FRESHNESS_FRESH); } } http://git-wip-us.apache.org/repos/asf/trafficserver/blob/999a3a6b/proxy/http/HttpTransactCache.cc ---------------------------------------------------------------------- diff --git a/proxy/http/HttpTransactCache.cc b/proxy/http/HttpTransactCache.cc index 01c0f7c..a44e34d 100644 --- a/proxy/http/HttpTransactCache.cc +++ b/proxy/http/HttpTransactCache.cc @@ -181,14 +181,12 @@ HttpTransactCache::SelectFromAlternates(CacheHTTPInfoVector * cache_vector, } - if (diags->on()) { - DebugOn("http_match", "[SelectFromAlternates] # alternates = %d", alt_count); - DebugOn("http_seq", "[SelectFromAlternates] %d alternates for this cached doc", alt_count); - if (diags->on("http_alts")) { - ACQUIRE_PRINT_LOCK() - fprintf(stderr, "[alts] There are %d alternates for this request header.\n", alt_count); - RELEASE_PRINT_LOCK() - } + Debug("http_match", "[SelectFromAlternates] # alternates = %d", alt_count); + Debug("http_seq", "[SelectFromAlternates] %d alternates for this cached doc", alt_count); + if (diags->on("http_alts")) { + ACQUIRE_PRINT_LOCK() + fprintf(stderr, "[alts] There are %d alternates for this request header.\n", alt_count); + RELEASE_PRINT_LOCK() } // used by ICP to bypass this function if (http_config_params == &global_cache_lookup_config) @@ -262,13 +260,11 @@ HttpTransactCache::SelectFromAlternates(CacheHTTPInfoVector * cache_vector, } } } - if (diags->on()) { - DebugOn("http_seq", "[SelectFromAlternates] Chosen alternate # %d", best_index); - if (diags->on("http_alts")) { - ACQUIRE_PRINT_LOCK() - fprintf(stderr, "[alts] and the winner is alternate number %d\n", best_index + 1); - RELEASE_PRINT_LOCK() - } + Debug("http_seq", "[SelectFromAlternates] Chosen alternate # %d", best_index); + if (diags->on("http_alts")) { + ACQUIRE_PRINT_LOCK() + fprintf(stderr, "[alts] and the winner is alternate number %d\n", best_index + 1); + RELEASE_PRINT_LOCK() } if ((best_index != -1) && (best_Q > unacceptable_Q)) { @@ -392,26 +388,24 @@ HttpTransactCache::calculate_quality_of_match(CacheLookupHttpConfig * http_confi // final quality is minimum Q, or -1, if some match failed // Q = ((q[0] < 0) || (q[1] < 0) || (q[2] < 0) || (q[3] < 0)) ? -1.0 : q[0] * q[1] * q[2] * q[3]; - if (diags->on()) { - DebugOn("http_match", " CalcQualityOfMatch: Accept match = %g", q[0]); - DebugOn("http_seq", " CalcQualityOfMatch: Accept match = %g", q[0]); - DebugOn("http_alternate", "Content-Type and Accept %f", q[0]); + Debug("http_match", " CalcQualityOfMatch: Accept match = %g", q[0]); + Debug("http_seq", " CalcQualityOfMatch: Accept match = %g", q[0]); + Debug("http_alternate", "Content-Type and Accept %f", q[0]); - DebugOn("http_match", " CalcQualityOfMatch: AcceptCharset match = %g", q[1]); - DebugOn("http_seq", " CalcQualityOfMatch: AcceptCharset match = %g", q[1]); - DebugOn("http_alternate", "Content-Type and Accept-Charset %f", q[1]); + Debug("http_match", " CalcQualityOfMatch: AcceptCharset match = %g", q[1]); + Debug("http_seq", " CalcQualityOfMatch: AcceptCharset match = %g", q[1]); + Debug("http_alternate", "Content-Type and Accept-Charset %f", q[1]); - DebugOn("http_match", " CalcQualityOfMatch: AcceptEncoding match = %g", q[2]); - DebugOn("http_seq", " CalcQualityOfMatch: AcceptEncoding match = %g", q[2]); - DebugOn("http_alternate", "Content-Encoding and Accept-Encoding %f", q[2]); + Debug("http_match", " CalcQualityOfMatch: AcceptEncoding match = %g", q[2]); + Debug("http_seq", " CalcQualityOfMatch: AcceptEncoding match = %g", q[2]); + Debug("http_alternate", "Content-Encoding and Accept-Encoding %f", q[2]); - DebugOn("http_match", " CalcQualityOfMatch: AcceptLanguage match = %g", q[3]); - DebugOn("http_seq", " CalcQualityOfMatch: AcceptLanguage match = %g", q[3]); - DebugOn("http_alternate", "Content-Language and Accept-Language %f", q[3]); + Debug("http_match", " CalcQualityOfMatch: AcceptLanguage match = %g", q[3]); + Debug("http_seq", " CalcQualityOfMatch: AcceptLanguage match = %g", q[3]); + Debug("http_alternate", "Content-Language and Accept-Language %f", q[3]); - DebugOn("http_alternate", "Mult's Quality Factor: %f", Q); - DebugOn("http_alternate", "----------End of Alternate----------"); - } + Debug("http_alternate", "Mult's Quality Factor: %f", Q); + Debug("http_alternate", "----------End of Alternate----------"); if (Q > 0.0) { APIHook *hook; @@ -455,15 +449,13 @@ HttpTransactCache::calculate_quality_of_match(CacheLookupHttpConfig * http_confi Q = -1.0; } - if (diags->on()) { - DebugOn("http_match", " CalcQualityOfMatch: CalcVariability says variability = %d", - (variability != VARIABILITY_NONE)); - DebugOn("http_seq", " CalcQualityOfMatch: CalcVariability says variability = %d", - (variability != VARIABILITY_NONE)); + Debug("http_match", " CalcQualityOfMatch: CalcVariability says variability = %d", + (variability != VARIABILITY_NONE)); + Debug("http_seq", " CalcQualityOfMatch: CalcVariability says variability = %d", + (variability != VARIABILITY_NONE)); - DebugOn("http_match", " CalcQualityOfMatch: Returning final Q = %g", Q); - DebugOn("http_seq", " CalcQualityOfMatch: Returning final Q = %g", Q); - } + Debug("http_match", " CalcQualityOfMatch: Returning final Q = %g", Q); + Debug("http_seq", " CalcQualityOfMatch: Returning final Q = %g", Q); } return (Q); } @@ -1208,8 +1200,8 @@ HttpTransactCache::CalcVariability(CacheLookupHttpConfig * http_config_params, HttpCompat::parse_comma_list(&vary_list, (vary_values ? vary_values : "")); } #ifdef DEBUG - if (diags->on("http_match") && vary_list.head) { - DebugOn("http_match", "Vary list of %d elements", vary_list.count); + if (vary_list.head) { + Debug("http_match", "Vary list of %d elements", vary_list.count); vary_list.dump(stderr); } #endif @@ -1228,9 +1220,9 @@ HttpTransactCache::CalcVariability(CacheLookupHttpConfig * http_config_params, if (((field->str[0] == '*') && (field->str[1] == NUL))) { #ifdef DEBUG - if (diags->on("http_match")) { - Note("\"Vary: %s\" --- object not served from cache\n", field->str); - } + if (diags->on("http_match")) { + Note("\"Vary: %s\" --- object not served from cache\n", field->str); + } #endif variability = VARIABILITY_ALL; break; http://git-wip-us.apache.org/repos/asf/trafficserver/blob/999a3a6b/proxy/http/HttpTransactHeaders.cc ---------------------------------------------------------------------- diff --git a/proxy/http/HttpTransactHeaders.cc b/proxy/http/HttpTransactHeaders.cc index cabae22..ce9475f 100644 --- a/proxy/http/HttpTransactHeaders.cc +++ b/proxy/http/HttpTransactHeaders.cc @@ -435,19 +435,17 @@ HttpTransactHeaders::calculate_document_age(ink_time_t request_time, current_age = corrected_initial_age + resident_time; } - if (diags->on()) { - DebugOn("http_age", "[calculate_document_age] age_value: %lld", (long long)age_value); - DebugOn("http_age", "[calculate_document_age] date_value: %lld", (long long)date_value); - DebugOn("http_age", "[calculate_document_age] response_time: %lld", (long long)response_time); - DebugOn("http_age", "[calculate_document_age] now: %lld", (long long)now); - DebugOn("http_age", "[calculate_document_age] now (fixed): %lld", (long long)now_value); - DebugOn("http_age", "[calculate_document_age] apparent_age: %lld", (long long)apparent_age); - DebugOn("http_age", "[calculate_document_age] corrected_received_age: %lld", (long long)corrected_received_age); - DebugOn("http_age", "[calculate_document_age] response_delay: %lld", (long long)response_delay); - DebugOn("http_age", "[calculate_document_age] corrected_initial_age: %lld", (long long)corrected_initial_age); - DebugOn("http_age", "[calculate_document_age] resident_time: %lld", (long long)resident_time); - DebugOn("http_age", "[calculate_document_age] current_age: %lld", (long long)current_age); - } + Debug("http_age", "[calculate_document_age] age_value: %lld", (long long)age_value); + Debug("http_age", "[calculate_document_age] date_value: %lld", (long long)date_value); + Debug("http_age", "[calculate_document_age] response_time: %lld", (long long)response_time); + Debug("http_age", "[calculate_document_age] now: %lld", (long long)now); + Debug("http_age", "[calculate_document_age] now (fixed): %lld", (long long)now_value); + Debug("http_age", "[calculate_document_age] apparent_age: %lld", (long long)apparent_age); + Debug("http_age", "[calculate_document_age] corrected_received_age: %lld", (long long)corrected_received_age); + Debug("http_age", "[calculate_document_age] response_delay: %lld", (long long)response_delay); + Debug("http_age", "[calculate_document_age] corrected_initial_age: %lld", (long long)corrected_initial_age); + Debug("http_age", "[calculate_document_age] resident_time: %lld", (long long)resident_time); + Debug("http_age", "[calculate_document_age] current_age: %lld", (long long)current_age); return current_age; }
