]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug #212: variable %i always 0.0.0.0
authorserassio <>
Fri, 25 Aug 2006 21:22:34 +0000 (21:22 +0000)
committerserassio <>
Fri, 25 Aug 2006 21:22:34 +0000 (21:22 +0000)
This patch extends errorCon() with a request_t argument, pulling some of the common
details of the request:

  ->request
  ->src_addr

Also cleaned all the duplicated related code.

Some of the 2.6 failing cases was already fixed in 3.0 using
clientBuildError(), but there are many other failing cases now fixed by this
patch.

13 files changed:
src/cache_manager.cc
src/client_side_reply.cc
src/errorpage.cc
src/errorpage.h
src/forward.cc
src/ftp.cc
src/gopher.cc
src/http.cc
src/internal.cc
src/tunnel.cc
src/urn.cc
src/wais.cc
src/whois.cc

index 37d734b23c15c0e5b0388dadab21ecbe4bdcc2ca..fdf9e252c415e4109e7ccbc3e1906281a4dcabd7 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: cache_manager.cc,v 1.44 2006/08/21 00:50:41 robertc Exp $
+ * $Id: cache_manager.cc,v 1.45 2006/08/25 15:22:34 serassio Exp $
  *
  * DEBUG: section 16    Cache Manager Objects
  * AUTHOR: Duane Wessels
@@ -247,9 +247,8 @@ cachemgrStart(int fd, HttpRequest * request, StoreEntry * entry)
     debug(16, 3) ("objectcacheStart: '%s'\n", storeUrl(entry));
 
     if ((mgr = cachemgrParseUrl(storeUrl(entry))) == NULL) {
-        err = errorCon(ERR_INVALID_URL, HTTP_NOT_FOUND);
+        err = errorCon(ERR_INVALID_URL, HTTP_NOT_FOUND, request);
         err->url = xstrdup(storeUrl(entry));
-        err->request = HTTPMSGLOCK(request);
         errorAppendEntry(entry, err);
         entry->expires = squid_curtime;
         return;
@@ -274,7 +273,7 @@ cachemgrStart(int fd, HttpRequest * request, StoreEntry * entry)
         /* build error message */
         ErrorState *err;
         HttpReply *rep;
-        err = errorCon(ERR_CACHE_MGR_ACCESS_DENIED, HTTP_UNAUTHORIZED);
+        err = errorCon(ERR_CACHE_MGR_ACCESS_DENIED, HTTP_UNAUTHORIZED, request);
         /* warn if user specified incorrect password */
 
         if (mgr->passwd)
@@ -286,8 +285,6 @@ cachemgrStart(int fd, HttpRequest * request, StoreEntry * entry)
                           mgr->user_name ? mgr->user_name : "<unknown>",
                           fd_table[fd].ipaddr, mgr->action);
 
-        err->request = HTTPMSGLOCK(request);
-
         rep = errorBuildReply(err);
 
         errorStateFree(err);
index 78a2be24b2708d80b5dbb706d51aef256cbf3c02..7d367f9cadf4b984b5eaac03c943fbf9a6185834 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: client_side_reply.cc,v 1.111 2006/08/21 00:50:41 robertc Exp $
+ * $Id: client_side_reply.cc,v 1.112 2006/08/25 15:22:34 serassio Exp $
  *
  * DEBUG: section 88    Client-side Reply Routines
  * AUTHOR: Robert Collins (Originally Duane Wessels in client_side.c)
@@ -2081,14 +2081,11 @@ clientBuildError(err_type page_id, http_status status, char const *url,
 
                  struct IN_ADDR * src_addr, HttpRequest * request)
 {
-    ErrorState *err = errorCon(page_id, status);
+    ErrorState *err = errorCon(page_id, status, request);
     err->src_addr = *src_addr;
 
     if (url)
         err->url = xstrdup(url);
 
-    if (request)
-        err->request = HTTPMSGLOCK(request);
-
     return err;
 }
index c25ddf7ebe79dab5013db8e7751206a6069bb1b4..e5997ee9e5216418bb4d9ca9f9707b2e93b5ba30 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: errorpage.cc,v 1.216 2006/08/24 14:59:32 serassio Exp $
+ * $Id: errorpage.cc,v 1.217 2006/08/25 15:22:34 serassio Exp $
  *
  * DEBUG: section 4     Error Generation
  * AUTHOR: Duane Wessels
@@ -322,12 +322,18 @@ errorPageName(int pageId)
  * Abstract:  This function creates a ErrorState object.
  */
 ErrorState *
-errorCon(err_type type, http_status status)
+errorCon(err_type type, http_status status, HttpRequest * request)
 {
     ErrorState *err = new ErrorState;
     err->page_id = type;       /* has to be reset manually if needed */
     err->type = type;
     err->httpStatus = status;
+
+    if (request != NULL) {
+        err->request = HTTPMSGLOCK(request);
+        err->src_addr = request->client_addr;
+    }
+
     return err;
 }
 
index 6ec68f5b364db343bfe07cb59ace1c614adc2c75..e909925d71986ae8945d075b869bc7e6dc2c2fc4 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: errorpage.h,v 1.1 2006/08/21 00:50:41 robertc Exp $
+ * $Id: errorpage.h,v 1.2 2006/08/25 15:22:34 serassio Exp $
  *
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
@@ -40,7 +40,8 @@
 
 class ErrorState
 {
-  public:
+
+public:
     err_type type;
     int page_id;
     http_status httpStatus;
@@ -76,7 +77,8 @@ unsigned int flag_cbdata:
     ftp;
     char *request_hdrs;
     char *err_msg; /* Preformatted error message from the cache */
-  private:
+
+private:
     CBDATA_CLASS2(ErrorState);
 };
 
@@ -87,7 +89,7 @@ SQUIDCEXTERN void errorSend(int fd, ErrorState *);
 SQUIDCEXTERN void errorAppendEntry(StoreEntry *, ErrorState *);
 SQUIDCEXTERN void errorStateFree(ErrorState * err);
 SQUIDCEXTERN err_type errorReservePageId(const char *page_name);
-SQUIDCEXTERN ErrorState *errorCon(err_type type, http_status);
+SQUIDCEXTERN ErrorState *errorCon(err_type type, http_status, HttpRequest * request);
 
 
 #endif /* SQUID_ERRORPAGE_H */
index da946a40eec23a5da38786c2fc0c962a48bd950e..b00cf383bca3dc42d6437e06f550df8623715881 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: forward.cc,v 1.148 2006/08/21 00:50:41 robertc Exp $
+ * $Id: forward.cc,v 1.149 2006/08/25 15:22:34 serassio Exp $
  *
  * DEBUG: section 17    Request Forwarding
  * AUTHOR: Duane Wessels
@@ -191,11 +191,7 @@ FwdState::fwdStart(int client_fd, StoreEntry *entry, HttpRequest *request)
             if (page_id == ERR_NONE)
                 page_id = ERR_FORWARDING_DENIED;
 
-            ErrorState *anErr = errorCon(page_id, HTTP_FORBIDDEN);
-
-            anErr->request = HTTPMSGLOCK(request);
-
-            anErr->src_addr = request->client_addr;
+            ErrorState *anErr = errorCon(page_id, HTTP_FORBIDDEN, request);
 
             errorAppendEntry(entry, anErr);    // frees anErr
 
@@ -216,8 +212,7 @@ FwdState::fwdStart(int client_fd, StoreEntry *entry, HttpRequest *request)
 
     if (shutting_down) {
         /* more yuck */
-        ErrorState *anErr = errorCon(ERR_SHUTTING_DOWN, HTTP_SERVICE_UNAVAILABLE);
-        anErr->request = HTTPMSGLOCK(request);
+        ErrorState *anErr = errorCon(ERR_SHUTTING_DOWN, HTTP_SERVICE_UNAVAILABLE, request);
         errorAppendEntry(entry, anErr);        // frees anErr
         return;
     }
@@ -488,8 +483,7 @@ FwdState::serverClosed(int fd)
     }
 
     if (!err && shutting_down) {
-        ErrorState *anErr = errorCon(ERR_SHUTTING_DOWN, HTTP_SERVICE_UNAVAILABLE);
-        anErr->request = HTTPMSGLOCK(request);
+        errorCon(ERR_SHUTTING_DOWN, HTTP_SERVICE_UNAVAILABLE, request);
     }
 
     self = NULL;       // refcounted
@@ -518,7 +512,7 @@ FwdState::negotiateSSL(int fd)
 
         default:
             debug(81, 1) ("fwdNegotiateSSL: Error negotiating SSL connection on FD %d: %s (%d/%d/%d)\n", fd, ERR_error_string(ERR_get_error(), NULL), ssl_error, ret, errno);
-            ErrorState *anErr = errorCon(ERR_CONNECT_FAIL, HTTP_SERVICE_UNAVAILABLE);
+            ErrorState *anErr = errorCon(ERR_CONNECT_FAIL, HTTP_SERVICE_UNAVAILABLE, request);
 #ifdef EPROTO
 
             anErr->xerrno = EPROTO;
@@ -527,7 +521,6 @@ FwdState::negotiateSSL(int fd)
             anErr->xerrno = EACCES;
 #endif
 
-            anErr->request = HTTPMSGLOCK(request);
             fail(anErr);
 
             if (fs->_peer) {
@@ -571,9 +564,8 @@ FwdState::initiateSSL()
     if ((ssl = SSL_new(sslContext)) == NULL) {
         debug(83, 1) ("fwdInitiateSSL: Error allocating handle: %s\n",
                       ERR_error_string(ERR_get_error(), NULL));
-        ErrorState *anErr = errorCon(ERR_SOCKET_FAILURE, HTTP_INTERNAL_SERVER_ERROR);
+        ErrorState *anErr = errorCon(ERR_SOCKET_FAILURE, HTTP_INTERNAL_SERVER_ERROR, request);
         anErr->xerrno = errno;
-        anErr->request = HTTPMSGLOCK(request);
         fail(anErr);
         self = NULL;           // refcounted
         return;
@@ -632,7 +624,7 @@ FwdState::connectDone(int aServerFD, comm_err_t status, int xerrno)
         debug(17, 4) ("fwdConnectDone: Unknown host: %s\n",
                       request->host);
 
-        ErrorState *anErr = errorCon(ERR_DNS_FAIL, HTTP_SERVICE_UNAVAILABLE);
+        ErrorState *anErr = errorCon(ERR_DNS_FAIL, HTTP_SERVICE_UNAVAILABLE, request);
 
         anErr->dnsserver_msg = xstrdup(dns_error_message);
 
@@ -641,7 +633,7 @@ FwdState::connectDone(int aServerFD, comm_err_t status, int xerrno)
         comm_close(server_fd);
     } else if (status != COMM_OK) {
         assert(fs);
-        ErrorState *anErr = errorCon(ERR_CONNECT_FAIL, HTTP_SERVICE_UNAVAILABLE);
+        ErrorState *anErr = errorCon(ERR_CONNECT_FAIL, HTTP_SERVICE_UNAVAILABLE, request);
         anErr->xerrno = xerrno;
 
         fail(anErr);
@@ -681,7 +673,7 @@ FwdState::connectTimeout(int fd)
         hierarchyNote(&request->hier, fs->code, fd_table[fd].ipaddr);
 
     if (entry->isEmpty()) {
-        ErrorState *anErr = errorCon(ERR_CONNECT_FAIL, HTTP_GATEWAY_TIMEOUT);
+        ErrorState *anErr = errorCon(ERR_CONNECT_FAIL, HTTP_GATEWAY_TIMEOUT, request);
         anErr->xerrno = ETIMEDOUT;
         fail(anErr);
         /*
@@ -779,7 +771,7 @@ FwdState::connectStart()
 
     if (fd < 0) {
         debug(50, 4) ("fwdConnectStart: %s\n", xstrerror());
-        ErrorState *anErr = errorCon(ERR_SOCKET_FAILURE, HTTP_INTERNAL_SERVER_ERROR);
+        ErrorState *anErr = errorCon(ERR_SOCKET_FAILURE, HTTP_INTERNAL_SERVER_ERROR, request);
         anErr->xerrno = errno;
         fail(anErr);
         self = NULL;   // refcounted
@@ -833,7 +825,7 @@ void
 FwdState::startFail()
 {
     debug(17, 3) ("fwdStartFail: %s\n", storeUrl(entry));
-    ErrorState *anErr = errorCon(ERR_CANNOT_FORWARD, HTTP_SERVICE_UNAVAILABLE);
+    ErrorState *anErr = errorCon(ERR_CANNOT_FORWARD, HTTP_SERVICE_UNAVAILABLE, request);
     anErr->xerrno = errno;
     fail(anErr);
     self = NULL;       // refcounted
@@ -915,7 +907,7 @@ FwdState::dispatch()
         default:
             debug(17, 1) ("fwdDispatch: Cannot retrieve '%s'\n",
                           storeUrl(entry));
-            ErrorState *anErr = errorCon(ERR_UNSUP_REQ, HTTP_BAD_REQUEST);
+            ErrorState *anErr = errorCon(ERR_UNSUP_REQ, HTTP_BAD_REQUEST, request);
             fail(anErr);
             /*
              * Force a persistent connection to be closed because
index 1050b76d935384e3ce51c967660cf7ffdd9b51a1..e1b88f9590fafd58631159f0c21d8814168cf8d6 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: ftp.cc,v 1.400 2006/08/21 00:50:41 robertc Exp $
+ * $Id: ftp.cc,v 1.401 2006/08/25 15:22:34 serassio Exp $
  *
  * DEBUG: section 9     File Transfer Protocol (FTP)
  * AUTHOR: Harvest Derived
@@ -2966,12 +2966,12 @@ FtpStateData::failedErrorMessage(err_type error, int xerrno)
 
             if (ctrl.replycode > 500)
                 if (password_url)
-                    err = errorCon(ERR_FTP_FORBIDDEN, HTTP_FORBIDDEN);
+                    err = errorCon(ERR_FTP_FORBIDDEN, HTTP_FORBIDDEN, fwd->request);
                 else
-                    err = errorCon(ERR_FTP_FORBIDDEN, HTTP_UNAUTHORIZED);
+                    err = errorCon(ERR_FTP_FORBIDDEN, HTTP_UNAUTHORIZED, fwd->request);
 
             else if (ctrl.replycode == 421)
-                err = errorCon(ERR_FTP_UNAVAILABLE, HTTP_SERVICE_UNAVAILABLE);
+                err = errorCon(ERR_FTP_UNAVAILABLE, HTTP_SERVICE_UNAVAILABLE, fwd->request);
 
             break;
 
@@ -2979,7 +2979,7 @@ FtpStateData::failedErrorMessage(err_type error, int xerrno)
 
         case SENT_RETR:
             if (ctrl.replycode == 550)
-                err = errorCon(ERR_FTP_NOT_FOUND, HTTP_NOT_FOUND);
+                err = errorCon(ERR_FTP_NOT_FOUND, HTTP_NOT_FOUND, fwd->request);
 
             break;
 
@@ -2990,16 +2990,16 @@ FtpStateData::failedErrorMessage(err_type error, int xerrno)
         break;
 
     case ERR_READ_TIMEOUT:
-        err = errorCon(error, HTTP_GATEWAY_TIMEOUT);
+        err = errorCon(error, HTTP_GATEWAY_TIMEOUT, fwd->request);
         break;
 
     default:
-        err = errorCon(error, HTTP_BAD_GATEWAY);
+        err = errorCon(error, HTTP_BAD_GATEWAY, fwd->request);
         break;
     }
 
     if (err == NULL)
-        err = errorCon(ERR_FTP_FAILURE, HTTP_BAD_GATEWAY);
+        err = errorCon(ERR_FTP_FAILURE, HTTP_BAD_GATEWAY, fwd->request);
 
     err->xerrno = xerrno;
 
@@ -3053,8 +3053,7 @@ ftpSendReply(FtpStateData * ftpState)
         http_code = HTTP_INTERNAL_SERVER_ERROR;
     }
 
-    err = errorCon(err_code, http_code);
-    err->request = HTTPMSGLOCK(ftpState->request);
+    err = errorCon(err_code, http_code, ftpState->request);
 
     if (ftpState->old_request)
         err->ftp.request = xstrdup(ftpState->old_request);
@@ -3180,8 +3179,7 @@ FtpStateData::appendSuccessHeader()
 HttpReply *
 FtpStateData::ftpAuthRequired(HttpRequest * request, const char *realm)
 {
-    ErrorState *err = errorCon(ERR_CACHE_ACCESS_DENIED, HTTP_UNAUTHORIZED);
-    err->request = HTTPMSGLOCK(request);
+    ErrorState *err = errorCon(ERR_CACHE_ACCESS_DENIED, HTTP_UNAUTHORIZED, request);
     HttpReply *newrep = errorBuildReply(err);
     errorStateFree(err);
     /* add Authenticate header */
@@ -3326,9 +3324,8 @@ FtpStateData::icapAclCheckDone(ICAPServiceRep::Pointer service)
          * XXX Maybe instead of an error page we should
          * handle the reply normally (without ICAP).
          */
-        ErrorState *err = errorCon(ERR_ICAP_FAILURE, HTTP_INTERNAL_SERVER_ERROR);
+        ErrorState *err = errorCon(ERR_ICAP_FAILURE, HTTP_INTERNAL_SERVER_ERROR, request);
         err->xerrno = errno;
-        err->request = HTTPMSGLOCK(request);
         errorAppendEntry(entry, err);
         comm_close(ctrl.fd);
         return;
@@ -3422,8 +3419,7 @@ FtpStateData::abortAdapting()
 
     if (entry->isEmpty()) {
         ErrorState *err;
-        err = errorCon(ERR_ICAP_FAILURE, HTTP_INTERNAL_SERVER_ERROR);
-        err->request = HTTPMSGLOCK((HttpRequest *) request);
+        err = errorCon(ERR_ICAP_FAILURE, HTTP_INTERNAL_SERVER_ERROR, request);
         err->xerrno = errno;
         fwd->fail(err);
         fwd->dontRetry(true);
index f35fcc3ca818d11e8acb9dd284393e9b14f8e7bd..63bb1839751d376ef6d822cd6c8c5af00119ff6a 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: gopher.cc,v 1.198 2006/08/21 00:50:41 robertc Exp $
+ * $Id: gopher.cc,v 1.199 2006/08/25 15:22:34 serassio Exp $
  *
  * DEBUG: section 10    Gopher
  * AUTHOR: Harvest Derived
@@ -710,7 +710,7 @@ gopherTimeout(int fd, void *data)
     StoreEntry *entry = gopherState->entry;
     debug(10, 4) ("gopherTimeout: FD %d: '%s'\n", fd, storeUrl(entry));
 
-    gopherState->fwd->fail(errorCon(ERR_READ_TIMEOUT, HTTP_GATEWAY_TIMEOUT));
+    gopherState->fwd->fail(errorCon(ERR_READ_TIMEOUT, HTTP_GATEWAY_TIMEOUT, gopherState->fwd->request));
 
     comm_close(fd);
 }
@@ -780,14 +780,14 @@ gopherReadReply(int fd, char *buf, size_t len, comm_err_t flag, int xerrno, void
             do_next_read = 1;
         } else {
             ErrorState *err;
-            err = errorCon(ERR_READ_ERROR, HTTP_INTERNAL_SERVER_ERROR);
+            err = errorCon(ERR_READ_ERROR, HTTP_INTERNAL_SERVER_ERROR, gopherState->fwd->request);
             err->xerrno = errno;
             gopherState->fwd->fail(err);
             comm_close(fd);
             do_next_read = 0;
         }
     } else if (len == 0 && entry->isEmpty()) {
-        gopherState->fwd->fail(errorCon(ERR_ZERO_SIZE_OBJECT, HTTP_SERVICE_UNAVAILABLE));
+        gopherState->fwd->fail(errorCon(ERR_ZERO_SIZE_OBJECT, HTTP_SERVICE_UNAVAILABLE, gopherState->fwd->request));
         comm_close(fd);
         do_next_read = 0;
     } else if (len == 0) {
@@ -840,7 +840,7 @@ gopherSendComplete(int fd, char *buf, size_t size, comm_err_t errflag, int xerrn
 
     if (errflag) {
         ErrorState *err;
-        err = errorCon(ERR_WRITE_ERROR, HTTP_SERVICE_UNAVAILABLE);
+        err = errorCon(ERR_WRITE_ERROR, HTTP_SERVICE_UNAVAILABLE, gopherState->fwd->request);
         err->xerrno = errno;
         err->port = gopherState->req->port;
         err->url = xstrdup(storeUrl(entry));
index beb68e50ef9b72aea57b32dcdf21621529f6eacf..b882104c27fe529614a737bb5a25023150b1acdc 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: http.cc,v 1.504 2006/08/21 00:50:41 robertc Exp $
+ * $Id: http.cc,v 1.505 2006/08/25 15:22:34 serassio Exp $
  *
  * DEBUG: section 11    Hypertext Transfer Protocol (HTTP)
  * AUTHOR: Harvest Derived
@@ -186,7 +186,7 @@ httpTimeout(int fd, void *data)
     debug(11, 4) ("httpTimeout: FD %d: '%s'\n", fd, storeUrl(entry));
 
     if (entry->store_status == STORE_PENDING) {
-        httpState->fwd->fail(errorCon(ERR_READ_TIMEOUT, HTTP_GATEWAY_TIMEOUT));
+        httpState->fwd->fail(errorCon(ERR_READ_TIMEOUT, HTTP_GATEWAY_TIMEOUT, httpState->fwd->request));
     }
 
     comm_close(fd);
@@ -1024,14 +1024,14 @@ HttpStateData::readReply (size_t len, comm_err_t flag, int xerrno)
             flags.do_next_read = 1;
         } else {
             ErrorState *err;
-            err = errorCon(ERR_READ_ERROR, HTTP_BAD_GATEWAY);
+            err = errorCon(ERR_READ_ERROR, HTTP_BAD_GATEWAY, fwd->request);
             err->xerrno = errno;
             fwd->fail(err);
             flags.do_next_read = 0;
             comm_close(fd);
         }
     } else if (flag == COMM_OK && len == 0 && !flags.headers_parsed) {
-        fwd->fail(errorCon(ERR_ZERO_SIZE_OBJECT, HTTP_BAD_GATEWAY));
+        fwd->fail(errorCon(ERR_ZERO_SIZE_OBJECT, HTTP_BAD_GATEWAY, fwd->request));
         eof = 1;
         flags.do_next_read = 0;
         comm_close(fd);
@@ -1048,12 +1048,12 @@ HttpStateData::readReply (size_t len, comm_err_t flag, int xerrno)
              */
             processReplyHeader();
         else if (getReply()->sline.status == HTTP_INVALID_HEADER && HttpVersion(0,9) != getReply()->sline.version) {
-            fwd->fail(errorCon(ERR_INVALID_RESP, HTTP_BAD_GATEWAY));
+            fwd->fail(errorCon(ERR_INVALID_RESP, HTTP_BAD_GATEWAY, fwd->request));
             flags.do_next_read = 0;
         } else {
             if (entry->mem_obj->getReply()->sline.status == HTTP_HEADER_TOO_LARGE) {
                 storeEntryReset(entry);
-                fwd->fail( errorCon(ERR_TOO_BIG, HTTP_BAD_GATEWAY));
+                fwd->fail( errorCon(ERR_TOO_BIG, HTTP_BAD_GATEWAY, fwd->request));
                 fwd->dontRetry(true);
                 flags.do_next_read = 0;
                 comm_close(fd);
@@ -1076,7 +1076,7 @@ HttpStateData::readReply (size_t len, comm_err_t flag, int xerrno)
 
                 if (fail) {
                     storeEntryReset(entry);
-                    fwd->fail( errorCon(ERR_INVALID_RESP, HTTP_BAD_GATEWAY));
+                    fwd->fail( errorCon(ERR_INVALID_RESP, HTTP_BAD_GATEWAY, fwd->request));
                     comm_close(fd);
                     return;
                 }
@@ -1268,7 +1268,7 @@ HttpStateData::SendComplete(int fd, char *bufnotused, size_t size, comm_err_t er
 
     if (errflag) {
         ErrorState *err;
-        err = errorCon(ERR_WRITE_ERROR, HTTP_BAD_GATEWAY);
+        err = errorCon(ERR_WRITE_ERROR, HTTP_BAD_GATEWAY, httpState->fwd->request);
         err->xerrno = errno;
         httpState->fwd->fail(err);
         comm_close(fd);
@@ -1932,7 +1932,7 @@ HttpStateData::sendRequestEntity(int fd, size_t size, comm_err_t errflag)
 
     if (errflag) {
         ErrorState *err;
-        err = errorCon(ERR_WRITE_ERROR, HTTP_BAD_GATEWAY);
+        err = errorCon(ERR_WRITE_ERROR, HTTP_BAD_GATEWAY, fwd->request);
         err->xerrno = errno;
         fwd->fail(err);
         comm_close(fd);
@@ -1995,9 +1995,8 @@ HttpStateData::icapAclCheckDone(ICAPServiceRep::Pointer service)
          * XXX Maybe instead of an error page we should
          * handle the reply normally (without ICAP).
          */
-        ErrorState *err = errorCon(ERR_ICAP_FAILURE, HTTP_INTERNAL_SERVER_ERROR);
+        ErrorState *err = errorCon(ERR_ICAP_FAILURE, HTTP_INTERNAL_SERVER_ERROR, orig_request);
         err->xerrno = errno;
-        err->request = HTTPMSGLOCK(orig_request);
         errorAppendEntry(entry, err);
         comm_close(fd);
         return;
@@ -2095,8 +2094,7 @@ HttpStateData::abortAdapting()
 
     if (entry->isEmpty()) {
         ErrorState *err;
-        err = errorCon(ERR_ICAP_FAILURE, HTTP_INTERNAL_SERVER_ERROR);
-        err->request = HTTPMSGLOCK((HttpRequest *) request);
+        err = errorCon(ERR_ICAP_FAILURE, HTTP_INTERNAL_SERVER_ERROR, request);
         err->xerrno = errno;
         fwd->fail( err);
         fwd->dontRetry(true);
index 563cdfdbe29776e70621870ba4d4739166e3d3c3..5910426cc6966cceb62fee09c21b896bdb611ec4 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: internal.cc,v 1.42 2006/08/21 00:50:41 robertc Exp $
+ * $Id: internal.cc,v 1.43 2006/08/25 15:22:34 serassio Exp $
  *
  * DEBUG: section 76    Internal Squid Object handling
  * AUTHOR: Duane, Alex, Henrik
@@ -79,8 +79,7 @@ internalStart(HttpRequest * request, StoreEntry * entry)
     } else {
         debugObj(76, 1, "internalStart: unknown request:\n",
                  request, (ObjPackMethod) & httpRequestPack);
-        err = errorCon(ERR_INVALID_REQ, HTTP_NOT_FOUND);
-        err->request = HTTPMSGLOCK(request);
+        err = errorCon(ERR_INVALID_REQ, HTTP_NOT_FOUND, request);
         errorAppendEntry(entry, err);
     }
 }
index d266cad2382624463a607efc456ce2f4c48a5f28..140f729bc9f58efafe65ca6601dfaf977be746bc 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: tunnel.cc,v 1.163 2006/08/21 00:50:41 robertc Exp $
+ * $Id: tunnel.cc,v 1.164 2006/08/25 15:22:34 serassio Exp $
  *
  * DEBUG: section 26    Secure Sockets Layer Proxy
  * AUTHOR: Duane Wessels
@@ -456,7 +456,7 @@ sslConnectTimeout(int fd, void *data)
 
     comm_close(fd);
 
-    err = errorCon(ERR_CONNECT_FAIL, HTTP_SERVICE_UNAVAILABLE);
+    err = errorCon(ERR_CONNECT_FAIL, HTTP_SERVICE_UNAVAILABLE, request);
 
     *sslState->status_ptr = HTTP_SERVICE_UNAVAILABLE;
 
@@ -464,8 +464,6 @@ sslConnectTimeout(int fd, void *data)
 
     err->port = sslState->port;
 
-    err->request = HTTPMSGLOCK(request);
-
     err->callback = sslErrorComplete;
 
     err->callback_data = sslState;
@@ -545,19 +543,17 @@ sslConnectDone(int fdnotused, comm_err_t status, int xerrno, void *data)
 
     if (status == COMM_ERR_DNS) {
         debug(26, 4) ("sslConnect: Unknown host: %s\n", sslState->host);
-        err = errorCon(ERR_DNS_FAIL, HTTP_NOT_FOUND);
+        err = errorCon(ERR_DNS_FAIL, HTTP_NOT_FOUND, request);
         *sslState->status_ptr = HTTP_NOT_FOUND;
-        err->request = HTTPMSGLOCK(request);
         err->dnsserver_msg = xstrdup(dns_error_message);
         err->callback = sslErrorComplete;
         err->callback_data = sslState;
         errorSend(sslState->client.fd(), err);
     } else if (status != COMM_OK) {
-        err = errorCon(ERR_CONNECT_FAIL, HTTP_SERVICE_UNAVAILABLE);
+        err = errorCon(ERR_CONNECT_FAIL, HTTP_SERVICE_UNAVAILABLE, request);
         *sslState->status_ptr = HTTP_SERVICE_UNAVAILABLE;
         err->xerrno = xerrno;
         err->port = sslState->port;
-        err->request = HTTPMSGLOCK(request);
         err->callback = sslErrorComplete;
         err->callback_data = sslState;
         errorSend(sslState->client.fd(), err);
@@ -606,10 +602,8 @@ sslStart(ClientHttpRequest * http, size_t * size_ptr, int *status_ptr)
         answer = ch.fastCheck();
 
         if (answer == 0) {
-            err = errorCon(ERR_FORWARDING_DENIED, HTTP_FORBIDDEN);
+            err = errorCon(ERR_FORWARDING_DENIED, HTTP_FORBIDDEN, request);
             *status_ptr = HTTP_FORBIDDEN;
-            err->request = HTTPMSGLOCK(request);
-            err->src_addr = request->client_addr;
             errorSend(fd, err);
             return;
         }
@@ -630,10 +624,9 @@ sslStart(ClientHttpRequest * http, size_t * size_ptr, int *status_ptr)
 
     if (sock == COMM_ERROR) {
         debug(26, 4) ("sslStart: Failed because we're out of sockets.\n");
-        err = errorCon(ERR_SOCKET_FAILURE, HTTP_INTERNAL_SERVER_ERROR);
+        err = errorCon(ERR_SOCKET_FAILURE, HTTP_INTERNAL_SERVER_ERROR, request);
         *status_ptr = HTTP_INTERNAL_SERVER_ERROR;
         err->xerrno = errno;
-        err->request = HTTPMSGLOCK(request);
         errorSend(fd, err);
         return;
     }
@@ -716,9 +709,8 @@ sslPeerSelectComplete(FwdServer * fs, void *data)
 
     if (fs == NULL) {
         ErrorState *err;
-        err = errorCon(ERR_CANNOT_FORWARD, HTTP_SERVICE_UNAVAILABLE);
+        err = errorCon(ERR_CANNOT_FORWARD, HTTP_SERVICE_UNAVAILABLE, request);
         *sslState->status_ptr = HTTP_SERVICE_UNAVAILABLE;
-        err->request = HTTPMSGLOCK(sslState->request);
         err->callback = sslErrorComplete;
         err->callback_data = sslState;
         errorSend(sslState->client.fd(), err);
index c759440731f1a7185bef63b1802639a50d24c39a..6797d2ae33baa226eff4a9f161cc6a7f8c322068 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: urn.cc,v 1.102 2006/08/21 00:50:42 robertc Exp $
+ * $Id: urn.cc,v 1.103 2006/08/25 15:22:34 serassio Exp $
  *
  * DEBUG: section 52    URN Parsing
  * AUTHOR: Kostas Anagnostakis
@@ -228,9 +228,8 @@ UrnState::setUriResFromRequest(HttpRequest *r)
 
     if (urlres_r == NULL) {
         debug(52, 3) ("urnStart: Bad uri-res URL %s\n", urlres);
-        ErrorState *err = errorCon(ERR_URN_RESOLVE, HTTP_NOT_FOUND);
+        ErrorState *err = errorCon(ERR_URN_RESOLVE, HTTP_NOT_FOUND, r);
         err->url = urlres;
-        err->request = HTTPMSGLOCK(r);
         urlres = NULL;
         errorAppendEntry(entry, err);
         return;
@@ -382,8 +381,7 @@ urnHandleReply(void *data, StoreIOBuffer result)
 
     if (rep->sline.status != HTTP_OK) {
         debug(52, 3) ("urnHandleReply: failed.\n");
-        err = errorCon(ERR_URN_RESOLVE, HTTP_NOT_FOUND);
-        err->request = HTTPMSGLOCK(urnState->request);
+        err = errorCon(ERR_URN_RESOLVE, HTTP_NOT_FOUND, urnState->request);
         err->url = xstrdup(storeUrl(e));
         errorAppendEntry(e, err);
         delete rep;
@@ -404,8 +402,7 @@ urnHandleReply(void *data, StoreIOBuffer result)
 
     if (urls == NULL) {                /* unkown URN error */
         debug(52, 3) ("urnTranslateDone: unknown URN %s\n", storeUrl(e));
-        err = errorCon(ERR_URN_RESOLVE, HTTP_NOT_FOUND);
-        err->request = HTTPMSGLOCK(urnState->request);
+        err = errorCon(ERR_URN_RESOLVE, HTTP_NOT_FOUND, urnState->request);
         err->url = xstrdup(storeUrl(e));
         errorAppendEntry(e, err);
         goto error;
index 4b8656617fb1a185d1a461971a7462c396827d31..9f62c05bbd0df5bd56f0d0023d60db84b7e8d81f 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: wais.cc,v 1.161 2006/08/21 00:50:42 robertc Exp $
+ * $Id: wais.cc,v 1.162 2006/08/25 15:22:34 serassio Exp $
  *
  * DEBUG: section 24    WAIS Relay
  * AUTHOR: Harvest Derived
@@ -93,7 +93,7 @@ waisTimeout(int fd, void *data)
     debug(24, 4) ("waisTimeout: FD %d: '%s'\n", fd, storeUrl(entry));
 
     if (entry->store_status == STORE_PENDING) {
-        waisState->fwd->fail(errorCon(ERR_READ_TIMEOUT, HTTP_GATEWAY_TIMEOUT));
+        waisState->fwd->fail(errorCon(ERR_READ_TIMEOUT, HTTP_GATEWAY_TIMEOUT, waisState->fwd->request));
     }
 
     comm_close(fd);
@@ -164,13 +164,13 @@ waisReadReply(int fd, char *buf, size_t len, comm_err_t flag, int xerrno, void *
             comm_read(fd, waisState->buf, read_sz, waisReadReply, waisState);
         } else {
             ErrorState *err;
-            err = errorCon(ERR_READ_ERROR, HTTP_INTERNAL_SERVER_ERROR);
+            err = errorCon(ERR_READ_ERROR, HTTP_INTERNAL_SERVER_ERROR, waisState->fwd->request);
             err->xerrno = errno;
             waisState->fwd->fail(err);
             comm_close(fd);
         }
     } else if (flag == COMM_OK && len == 0 && !waisState->dataWritten) {
-        waisState->fwd->fail(errorCon(ERR_ZERO_SIZE_OBJECT, HTTP_SERVICE_UNAVAILABLE));
+        waisState->fwd->fail(errorCon(ERR_ZERO_SIZE_OBJECT, HTTP_SERVICE_UNAVAILABLE, waisState->fwd->request));
         comm_close(fd);
     } else if (flag == COMM_OK && len == 0) {
         /* Connection closed; retrieval done. */
@@ -205,7 +205,7 @@ waisSendComplete(int fd, char *bufnotused, size_t size, comm_err_t errflag, void
 
     if (errflag) {
         ErrorState *err;
-        err = errorCon(ERR_WRITE_ERROR, HTTP_SERVICE_UNAVAILABLE);
+        err = errorCon(ERR_WRITE_ERROR, HTTP_SERVICE_UNAVAILABLE, waisState->fwd->request);
         err->xerrno = errno;
         waisState->fwd->fail(err);
         comm_close(fd);
index 51d22232c8a162c3203da59b21335676dfa1b8bc..8e5418bea71f2c321cb98e34dd153eef7dd58b5a 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: whois.cc,v 1.36 2006/08/21 00:50:42 robertc Exp $
+ * $Id: whois.cc,v 1.37 2006/08/25 15:22:34 serassio Exp $
  *
  * DEBUG: section 75    WHOIS protocol
  * AUTHOR: Duane Wessels, Kostas Anagnostakis
@@ -175,7 +175,7 @@ WhoisState::readReply (int fd, char *buf, size_t len, comm_err_t flag, int xerrn
             do_next_read = 1;
         } else {
             ErrorState *err;
-            err = errorCon(ERR_READ_ERROR, HTTP_INTERNAL_SERVER_ERROR);
+            err = errorCon(ERR_READ_ERROR, HTTP_INTERNAL_SERVER_ERROR, fwd->request);
             err->xerrno = errno;
             fwd->fail(err);
             comm_close(fd);