<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple style='word-wrap:break-word'><div class=WordSection1><p class=MsoNormal>Hey Alexey,<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>What version of Squid are you using?<o:p></o:p></p><p class=MsoNormal>Can you provide a setup example for re-production?<o:p></o:p></p><p class=MsoNormal>I can write the relevant ICAP service however I am missing pcap file to understand the ICAP sessions.<o:p></o:p></p><p class=MsoNormal>If you can supply couple(2-3 or more) ICAP connections pcap I can try to see what happens in the connection level.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>From my experience there is much differences between holding the ICAP session open or closed after once request.<o:p></o:p></p><p class=MsoNormal>The reason for this is that like HTTP/1.0 ICAP is a “blocking”(don’t remember the exact word, Alex might remember).<o:p></o:p></p><p class=MsoNormal>There for if the proxy has 800 requests per seconds it’s better for the setup to open new connection per request to match the load.<o:p></o:p></p><p class=MsoNormal>It will const memory and CPU in the short term but in the long term the clients requests will bock less and..<o:p></o:p></p><p class=MsoNormal>It will probably consume less then the ICAP connections memory leak.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Waiting,<o:p></o:p></p><p class=MsoNormal>Eliezer<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>----<o:p></o:p></p><p class=MsoNormal>Eliezer Croitoru<o:p></o:p></p><p class=MsoNormal>Tech Support<o:p></o:p></p><p class=MsoNormal>Mobile: +972-5-28704261<o:p></o:p></p><p class=MsoNormal>Email: <a href="mailto:ngtech1ltd@gmail.com">ngtech1ltd@gmail.com</a><o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><div style='border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in'><p class=MsoNormal><b>From:</b> squid-dev <squid-dev-bounces@lists.squid-cache.org> <b>On Behalf Of </b>Alexey Sergin<br><b>Sent:</b> Thursday, December 10, 2020 10:33 PM<br><b>To:</b> squid-dev@lists.squid-cache.org<br><b>Subject:</b> [squid-dev] File descriptor leak at ICAP reqmod rewrites of CONNECT requests<o:p></o:p></p></div><p class=MsoNormal><o:p> </o:p></p><div><p class=MsoNormal>Hello Squid Developers.<br><br>I'm a software engineer.<br><br>My team uses Squid with an ICAP server. We have noticed that Squid leaks file descriptor and memory when (reqmod) ICAP server replies with http "403 Forbidden" on http CONNECT request.<br><br>Here is a step-by-step description of the problematic scenario:<br>- An http client connects to Squid and sends CONNECT request (for example, "curl -q -x <a href="http://127.0.0.1:3128">http://127.0.0.1:3128</a> <a href="https://example.com">https://example.com</a>");<br>- Squid sends CONNECT request to the (reqmod) ICAP server;<br>- ICAP server sends back a "403 Forbidden" http response;<br>- Squid sends "403 Forbidden" http response to the http client (in the example above, curl reports "Received HTTP code 403 from proxy after CONNECT");<br>- Squid writes to cache.log a message like "kick abandoning <....>";<br>- Squid does not close the file descriptor used for http client connection.<br><br>Those file descriptors and associated memory do pile up. For instance, after 200.000 forbidden requests squid (built from git master) has ~200.000 open descriptors and consumes ~4 Gb RAM. On production deployment with 1000+ users it takes less than a day for Squid to eat out all available RAM.<br><br>It seems that the same problem was previously reported here: <a href="http://www.squid-cache.org/mail-archive/squid-users/201301/0096.html">http://www.squid-cache.org/mail-archive/squid-users/201301/0096.html</a><br><br>Message "kick abandoning <....>" comes from ConnStateData::kick() in client_side.cc. Closing clientConnection right after "debugs(<....>abandoning<....>)" fixes the leak.<br><br>Is it ok to always close() clientConnection when "abandoning" thing happens? Are there any known scenarios where this close() would be inappropriate?<br><br>Could you please give me some advice on a better/proper fix, if close() at "abandoning" time is wrong?<o:p></o:p></p></div></div></body></html>