]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Silence messages about MGR_INDEX when not installed
authorAmos Jeffries <squid3@treenet.co.nz>
Sun, 5 Feb 2012 11:24:07 +0000 (04:24 -0700)
committerAmos Jeffries <squid3@treenet.co.nz>
Sun, 5 Feb 2012 11:24:07 +0000 (04:24 -0700)
src/err_type.h
src/errorpage.cc
src/errorpage.h
src/ssl/ErrorDetailManager.cc
src/tests/stub_errorpage.cc

index 9c5c91043b1c3862dcc5d0451bc3dad0ab02f3ed..c5be81965727a23affad05824f15f46c167cbbbb 100644 (file)
@@ -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;
index 53803ea6d373698984e29513f25617797eee05a7..ef1418017da69c1fbba8af24d34408f83f408c97 100644 (file)
@@ -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<err_type>(page_id));
         if (localeTmpl->loadFor(request)) {
             m = localeTmpl->text();
             assert(localeTmpl->language());
index 5b2bcf205142c5230938fcc63707883c864c2441..d4104b061cc888d2f2dd24a1d3a5c5d53cd99bb4 100644 (file)
@@ -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.
 };
 
 /**
index 76ddc1a7d6ca0ef6329a437a933af4bf63f166f5..30a23e6eede724f27a9228cbca41ffe235d3c61f 100644 (file)
@@ -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;
     }
index 99bb0bcfefc4aff300d731cc7700a4a865182ebd..90eb844d2d653964cc2b5ba3c19c29248f48b877 100644 (file)
@@ -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)