diff -u -r1.1.2.65 icap_respmod.c --- icap_respmod.c 25 May 2006 16:04:55 -0000 1.1.2.65 +++ icap_respmod.c 15 Jun 2006 18:01:52 -0000 @@ -500,6 +500,8 @@ #if SUPPORT_ICAP_204 || ICAP_PREVIEW if (204 == status) { debug(81, 3) ("got 204 status from ICAP server\n"); + icapRespModKeepAliveOrClose(icap,0); + debug(81, 3) ("setting icap->flags.no_content\n"); icap->flags.no_content = 1; /* @@ -511,7 +513,8 @@ icap->respmod.resp_copy.buf, icap->respmod.resp_copy.size); icap->respmod.resp_copy.size = 0; if (icapReadReply2(icap) < 0) - comm_close(fd); + icapStateFree(-1, icap); +// comm_close(fd); /* * XXX ideally want to clean icap->respmod.resp_copy here * XXX ideally want to "close" ICAP server connection here @@ -801,26 +804,29 @@ * transaction. */ static void -icapRespModKeepAliveOrClose(IcapStateData * icap) +icapRespModKeepAliveOrClose(IcapStateData * icap,int free_icap_state) { int fd = icap->icap_fd; if (fd < 0) return; - if (!icap->flags.keep_alive) { - debug(81, 3) ("%s:%d keep_alive not set, closing\n", __FILE__, - __LINE__); - comm_close(fd); - return; - } debug(81, 3) ("%s:%d FD %d looks good, keeping alive\n", __FILE__, __LINE__, fd); commSetDefer(fd, NULL, NULL); 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); icap->icap_fd = -1; - icapStateFree(-1, icap); + if(free_icap_state) + icapStateFree(-1, icap); + if (!icap->flags.keep_alive) { + debug(81, 3) ("%s:%d keep_alive not set, closing\n", __FILE__, + __LINE__); + comm_close(fd); + return; + } + else{ + pconnPush(fd, icap->current_service->hostname, icap->current_service->port); + } } @@ -1042,7 +1048,10 @@ comm_close(fd); } else if (icapPconnTransferDone(fd, icap)) { storeComplete(entry); - icapRespModKeepAliveOrClose(icap); + if(icap->flags.no_content) + icapStateFree(-1, icap); + else + icapRespModKeepAliveOrClose(icap,1); } else if (!icap->flags.no_content) { /* Wait for EOF condition */ commSetSelect(fd, COMM_SELECT_READ, icapReadReply, icap, 0);