MCPcopy Create free account
hub / github.com/apache/trafficserver / Init

Method Init

src/proxy/ParentSelection.cc:640–847  ·  view source on GitHub ↗

Result ParentRecord::Init(matcher_line* line_info) matcher_line* line_info - contains parsed label/value pairs of the current cache.config line Returns NULL if everything is OK Otherwise, returns an error string that the caller MUST DEALLOCATE with ats_free()

Source from the content-addressed store, hash-verified

638// DEALLOCATE with ats_free()
639//
640Result
641ParentRecord::Init(matcher_line *line_info)
642{
643 const char *errPtr = nullptr;
644 const char *tmp;
645 char *label;
646 char *val;
647 char parent_buf[16384] = {0};
648 bool used = false;
649 ParentRR_t round_robin = P_NO_ROUND_ROBIN;
650 char buf[128];
651 RecInt rec_self_detect = 2;
652
653 this->line_num = line_info->line_num;
654 this->scheme = nullptr;
655
656 if (RecGetRecordInt("proxy.config.http.parent_proxy.self_detect", &rec_self_detect) == REC_ERR_OKAY) {
657 self_detect = static_cast<int>(rec_self_detect);
658 }
659
660 for (int i = 0; i < MATCHER_MAX_TOKENS; i++) {
661 used = false;
662 label = line_info->line[0][i];
663 val = line_info->line[1][i];
664
665 if (label == nullptr) {
666 continue;
667 }
668
669 if (strcasecmp(label, "round_robin") == 0) {
670 if (strcasecmp(val, "true") == 0) {
671 round_robin = P_HASH_ROUND_ROBIN;
672 } else if (strcasecmp(val, "strict") == 0) {
673 round_robin = P_STRICT_ROUND_ROBIN;
674 } else if (strcasecmp(val, "false") == 0) {
675 round_robin = P_NO_ROUND_ROBIN;
676 } else if (strcasecmp(val, "consistent_hash") == 0) {
677 round_robin = P_CONSISTENT_HASH;
678 } else if (strcasecmp(val, "latched") == 0) {
679 round_robin = P_LATCHED_ROUND_ROBIN;
680 } else {
681 round_robin = P_NO_ROUND_ROBIN;
682 errPtr = "invalid argument to round_robin directive";
683 }
684 used = true;
685 } else if (strcasecmp(label, "parent") == 0 || strcasecmp(label, "primary_parent") == 0) {
686 PreProcessParents(val, line_num, parent_buf, sizeof(parent_buf) - 1);
687 errPtr = ProcessParents(parent_buf, true);
688 used = true;
689 } else if (strcasecmp(label, "secondary_parent") == 0) {
690 PreProcessParents(val, line_num, parent_buf, sizeof(parent_buf) - 1);
691 errPtr = ProcessParents(parent_buf, false);
692 used = true;
693 } else if (strcasecmp(label, "go_direct") == 0) {
694 if (strcasecmp(val, "false") == 0) {
695 go_direct = false;
696 } else if (strcasecmp(val, "true") != 0) {
697 errPtr = "invalid argument to go_direct directive";

Callers

nothing calls this directly

Calls 3

RecGetRecordIntFunction · 0.85
strcasecmpFunction · 0.85
getSchemeModTextMethod · 0.80

Tested by

no test coverage detected