From: Amos Jeffries Date: Sun, 25 Apr 2010 06:58:26 +0000 (+1200) Subject: Prevent assertion on startup with --enable-replacement-policies X-Git-Tag: SQUID_3_2_0_1~272 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d64c14983d97a25f33989b197d1fd378eb6f2b1e;p=thirdparty%2Fsquid.git Prevent assertion on startup with --enable-replacement-policies Option without specific policies listed was asserting on a double-add for the LRU module. This just makes duplicate additions a no-op and non-fatal. No attempt at a cleanup yet. TODO: sync the repl_modules.cc code with the other dynamic modules init. --- diff --git a/src/Makefile.am b/src/Makefile.am index 554fbde823..bc6c17ebe6 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -753,23 +753,23 @@ DEFS += -DDEFAULT_CONFIG_FILE=\"$(DEFAULT_CONFIG_FILE)\" -DDEFAULT_SQUID_DATA_DI snmp_core.o snmp_agent.o: ../snmplib/libsnmp.a $(top_srcdir)/include/cache_snmp.h globals.cc: globals.h mk-globals-c.awk - $(AWK) -f $(srcdir)/mk-globals-c.awk < $(srcdir)/globals.h > $@ || $(RM) -f $@ + $(AWK) -f $(srcdir)/mk-globals-c.awk < $(srcdir)/globals.h > $@ || ($(RM) -f $@ && exit 1) ## Generate files containing strng arrays for various enums.... hier_code.cc: hier_code.h mk-string-arrays.awk - $(AWK) -f $(srcdir)/mk-string-arrays.awk < $(srcdir)/hier_code.h > $@ || $(RM) -f $@ + $(AWK) -f $(srcdir)/mk-string-arrays.awk < $(srcdir)/hier_code.h > $@ || ($(RM) -f $@ && exit 1) err_type.cc: err_type.h mk-string-arrays.awk - $(AWK) -f $(srcdir)/mk-string-arrays.awk < $(srcdir)/err_type.h > $@ || $(RM) -f $@ + $(AWK) -f $(srcdir)/mk-string-arrays.awk < $(srcdir)/err_type.h > $@ || ($(RM) -f $@ && exit 1) lookup_t.cc: lookup_t.h mk-string-arrays.awk - $(AWK) -f $(srcdir)/mk-string-arrays.awk < $(srcdir)/lookup_t.h > $@ || $(RM) -f $@ + $(AWK) -f $(srcdir)/mk-string-arrays.awk < $(srcdir)/lookup_t.h > $@ || ($(RM) -f $@ && exit 1) icp_opcode.cc: icp_opcode.h mk-string-arrays.awk - $(AWK) -f $(srcdir)/mk-string-arrays.awk < $(srcdir)/icp_opcode.h > $@ || $(RM) -f $@ + $(AWK) -f $(srcdir)/mk-string-arrays.awk < $(srcdir)/icp_opcode.h > $@ || ($(RM) -f $@ && exit 1) swap_log_op.cc: swap_log_op.h mk-string-arrays.awk - $(AWK) -f $(srcdir)/mk-string-arrays.awk < $(srcdir)/swap_log_op.h > $@ || $(RM) -f $@ + $(AWK) -f $(srcdir)/mk-string-arrays.awk < $(srcdir)/swap_log_op.h > $@ || ($(RM) -f $@ && exit 1) ## other generated files... @@ -791,7 +791,7 @@ cf_parser.h: cf.data cf_gen$(EXEEXT) ./cf_gen cf.data $(srcdir)/cf.data.depend cf_gen_defines.h: $(srcdir)/cf_gen_defines $(srcdir)/cf.data.pre - $(AWK) -f $(srcdir)/cf_gen_defines <$(srcdir)/cf.data.pre >$@ || $(RM) -f $@ + $(AWK) -f $(srcdir)/cf_gen_defines <$(srcdir)/cf.data.pre >$@ || ($(RM) -f $@ && exit 1) ## FIXME: generate a sed command file from configure. Then this doesn't diff --git a/src/store.cc b/src/store.cc index f5974a3700..5fcea64c76 100644 --- a/src/store.cc +++ b/src/store.cc @@ -1707,10 +1707,13 @@ void storeReplAdd(const char *type, REMOVALPOLICYCREATE * create) { int i; - /* find the number of currently known repl types */ + /* find the number of currently known repl types */ for (i = 0; storerepl_list && storerepl_list[i].typestr; i++) { - assert(strcmp(storerepl_list[i].typestr, type) != 0); + if (strcmp(storerepl_list[i].typestr, type) == 0) { + debugs(20, 1, "WARNING: Trying to load store replacement policy " << type << " twice."); + return; + } } /* add the new type */