From: serassio <> Date: Fri, 25 Aug 2006 21:22:34 +0000 (+0000) Subject: Bug #212: variable %i always 0.0.0.0 X-Git-Tag: SQUID_3_0_PRE5~174 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2cc81f1f75499bfbcef471fbb58f8ef796ad211b;p=thirdparty%2Fsquid.git Bug #212: variable %i always 0.0.0.0 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. --- diff --git a/src/cache_manager.cc b/src/cache_manager.cc index 37d734b23c..fdf9e252c4 100644 --- a/src/cache_manager.cc +++ b/src/cache_manager.cc @@ -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 : "", fd_table[fd].ipaddr, mgr->action); - err->request = HTTPMSGLOCK(request); - rep = errorBuildReply(err); errorStateFree(err); diff --git a/src/client_side_reply.cc b/src/client_side_reply.cc index 78a2be24b2..7d367f9cad 100644 --- a/src/client_side_reply.cc +++ b/src/client_side_reply.cc @@ -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; } diff --git a/src/errorpage.cc b/src/errorpage.cc index c25ddf7ebe..e5997ee9e5 100644 --- a/src/errorpage.cc +++ b/src/errorpage.cc @@ -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; } diff --git a/src/errorpage.h b/src/errorpage.h index 6ec68f5b36..e909925d71 100644 --- a/src/errorpage.h +++ b/src/errorpage.h @@ -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 */ diff --git a/src/forward.cc b/src/forward.cc index da946a40ee..b00cf383bc 100644 --- a/src/forward.cc +++ b/src/forward.cc @@ -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 diff --git a/src/ftp.cc b/src/ftp.cc index 1050b76d93..e1b88f9590 100644 --- a/src/ftp.cc +++ b/src/ftp.cc @@ -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); diff --git a/src/gopher.cc b/src/gopher.cc index f35fcc3ca8..63bb183975 100644 --- a/src/gopher.cc +++ b/src/gopher.cc @@ -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)); diff --git a/src/http.cc b/src/http.cc index beb68e50ef..b882104c27 100644 --- a/src/http.cc +++ b/src/http.cc @@ -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); diff --git a/src/internal.cc b/src/internal.cc index 563cdfdbe2..5910426cc6 100644 --- a/src/internal.cc +++ b/src/internal.cc @@ -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); } } diff --git a/src/tunnel.cc b/src/tunnel.cc index d266cad238..140f729bc9 100644 --- a/src/tunnel.cc +++ b/src/tunnel.cc @@ -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); diff --git a/src/urn.cc b/src/urn.cc index c759440731..6797d2ae33 100644 --- a/src/urn.cc +++ b/src/urn.cc @@ -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; diff --git a/src/wais.cc b/src/wais.cc index 4b8656617f..9f62c05bbd 100644 --- a/src/wais.cc +++ b/src/wais.cc @@ -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); diff --git a/src/whois.cc b/src/whois.cc index 51d22232c8..8e5418bea7 100644 --- a/src/whois.cc +++ b/src/whois.cc @@ -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);