]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[MINOR] indicate the proxy type in the logs after a loss of servers
authorWilly Tarreau <w@1wt.eu>
Sun, 31 Dec 2006 16:46:05 +0000 (17:46 +0100)
committerWilly Tarreau <w@1wt.eu>
Sun, 31 Dec 2006 16:46:05 +0000 (17:46 +0100)
When the last server goes down in a backend, indicate 'backend' or
'listener' in the log message depending on the type of the backend.

include/proto/proxy.h
include/types/proxy.h
src/cfgparse.c
src/checks.c
src/proto_http.c
src/proxy.c

index 968495f3a2e9dc09e7590f70aad06fc08b737f40..3fa541a2db3a4acd26a7864f20c5046376329910 100644 (file)
@@ -31,6 +31,7 @@ void soft_stop(void);
 void pause_proxy(struct proxy *p);
 void pause_proxies(void);
 void listen_proxies(void);
+const char *proxy_type_str(struct proxy *proxy);
 
 
 #endif /* _PROTO_PROXY_H */
index 9a5da7cd98e644d6c486a88d186a4f8572b71856..bf946a3cd3f3e610758bcef04b86b36bbeaa1666 100644 (file)
@@ -139,7 +139,6 @@ struct proxy {
 };
 
 extern struct proxy *proxy;
-extern const char *proxy_type_str(int capabilities);
 
 #endif /* _TYPES_PROXY_H */
 
index 50faebd113fceb234bf15b7ae72e6b028a9f821e..9589841980c80f1895f0478629e5d16f9ec0484f 100644 (file)
@@ -35,6 +35,7 @@
 #include <proto/checks.h>
 #include <proto/httperr.h>
 #include <proto/log.h>
+#include <proto/proxy.h>
 #include <proto/server.h>
 #include <proto/task.h>
 
@@ -227,7 +228,7 @@ int warnifnotcap(struct proxy *proxy, int cap, const char *file, int line, char
 
        if (!(proxy->cap & cap)) {
                Warning("parsing [%s:%d] : '%s' ignored because %s '%s' has %s capability.%s\n",
-                       file, line, arg, proxy_type_str(proxy->cap), proxy->id, msg, hint ? hint : "");
+                       file, line, arg, proxy_type_str(proxy), proxy->id, msg, hint ? hint : "");
                return 1;
        }
        return 0;
@@ -2043,7 +2044,7 @@ int readcfgfile(const char *file)
 
                if (curproxy->cap & PR_CAP_FE && curproxy->listen == NULL)  {
                        Alert("parsing %s : %s '%s' has no listen address. Please either specify a valid address on the <listen> line, or use the <bind> keyword.\n",
-                             file, proxy_type_str(curproxy->cap), curproxy->id);
+                             file, proxy_type_str(curproxy), curproxy->id);
                        cfgerr++;
                }
                else if (curproxy->cap & PR_CAP_BE &&
@@ -2051,47 +2052,47 @@ int readcfgfile(const char *file)
                          !(curproxy->options & (PR_O_TRANSP | PR_O_BALANCE)) &&
                          (*(int *)&curproxy->dispatch_addr.sin_addr == 0))) {
                        Alert("parsing %s : %s '%s' has no dispatch address and is not in transparent or balance mode.\n",
-                             file, proxy_type_str(curproxy->cap), curproxy->id);
+                             file, proxy_type_str(curproxy), curproxy->id);
                        cfgerr++;
                }
                else if ((curproxy->mode != PR_MODE_HEALTH) && (curproxy->options & PR_O_BALANCE)) {
                        if (curproxy->options & PR_O_TRANSP) {
                                Alert("parsing %s : %s '%s' cannot use both transparent and balance mode.\n",
-                                     file, proxy_type_str(curproxy->cap), curproxy->id);
+                                     file, proxy_type_str(curproxy), curproxy->id);
                                cfgerr++;
                        }
 #ifdef WE_DONT_SUPPORT_SERVERLESS_LISTENERS
                        else if (curproxy->srv == NULL) {
                                Alert("parsing %s : %s '%s' needs at least 1 server in balance mode.\n",
-                                     file, proxy_type_str(curproxy->cap), curproxy->id);
+                                     file, proxy_type_str(curproxy), curproxy->id);
                                cfgerr++;
                        }
 #endif
                        else if (*(int *)&curproxy->dispatch_addr.sin_addr != 0) {
                                Warning("parsing %s : dispatch address of %s '%s' will be ignored in balance mode.\n",
-                                       file, proxy_type_str(curproxy->cap), curproxy->id);
+                                       file, proxy_type_str(curproxy), curproxy->id);
                        }
                }
                else if (curproxy->mode == PR_MODE_TCP || curproxy->mode == PR_MODE_HEALTH) { /* TCP PROXY or HEALTH CHECK */
                        if (curproxy->cookie_name != NULL) {
                                Warning("parsing %s : cookie will be ignored for %s '%s'.\n",
-                                       file, proxy_type_str(curproxy->cap), curproxy->id);
+                                       file, proxy_type_str(curproxy), curproxy->id);
                        }
                        if ((newsrv = curproxy->srv) != NULL) {
                                Warning("parsing %s : servers will be ignored for %s '%s'.\n",
-                                       file, proxy_type_str(curproxy->cap), curproxy->id);
+                                       file, proxy_type_str(curproxy), curproxy->id);
                        }
                        if (curproxy->rsp_exp != NULL) {
                                Warning("parsing %s : server regular expressions will be ignored for %s '%s'.\n",
-                                       file, proxy_type_str(curproxy->cap), curproxy->id);
+                                       file, proxy_type_str(curproxy), curproxy->id);
                        }
                        if (curproxy->req_exp != NULL) {
                                Warning("parsing %s : client regular expressions will be ignored for %s '%s'.\n",
-                                       file, proxy_type_str(curproxy->cap), curproxy->id);
+                                       file, proxy_type_str(curproxy), curproxy->id);
                        }
                        if (curproxy->monitor_uri != NULL) {
                                Warning("parsing %s : monitor-uri will be ignored for %s '%s'.\n",
-                                       file, proxy_type_str(curproxy->cap), curproxy->id);
+                                       file, proxy_type_str(curproxy), curproxy->id);
                        }
                }
                else if (curproxy->mode == PR_MODE_HTTP) { /* HTTP PROXY */
@@ -2115,18 +2116,18 @@ int readcfgfile(const char *file)
                                }
                                if (target == NULL) {
                                        Alert("parsing %s : backend '%s' in HTTP %s '%s' was not found !\n", 
-                                             file, exp->replace, proxy_type_str(curproxy->cap), curproxy->id);
+                                             file, exp->replace, proxy_type_str(curproxy), curproxy->id);
                                        cfgerr++;
                                } else if (target == curproxy) {
                                        Alert("parsing %s : loop detected for backend %s !\n", file, exp->replace);
                                        cfgerr++;
                                } else if (!(target->cap & PR_CAP_BE)) {
                                        Alert("parsing %s : target '%s' in HTTP %s '%s' has no backend capability !\n",
-                                             file, exp->replace, proxy_type_str(curproxy->cap), curproxy->id);
+                                             file, exp->replace, proxy_type_str(curproxy), curproxy->id);
                                        cfgerr++;
                                } else if (target->mode != PR_MODE_HTTP) {
                                        Alert("parsing %s : backend '%s' in HTTP %s '%s' is not HTTP (use 'mode http') !\n",
-                                             file, exp->replace, proxy_type_str(curproxy->cap), curproxy->id);
+                                             file, exp->replace, proxy_type_str(curproxy), curproxy->id);
                                        cfgerr++;
                                } else {
                                        free((void *)exp->replace);
@@ -2141,7 +2142,7 @@ int readcfgfile(const char *file)
                                "   | While not properly invalid, you will certainly encounter various problems\n"
                                "   | with such a configuration. To fix this, please ensure that all following\n"
                                "   | values are set to a non-zero value: clitimeout, contimeout, srvtimeout.\n",
-                               file, proxy_type_str(curproxy->cap), curproxy->id);
+                               file, proxy_type_str(curproxy), curproxy->id);
                }
 
                if (curproxy->options & PR_O_SSL3_CHK) {
@@ -2230,7 +2231,7 @@ int readcfgfile(const char *file)
                                newsrv->minconn = newsrv->maxconn;
                        } else if (newsrv->minconn != newsrv->maxconn && !curproxy->fullconn) {
                                Alert("parsing %s, %s '%s' : fullconn is mandatory when minconn is set on a server.\n",
-                                     file, proxy_type_str(curproxy->cap), curproxy->id, linenum);
+                                     file, proxy_type_str(curproxy), curproxy->id, linenum);
                                return -1;
                        }
 
index e190a2e2625693fd452ce65b0a36d205a05736c3..054571e0681b4dbcc747813d9c23067e9c799a8b 100644 (file)
@@ -33,6 +33,7 @@
 #include <proto/fd.h>
 #include <proto/log.h>
 #include <proto/queue.h>
+#include <proto/proxy.h>
 #include <proto/server.h>
 #include <proto/task.h>
 
@@ -91,8 +92,8 @@ void set_server_down(struct server *s)
                send_log(s->proxy, LOG_ALERT, "%s", trash);
        
                if (s->proxy->srv_bck == 0 && s->proxy->srv_act == 0) {
-                       Alert("Proxy %s has no server available !\n", s->proxy->id);
-                       send_log(s->proxy, LOG_EMERG, "Proxy %s has no server available !\n", s->proxy->id);
+                       Alert("%s '%s' has no server available !\n", proxy_type_str(s->proxy), s->proxy->id);
+                       send_log(s->proxy, LOG_EMERG, "%s %s has no server available !\n", proxy_type_str(s->proxy), s->proxy->id);
                }
                s->down_trans++;
        }
@@ -289,8 +290,8 @@ int process_chk(struct task *t)
                                else if (s->proxy->options & PR_O_BIND_SRC) {
                                        setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char *) &one, sizeof(one));
                                        if (bind(fd, (struct sockaddr *)&s->proxy->source_addr, sizeof(s->proxy->source_addr)) == -1) {
-                                               Alert("Cannot bind to source address before connect() for proxy %s. Aborting.\n",
-                                                     s->proxy->id);
+                                               Alert("Cannot bind to source address before connect() for %s '%s'. Aborting.\n",
+                                                     proxy_type_str(s->proxy), s->proxy->id);
                                                s->result = -1;
                                        }
 #ifdef CONFIG_HAP_CTTPROXY
@@ -308,8 +309,8 @@ int process_chk(struct task *t)
                                                
                                                if (setsockopt(fd, SOL_IP, IP_TPROXY, &itp1, sizeof(itp1)) == -1 ||
                                                    setsockopt(fd, SOL_IP, IP_TPROXY, &itp2, sizeof(itp2)) == -1) {
-                                                       Alert("Cannot bind to tproxy source address before connect() for proxy %s. Aborting.\n",
-                                                             s->proxy->id);
+                                                       Alert("Cannot bind to tproxy source address before connect() for %s '%s'. Aborting.\n",
+                                                             proxy_type_str(s->proxy), s->proxy->id);
                                                        s->result = -1;
                                                }
                                        }
index 1e24f01e1ac9064134dca0467ae4c745ddc1f053..21ea4c91078f9b7c68f6a7a37fd9c99ab65ffb71 100644 (file)
@@ -2743,7 +2743,7 @@ int produce_content(struct session *s)
                                           "Cache-Control: no-cache\r\n"
                                           "Connection: close\r\n"
                                           "Content-Type: text/html\r\n"
-                                          "\r\n\r\n");
+                                          "\r\n");
            
                        s->logs.status = 200;
                        client_retnclose(s, &msg); // send the start of the response.
index ac84337feb40885f4bca15d017c5943fc13a8f7e..41bf46b747c78075ec3ffae434af1318aa42f5a1 100644 (file)
@@ -37,8 +37,9 @@ struct proxy *proxy  = NULL;  /* list of all existing proxies */
  * This function returns a string containing the type of the proxy in a format
  * suitable for error messages, from its capabilities.
  */
-const char *proxy_type_str(int cap)
+const char *proxy_type_str(struct proxy *proxy)
 {
+       int cap = proxy->cap;
        if ((cap & PR_CAP_LISTEN) == PR_CAP_LISTEN)
                return "listener";
        else if (cap & PR_CAP_FE)