--------------------- PatchSet 7177 Date: 2005/11/22 22:41:48 Author: dwsquid Branch: icap-2_5 Tag: (none) Log: ran 'gindent -br -ce -i4 -ci4 -l80 -nlp -npcs -npsl -d0 -sc -di0 -psl' Members: src/HttpRequest.c:1.7.72.6->1.7.72.7 src/cache_cf.c:1.38.6.11.2.20->1.38.6.11.2.21 src/client_db.c:1.6.88.7->1.6.88.8 src/client_side.c:1.47.2.28.2.33->1.47.2.28.2.34 src/http.c:1.17.6.3.6.37->1.17.6.3.6.38 src/icap_common.c:1.1.2.38->1.1.2.39 src/icap_opt.c:1.1.2.16->1.1.2.17 src/icap_reqmod.c:1.1.2.51->1.1.2.52 src/icap_respmod.c:1.1.2.57->1.1.2.58 Index: squid/src/HttpRequest.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/HttpRequest.c,v retrieving revision 1.7.72.6 retrieving revision 1.7.72.7 diff -u -r1.7.72.6 -r1.7.72.7 --- squid/src/HttpRequest.c 19 Sep 2005 17:19:36 -0000 1.7.72.6 +++ squid/src/HttpRequest.c 22 Nov 2005 22:41:48 -0000 1.7.72.7 @@ -1,6 +1,6 @@ /* - * $Id: HttpRequest.c,v 1.7.72.6 2005/09/19 17:19:36 chtsanti Exp $ + * $Id: HttpRequest.c,v 1.7.72.7 2005/11/22 22:41:48 dwsquid Exp $ * * DEBUG: section 73 HTTP Request * AUTHOR: Duane Wessels @@ -193,10 +193,10 @@ request->body_reader = NULL; cbdataUnlock(request->body_reader_data); request->body_reader_data = NULL; - callback(buf, 0, cbdata); /* Signal end of body */ + callback(buf, 0, cbdata); /* Signal end of body */ } } else { - callback(buf, 0, cbdata); /* Signal end of body */ + callback(buf, 0, cbdata); /* Signal end of body */ } } Index: squid/src/cache_cf.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/cache_cf.c,v retrieving revision 1.38.6.11.2.20 retrieving revision 1.38.6.11.2.21 diff -u -r1.38.6.11.2.20 -r1.38.6.11.2.21 --- squid/src/cache_cf.c 24 Oct 2005 17:07:41 -0000 1.38.6.11.2.20 +++ squid/src/cache_cf.c 22 Nov 2005 22:41:48 -0000 1.38.6.11.2.21 @@ -1,6 +1,6 @@ /* - * $Id: cache_cf.c,v 1.38.6.11.2.20 2005/10/24 17:07:41 chtsanti Exp $ + * $Id: cache_cf.c,v 1.38.6.11.2.21 2005/11/22 22:41:48 dwsquid Exp $ * * DEBUG: section 3 Configuration File Parsing * AUTHOR: Harvest Derived @@ -2230,13 +2230,13 @@ parse_string(&A->type_name); parse_ushort(&A->bypass); parse_string(&A->uri); - while((token=strtok(NULL,w_space))){ - if (strcasecmp(token,"no-keep-alive") == 0) { - A->keep_alive=0; - } else { - debug(3, 0) ("parse_peer: token='%s'\n", token); - self_destruct(); - } + while ((token = strtok(NULL, w_space))) { + if (strcasecmp(token, "no-keep-alive") == 0) { + A->keep_alive = 0; + } else { + debug(3, 0) ("parse_peer: token='%s'\n", token); + self_destruct(); + } } debug(3, 5) ("parse_icap_service_type (line %d): %s %s %d %s\n", config_lineno, A->name, A->type_name, A->bypass, A->name); if (icap_service_process(A)) { @@ -2265,10 +2265,10 @@ while (current_node) { storeAppendPrintf(e, "%s %s %s %d %s", name, current_node->name, current_node->type_name, current_node->bypass, current_node->uri); - if(current_node->keep_alive == 0){ - storeAppendPrintf(e," no-keep-alive"); + if (current_node->keep_alive == 0) { + storeAppendPrintf(e, " no-keep-alive"); } - storeAppendPrintf(e,"\n"); + storeAppendPrintf(e, "\n"); current_node = current_node->next; } @@ -2295,7 +2295,7 @@ char *start, *end, *tempEnd; char *tailp; unsigned int len; - int port_in_uri, resource_in_uri=0; + int port_in_uri, resource_in_uri = 0; s->type = icapServiceToType(s->type_name); if (s->type >= ICAP_SERVICE_MAX) { debug(3, 0) ("icap_service_process (line %d): wrong service type %s\n", config_lineno, s->type_name); @@ -2344,7 +2344,6 @@ if (end == '\0') { end = tempEnd; } - len = end - start; s->hostname = xstrndup(start, len + 1); s->hostname[len] = 0; @@ -2354,9 +2353,9 @@ if (port_in_uri) { start++; /* skip ':' */ if (resource_in_uri) - end = strchr(start, '/'); + end = strchr(start, '/'); else - end = strchr(start, '\0'); + end = strchr(start, '\0'); s->port = strtoul(start, &tailp, 0) % 65536; if (tailp != end) { debug(3, 0) ("icap_service_process (line %d): wrong service uri (port could not be parsed): %s\n", config_lineno, s->uri); @@ -2378,18 +2377,17 @@ } if (resource_in_uri) { - start++; /* skip '/' */ - /* the rest is resource name */ - end = strchr(start, '\0'); - len = end - start; - if (len > 1024) { + start++; /* skip '/' */ + /* the rest is resource name */ + end = strchr(start, '\0'); + len = end - start; + if (len > 1024) { debug(3, 0) ("icap_service_process (line %d): long resource name (>1024), probably wrong\n", config_lineno); - } - s->resource = xstrndup(start, len + 1); - s->resource[len] = 0; + } + s->resource = xstrndup(start, len + 1); + s->resource[len] = 0; debug(3, 5) ("icap_service_process (line %d): service=%s\n", config_lineno, s->resource); } - /* check bypass */ if ((s->bypass != 0) && (s->bypass != 1)) { debug(3, 0) ("icap_service_process (line %d): invalid bypass value\n", config_lineno); @@ -2407,7 +2405,7 @@ s->type = ICAP_SERVICE_MAX; /* means undefined */ s->preview = Config.icapcfg.preview_size; s->opt = 0; - s->keep_alive=1; + s->keep_alive = 1; s->istag = StringNull; s->transfer_preview = StringNull; s->transfer_ignore = StringNull; @@ -2450,23 +2448,23 @@ */ static void -icap_service_list_add(icap_service_list ** isl, char * service_name) +icap_service_list_add(icap_service_list ** isl, char *service_name) { icap_service_list **iter; icap_service_list *new; - icap_service *gbl_service; - int i; - int max_services; + icap_service *gbl_service; + int i; + int max_services; new = memAllocate(MEM_ICAP_SERVICE_LIST); /* Found all services with that name, and add to the array */ - max_services = sizeof(new->services)/sizeof(icap_service *); + max_services = sizeof(new->services) / sizeof(icap_service *); gbl_service = Config.icapcfg.service_head; - i=0; - while(gbl_service && i < max_services) { - if (!strcmp(service_name, gbl_service->name)) - new->services[i++] = gbl_service; - gbl_service = gbl_service->next; + i = 0; + while (gbl_service && i < max_services) { + if (!strcmp(service_name, gbl_service->name)) + new->services[i++] = gbl_service; + gbl_service = gbl_service->next; } new->nservices = i; @@ -2757,9 +2755,9 @@ printf(" %s: \n", c_iter->name); printf(" services = \n"); for (isl_iter = c_iter->isl; isl_iter; isl_iter = isl_iter->next) { - int i; - for (i = 0; i < isl_iter->nservices; i++) - printf(" %s\n", isl_iter->services[i]->name); + int i; + for (i = 0; i < isl_iter->nservices; i++) + printf(" %s\n", isl_iter->services[i]->name); } } debug(3, 0) ("IcapConfig: access =\n"); Index: squid/src/client_db.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/client_db.c,v retrieving revision 1.6.88.7 retrieving revision 1.6.88.8 diff -u -r1.6.88.7 -r1.6.88.8 --- squid/src/client_db.c 12 Sep 2005 18:34:40 -0000 1.6.88.7 +++ squid/src/client_db.c 22 Nov 2005 22:41:48 -0000 1.6.88.8 @@ -1,6 +1,6 @@ /* - * $Id: client_db.c,v 1.6.88.7 2005/09/12 18:34:40 chtsanti Exp $ + * $Id: client_db.c,v 1.6.88.8 2005/11/22 22:41:48 dwsquid Exp $ * * DEBUG: section 0 Client Database * AUTHOR: Duane Wessels @@ -60,7 +60,7 @@ if ((statCounter.client_http.clients > max_clients) && !cleanup_running && cleanup_scheduled < 2) { cleanup_scheduled++; eventAdd("client_db garbage collector", clientdbScheduledGC, NULL, 90, 0); - } + } return c; } Index: squid/src/client_side.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/client_side.c,v retrieving revision 1.47.2.28.2.33 retrieving revision 1.47.2.28.2.34 diff -u -r1.47.2.28.2.33 -r1.47.2.28.2.34 --- squid/src/client_side.c 22 Nov 2005 22:36:51 -0000 1.47.2.28.2.33 +++ squid/src/client_side.c 22 Nov 2005 22:41:48 -0000 1.47.2.28.2.34 @@ -1,6 +1,6 @@ /* - * $Id: client_side.c,v 1.47.2.28.2.33 2005/11/22 22:36:51 dwsquid Exp $ + * $Id: client_side.c,v 1.47.2.28.2.34 2005/11/22 22:41:48 dwsquid Exp $ * * DEBUG: section 33 Client-side Routines * AUTHOR: Duane Wessels @@ -852,7 +852,7 @@ MemObject *mem = NULL; debug(33, 3) ("httpRequestFree: %s\n", storeUrl(http->entry)); if (!clientCheckTransferDone(http)) { - requestAbortBody(request); /* abort request body transter */ + requestAbortBody(request); /* abort request body transter */ /* HN: This looks a bit odd.. why should client_side care about * the ICP selection status? */ @@ -940,13 +940,13 @@ dlinkDelete(&http->active, &ClientActiveRequests); #if HS_FEAT_ICAP /*In the case that the upload of data breaks, we need this code here .... */ - if (NULL != http->icap_reqmod){ - if(cbdataValid(http->icap_reqmod)) - if (http->icap_reqmod->icap_fd > -1){ + if (NULL != http->icap_reqmod) { + if (cbdataValid(http->icap_reqmod)) + if (http->icap_reqmod->icap_fd > -1) { comm_close(http->icap_reqmod->icap_fd); - } + } cbdataUnlock(http->icap_reqmod); - http->icap_reqmod=NULL; + http->icap_reqmod = NULL; } #endif cbdataFree(http); @@ -977,10 +977,10 @@ safe_free(connState->in.buf); /* XXX account connState->in.buf */ if (-1 == connState->nrequests) - /* this is a faked-up connState for ICAP */ - (void) 0; - else - pconnHistCount(0, connState->nrequests); + /* this is a faked-up connState for ICAP */ + (void) 0; + else + pconnHistCount(0, connState->nrequests); cbdataFree(connState); #ifdef _SQUID_LINUX_ /* prevent those nasty RST packets */ @@ -3392,10 +3392,10 @@ /* Remove request link if this is the last part of the body, as * clientReadRequest automatically continues to process next request */ if (conn->body.size_left <= 0 && request != NULL) { - request->body_reader = NULL; - if (request->body_reader_data) + request->body_reader = NULL; + if (request->body_reader_data) cbdataUnlock(request->body_reader_data); - request->body_reader_data = NULL; + request->body_reader_data = NULL; } /* Remove clientReadBody arguments (the call is completed) */ conn->body.request = NULL; Index: squid/src/http.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/http.c,v retrieving revision 1.17.6.3.6.37 retrieving revision 1.17.6.3.6.38 diff -u -r1.17.6.3.6.37 -r1.17.6.3.6.38 --- squid/src/http.c 24 Oct 2005 17:07:42 -0000 1.17.6.3.6.37 +++ squid/src/http.c 22 Nov 2005 22:41:48 -0000 1.17.6.3.6.38 @@ -1,6 +1,6 @@ /* - * $Id: http.c,v 1.17.6.3.6.37 2005/10/24 17:07:42 chtsanti Exp $ + * $Id: http.c,v 1.17.6.3.6.38 2005/11/22 22:41:48 dwsquid Exp $ * * DEBUG: section 11 Hypertext Transfer Protocol (HTTP) * AUTHOR: Harvest Derived @@ -544,12 +544,11 @@ clen = httpReplyBodySize(httpState->request->method, reply); #ifdef HS_FEAT_ICAP if (httpState->icap_writer) { - content_bytes_read = httpState->icap_writer->fake_content_length; - debug(11, 3) ("using fake conten length %" PRINTF_OFF_T "\n", content_bytes_read); - } - else + content_bytes_read = httpState->icap_writer->fake_content_length; + debug(11, 3) ("using fake conten length %" PRINTF_OFF_T "\n", content_bytes_read); + } else #endif - content_bytes_read = mem->inmem_hi; + content_bytes_read = mem->inmem_hi; /* If the body size is unknown we must wait for EOF */ if (clen < 0) return 0; @@ -586,15 +585,14 @@ #if HS_FEAT_ICAP if (httpState->icap_writer) { - if (!httpState->icap_writer->respmod.entry) { - debug(11, 3) ("httpReadReply: FD: %d: icap respmod aborded!\n", fd); - comm_close(fd); - return; - } - /*The folowing entry can not be marked as aborted. - The StoreEntry icap_writer->respmod.entry used when the icap_write used......*/ - } - else + if (!httpState->icap_writer->respmod.entry) { + debug(11, 3) ("httpReadReply: FD: %d: icap respmod aborded!\n", fd); + comm_close(fd); + return; + } + /*The folowing entry can not be marked as aborted. + * The StoreEntry icap_writer->respmod.entry used when the icap_write used...... */ + } else #endif if (EBIT_TEST(entry->flags, ENTRY_ABORTED)) { comm_close(fd); @@ -610,28 +608,27 @@ #if HS_FEAT_ICAP if (httpState->icap_writer) { - IcapStateData * icap = httpState->icap_writer; - /* - * Ok we have a received a response from the web server, so try to - * connect the icap server if it's the first attemps. If we try - * to connect to the icap server, defer this request (do not read - * the buffer), and defer until icapConnectOver() is not called. - */ - if (icap->flags.connect_requested == 0) { - debug(81, 2) ("icapSendRespMod: Create a new connection to icap server\n"); - if (!icapConnect(icap, icapConnectOver)) - { - debug(81, 2) ("icapSendRespMod: Something strange while creating a socket to icap server\n"); - commSetSelect(fd, COMM_SELECT_READ, httpReadReply, httpState, 0); - return; - } - debug(81, 2) ("icapSendRespMod: new connection to icap server (using FD=%d)\n",icap->icap_fd); - icap->flags.connect_requested = 1; - /* Wait for more data or EOF condition */ - commSetTimeout(fd, httpState->flags.keepalive_broken?10:Config.Timeout.read, NULL, NULL); - commSetSelect(fd, COMM_SELECT_READ, httpReadReply, httpState, 0); - return; - } + IcapStateData *icap = httpState->icap_writer; + /* + * Ok we have a received a response from the web server, so try to + * connect the icap server if it's the first attemps. If we try + * to connect to the icap server, defer this request (do not read + * the buffer), and defer until icapConnectOver() is not called. + */ + if (icap->flags.connect_requested == 0) { + debug(81, 2) ("icapSendRespMod: Create a new connection to icap server\n"); + if (!icapConnect(icap, icapConnectOver)) { + debug(81, 2) ("icapSendRespMod: Something strange while creating a socket to icap server\n"); + commSetSelect(fd, COMM_SELECT_READ, httpReadReply, httpState, 0); + return; + } + debug(81, 2) ("icapSendRespMod: new connection to icap server (using FD=%d)\n", icap->icap_fd); + icap->flags.connect_requested = 1; + /* Wait for more data or EOF condition */ + commSetTimeout(fd, httpState->flags.keepalive_broken ? 10 : Config.Timeout.read, NULL, NULL); + commSetSelect(fd, COMM_SELECT_READ, httpReadReply, httpState, 0); + return; + } } #endif @@ -687,10 +684,10 @@ } else if (len == 0) { /* Connection closed; retrieval done. */ httpState->eof = 1; -#ifdef HS_FEAT_ICAP - if(httpState->icap_writer && cbdataValid(httpState->icap_writer)) { - debug(81, 3) ("httpReadReply: EOF for ICAP writer\n"); - icapSendRespMod(httpState->icap_writer, buf, len, 1); +#ifdef HS_FEAT_ICAP + if (httpState->icap_writer && cbdataValid(httpState->icap_writer)) { + debug(81, 3) ("httpReadReply: EOF for ICAP writer\n"); + icapSendRespMod(httpState->icap_writer, buf, len, 1); } #endif if (httpState->reply_hdr_state < 2) @@ -746,13 +743,13 @@ } } #ifdef HS_FEAT_ICAP - if (httpState->icap_writer){ + if (httpState->icap_writer) { debug(81, 5) ("calling icapSendRespMod from %s:%d\n", __FILE__, __LINE__); if (cbdataValid(httpState->icap_writer)) { icapSendRespMod(httpState->icap_writer, buf, len, 0); httpState->icap_writer->fake_content_length += len; } - }else + } else #endif storeAppend(entry, buf, len); @@ -760,13 +757,12 @@ debug(11, 5) ("httpReadReply: after storeAppend FD %d read %d\n", fd, len); #if HS_FEAT_ICAP if (httpState->icap_writer) { - if (!httpState->icap_writer->respmod.entry) { - debug(11, 3) ("httpReadReply: FD: %d: icap respmod aborded!\n", fd); - comm_close(fd); - return; - } - } - else + if (!httpState->icap_writer->respmod.entry) { + debug(11, 3) ("httpReadReply: FD: %d: icap respmod aborded!\n", fd); + comm_close(fd); + return; + } + } else #endif if (EBIT_TEST(entry->flags, ENTRY_ABORTED)) { /* @@ -816,18 +812,18 @@ storeUrl(entry)); #ifdef HS_FEAT_ICAP if (httpState->icap_writer) { - debug(81, 5) ("calling icapSendRespMod from %s:%d\n", __FILE__, __LINE__); - icapSendRespMod(httpState->icap_writer, buf, len, 0); - httpState->icap_writer->fake_content_length += len; - }else + debug(81, 5) ("calling icapSendRespMod from %s:%d\n", __FILE__, __LINE__); + icapSendRespMod(httpState->icap_writer, buf, len, 0); + httpState->icap_writer->fake_content_length += len; + } else #endif - storeAppend(entry, buf, len); + storeAppend(entry, buf, len); keep_alive = 0; } } #ifdef HS_FEAT_ICAP - if (httpState->icap_writer) - icapSendRespMod(httpState->icap_writer, NULL, 0, 1); + if (httpState->icap_writer) + icapSendRespMod(httpState->icap_writer, NULL, 0, 1); #endif if (keep_alive) { /* yes we have to clear all these! */ @@ -868,8 +864,8 @@ RequestMethodStr[httpState->orig_request->method], storeUrl(entry)); #ifdef HS_FEAT_ICAP - if (httpState->icap_writer) - icapSendRespMod(httpState->icap_writer, NULL, 0, 1); + if (httpState->icap_writer) + icapSendRespMod(httpState->icap_writer, NULL, 0, 1); #endif fwdComplete(httpState->fwd); comm_close(fd); @@ -896,7 +892,7 @@ debug(11, 5) ("httpReadReplyWaitForIcap: FD %d, connect_requested=%d\n", fd, httpState->icap_writer->flags.connect_requested); if (!httpState->icap_writer->flags.connect_requested) - return 0; + return 0; debug(11, 5) ("httpReadReplyWaitForIcap: FD %d, connect_pending=%d\n", fd, httpState->icap_writer->flags.connect_pending); if (httpState->icap_writer->flags.connect_pending) @@ -1012,7 +1008,7 @@ commSetDefer(httpState->fd, httpReadReplyWaitForIcap, httpState); } else #endif - commSetDefer(httpState->fd, fwdCheckDeferRead, entry); + commSetDefer(httpState->fd, fwdCheckDeferRead, entry); } httpState->flags.request_sent = 1; } Index: squid/src/icap_common.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Attic/icap_common.c,v retrieving revision 1.1.2.38 retrieving revision 1.1.2.39 diff -u -r1.1.2.38 -r1.1.2.39 --- squid/src/icap_common.c 16 May 2005 20:52:41 -0000 1.1.2.38 +++ squid/src/icap_common.c 22 Nov 2005 22:41:48 -0000 1.1.2.39 @@ -1,5 +1,5 @@ /* - * $Id: icap_common.c,v 1.1.2.38 2005/05/16 20:52:41 hno Exp $ + * $Id: icap_common.c,v 1.1.2.39 2005/11/22 22:41:48 dwsquid Exp $ * * DEBUG: section 81 Internet Content Adaptation Protocol (ICAP) Client * AUTHOR: Geetha Manjunath, Hewlett Packard Company @@ -524,10 +524,10 @@ strncpy(t, s, e - s); *(t + (e - s)) = '\0'; for (q = strtok(t, ","); q; q = strtok(NULL, ",")) { - if (0 == strcasecmp(q, "close")){ - xfree(t); + if (0 == strcasecmp(q, "close")) { + xfree(t); return 1; - } + } } xfree(t); return 0; Index: squid/src/icap_opt.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Attic/icap_opt.c,v retrieving revision 1.1.2.16 retrieving revision 1.1.2.17 diff -u -r1.1.2.16 -r1.1.2.17 --- squid/src/icap_opt.c 2 Nov 2005 18:21:26 -0000 1.1.2.16 +++ squid/src/icap_opt.c 22 Nov 2005 22:41:48 -0000 1.1.2.17 @@ -1,6 +1,6 @@ /* - * $Id: icap_opt.c,v 1.1.2.16 2005/11/02 18:21:26 chtsanti Exp $ + * $Id: icap_opt.c,v 1.1.2.17 2005/11/22 22:41:48 dwsquid Exp $ * * DEBUG: section 81 Internet Content Adaptation Protocol (ICAP) Client OPTIONS * AUTHOR: Ralf Horstmann @@ -296,8 +296,7 @@ if (!icapOptParseReply(s, i)) { debug(81, 3) ("icapOptReadReply: OPTIONS request not successful. scheduling again in %d seconds\n", Config.icapcfg.check_interval); s->unreachable = 1; - } - else + } else s->unreachable = 0; if (s->options_ttl <= 0) @@ -435,11 +434,11 @@ if (strstr(value_start, "X-Client-IP")) { debug(81, 5) ("icapOptParseEntry: X-Include: found X-Client-IP\n"); s->flags.need_x_client_ip = 1; - } + } if (strstr(value_start, "X-Authenticated-User")) { debug(81, 5) ("icapOptParseEntry: X-Include: found X-Authenticated-User\n"); s->flags.need_x_authenticated_user = 1; - } + } } else { debug(81, 5) ("icapOptParseEntry: unknown options header\n"); } @@ -459,8 +458,8 @@ const char *blk_end; if ((status = - icapParseStatusLine(i->buf, i->offset, - &version_major, &version_minor, &str_status)) < 0) { + icapParseStatusLine(i->buf, i->offset, + &version_major, &version_minor, &str_status)) < 0) { debug(81, 2) ("icapOptParseReply: bad status line <%s>\n", i->buf); return 0; } Index: squid/src/icap_reqmod.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Attic/icap_reqmod.c,v retrieving revision 1.1.2.51 retrieving revision 1.1.2.52 diff -u -r1.1.2.51 -r1.1.2.52 --- squid/src/icap_reqmod.c 22 Nov 2005 22:36:51 -0000 1.1.2.51 +++ squid/src/icap_reqmod.c 22 Nov 2005 22:41:48 -0000 1.1.2.52 @@ -1,6 +1,6 @@ /* - * $Id: icap_reqmod.c,v 1.1.2.51 2005/11/22 22:36:51 dwsquid Exp $ + * $Id: icap_reqmod.c,v 1.1.2.52 2005/11/22 22:41:48 dwsquid Exp $ * * DEBUG: section 81 Internet Content Adaptation Protocol (ICAP) Client * AUTHOR: Geetha Manjunath, Hewlett Packard Company @@ -109,7 +109,7 @@ http->request = requestLink(request ? request : icap->request); http->flags.did_icap_reqmod = 1; http->start = icap->reqmod.start; -#ifdef ICAP_PROXY_KEEP_ALIVE +#ifdef ICAP_PROXY_KEEP_ALIVE /* * Here it is possible becouse we are using as client_cookie the original http->conn * if we will keep this code we must declare an icap->conn field........ @@ -119,20 +119,20 @@ * OK,all this code is a hack and possibly must not exists in cvs ...... */ - http->conn=icap->reqmod.client_cookie; - assert(http->conn->chr->next==NULL); + http->conn = icap->reqmod.client_cookie; + assert(http->conn->chr->next == NULL); { ConnStateData *dummyconn; dummyconn = cbdataAlloc(ConnStateData); dummyconn->fd = icap->reqmod.client_fd; - dummyconn->chr=http->conn->chr; - dummyconn->chr->conn=dummyconn; - dummyconn->nrequests = -1; /* hack to avoid counting in pconn usage */ + dummyconn->chr = http->conn->chr; + dummyconn->chr->conn = dummyconn; + dummyconn->nrequests = -1; /* hack to avoid counting in pconn usage */ comm_add_close_handler(dummyconn->fd, connStateFree, dummyconn); } - - http->conn->chr=http; - + + http->conn->chr = http; + #else http->conn = cbdataAlloc(ConnStateData); http->conn->fd = icap->reqmod.client_fd; @@ -140,7 +140,7 @@ http->conn->in.buf = NULL; http->conn->log_addr = icap->reqmod.log_addr; http->conn->chr = http; - http->conn->nrequests = -1; /* hack to avoid counting in pconn usage */ + http->conn->nrequests = -1; /* hack to avoid counting in pconn usage */ comm_add_close_handler(http->conn->fd, connStateFree, http->conn); #endif http->icap_reqmod = NULL; @@ -190,10 +190,10 @@ if (request->content_length > 0) { debug(81, 5) ("handing request bodies in ICAP REQMOD\n"); if (request->body_reader_data) - cbdataUnlock(request->body_reader_data); + cbdataUnlock(request->body_reader_data); request->body_reader = icapReqModBodyReader; request->body_reader_data = icap; /* XXX cbdataLock? */ - cbdataLock(icap); /*Yes sure .....*/ + cbdataLock(icap); /*Yes sure ..... */ memBufDefInit(&icap->reqmod.http_entity.buf); } if (clientCachable(http)) @@ -695,11 +695,10 @@ || service->flags.need_x_authenticated_user) && (icap->request->auth_user_request != NULL)) icapAddAuthUserHeader(&mb, icap->request->auth_user_request); - if(service->keep_alive){ + if (service->keep_alive) { icap->flags.keep_alive = 1; - } - else{ - icap->flags.keep_alive=0; + } else { + icap->flags.keep_alive = 0; memBufAppend(&mb, "Connection: close\r\n", 19); } memBufAppend(&mb, crlf, 2); Index: squid/src/icap_respmod.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Attic/icap_respmod.c,v retrieving revision 1.1.2.57 retrieving revision 1.1.2.58 diff -u -r1.1.2.57 -r1.1.2.58 --- squid/src/icap_respmod.c 12 Sep 2005 17:15:35 -0000 1.1.2.57 +++ squid/src/icap_respmod.c 22 Nov 2005 22:41:48 -0000 1.1.2.58 @@ -1,6 +1,6 @@ /* - * $Id: icap_respmod.c,v 1.1.2.57 2005/09/12 17:15:35 chtsanti Exp $ + * $Id: icap_respmod.c,v 1.1.2.58 2005/11/22 22:41:48 dwsquid Exp $ * * DEBUG: section 81 Internet Content Adaptation Protocol (ICAP) Client * AUTHOR: Geetha Manjunath, Hewlett Packard Company @@ -83,8 +83,8 @@ { MemBuf mb_hdr; char *client_addr; - int o2=0; - int o3=0; + int o2 = 0; + int o3 = 0; int hlen; int consumed; icap_service *service; @@ -101,17 +101,16 @@ *Possible we can consider that we did not have http responce headers *(maybe HTTP 0.9 protocol), lets returning -1... */ - consumed=-1; - o2=-1; + consumed = -1; + o2 = -1; memBufDefInit(&mb_hdr); - } - else{ + } else { - hlen = headersEnd(icap->respmod.req_hdr_copy.buf, - icap->respmod.req_hdr_copy.size); - debug(81, 3) ("buildRespModHeader: headersEnd = %d(%s)\n", hlen,buf); - if (0 == hlen) - return 0; + hlen = headersEnd(icap->respmod.req_hdr_copy.buf, + icap->respmod.req_hdr_copy.size); + debug(81, 3) ("buildRespModHeader: headersEnd = %d(%s)\n", hlen, buf); + if (0 == hlen) + return 0; /* * calc how many bytes from this 'buf' went towards the @@ -126,12 +125,12 @@ * this 'if' statement might be unncessary? */ if (hlen < icap->respmod.req_hdr_copy.size) - icap->respmod.req_hdr_copy.size = hlen; - + icap->respmod.req_hdr_copy.size = hlen; + /* Copy request header */ memBufDefInit(&mb_hdr); httpBuildRequestPrefix(icap->request, icap->request, - icap->respmod.entry, &mb_hdr, icap->http_flags); + icap->respmod.entry, &mb_hdr, icap->http_flags); o2 = mb_hdr.size; } @@ -158,11 +157,10 @@ memBufPrintf(mb, "Preview: %d\r\n", icap->preview_size); icap->flags.preview_done = 0; } - if(service->keep_alive){ + if (service->keep_alive) { icap->flags.keep_alive = 1; memBufAppend(mb, "Connection: keep-alive\r\n", 24); - } - else{ + } else { icap->flags.keep_alive = 0; memBufAppend(mb, "Connection: close\r\n", 19); } @@ -247,32 +245,31 @@ */ if (len && icap->flags.copy_response) { - if (memBufIsNull(&icap->respmod.resp_copy)) - memBufDefInit(&icap->respmod.resp_copy); - memBufAppend(&icap->respmod.resp_copy, buf, len); + if (memBufIsNull(&icap->respmod.resp_copy)) + memBufDefInit(&icap->respmod.resp_copy); + memBufAppend(&icap->respmod.resp_copy, buf, len); } - #endif if (icap->sc == 0) { /* No data sent yet. Start with headers */ - if((icap->sc = buildRespModHeader(&mb, icap, buf, len, theEnd))>0){ - buf += icap->sc; - len -= icap->sc; - } - /* - * Then we do not have http responce headers. All data (previous and those in buf) - * now are exist to icap->respmod.req_hdr_copy. Lets get them back....... - */ - if(icap->sc <0){ - memBufAppend(&icap->respmod.buffer, - icap->respmod.req_hdr_copy.buf, - icap->respmod.req_hdr_copy.size); - icap->sc=icap->respmod.req_hdr_copy.size; - icap->respmod.req_hdr_copy.size=0; - buf=NULL; - len=0; - } + if ((icap->sc = buildRespModHeader(&mb, icap, buf, len, theEnd)) > 0) { + buf += icap->sc; + len -= icap->sc; + } + /* + * Then we do not have http responce headers. All data (previous and those in buf) + * now are exist to icap->respmod.req_hdr_copy. Lets get them back....... + */ + if (icap->sc < 0) { + memBufAppend(&icap->respmod.buffer, + icap->respmod.req_hdr_copy.buf, + icap->respmod.req_hdr_copy.size); + icap->sc = icap->respmod.req_hdr_copy.size; + icap->respmod.req_hdr_copy.size = 0; + buf = NULL; + len = 0; + } } if (0 == icap->sc) { /* check again; bail if we're not ready to send ICAP/HTTP hdrs */ @@ -471,9 +468,9 @@ if (!memBufIsNull(&icap->icap_hdr)) memBufReset(&icap->icap_hdr); - /*We do n't need it any more .......*/ + /*We do n't need it any more ....... */ if (!memBufIsNull(&icap->respmod.resp_copy)) - memBufClean(&icap->respmod.resp_copy); + memBufClean(&icap->respmod.resp_copy); return; } @@ -506,7 +503,7 @@ * OK do it.... */ if (!memBufIsNull(&icap->respmod.resp_copy)) - memBufClean(&icap->respmod.resp_copy); + memBufClean(&icap->respmod.resp_copy); return; } #endif @@ -610,7 +607,7 @@ return; } if (EBIT_TEST(icap->respmod.entry->flags, ENTRY_ABORTED)) { - debug(81, 3) ("icapSendRespModDone: Entry Aborded\n"); + debug(81, 3) ("icapSendRespModDone: Entry Aborded\n"); comm_close(fd); return; } @@ -741,14 +738,14 @@ #ifdef SUPPORT_ICAP_204 icap->flags.copy_response = 1; #elif ICAP_PREVIEW - if(preview_size < 0 || !Config.icapcfg.preview_enable) - icap->flags.copy_response = 0; + if (preview_size < 0 || !Config.icapcfg.preview_enable) + icap->flags.copy_response = 0; else - icap->flags.copy_response = 1; + icap->flags.copy_response = 1; #else icap->flags.copy_response = 0; #endif - + statCounter.icap.all.requests++; debug(81, 3) ("icapRespModStart: returning %p\n", icap); return icap; @@ -841,7 +838,6 @@ debug(81, 5) ("icapPconnTransferDone: got zero end chunk\n"); return 1; } - debug(81, 5) ("icapPconnTransferDone: didnt get zero end chunk yet\n"); //AI: change with second top condition return 0; @@ -854,9 +850,9 @@ return (icap->enc.res_body - icap->enc.res_hdr); if (icap->enc.null_body > -1 && icap->enc.res_hdr > -1) return icap->enc.null_body - icap->enc.res_hdr; - /*The case we did not get res_hdr .....*/ - if(icap->enc.res_body > -1 ) - return icap->enc.res_body; + /*The case we did not get res_hdr ..... */ + if (icap->enc.res_body > -1) + return icap->enc.res_body; if (icap->enc.null_body > -1) return icap->enc.null_body; return -1; @@ -964,15 +960,15 @@ */ debug(81, 1) ("WARNING: untested code at %s:%d\n", __FILE__, __LINE__); - if(icap->respmod.req_hdr_copy.size){/*For HTTP 0.9 we do not have headers*/ - storeAppend(entry, - icap->respmod.req_hdr_copy.buf, - icap->respmod.req_hdr_copy.size); + if (icap->respmod.req_hdr_copy.size) { /*For HTTP 0.9 we do not have headers */ + storeAppend(entry, + icap->respmod.req_hdr_copy.buf, + icap->respmod.req_hdr_copy.size); } icapProcessHttpReplyHeader(icap, icap->chunk_buf.buf, - icap->chunk_buf.size); + icap->chunk_buf.size); assert(icapHttpReplyHdrState(icap) == 2); - icap->chunk_size = 0;/*we are ready to read chunks of data now....*/ + icap->chunk_size = 0; /*we are ready to read chunks of data now.... */ } else if (needed) { icapProcessHttpReplyHeader(icap, icap->chunk_buf.buf, icap->chunk_buf.size); @@ -991,8 +987,8 @@ * the partial reply buffered in 'chunk_buf' and wait * for more. */ - debug(81,3)("We don't have full Http headers.Schedule a new read\n"); - commSetSelect(icap->icap_fd, COMM_SELECT_READ, icapReadReply, icap, 0); + debug(81, 3) ("We don't have full Http headers.Schedule a new read\n"); + commSetSelect(icap->icap_fd, COMM_SELECT_READ, icapReadReply, icap, 0); } } icap->http_header_bytes_read_so_far = so_far;