--------------------- PatchSet 7789 Date: 2006/05/17 18:27:45 Author: chtsanti Branch: icap-2_6 Tag: (none) Log: - pconnPop/pconnPush functions take one more argumenti the domain For our case looks safe to pass NULL as domain - Run indent on changed files Members: src/icap_common.c:1.1.14.1->1.1.14.2 src/icap_reqmod.c:1.1.14.1->1.1.14.2 src/icap_respmod.c:1.1.14.1->1.1.14.2 Index: squid/src/icap_common.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Attic/icap_common.c,v retrieving revision 1.1.14.1 retrieving revision 1.1.14.2 diff -u -r1.1.14.1 -r1.1.14.2 --- squid/src/icap_common.c 17 May 2006 17:58:01 -0000 1.1.14.1 +++ squid/src/icap_common.c 17 May 2006 18:27:45 -0000 1.1.14.2 @@ -1,5 +1,5 @@ /* - * $Id: icap_common.c,v 1.1.14.1 2006/05/17 17:58:01 chtsanti Exp $ + * $Id: icap_common.c,v 1.1.14.2 2006/05/17 18:27:45 chtsanti Exp $ * * DEBUG: section 81 Internet Content Adaptation Protocol (ICAP) Client * AUTHOR: Geetha Manjunath, Hewlett Packard Company @@ -204,7 +204,7 @@ { int rc; icap->icap_fd = pconnPop(icap->current_service->hostname, - icap->current_service->port); + icap->current_service->port, NULL); if (icap->icap_fd >= 0) { debug(81, 3) ("icapConnect: reused pconn FD %d\n", icap->icap_fd); fd_note(icap->icap_fd, icap->current_service->uri); @@ -790,28 +790,26 @@ * Builds and adds the X-Server-IP header to an ICAP request headers. */ void -icapAddOriginIP(MemBuf *mb, const char *host) +icapAddOriginIP(MemBuf * mb, const char *host) { - const ipcache_addrs *addrs; - struct in_addr s; + const ipcache_addrs *addrs; + struct in_addr s; - if (host == NULL) { - debug(81, 5)("icapAddOriginIP: NULL host\n"); - return; - } - - addrs = ipcache_gethostbyname(host, IP_LOOKUP_IF_MISS); - if (addrs == NULL) { - /* - * http://www.i-cap.org/spec/draft-stecher-icap-subid-00.txt : - * - * [...] If the meta information for some header is not available, - * the header field MUST be omitted. - */ - debug(81, 5)("icapAddOriginIP: can't tell IP address\n"); - return; - } - - s = addrs->in_addrs[0]; - memBufPrintf(mb, "X-Server-IP: %s\r\n", inet_ntoa(s)); + if (host == NULL) { + debug(81, 5) ("icapAddOriginIP: NULL host\n"); + return; + } + addrs = ipcache_gethostbyname(host, IP_LOOKUP_IF_MISS); + if (addrs == NULL) { + /* + * http://www.i-cap.org/spec/draft-stecher-icap-subid-00.txt : + * + * [...] If the meta information for some header is not available, + * the header field MUST be omitted. + */ + debug(81, 5) ("icapAddOriginIP: can't tell IP address\n"); + return; + } + s = addrs->in_addrs[0]; + memBufPrintf(mb, "X-Server-IP: %s\r\n", inet_ntoa(s)); } Index: squid/src/icap_reqmod.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Attic/icap_reqmod.c,v retrieving revision 1.1.14.1 retrieving revision 1.1.14.2 diff -u -r1.1.14.1 -r1.1.14.2 --- squid/src/icap_reqmod.c 17 May 2006 17:58:01 -0000 1.1.14.1 +++ squid/src/icap_reqmod.c 17 May 2006 18:27:45 -0000 1.1.14.2 @@ -1,6 +1,6 @@ /* - * $Id: icap_reqmod.c,v 1.1.14.1 2006/05/17 17:58:01 chtsanti Exp $ + * $Id: icap_reqmod.c,v 1.1.14.2 2006/05/17 18:27:45 chtsanti Exp $ * * DEBUG: section 81 Internet Content Adaptation Protocol (ICAP) Client * AUTHOR: Geetha Manjunath, Hewlett Packard Company @@ -434,7 +434,7 @@ commSetTimeout(fd, -1, NULL, NULL); commSetSelect(fd, COMM_SELECT_READ, NULL, NULL, 0); comm_remove_close_handler(fd, icapStateFree, icap); - pconnPush(fd, icap->current_service->hostname, icap->current_service->port); + pconnPush(fd, icap->current_service->hostname, icap->current_service->port, NULL); icap->icap_fd = -1; icapStateFree(-1, icap); } @@ -702,7 +702,7 @@ memBufPrintf(&mb, "X-Client-IP: %s\r\n", client_addr); if (service->flags.need_x_server_ip && Config.icapcfg.send_server_ip) - icapAddOriginIP(&mb, icap->request->host); + icapAddOriginIP(&mb, icap->request->host); if ((service->flags.need_x_authenticated_user && Config.icapcfg.send_auth_user) @@ -730,7 +730,7 @@ * structure and request a TCP connection to the server. */ IcapStateData * -icapReqModStart(icap_service *service, const char *uri, request_t * request, +icapReqModStart(icap_service * service, const char *uri, request_t * request, int fd, struct timeval start, struct in_addr log_addr, void *cookie) { IcapStateData *icap = NULL; Index: squid/src/icap_respmod.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Attic/icap_respmod.c,v retrieving revision 1.1.14.1 retrieving revision 1.1.14.2 diff -u -r1.1.14.1 -r1.1.14.2 --- squid/src/icap_respmod.c 17 May 2006 17:58:01 -0000 1.1.14.1 +++ squid/src/icap_respmod.c 17 May 2006 18:27:45 -0000 1.1.14.2 @@ -1,6 +1,6 @@ /* - * $Id: icap_respmod.c,v 1.1.14.1 2006/05/17 17:58:01 chtsanti Exp $ + * $Id: icap_respmod.c,v 1.1.14.2 2006/05/17 18:27:45 chtsanti Exp $ * * DEBUG: section 81 Internet Content Adaptation Protocol (ICAP) Client * AUTHOR: Geetha Manjunath, Hewlett Packard Company @@ -63,9 +63,8 @@ if (service->flags.need_x_client_ip && Config.icapcfg.send_client_ip) { memBufPrintf(mb, "X-Client-IP: %s\r\n", client_addr); } - if (service->flags.need_x_server_ip && Config.icapcfg.send_server_ip) - icapAddOriginIP(mb, icap->request->host); + icapAddOriginIP(mb, icap->request->host); if ((service->flags.need_x_authenticated_user && Config.icapcfg.send_auth_user) @@ -109,7 +108,7 @@ o2 = -1; memBufDefInit(&mb_hdr); httpBuildRequestPrefix(icap->request, icap->request, - icap->respmod.entry, &mb_hdr, icap->http_flags); + icap->respmod.entry, &mb_hdr, icap->http_flags); o3 = mb_hdr.size; } else { @@ -140,9 +139,9 @@ icap->respmod.entry, &mb_hdr, icap->http_flags); o2 = mb_hdr.size; - /* Copy response header - Append to request header mbuffer */ + /* Copy response header - Append to request header mbuffer */ memBufAppend(&mb_hdr, - icap->respmod.req_hdr_copy.buf, icap->respmod.req_hdr_copy.size); + icap->respmod.req_hdr_copy.buf, icap->respmod.req_hdr_copy.size); o3 = mb_hdr.size; } @@ -259,16 +258,15 @@ #endif if (icap->sc == 0) { - // http connection has been closed without sending us anything - if(len == 0 && theEnd == 1) { + // http connection has been closed without sending us anything + if (len == 0 && theEnd == 1) { ErrorState *err; err = errorCon(ERR_INVALID_RESP, HTTP_BAD_GATEWAY); err->request = requestLink(icap->request); errorAppendEntry(icap->respmod.entry, err); comm_close(icap->icap_fd); return; - } - + } /* No data sent yet. Start with headers */ if ((icap->sc = buildRespModHeader(&mb, icap, buf, len, theEnd)) > 0) { buf += icap->sc; @@ -820,7 +818,7 @@ commSetTimeout(fd, -1, NULL, NULL); commSetSelect(fd, COMM_SELECT_READ, NULL, NULL, 0); comm_remove_close_handler(fd, icapStateFree, icap); - pconnPush(fd, icap->current_service->hostname, icap->current_service->port); + pconnPush(fd, icap->current_service->hostname, icap->current_service->port, NULL); icap->icap_fd = -1; icapStateFree(-1, icap); }