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

Method TableInsert

src/proxy/http/remap/UrlRewrite.cc:880–912  ·  view source on GitHub ↗

Inserts arg mapping in h_table with key src_host chaining the mapping of existing entries bound to src_host if necessary. */

Source from the content-addressed store, hash-verified

878
879*/
880bool
881UrlRewrite::TableInsert(std::unique_ptr<URLTable> &h_table, url_mapping *mapping, const char *src_host)
882{
883 if (!h_table) {
884 h_table.reset(new URLTable);
885 }
886 char src_host_tmp_buf[1];
887 UrlMappingPathIndex *ht_contents;
888
889 if (!src_host) {
890 src_host = &src_host_tmp_buf[0];
891 src_host_tmp_buf[0] = 0;
892 }
893 // Insert the new_mapping into hash table
894 if (auto it = h_table->find(src_host); it != h_table->end()) {
895 ht_contents = it->second;
896 // There is already a path index for this host
897 if (it->second == nullptr) {
898 // why should this happen?
899 Warning("Found entry cannot be null!");
900 return false;
901 }
902 } else {
903 ht_contents = new UrlMappingPathIndex();
904 h_table->emplace(src_host, ht_contents);
905 }
906 if (!ht_contents->Insert(mapping)) {
907 // Trie::Insert only fails due to an attempt to add a duplicate entry.
908 Warning("Could not insert new mapping: duplicated entry exists");
909 return false;
910 }
911 return true;
912}
913
914/** First looks up the hash table for "simple" mappings and then the
915 regex mappings. Only higher-ranked regex mappings are examined if

Callers

nothing calls this directly

Calls 5

emplaceMethod · 0.80
resetMethod · 0.45
findMethod · 0.45
endMethod · 0.45
InsertMethod · 0.45

Tested by

no test coverage detected