MCPcopy Create free account
hub / github.com/apache/httpd / find_closest_match

Function find_closest_match

modules/md/md_reg.c:788–818  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

786}
787
788static md_t *find_closest_match(apr_array_header_t *mds, const md_t *md)
789{
790 md_t *candidate, *m;
791 apr_size_t cand_n, n;
792 int i;
793
794 candidate = md_get_by_name(mds, md->name);
795 if (!candidate) {
796 /* try to find an instance that contains all domain names from md */
797 for (i = 0; i < mds->nelts; ++i) {
798 m = APR_ARRAY_IDX(mds, i, md_t *);
799 if (md_contains_domains(m, md)) {
800 return m;
801 }
802 }
803 /* no matching name and no md in the list has all domains.
804 * We consider that managed domain as closest match that contains at least one
805 * domain name from md, ONLY if there is no other one that also has.
806 */
807 cand_n = 0;
808 for (i = 0; i < mds->nelts; ++i) {
809 m = APR_ARRAY_IDX(mds, i, md_t *);
810 n = md_common_name_count(md, m);
811 if (n > cand_n) {
812 candidate = m;
813 cand_n = n;
814 }
815 }
816 }
817 return candidate;
818}
819
820typedef struct {
821 apr_pool_t *p;

Callers 1

md_reg_sync_startFunction · 0.85

Calls 3

md_get_by_nameFunction · 0.85
md_contains_domainsFunction · 0.85
md_common_name_countFunction · 0.85

Tested by

no test coverage detected