This is an automated email from the ASF dual-hosted git repository. jpeach pushed a commit to branch master in repository https://git-dual.apache.org/repos/asf/trafficserver.git
commit 41e013db839c0ece543ddc854805fa59a731b0db Author: James Peach <[email protected]> AuthorDate: Fri Apr 29 20:04:20 2016 -0700 TS-4388: Rename ParentResult:r. A single-letter state variable name is hard to read and hard to search for. Rename this to result since it is the result of a parent proxy lookup. --- iocore/net/Socks.cc | 6 +++--- proxy/ParentConsistentHash.cc | 20 ++++++++++---------- proxy/ParentRoundRobin.cc | 22 +++++++++++----------- proxy/ParentSelection.cc | 40 ++++++++++++++++++++-------------------- proxy/ParentSelection.h | 4 ++-- proxy/http/HttpSM.cc | 6 +++--- proxy/http/HttpTransact.cc | 28 ++++++++++++++-------------- 7 files changed, 63 insertions(+), 63 deletions(-) diff --git a/iocore/net/Socks.cc b/iocore/net/Socks.cc index a4b0330..792c949 100644 --- a/iocore/net/Socks.cc +++ b/iocore/net/Socks.cc @@ -87,7 +87,7 @@ SocksEntry::findServer() #ifdef SOCKS_WITH_TS if (nattempts == 1) { - ink_assert(server_result.r == PARENT_UNDEFINED); + ink_assert(server_result.result == PARENT_UNDEFINED); server_params->findParent(&req_data, &server_result); } else { socks_conf_struct *conf = netProcessor.socks_conf_stuff; @@ -97,12 +97,12 @@ SocksEntry::findServer() server_params->markParentDown(&server_result); if (nattempts > conf->connection_attempts) - server_result.r = PARENT_FAIL; + server_result.result = PARENT_FAIL; else server_params->nextParent(&req_data, &server_result); } - switch (server_result.r) { + switch (server_result.result) { case PARENT_SPECIFIED: // Original was inet_addr, but should hostnames work? // ats_ip_pton only supports numeric (because other clients diff --git a/proxy/ParentConsistentHash.cc b/proxy/ParentConsistentHash.cc index 6c19e9a..1b5e396 100644 --- a/proxy/ParentConsistentHash.cc +++ b/proxy/ParentConsistentHash.cc @@ -105,9 +105,9 @@ ParentConsistentHash::selectParent(const ParentSelectionPolicy *policy, bool fir // Should only get into this state if we are supposed to go direct. if (parents[PRIMARY] == NULL && parents[SECONDARY] == NULL) { if (result->rec->go_direct == true && result->rec->parent_is_proxy == true) { - result->r = PARENT_DIRECT; + result->result = PARENT_DIRECT; } else { - result->r = PARENT_FAIL; + result->result = PARENT_FAIL; } result->hostname = NULL; result->port = 0; @@ -156,7 +156,7 @@ ParentConsistentHash::selectParent(const ParentSelectionPolicy *policy, bool fir result->last_parent = pRec->idx; result->last_lookup = last_lookup; result->retry = parentRetry; - result->r = PARENT_SPECIFIED; + result->result = PARENT_SPECIFIED; Debug("parent_select", "Down parent %s is now retryable, marked it available.", pRec->hostname); break; } @@ -196,7 +196,7 @@ ParentConsistentHash::selectParent(const ParentSelectionPolicy *policy, bool fir // use the available or marked for retry parent. if (pRec && (pRec->available || result->retry)) { - result->r = PARENT_SPECIFIED; + result->result = PARENT_SPECIFIED; result->hostname = pRec->hostname; result->port = pRec->port; result->last_parent = pRec->idx; @@ -207,9 +207,9 @@ ParentConsistentHash::selectParent(const ParentSelectionPolicy *policy, bool fir Debug("parent_select", "Chosen parent: %s.%d", result->hostname, result->port); } else { if (result->rec->go_direct == true && result->rec->parent_is_proxy == true) { - result->r = PARENT_DIRECT; + result->result = PARENT_DIRECT; } else { - result->r = PARENT_FAIL; + result->result = PARENT_FAIL; } result->hostname = NULL; result->port = 0; @@ -230,8 +230,8 @@ ParentConsistentHash::markParentDown(const ParentSelectionPolicy *policy, Parent // Make sure that we are being called back with with a // result structure with a parent - ink_assert(result->r == PARENT_SPECIFIED); - if (result->r != PARENT_SPECIFIED) { + ink_assert(result->result == PARENT_SPECIFIED); + if (result->result != PARENT_SPECIFIED) { return; } // If we were set through the API we currently have not failover @@ -306,8 +306,8 @@ ParentConsistentHash::markParentUp(ParentResult *result) // Make sure that we are being called back with with a // result structure with a parent that is being retried ink_release_assert(result->retry == true); - ink_assert(result->r == PARENT_SPECIFIED); - if (result->r != PARENT_SPECIFIED) { + ink_assert(result->result == PARENT_SPECIFIED); + if (result->result != PARENT_SPECIFIED) { return; } // If we were set through the API we currently have not failover diff --git a/proxy/ParentRoundRobin.cc b/proxy/ParentRoundRobin.cc index ac453d3..0716d78 100644 --- a/proxy/ParentRoundRobin.cc +++ b/proxy/ParentRoundRobin.cc @@ -69,9 +69,9 @@ ParentRoundRobin::selectParent(const ParentSelectionPolicy *policy, bool first_c ink_assert(result->rec->go_direct == true); // Could not find a parent if (result->rec->go_direct == true && result->rec->parent_is_proxy == true) { - result->r = PARENT_DIRECT; + result->result = PARENT_DIRECT; } else { - result->r = PARENT_FAIL; + result->result = PARENT_FAIL; } result->hostname = NULL; @@ -112,9 +112,9 @@ ParentRoundRobin::selectParent(const ParentSelectionPolicy *policy, bool first_c if (bypass_ok == true) { // Could not find a parent if (result->rec->go_direct == true && result->rec->parent_is_proxy == true) { - result->r = PARENT_DIRECT; + result->result = PARENT_DIRECT; } else { - result->r = PARENT_FAIL; + result->result = PARENT_FAIL; } result->hostname = NULL; result->port = 0; @@ -153,7 +153,7 @@ ParentRoundRobin::selectParent(const ParentSelectionPolicy *policy, bool first_c } if (parentUp == true) { - result->r = PARENT_SPECIFIED; + result->result = PARENT_SPECIFIED; result->hostname = result->rec->parents[cur_index].hostname; result->port = result->rec->parents[cur_index].port; result->last_parent = cur_index; @@ -167,9 +167,9 @@ ParentRoundRobin::selectParent(const ParentSelectionPolicy *policy, bool first_c } while ((unsigned int)cur_index != result->start_parent); if (result->rec->go_direct == true && result->rec->parent_is_proxy == true) { - result->r = PARENT_DIRECT; + result->result = PARENT_DIRECT; } else { - result->r = PARENT_FAIL; + result->result = PARENT_FAIL; } result->hostname = NULL; @@ -192,8 +192,8 @@ ParentRoundRobin::markParentDown(const ParentSelectionPolicy *policy, ParentResu Debug("parent_select", "Starting ParentRoundRobin::markParentDown()"); // Make sure that we are being called back with with a // result structure with a parent - ink_assert(result->r == PARENT_SPECIFIED); - if (result->r != PARENT_SPECIFIED) { + ink_assert(result->result == PARENT_SPECIFIED); + if (result->result != PARENT_SPECIFIED) { return; } // If we were set through the API we currently have not failover @@ -251,8 +251,8 @@ ParentRoundRobin::markParentUp(ParentResult *result) // Make sure that we are being called back with with a // result structure with a parent that is being retried ink_release_assert(result->retry == true); - ink_assert(result->r == PARENT_SPECIFIED); - if (result->r != PARENT_SPECIFIED) { + ink_assert(result->result == PARENT_SPECIFIED); + if (result->result != PARENT_SPECIFIED) { return; } // If we were set through the API we currently have not failover diff --git a/proxy/ParentSelection.cc b/proxy/ParentSelection.cc index abb6cb5..280ac9c 100644 --- a/proxy/ParentSelection.cc +++ b/proxy/ParentSelection.cc @@ -110,12 +110,12 @@ ParentConfigParams::findParent(HttpRequestData *rdata, ParentResult *result) ParentRecord *rec; Debug("parent_select", "In ParentConfigParams::findParent(): parent_table: %p.", parent_table); - ink_assert(result->r == PARENT_UNDEFINED); + ink_assert(result->result == PARENT_UNDEFINED); // Check to see if we are enabled Debug("parent_select", "policy.ParentEnable: %d", policy.ParentEnable); if (policy.ParentEnable == 0) { - result->r = PARENT_DIRECT; + result->result = PARENT_DIRECT; return; } // Initialize the result structure @@ -128,7 +128,7 @@ ParentConfigParams::findParent(HttpRequestData *rdata, ParentResult *result) // Check to see if the parent was set through the // api if (apiParentExists(rdata)) { - result->r = PARENT_SPECIFIED; + result->result = PARENT_SPECIFIED; result->hostname = rdata->api_info->parent_proxy_name; result->port = rdata->api_info->parent_proxy_port; result->rec = extApiRecord; @@ -148,7 +148,7 @@ ParentConfigParams::findParent(HttpRequestData *rdata, ParentResult *result) if (defaultPtr != NULL) { rec = result->rec = defaultPtr; } else { - result->r = PARENT_DIRECT; + result->result = PARENT_DIRECT; Debug("parent_select", "Returning PARENT_DIRECT (no parents were found)"); return; } @@ -160,17 +160,17 @@ ParentConfigParams::findParent(HttpRequestData *rdata, ParentResult *result) const char *host = rdata->get_host(); - switch (result->r) { + switch (result->result) { case PARENT_UNDEFINED: Debug("parent_select", "PARENT_UNDEFINED"); - Debug("parent_select", "Result for %s was %s", host, ParentResultStr[result->r]); + Debug("parent_select", "Result for %s was %s", host, ParentResultStr[result->result]); break; case PARENT_FAIL: Debug("parent_select", "PARENT_FAIL"); break; case PARENT_DIRECT: Debug("parent_select", "PARENT_DIRECT"); - Debug("parent_select", "Result for %s was %s", host, ParentResultStr[result->r]); + Debug("parent_select", "Result for %s was %s", host, ParentResultStr[result->result]); break; case PARENT_SPECIFIED: Debug("parent_select", "PARENT_SPECIFIED"); @@ -192,19 +192,19 @@ ParentConfigParams::nextParent(HttpRequestData *rdata, ParentResult *result) // Make sure that we are being called back with a // result structure with a parent - ink_assert(result->r == PARENT_SPECIFIED); - if (result->r != PARENT_SPECIFIED) { - result->r = PARENT_FAIL; + ink_assert(result->result == PARENT_SPECIFIED); + if (result->result != PARENT_SPECIFIED) { + result->result = PARENT_FAIL; return; } // If we were set through the API we currently have not failover // so just return fail if (result->rec == extApiRecord) { - Debug("parent_select", "Retry result for %s was %s", rdata->get_host(), ParentResultStr[result->r]); - result->r = PARENT_FAIL; + Debug("parent_select", "Retry result for %s was %s", rdata->get_host(), ParentResultStr[result->result]); + result->result = PARENT_FAIL; return; } - Debug("parent_select", "ParentConfigParams::nextParent(): result->r: %d, tablePtr: %p", result->r, tablePtr); + Debug("parent_select", "ParentConfigParams::nextParent(): result->r: %d, tablePtr: %p", result->result, tablePtr); // Find the next parent in the array Debug("parent_select", "Calling selectParent() from nextParent"); @@ -212,18 +212,18 @@ ParentConfigParams::nextParent(HttpRequestData *rdata, ParentResult *result) const char *host = rdata->get_host(); - switch (result->r) { + switch (result->result) { case PARENT_UNDEFINED: Debug("parent_select", "PARENT_UNDEFINED"); - Debug("parent_select", "Retry result for %s was %s", host, ParentResultStr[result->r]); + Debug("parent_select", "Retry result for %s was %s", host, ParentResultStr[result->result]); break; case PARENT_FAIL: Debug("parent_select", "PARENT_FAIL"); - Debug("parent_select", "Retry result for %s was %s", host, ParentResultStr[result->r]); + Debug("parent_select", "Retry result for %s was %s", host, ParentResultStr[result->result]); break; case PARENT_DIRECT: Debug("parent_select", "PARENT_DIRECT"); - Debug("parent_select", "Retry result for %s was %s", host, ParentResultStr[result->r]); + Debug("parent_select", "Retry result for %s was %s", host, ParentResultStr[result->result]); break; case PARENT_SPECIFIED: Debug("parent_select", "Retry result for %s was parent %s:%d", host, result->hostname, result->port); @@ -242,7 +242,7 @@ ParentConfigParams::parentExists(HttpRequestData *rdata) findParent(rdata, &result); - if (result.r == PARENT_SPECIFIED) { + if (result.result == PARENT_SPECIFIED) { return true; } else { return false; @@ -1308,7 +1308,7 @@ verify(ParentResult *r, ParentResultType e, const char *h, int p) { if (is_debug_tag_set("parent_select")) show_result(r); - return (r->r != e) ? 0 : ((e != PARENT_SPECIFIED) ? 1 : (strcmp(r->hostname, h) ? 0 : ((r->port == p) ? 1 : 0))); + return (r->result != e) ? 0 : ((e != PARENT_SPECIFIED) ? 1 : (strcmp(r->hostname, h) ? 0 : ((r->port == p) ? 1 : 0))); } // br creates an HttpRequestData object @@ -1330,7 +1330,7 @@ br(HttpRequestData *h, const char *os_hostname, sockaddr const *dest_ip) void show_result(ParentResult *p) { - switch (p->r) { + switch (p->result) { case PARENT_UNDEFINED: printf("result is PARENT_UNDEFINED\n"); break; diff --git a/proxy/ParentSelection.h b/proxy/ParentSelection.h index 79c8b5e..6d8db3b 100644 --- a/proxy/ParentSelection.h +++ b/proxy/ParentSelection.h @@ -159,13 +159,13 @@ ParentRecord *const extApiRecord = (ParentRecord *)0xeeeeffff; struct ParentResult { ParentResult() - : r(PARENT_UNDEFINED), hostname(NULL), port(0), retry(false), line_number(0), rec(NULL), last_parent(0), start_parent(0), + : result(PARENT_UNDEFINED), hostname(NULL), port(0), retry(false), line_number(0), rec(NULL), last_parent(0), start_parent(0), wrap_around(false), last_lookup(0) { } // For outside consumption - ParentResultType r; + ParentResultType result; const char *hostname; int port; bool retry; diff --git a/proxy/http/HttpSM.cc b/proxy/http/HttpSM.cc index 9582c0f..be76c29 100644 --- a/proxy/http/HttpSM.cc +++ b/proxy/http/HttpSM.cc @@ -7107,7 +7107,7 @@ HttpSM::set_next_state() call_transact_and_set_next_state(HttpTransact::HandleFiltering); break; } else if (t_state.http_config_param->use_client_target_addr == 2 && !t_state.url_remap_success && - t_state.parent_result.r != PARENT_SPECIFIED && t_state.client_info.is_transparent && + t_state.parent_result.result != PARENT_SPECIFIED && t_state.client_info.is_transparent && t_state.dns_info.os_addr_style == HttpTransact::DNSLookupInfo::OS_ADDR_TRY_DEFAULT && ats_is_ip(addr = t_state.state_machine->ua_session->get_netvc()->get_local_addr())) { /* If the connection is client side transparent and the URL @@ -7135,7 +7135,7 @@ HttpSM::set_next_state() t_state.dns_info.os_addr_style = HttpTransact::DNSLookupInfo::OS_ADDR_TRY_CLIENT; call_transact_and_set_next_state(NULL); break; - } else if (t_state.parent_result.r == PARENT_UNDEFINED && t_state.dns_info.lookup_success) { + } else if (t_state.parent_result.result == PARENT_UNDEFINED && t_state.dns_info.lookup_success) { // Already set, and we don't have a parent proxy to lookup ink_assert(ats_is_ip(t_state.host_db_info.ip())); DebugSM("dns", "[HttpTransact::HandleRequest] Skipping DNS lookup, provided by plugin"); @@ -7647,7 +7647,7 @@ HttpSM::redirect_request(const char *redirect_url, const int redirect_len) // we want to close the server session // will do that in handle_api_return under the // HttpTransact::SM_ACTION_REDIRECT_READ state - t_state.parent_result.r = PARENT_UNDEFINED; + t_state.parent_result.result = PARENT_UNDEFINED; t_state.request_sent_time = 0; t_state.response_received_time = 0; t_state.cache_info.write_lock_state = HttpTransact::CACHE_WL_INIT; diff --git a/proxy/http/HttpTransact.cc b/proxy/http/HttpTransact.cc index 093f13f..5a333c3 100644 --- a/proxy/http/HttpTransact.cc +++ b/proxy/http/HttpTransact.cc @@ -251,12 +251,12 @@ find_server_and_update_current_info(HttpTransact::State *s) // Do not forward requests to local_host onto a parent. // I just wanted to do this for cop heartbeats, someone else // wanted it for all requests to local_host. - s->parent_result.r = PARENT_DIRECT; + s->parent_result.result = PARENT_DIRECT; } else if (s->method == HTTP_WKSIDX_CONNECT && s->http_config_param->disable_ssl_parenting) { s->parent_params->findParent(&s->request_data, &s->parent_result); if (s->parent_result.rec == NULL || s->parent_result.rec->parent_is_proxy) { DebugTxn("http_trans", "request not cacheable, so bypass parent"); - s->parent_result.r = PARENT_DIRECT; + s->parent_result.result = PARENT_DIRECT; } } else if (s->http_config_param->uncacheable_requests_bypass_parent && s->http_config_param->no_dns_forward_to_parent == 0 && !HttpTransact::is_request_cache_lookupable(s)) { @@ -269,10 +269,10 @@ find_server_and_update_current_info(HttpTransact::State *s) s->parent_params->findParent(&s->request_data, &s->parent_result); if (s->parent_result.rec == NULL || s->parent_result.rec->parent_is_proxy) { DebugTxn("http_trans", "request not cacheable, so bypass parent"); - s->parent_result.r = PARENT_DIRECT; + s->parent_result.result = PARENT_DIRECT; } } else { - switch (s->parent_result.r) { + switch (s->parent_result.result) { case PARENT_UNDEFINED: s->parent_params->findParent(&s->request_data, &s->parent_result); break; @@ -283,9 +283,9 @@ find_server_and_update_current_info(HttpTransact::State *s) // We already have a parent that failed, if we are now told // to go the origin server, we can only obey this if we // dns'ed the origin server - if (s->parent_result.r == PARENT_DIRECT && s->http_config_param->no_dns_forward_to_parent != 0) { + if (s->parent_result.result == PARENT_DIRECT && s->http_config_param->no_dns_forward_to_parent != 0) { ink_assert(!s->server_info.dst_addr.isValid()); - s->parent_result.r = PARENT_FAIL; + s->parent_result.result = PARENT_FAIL; } break; case PARENT_FAIL: @@ -296,7 +296,7 @@ find_server_and_update_current_info(HttpTransact::State *s) // 3) the config permitted us to dns the origin server if (!s->parent_params->apiParentExists(&s->request_data) && s->parent_result.rec->bypass_ok() && s->http_config_param->no_dns_forward_to_parent == 0 && s->parent_result.rec->parent_is_proxy) { - s->parent_result.r = PARENT_DIRECT; + s->parent_result.result = PARENT_DIRECT; } break; default: @@ -310,7 +310,7 @@ find_server_and_update_current_info(HttpTransact::State *s) } } - switch (s->parent_result.r) { + switch (s->parent_result.result) { case PARENT_SPECIFIED: s->parent_info.name = s->arena.str_store(s->parent_result.hostname, strlen(s->parent_result.hostname)); update_current_info(&s->current, &s->parent_info, HttpTransact::PARENT_PROXY, (s->current.attempts)++); @@ -457,7 +457,7 @@ how_to_open_connection(HttpTransact::State *s) break; } - if (s->method == HTTP_WKSIDX_CONNECT && s->parent_result.r != PARENT_SPECIFIED) { + if (s->method == HTTP_WKSIDX_CONNECT && s->parent_result.result != PARENT_SPECIFIED) { s->cdn_saved_next_action = HttpTransact::SM_ACTION_ORIGIN_SERVER_RAW_OPEN; } else { s->cdn_saved_next_action = HttpTransact::SM_ACTION_ORIGIN_SERVER_OPEN; @@ -2706,7 +2706,7 @@ HttpTransact::HandleCacheOpenReadHit(State *s) } // a parent lookup could come back as PARENT_FAIL if in parent.config, go_direct == false and // there are no available parents (all down). - else if (s->current.request_to == HOST_NONE && s->parent_result.r == PARENT_FAIL) { + else if (s->current.request_to == HOST_NONE && s->parent_result.result == PARENT_FAIL) { if (is_server_negative_cached(s) && response_returnable == true && is_stale_cache_response_returnable(s) == true) { server_up = false; update_current_info(&s->current, NULL, UNDEFINED_LOOKUP, 0); @@ -3153,7 +3153,7 @@ HttpTransact::HandleCacheOpenReadMiss(State *s) find_server_and_update_current_info(s); // a parent lookup could come back as PARENT_FAIL if in parent.config go_direct == false and // there are no available parents (all down). - if (s->parent_result.r == PARENT_FAIL) { + if (s->parent_result.result == PARENT_FAIL) { handle_parent_died(s); return; } @@ -3583,7 +3583,7 @@ HttpTransact::handle_response_from_parent(State *s) // If the request is not retryable, just give up! if (!is_request_retryable(s)) { s->parent_params->markParentDown(&s->parent_result); - s->parent_result.r = PARENT_FAIL; + s->parent_result.result = PARENT_FAIL; handle_parent_died(s); return; } @@ -3639,7 +3639,7 @@ HttpTransact::handle_response_from_parent(State *s) // appropriate DebugTxn("http_trans", "[handle_response_from_parent] Error. No more retries."); s->parent_params->markParentDown(&s->parent_result); - s->parent_result.r = PARENT_FAIL; + s->parent_result.result = PARENT_FAIL; next_lookup = find_server_and_update_current_info(s); } @@ -7601,7 +7601,7 @@ HttpTransact::AuthenticationNeeded(const OverridableHttpConfigParams *p, HTTPHdr void HttpTransact::handle_parent_died(State *s) { - ink_assert(s->parent_result.r == PARENT_FAIL); + ink_assert(s->parent_result.result == PARENT_FAIL); build_error_response(s, HTTP_STATUS_BAD_GATEWAY, "Next Hop Connection Failed", "connect#failed_connect", NULL); TRANSACT_RETURN(SM_ACTION_SEND_ERROR_CACHE_NOOP, NULL); -- To stop receiving notification emails like this one, please contact "[email protected]" <[email protected]>.
