From: Amos Jeffries Date: Sun, 28 Jun 2009 08:11:27 +0000 (+1200) Subject: Simpler test for PURGE method X-Git-Tag: SQUID_3_2_0_1~924 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=936b23cdbef90f5812011687492a32f65ab8871c;p=thirdparty%2Fsquid.git Simpler test for PURGE method Uses a tri-state setting on enable_purge and acl parsing to detect PURGE method addition/removal instead of a complicated ACL creation test post-configure. This removes the annoying false errors about temp ACL and some minor speed up in all actions that parse squid.conf. --- diff --git a/src/acl/Gadgets.cc b/src/acl/Gadgets.cc index d2b5c5272e..1e555f0e69 100644 --- a/src/acl/Gadgets.cc +++ b/src/acl/Gadgets.cc @@ -309,37 +309,3 @@ aclDestroyDenyInfoList(acl_deny_info_list ** list) *list = NULL; } - -/* - * This function traverses all ACL elements referenced - * by an access list (presumably 'http_access'). If - * it finds a PURGE method ACL, then it returns TRUE, - * otherwise FALSE. - */ -/* XXX: refactor this more sensibly. perhaps have the parser detect it ? */ -int -aclPurgeMethodInUse(acl_access * a) -{ - ACLList *b; - - debugs(28, 6, "aclPurgeMethodInUse: invoked for '" << a->cfgline << "'"); - - for (; a; a = a->next) { - for (b = a->aclList; b; b = b->next) { - ACLStrategised *tempAcl = dynamic_cast *>(b->_acl); - - if (!tempAcl) { - debugs(28, 7, "aclPurgeMethodInUse: can't create tempAcl"); - continue; - } - - if (tempAcl->match(METHOD_PURGE)) { - debugs(28, 6, "aclPurgeMethodInUse: returning true"); - return true; - } - } - } - - debugs(28, 6, "aclPurgeMethodInUse: returning false"); - return false; -} diff --git a/src/acl/Gadgets.h b/src/acl/Gadgets.h index f33bdf4426..6c913b1a2b 100644 --- a/src/acl/Gadgets.h +++ b/src/acl/Gadgets.h @@ -37,7 +37,5 @@ extern wordlist *aclDumpGeneric(const ACL *); extern void aclCacheMatchFlush(dlink_list * cache); /// \ingroup ACLAPI extern void dump_acl_access(StoreEntry * entry, const char *name, acl_access * head); -/// \ingroup ACLAPI -int aclPurgeMethodInUse(acl_access * a); #endif /* SQUID_ACL_GADGETS_H */ diff --git a/src/acl/MethodData.cc b/src/acl/MethodData.cc index b502f7be48..ad6cf3c903 100644 --- a/src/acl/MethodData.cc +++ b/src/acl/MethodData.cc @@ -89,6 +89,10 @@ ACLMethodData::parse() for (Tail = &values; *Tail; Tail = &((*Tail)->next)); while ((t = strtokFile())) { + if(strcmp(t, "PURGE") == 0) { + // we need to use PURGE, can't just blanket-deny it. + Config2.onoff.enable_purge = 1; + } CbDataList *q = new CbDataList (HttpRequestMethod(t, NULL)); *(Tail) = q; Tail = &q->next; diff --git a/src/cache_cf.cc b/src/cache_cf.cc index 0510c4e6b1..3f379b7315 100644 --- a/src/cache_cf.cc +++ b/src/cache_cf.cc @@ -620,8 +620,10 @@ configDoConfigure(void) #endif - if (aclPurgeMethodInUse(Config.accessList.http)) - Config2.onoff.enable_purge = 1; + // we have reconfigured and in the process disabled any need for PURGE. + // turn it off now. + if(Config2.onoff.enable_purge == 2) + Config2.onoff.enable_purge = 0; Config2.onoff.mangle_request_headers = httpReqHdrManglersConfigured(); diff --git a/src/main.cc b/src/main.cc index 5a57f25ee9..2c785168d5 100644 --- a/src/main.cc +++ b/src/main.cc @@ -709,7 +709,13 @@ mainReconfigureFinish(void *) errorClean(); enter_suid(); /* root to read config file */ + + // we may have disabled the need for PURGE + if(Config2.onoff.enable_purge) + Config2.onoff.enable_purge = 2; + parseConfigFile(ConfigFile); + setUmask(Config.umask); Mem::Report(); setEffectiveUser();