From: Amos Jeffries Date: Sun, 5 Feb 2012 11:24:07 +0000 (-0700) Subject: Silence messages about MGR_INDEX when not installed X-Git-Tag: BumpSslServerFirst.take05~12^2~57 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8ff2520a3f4229d958c36c192e70a980fb6dc7dc;p=thirdparty%2Fsquid.git Silence messages about MGR_INDEX when not installed --- diff --git a/src/err_type.h b/src/err_type.h index 9c5c91043b..c5be819657 100644 --- a/src/err_type.h +++ b/src/err_type.h @@ -53,9 +53,6 @@ typedef enum { /* ICAP Errors */ ERR_ICAP_FAILURE, - /* Cache Manager */ - MGR_INDEX, - /* Squid problem */ ERR_GATEWAY_FAILURE, @@ -63,7 +60,13 @@ typedef enum { ERR_DIR_LISTING, /* Display of remote directory (FTP, Gopher) */ ERR_SQUID_SIGNATURE, /* not really an error */ ERR_SHUTTING_DOWN, - TCP_RESET, + + // NOTE: error types defined below TCP_RESET are optional and do not generate + // a log warning if the files are missing + TCP_RESET, // Send TCP RST packet instead of error page + + /* Cache Manager GUI can install a manager index/home page */ + MGR_INDEX, ERR_MAX } err_type; diff --git a/src/errorpage.cc b/src/errorpage.cc index 53803ea6d3..ef1418017d 100644 --- a/src/errorpage.cc +++ b/src/errorpage.cc @@ -142,7 +142,7 @@ static IOCB errorSendComplete; class ErrorPageFile: public TemplateFile { public: - ErrorPageFile(const char *name): TemplateFile(name) { textBuf.init();} + ErrorPageFile(const char *name, const err_type code): TemplateFile(name,code) { textBuf.init();} /// The template text data read from disk const char *text() { return textBuf.content(); } @@ -195,7 +195,7 @@ errorInitialize(void) * (a) default language translation directory (error_default_language) * (b) admin specified custom directory (error_directory) */ - ErrorPageFile errTmpl(err_type_str[i]); + ErrorPageFile errTmpl(err_type_str[i], i); error_text[i] = errTmpl.loadDefault() ? xstrdup(errTmpl.text()) : NULL; } else { /** \par @@ -210,7 +210,7 @@ errorInitialize(void) if (strchr(pg, ':') == NULL) { /** But only if they are not redirection URL. */ - ErrorPageFile errTmpl(pg); + ErrorPageFile errTmpl(pg, ERR_MAX); error_text[i] = errTmpl.loadDefault() ? xstrdup(errTmpl.text()) : NULL; } } @@ -220,7 +220,7 @@ errorInitialize(void) // look for and load stylesheet into global MemBuf for it. if (Config.errorStylesheet) { - ErrorPageFile tmpl("StylesSheet"); + ErrorPageFile tmpl("StylesSheet", ERR_MAX); tmpl.loadFromFile(Config.errorStylesheet); error_stylesheet.Printf("%s",tmpl.text()); } @@ -265,7 +265,7 @@ errorFindHardText(err_type type) return NULL; } -TemplateFile::TemplateFile(const char *name): silent(false), wasLoaded(false), templateName(name) +TemplateFile::TemplateFile(const char *name, const err_type code): silent(false), wasLoaded(false), templateName(name), templateCode(code) { assert(name); } @@ -287,7 +287,7 @@ TemplateFile::loadDefault() /** test error_default_language location */ if (!loaded() && Config.errorDefaultLanguage) { if (!tryLoadTemplate(Config.errorDefaultLanguage)) { - debugs(1, DBG_CRITICAL, "Unable to load default error language files. Reset to backups."); + debugs(1, (templateCode < TCP_RESET ? DBG_CRITICAL : 3), "Unable to load default error language files. Reset to backups."); } } #endif @@ -299,7 +299,7 @@ TemplateFile::loadDefault() /* giving up if failed */ if (!loaded()) { - debugs(1, DBG_CRITICAL, "WARNING: failed to find or read error text file " << templateName); + debugs(1, (templateCode < TCP_RESET ? DBG_CRITICAL : 3), "WARNING: failed to find or read error text file " << templateName); parse("Internal Error: Missing Template ", 33, '\0'); parse(templateName.termedBuf(), templateName.size(), '\0'); } @@ -346,7 +346,7 @@ TemplateFile::loadFromFile(const char *path) if (fd < 0) { /* with dynamic locale negotiation we may see some failures before a success. */ - if (!silent) + if (!silent && templateCode < TCP_RESET) debugs(4, DBG_CRITICAL, HERE << "'" << path << "': " << xstrerror()); wasLoaded = false; return wasLoaded; @@ -1231,7 +1231,7 @@ ErrorState::BuildContent() assert(page_id > ERR_NONE && page_id < error_page_count); #if USE_ERR_LOCALES - ErrorPageFile *localeTmpl = NULL; + ErrorPageFile *localeTmpl = NULL; /** error_directory option in squid.conf overrides translations. * Custom errors are always found either in error_directory or the templates directory. @@ -1241,7 +1241,7 @@ ErrorState::BuildContent() if (err_language && err_language != Config.errorDefaultLanguage) safe_free(err_language); - localeTmpl = new ErrorPageFile(err_type_str[page_id]); + localeTmpl = new ErrorPageFile(err_type_str[page_id], static_cast(page_id)); if (localeTmpl->loadFor(request)) { m = localeTmpl->text(); assert(localeTmpl->language()); diff --git a/src/errorpage.h b/src/errorpage.h index 5b2bcf2051..d4104b061c 100644 --- a/src/errorpage.h +++ b/src/errorpage.h @@ -254,7 +254,7 @@ SQUIDCEXTERN const char *errorPageName(int pageId); ///< error ID to string class TemplateFile { public: - TemplateFile(const char *name); + TemplateFile(const char *name, const err_type code); virtual ~TemplateFile() {} /// return true if the data loaded from disk without any problem @@ -301,6 +301,7 @@ protected: bool wasLoaded; ///< True if the template data read from disk without any problem String errLanguage; ///< The error language of the template. String templateName; ///< The name of the template + err_type templateCode; ///< The internal code for this template. }; /** diff --git a/src/ssl/ErrorDetailManager.cc b/src/ssl/ErrorDetailManager.cc index 76ddc1a7d6..30a23e6eed 100644 --- a/src/ssl/ErrorDetailManager.cc +++ b/src/ssl/ErrorDetailManager.cc @@ -20,7 +20,7 @@ namespace Ssl class ErrorDetailFile : public TemplateFile { public: - explicit ErrorDetailFile(ErrorDetailsList::Pointer const details): TemplateFile("error-details.txt") { + explicit ErrorDetailFile(ErrorDetailsList::Pointer const details): TemplateFile("error-details.txt", ERR_NONE) { buf.init(); theDetails = details; } diff --git a/src/tests/stub_errorpage.cc b/src/tests/stub_errorpage.cc index 99bb0bcfef..90eb844d2d 100644 --- a/src/tests/stub_errorpage.cc +++ b/src/tests/stub_errorpage.cc @@ -8,5 +8,5 @@ err_type errorReservePageId(const char *page_name) STUB_RETVAL(err_type()) void errorAppendEntry(StoreEntry * entry, ErrorState * err) STUB bool strHdrAcptLangGetItem(const String &hdr, char *lang, int langLen, size_t &pos) STUB_RETVAL(false) bool TemplateFile::loadDefault() STUB_RETVAL(false) -TemplateFile::TemplateFile(char const*) STUB +TemplateFile::TemplateFile(char const*, err_type) STUB bool TemplateFile::loadFor(HttpRequest*) STUB_RETVAL(false)