From: serassio <>
Date: Sun, 2 Apr 2006 20:32:35 +0000 (+0000)
Subject: Bug #1504: misleading error message message for bad/unresolveable cache_peer name
X-Git-Tag: SQUID_3_0_PRE4~269
X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=beed27a22dcbf485815b572eeac2b68a5a672f78;p=thirdparty%2Fsquid.git
Bug #1504: misleading error message message for bad/unresolveable cache_peer name
Forward port of 2.5 changes.
---
diff --git a/errors/English/ERR_CONNECT_FAIL b/errors/English/ERR_CONNECT_FAIL
index 30df94c71a..43e04be4d3 100644
--- a/errors/English/ERR_CONNECT_FAIL
+++ b/errors/English/ERR_CONNECT_FAIL
@@ -14,7 +14,7 @@ The following error was encountered:
-
-Connection Failed
+Connection to %I Failed
diff --git a/errors/Italian/ERR_CONNECT_FAIL b/errors/Italian/ERR_CONNECT_FAIL
index 42399469af..a1a73bf764 100644
--- a/errors/Italian/ERR_CONNECT_FAIL
+++ b/errors/Italian/ERR_CONNECT_FAIL
@@ -14,7 +14,7 @@ Mentre si cercava di recuperare la URL:
-
-Collegamento fallito
+Collegamento a %I fallito
diff --git a/src/errorpage.cc b/src/errorpage.cc
index 60ffc6fb7a..203d818fd9 100644
--- a/src/errorpage.cc
+++ b/src/errorpage.cc
@@ -1,6 +1,6 @@
/*
- * $Id: errorpage.cc,v 1.208 2006/02/17 20:15:35 wessels Exp $
+ * $Id: errorpage.cc,v 1.209 2006/04/02 14:32:35 serassio Exp $
*
* DEBUG: section 4 Error Generation
* AUTHOR: Duane Wessels
@@ -463,7 +463,6 @@ errorStateFree(ErrorState * err)
HTTPMSGUNLOCK(err->request);
safe_free(err->redirect_url);
safe_free(err->url);
- safe_free(err->host);
safe_free(err->dnsserver_msg);
safe_free(err->request_hdrs);
wordlistDestroy(&err->ftp.server_msg);
@@ -515,8 +514,8 @@ errorDump(ErrorState * err, MemBuf * mb)
/* - IP stuff */
str.Printf("ClientIP: %s\r\n", inet_ntoa(err->src_addr));
- if (err->host) {
- str.Printf("ServerIP: %s\r\n", err->host);
+ if (r && r->hier.host) {
+ str.Printf("ServerIP: %s\r\n", r->hier.host);
}
str.Printf("\r\n");
@@ -666,7 +665,13 @@ errorConvert(char token, ErrorState * err)
break;
case 'H':
- p = r ? r->host : "[unknown host]";
+ if (r) {
+ if (r->hier.host)
+ p = r->hier.host;
+ else
+ p = r->host;
+ } else
+ p = "[unknown host]";
break;
@@ -676,8 +681,8 @@ errorConvert(char token, ErrorState * err)
break;
case 'I':
- if (err->host) {
- mb.Printf("%s", err->host);
+ if (r && r->hier.host) {
+ mb.Printf("%s", r->hier.host);
} else
p = "[unknown]";
diff --git a/src/forward.cc b/src/forward.cc
index 8078f42ecf..404de983b3 100644
--- a/src/forward.cc
+++ b/src/forward.cc
@@ -1,6 +1,6 @@
/*
- * $Id: forward.cc,v 1.136 2006/02/17 18:10:59 wessels Exp $
+ * $Id: forward.cc,v 1.137 2006/04/02 14:32:35 serassio Exp $
*
* DEBUG: section 17 Request Forwarding
* AUTHOR: Duane Wessels
@@ -494,14 +494,6 @@ FwdState::negotiateSSL(int fd)
anErr->xerrno = EACCES;
#endif
- if (fs->_peer) {
- anErr->host = xstrdup(fs->_peer->host);
- anErr->port = fs->_peer->http_port;
- } else {
- anErr->host = xstrdup(request->host);
- anErr->port = request->port;
- }
-
anErr->request = HTTPMSGLOCK(request);
fail(anErr);
@@ -591,6 +583,9 @@ FwdState::connectDone(int aServerFD, comm_err_t status, int xerrno)
FwdServer *fs = servers;
assert(server_fd == aServerFD);
+ if (Config.onoff.log_ip_on_direct && status != COMM_ERR_DNS && fs->code == HIER_DIRECT)
+ hierarchyNote(&request->hier, fs->code, fd_table[server_fd].ipaddr);
+
if (status == COMM_ERR_DNS) {
/*
* Only set the dont_retry flag if the DNS lookup fails on
@@ -616,14 +611,6 @@ FwdState::connectDone(int aServerFD, comm_err_t status, int xerrno)
ErrorState *anErr = errorCon(ERR_CONNECT_FAIL, HTTP_SERVICE_UNAVAILABLE);
anErr->xerrno = xerrno;
- if (fs->_peer) {
- anErr->host = xstrdup(fs->_peer->host);
- anErr->port = fs->_peer->http_port;
- } else {
- anErr->host = xstrdup(request->host);
- anErr->port = request->port;
- }
-
fail(anErr);
if (fs->_peer)
@@ -652,9 +639,14 @@ FwdState::connectDone(int aServerFD, comm_err_t status, int xerrno)
void
FwdState::connectTimeout(int fd)
{
+ FwdServer *fs = servers;
+
debug(17, 2) ("fwdConnectTimeout: FD %d: '%s'\n", fd, storeUrl(entry));
assert(fd == server_fd);
+ if (Config.onoff.log_ip_on_direct && fs->code == HIER_DIRECT && fd_table[fd].ipaddr[0])
+ hierarchyNote(&request->hier, fs->code, fd_table[fd].ipaddr);
+
if (entry->isEmpty()) {
ErrorState *anErr = errorCon(ERR_CONNECT_FAIL, HTTP_GATEWAY_TIMEOUT);
anErr->xerrno = ETIMEDOUT;
@@ -783,6 +775,11 @@ FwdState::connectStart()
commSetTimeout(fd, ctimeout, fwdConnectTimeoutWrapper, this);
+ if (fs->_peer)
+ hierarchyNote(&request->hier, fs->code, fs->_peer->host);
+ else
+ hierarchyNote(&request->hier, fs->code, request->host);
+
commConnectStart(fd, host, port, fwdConnectDoneWrapper, this);
}
@@ -813,7 +810,6 @@ void
FwdState::dispatch()
{
peer *p = NULL;
- FwdServer *fs = servers;
debug(17, 3) ("fwdDispatch: FD %d: Fetching '%s %s'\n",
client_fd,
RequestMethodStr[request->method],
@@ -825,13 +821,6 @@ FwdState::dispatch()
*/
assert(server_fd > -1);
- if (fs->_peer)
- hierarchyNote(&request->hier, fs->code, fs->_peer->host);
- else if (Config.onoff.log_ip_on_direct)
- hierarchyNote(&request->hier, fs->code, fd_table[server_fd].ipaddr);
- else
- hierarchyNote(&request->hier, fs->code, request->host);
-
fd_note(server_fd, storeUrl(entry));
fd_table[server_fd].noteUse(fwdPconnPool);
diff --git a/src/gopher.cc b/src/gopher.cc
index 50f4fd28f0..697a3a3803 100644
--- a/src/gopher.cc
+++ b/src/gopher.cc
@@ -1,6 +1,6 @@
/*
- * $Id: gopher.cc,v 1.193 2006/02/17 18:10:59 wessels Exp $
+ * $Id: gopher.cc,v 1.194 2006/04/02 14:32:35 serassio Exp $
*
* DEBUG: section 10 Gopher
* AUTHOR: Harvest Derived
@@ -840,7 +840,6 @@ gopherSendComplete(int fd, char *buf, size_t size, comm_err_t errflag, int xerrn
ErrorState *err;
err = errorCon(ERR_WRITE_ERROR, HTTP_SERVICE_UNAVAILABLE);
err->xerrno = errno;
- err->host = xstrdup(gopherState->req->host);
err->port = gopherState->req->port;
err->url = xstrdup(storeUrl(entry));
gopherState->fwd->fail(err);
diff --git a/src/structs.h b/src/structs.h
index 08c4be3cec..9fb3244539 100644
--- a/src/structs.h
+++ b/src/structs.h
@@ -1,6 +1,6 @@
/*
- * $Id: structs.h,v 1.535 2006/04/02 10:15:24 serassio Exp $
+ * $Id: structs.h,v 1.536 2006/04/02 14:32:35 serassio Exp $
*
*
* SQUID Web Proxy Cache http://www.squid-cache.org/
@@ -1603,7 +1603,6 @@ struct _ErrorState
HttpRequest *request;
char *url;
int xerrno;
- char *host;
u_short port;
char *dnsserver_msg;
time_t ttl;
diff --git a/src/tunnel.cc b/src/tunnel.cc
index 4983b6ae65..15cb78d3a1 100644
--- a/src/tunnel.cc
+++ b/src/tunnel.cc
@@ -1,6 +1,6 @@
/*
- * $Id: tunnel.cc,v 1.159 2006/02/17 18:10:59 wessels Exp $
+ * $Id: tunnel.cc,v 1.160 2006/04/02 14:32:35 serassio Exp $
*
* DEBUG: section 26 Secure Sockets Layer Proxy
* AUTHOR: Duane Wessels
@@ -461,8 +461,6 @@ sslConnectTimeout(int fd, void *data)
err->xerrno = ETIMEDOUT;
- err->host = xstrdup(sslState->host);
-
err->port = sslState->port;
err->request = HTTPMSGLOCK(request);
@@ -557,7 +555,6 @@ sslConnectDone(int fdnotused, comm_err_t status, int xerrno, void *data)
err = errorCon(ERR_CONNECT_FAIL, HTTP_SERVICE_UNAVAILABLE);
*sslState->status_ptr = HTTP_SERVICE_UNAVAILABLE;
err->xerrno = xerrno;
- err->host = xstrdup(sslState->host);
err->port = sslState->port;
err->request = HTTPMSGLOCK(request);
err->callback = sslErrorComplete;