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

Function md_reg_sync_start

modules/md/md_reg.c:854–943  ·  view source on GitHub ↗

A better scaling version: * 1. The consistency of the MDs in 'master_mds' has already been verified. E.g. * that no domain lists overlap etc. * 2. All MD storage that exists will be overwritten by the settings we have. * And "exists" meaning that "store/MD_SG_DOMAINS/name" exists. * 3. For MDs that have no directory in "store/MD_SG_DOMAINS", we load all MDs * outside the list

Source from the content-addressed store, hash-verified

852 * 4. Any MD in store that does not match the "master_mds" will just be left as is.
853 */
854apr_status_t md_reg_sync_start(md_reg_t *reg, apr_array_header_t *master_mds, apr_pool_t *p)
855{
856 sync_ctx_v2 ctx;
857 apr_status_t rv;
858 md_t *md, *oldmd;
859 const char *name;
860 int i, idx;
861
862 md_log_perror(MD_LOG_MARK, MD_LOG_DEBUG, 0, p, "sync MDs, start");
863
864 ctx.p = p;
865 ctx.master_mds = master_mds;
866 ctx.store_names = apr_array_make(p, master_mds->nelts + 100, sizeof(const char*));
867 ctx.maybe_new_mds = apr_array_make(p, master_mds->nelts, sizeof(md_t*));
868 ctx.new_mds = apr_array_make(p, master_mds->nelts, sizeof(md_t*));
869 ctx.unassigned_mds = apr_array_make(p, master_mds->nelts, sizeof(md_t*));
870
871 rv = md_store_iter_names(iter_add_name, &ctx, reg->store, p, MD_SG_DOMAINS, "*");
872 if (APR_SUCCESS != rv) {
873 md_log_perror(MD_LOG_MARK, MD_LOG_ERR, rv, p, "listing existing store MD names");
874 goto leave;
875 }
876
877 /* Get all MDs that are not already present in store */
878 for (i = 0; i < ctx.master_mds->nelts; ++i) {
879 md = APR_ARRAY_IDX(ctx.master_mds, i, md_t*);
880 idx = md_array_str_index(ctx.store_names, md->name, 0, 1);
881 if (idx < 0) {
882 APR_ARRAY_PUSH(ctx.maybe_new_mds, md_t*) = md;
883 }
884 else {
885 md_array_remove_at(ctx.store_names, idx);
886 }
887 }
888
889 if (ctx.maybe_new_mds->nelts == 0) {
890 /* none new */
891 goto leave;
892 }
893 if (ctx.store_names->nelts == 0) {
894 /* all new */
895 for (i = 0; i < ctx.maybe_new_mds->nelts; ++i) {
896 md = APR_ARRAY_IDX(ctx.maybe_new_mds, i, md_t*);
897 APR_ARRAY_PUSH(ctx.new_mds, md_t*) = md;
898 }
899 goto leave;
900 }
901
902 md_log_perror(MD_LOG_MARK, MD_LOG_DEBUG, 0, p,
903 "sync MDs, %d potentially new MDs detected, looking for renames among "
904 "the %d unassigned store domains", (int)ctx.maybe_new_mds->nelts,
905 (int)ctx.store_names->nelts);
906 for (i = 0; i < ctx.store_names->nelts; ++i) {
907 name = APR_ARRAY_IDX(ctx.store_names, i, const char*);
908 if (APR_SUCCESS == md_load(reg->store, MD_SG_DOMAINS, name, &md, p)) {
909 APR_ARRAY_PUSH(ctx.unassigned_mds, md_t*) = md;
910 }
911 }

Callers 1

Calls 8

md_log_perrorFunction · 0.85
md_store_iter_namesFunction · 0.85
md_array_str_indexFunction · 0.85
md_array_remove_atFunction · 0.85
md_loadFunction · 0.85
find_closest_matchFunction · 0.85
md_store_renameFunction · 0.85
md_array_removeFunction · 0.85

Tested by

no test coverage detected