<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Hi Jay,</div><div><br></div><div>Thanks for looking at this. Answers below:</div><div><br></div><blockquote type="cite">I presume that you are using adjust-timeout! ? Or are you using a<br>dispatcher that wraps another and does something to the connection<br>while it runs?</blockquote><div><br></div><div>Yes. It's a one-line hack to web-server/http/response.ss:</div><div><br></div><div><div><font class="Apple-style-span" face="Monaco">===================================================================</font></div><div><font class="Apple-style-span" face="Monaco">--- http/response.ss</font><span class="Apple-tab-span" style="white-space:pre"><font class="Apple-style-span" face="Monaco">        </font></span><font class="Apple-style-span" face="Monaco">(revision 13220)</font></div><div><font class="Apple-style-span" face="Monaco">+++ http/response.ss</font><span class="Apple-tab-span" style="white-space:pre"><font class="Apple-style-span" face="Monaco">        </font></span><font class="Apple-style-span" face="Monaco">(working copy)</font></div><div><font class="Apple-style-span" face="Monaco">@@ -154,7 +154,9 @@</font></div><div><font class="Apple-style-span" face="Monaco"> ((response/incremental-generator bresp)</font></div><div><font class="Apple-style-span" face="Monaco"> (lambda chunks</font></div><div><font class="Apple-style-span" face="Monaco"> (fprintf o-port "~x\r\n"</font></div><div><font class="Apple-style-span" face="Monaco"> (apply + 0 (map data-length chunks)))</font></div><div><font class="Apple-style-span" face="Monaco">+ (adjust-connection-timeout! conn 5)</font></div><div><font class="Apple-style-span" face="Monaco"> (for-each (lambda (chunk) (display chunk o-port)) chunks)</font></div><div><font class="Apple-style-span" face="Monaco"> (fprintf o-port "\r\n")))</font></div><div><font class="Apple-style-span" face="Monaco"> ; one \r\n ends the last (empty) chunk and the second \r\n ends the (non-existant) trailers</font></div><div><br></div><div>My code is reading and writing 4kb chunks of the file so 5 seconds is easily enough. All downloads seem to complete properly now, even if they are very large.</div><div><br></div><div>I thought this hack would address the file handle retention issue but it looks like it hasn't, at least on our Debian server. Everything works okay on my Mac laptop but I might not have hit the right combination of factors to make it break.</div><div><br></div></div><blockquote type="cite"><span class="Apple-style-span" style="-webkit-text-stroke-width: -1; ">Regarding the file handles, I presume that are your file handles from call-with-input-file? </span></blockquote><blockquote type="cite"> [...] <span class="Apple-style-span" style="-webkit-text-stroke-width: -1; ">Can you track down what kind of file handles are being retained? I don't think that</span></blockquote><blockquote type="cite"><span class="Apple-style-span" style="-webkit-text-stroke-width: -1; ">there's a problem with call-with-input-file, but I'd like more info.</span></blockquote><br><div><div>call-with-input-file certainly seems to be the culprit. Here are some lines from lsof:</div><div><br></div><div><div>COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME</div><div># ... blah blah blah ...</div><div>mzscheme 9300 untyped 130u REG 9,0 5346912 950289 /data/fs/module/sbs524/lecture2.pdf</div><div>mzscheme 9300 untyped 131r REG 9,0 5346912 950289 /data/fs/module/sbs524/lecture2.pdf</div><div>mzscheme 9300 untyped 132u REG 9,0 3087554 950290 /data/fs/module/sbs524/lecture3.pdf</div><div>mzscheme 9300 untyped 133u REG 9,0 3087554 950290 /data/fs/module/sbs524/lecture3.pdf</div><div># ... blah blah blah ...</div><div><br></div><div>These are the files (lecture notes and so on) that are being read with call-with-input-file. I get one line for each file download. Some lines (not all) are retained after the download is complete. Only larger downloads seem to be retained (6+ megabytes, or 1+ minute of download underload). </div><div><br></div></div><blockquote type="cite"><div>When a servlet runs, its resources are owned by the servlet's<br>custodian, so they are shared by the entire servlet and not just the<br>instance or connection. This means that if you don't free resources,<br>it won't be removed until the servlet is, which only happens when you<br>conf/refresh-servlets.</div></blockquote><div><br></div><div>Returning gracefully from call-with-input-file should do this, right? Can I do anything to make sure the file handle is released if there is an abrupt exit?</div><div><br></div><div>I'll add a debugging message to make sure there is a graceful return. I'll also see if sleeping for a second after call-with-input-file finished helps at all.</div><div><br></div><div>Cheers,</div><div><br></div><div>-- Dave</div><div><br></div></div></body></html>