From 8d9a8184ab30e54b0efd0227adc0a2c275f91153 Mon Sep 17 00:00:00 2001 From: Francesco Chemolli Date: Mon, 10 Sep 2012 09:59:18 +0200 Subject: [PATCH] renamed refresh_t to RefreshPattern and moved to own header file. --- src/Makefile.am | 7 ++++++ src/RefreshPattern.h | 60 ++++++++++++++++++++++++++++++++++++++++++++ src/SquidConfig.h | 4 +-- src/cache_cf.cc | 17 +++++++------ src/http.cc | 3 ++- src/refresh.cc | 21 ++++++++-------- src/refresh.h | 4 ++- src/structs.h | 29 --------------------- 8 files changed, 94 insertions(+), 51 deletions(-) create mode 100644 src/RefreshPattern.h diff --git a/src/Makefile.am b/src/Makefile.am index 54e6ad0ad6..bd3937f6e0 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -271,6 +271,7 @@ squid_SOURCES = \ AuthReg.h \ YesNoNone.h \ YesNoNone.cc \ + RefreshPattern.h \ cache_cf.cc \ CacheDigest.h \ CacheDigest.cc \ @@ -1381,6 +1382,7 @@ tests_testCacheManager_SOURCES = \ AuthReg.h \ YesNoNone.h \ YesNoNone.cc \ + RefreshPattern.h \ cache_cf.cc \ CacheDigest.h \ CacheDigest.cc \ @@ -1771,6 +1773,7 @@ tests_testEvent_SOURCES = \ AuthReg.h \ YesNoNone.h \ YesNoNone.cc \ + RefreshPattern.h \ cache_cf.cc \ cache_manager.cc \ carp.h \ @@ -2008,6 +2011,7 @@ tests_testEventLoop_SOURCES = \ AuthReg.h \ YesNoNone.h \ YesNoNone.cc \ + RefreshPattern.h \ cache_cf.cc \ carp.h \ carp.cc \ @@ -2240,6 +2244,7 @@ tests_test_http_range_SOURCES = \ AuthReg.h \ YesNoNone.h \ YesNoNone.cc \ + RefreshPattern.h \ cache_cf.cc \ cache_manager.cc \ CacheDigest.h \ @@ -2528,6 +2533,7 @@ tests_testHttpRequest_SOURCES = \ AuthReg.h \ YesNoNone.h \ YesNoNone.cc \ + RefreshPattern.h \ cache_cf.cc \ debug.cc \ CacheDigest.h \ @@ -3586,6 +3592,7 @@ tests_testURL_SOURCES = \ AuthReg.h \ YesNoNone.h \ YesNoNone.cc \ + RefreshPattern.h \ cache_cf.cc \ cache_manager.cc \ CacheDigest.h \ diff --git a/src/RefreshPattern.h b/src/RefreshPattern.h new file mode 100644 index 0000000000..c3abe78246 --- /dev/null +++ b/src/RefreshPattern.h @@ -0,0 +1,60 @@ +#ifndef SQUID_REFRESHPATTERN_H_ +#define SQUID_REFRESHPATTERN_H_ +/* + * SQUID Web Proxy Cache http://www.squid-cache.org/ + * ---------------------------------------------------------- + * + * Squid is the result of efforts by numerous individuals from + * the Internet community; see the CONTRIBUTORS file for full + * details. Many organizations have provided support for Squid's + * development; see the SPONSORS file for full details. Squid is + * Copyrighted (C) 2001 by the Regents of the University of + * California; see the COPYRIGHT file for full details. Squid + * incorporates software developed and/or copyrighted by other + * sources; see the CREDITS file for full details. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. + * + */ + +class RefreshPattern { +public: + const char *pattern; + regex_t compiled_pattern; + time_t min; + double pct; + time_t max; + RefreshPattern *next; + + struct { + unsigned int icase:1; + unsigned int refresh_ims:1; + unsigned int store_stale:1; +#if USE_HTTP_VIOLATIONS + unsigned int override_expire:1; + unsigned int override_lastmod:1; + unsigned int reload_into_ims:1; + unsigned int ignore_reload:1; + unsigned int ignore_no_cache:1; + unsigned int ignore_no_store:1; + unsigned int ignore_must_revalidate:1; + unsigned int ignore_private:1; + unsigned int ignore_auth:1; +#endif + } flags; + int max_stale; +}; + +#endif /* SQUID_REFRESHPATTERN_H_ */ diff --git a/src/SquidConfig.h b/src/SquidConfig.h index 1e2fb33835..337f8ac284 100644 --- a/src/SquidConfig.h +++ b/src/SquidConfig.h @@ -50,7 +50,7 @@ class acl_access; class AclDenyInfoList; class acl_size_t; class HeaderManglers; -class refresh_t; +class RefreshPattern; class SwapDir; class RemovalPolicySettings; @@ -403,7 +403,7 @@ public: int sanitycheck; int telnet; } Ftp; - refresh_t *Refresh; + RefreshPattern *Refresh; struct _cacheSwap { RefCount *swapDirs; diff --git a/src/cache_cf.cc b/src/cache_cf.cc index a79dc20428..4fe46c3b56 100644 --- a/src/cache_cf.cc +++ b/src/cache_cf.cc @@ -63,6 +63,7 @@ #include "mgr/Registration.h" #include "Parsing.h" #include "PeerDigest.h" +#include "RefreshPattern.h" #include "rfc1738.h" #include "SquidConfig.h" #include "SquidString.h" @@ -181,7 +182,7 @@ static void free_access_log(CustomLog ** definitions); static void update_maxobjsize(void); static void configDoConfigure(void); -static void parse_refreshpattern(refresh_t **); +static void parse_refreshpattern(RefreshPattern **); static uint64_t parseTimeUnits(const char *unit, bool allowMsec); static void parseTimeLine(time_msec_t * tptr, const char *units, bool allowMsec); static void parse_u_short(unsigned short * var); @@ -765,7 +766,7 @@ configDoConfigure(void) #if USE_HTTP_VIOLATIONS { - const refresh_t *R; + const RefreshPattern *R; for (R = Config.Refresh; R; R = R->next) { if (!R->flags.override_expire) @@ -2643,7 +2644,7 @@ parse_tristate(int *var) #define free_tristate free_int static void -dump_refreshpattern(StoreEntry * entry, const char *name, refresh_t * head) +dump_refreshpattern(StoreEntry * entry, const char *name, RefreshPattern * head) { while (head != NULL) { storeAppendPrintf(entry, "%s%s %s %d %d%% %d", @@ -2701,7 +2702,7 @@ dump_refreshpattern(StoreEntry * entry, const char *name, refresh_t * head) } static void -parse_refreshpattern(refresh_t ** head) +parse_refreshpattern(RefreshPattern ** head) { char *token; char *pattern; @@ -2726,7 +2727,7 @@ parse_refreshpattern(refresh_t ** head) #endif int i; - refresh_t *t; + RefreshPattern *t; regex_t comp; int errcode; int flags = REG_EXTENDED | REG_NOSUB; @@ -2831,7 +2832,7 @@ parse_refreshpattern(refresh_t ** head) pct = pct < 0.0 ? 0.0 : pct; max = max < 0 ? 0 : max; - t = static_cast(xcalloc(1, sizeof(refresh_t))); + t = static_cast(xcalloc(1, sizeof(RefreshPattern))); t->pattern = (char *) xstrdup(pattern); t->compiled_pattern = comp; t->min = min; @@ -2891,9 +2892,9 @@ parse_refreshpattern(refresh_t ** head) } static void -free_refreshpattern(refresh_t ** head) +free_refreshpattern(RefreshPattern ** head) { - refresh_t *t; + RefreshPattern *t; while ((t = *head) != NULL) { *head = t->next; diff --git a/src/http.cc b/src/http.cc index 2fbdbd76b4..73ffa217da 100644 --- a/src/http.cc +++ b/src/http.cc @@ -65,6 +65,7 @@ #include "peer_proxy_negotiate_auth.h" #include "profiler/Profiler.h" #include "refresh.h" +#include "RefreshPattern.h" #include "rfc1738.h" #include "SquidConfig.h" #include "SquidTime.h" @@ -337,7 +338,7 @@ HttpStateData::cacheableReply() const char *v; #if USE_HTTP_VIOLATIONS - const refresh_t *R = NULL; + const RefreshPattern *R = NULL; /* This strange looking define first looks up the refresh pattern * and then checks if the specified flag is set. The main purpose diff --git a/src/refresh.cc b/src/refresh.cc index a7d4bd8486..be36c73de3 100644 --- a/src/refresh.cc +++ b/src/refresh.cc @@ -41,6 +41,7 @@ #include "HttpRequest.h" #include "HttpReply.h" #include "MemObject.h" +#include "RefreshPattern.h" #include "SquidTime.h" #include "SquidConfig.h" #include "Store.h" @@ -109,16 +110,16 @@ refreshCounts[rcCount]; #define REFRESH_DEFAULT_PCT 0.20 #define REFRESH_DEFAULT_MAX (time_t)259200 -static const refresh_t *refreshUncompiledPattern(const char *); +static const RefreshPattern *refreshUncompiledPattern(const char *); static OBJH refreshStats; -static int refreshStaleness(const StoreEntry * entry, time_t check_time, const time_t age, const refresh_t * R, stale_flags * sf); +static int refreshStaleness(const StoreEntry * entry, time_t check_time, const time_t age, const RefreshPattern * R, stale_flags * sf); -static refresh_t DefaultRefresh; +static RefreshPattern DefaultRefresh; -const refresh_t * +const RefreshPattern * refreshLimits(const char *url) { - const refresh_t *R; + const RefreshPattern *R; for (R = Config.Refresh; R; R = R->next) { if (!regexec(&(R->compiled_pattern), url, 0, 0, 0)) @@ -128,10 +129,10 @@ refreshLimits(const char *url) return NULL; } -static const refresh_t * +static const RefreshPattern * refreshUncompiledPattern(const char *pat) { - const refresh_t *R; + const RefreshPattern *R; for (R = Config.Refresh; R; R = R->next) { if (0 == strcmp(R->pattern, pat)) @@ -157,7 +158,7 @@ refreshUncompiledPattern(const char *pat) * times. */ static int -refreshStaleness(const StoreEntry * entry, time_t check_time, const time_t age, const refresh_t * R, stale_flags * sf) +refreshStaleness(const StoreEntry * entry, time_t check_time, const time_t age, const RefreshPattern * R, stale_flags * sf) { /** \par * Check for an explicit expiration time (Expires: header). @@ -231,7 +232,7 @@ refreshStaleness(const StoreEntry * entry, time_t check_time, const time_t age, static int refreshCheck(const StoreEntry * entry, HttpRequest * request, time_t delta) { - const refresh_t *R; + const RefreshPattern *R; const char *uri = NULL; time_t age = 0; time_t check_time = squid_curtime + delta; @@ -535,7 +536,7 @@ refreshCheckDigest(const StoreEntry * entry, time_t delta) time_t getMaxAge(const char *url) { - const refresh_t *R; + const RefreshPattern *R; debugs(22, 3, "getMaxAge: '" << url << "'"); if ((R = refreshLimits(url))) diff --git a/src/refresh.h b/src/refresh.h index 1c6b9d36d2..73757d178c 100644 --- a/src/refresh.h +++ b/src/refresh.h @@ -33,6 +33,8 @@ #ifndef SQUID_REFRESH_H_ #define SQUID_REFRESH_H_ +class RefreshPattern; + extern void refreshAddToList(const char *, int, time_t, int, time_t); extern int refreshIsCachable(const StoreEntry *); extern int refreshCheckHTTP(const StoreEntry *, HttpRequest *); @@ -41,6 +43,6 @@ extern int refreshCheckHTCP(const StoreEntry *, HttpRequest *); extern int refreshCheckDigest(const StoreEntry *, time_t delta); extern time_t getMaxAge(const char *url); extern void refreshInit(void); -extern const refresh_t *refreshLimits(const char *url); +extern const RefreshPattern *refreshLimits(const char *url); #endif /* SQUID_REFRESH_H_ */ diff --git a/src/structs.h b/src/structs.h index dc072636b8..5f75f1648c 100644 --- a/src/structs.h +++ b/src/structs.h @@ -105,7 +105,6 @@ class external_acl; class Store; class CustomLog; class cachemgr_passwd; -class refresh_t; namespace AnyP { struct PortCfg; @@ -313,34 +312,6 @@ public: cachemgr_passwd *next; }; -class refresh_t { -public: - const char *pattern; - regex_t compiled_pattern; - time_t min; - double pct; - time_t max; - refresh_t *next; - - struct { - unsigned int icase:1; - unsigned int refresh_ims:1; - unsigned int store_stale:1; -#if USE_HTTP_VIOLATIONS - unsigned int override_expire:1; - unsigned int override_lastmod:1; - unsigned int reload_into_ims:1; - unsigned int ignore_reload:1; - unsigned int ignore_no_cache:1; - unsigned int ignore_no_store:1; - unsigned int ignore_must_revalidate:1; - unsigned int ignore_private:1; - unsigned int ignore_auth:1; -#endif - } flags; - int max_stale; -}; - #if USE_SSL struct _sslproxy_cert_sign { -- 2.39.2