On Fri, Dec 16, 2011 at 11:39:56AM +0100, obscurolocon...@googlemail.com wrote: > 2011/12/15 Peter Bex <peter....@xs4all.nl>: > I would say the GC must close the connection. How will you ever be > able to close the socket in this case: > > (use tcp) > (let ((p (tcp-connect "localhost" 25))) > (if #f #f)) > > All references are lost. But the socket is still open. > > But you are right. It is the same for file handles. This will also > leak resources: > > (let ((p (open-input-file "/bin/bash"))) > (if #f #f)) > > And Bigloo, Gambit and Guile do not close them either. > > But this sounds somehow broken to me. File descriptors are a resource > like memory. It is a bit strange that memory gets collected but file > descriptors not. Is there a reason for this?
This could be done, but adding finalizers to them would cause quite a performance hit, and it wouldn't *really* fix anything. It would just sweep the problem deeper under the rug. For example, if you open a lot of files in a program that doesn't do any (or much) allocating, the GC wouldn't be triggered and you would start getting "out of filedescriptors" errors. > > Have you checked that there's no trailing data? > > I think the kernel function close does not care about any data not > read when closing a socket. Is this different in Chicken? Not sure. Just try it, if it helps we can think about why it helps. > > If you are still having trouble, please post a full example including > > the URI that's doing this. I can't reproduce this with for example > > I can not post the URI because it is an internal service of the > company I am working for. But I was able to solve the problem with the > function I have posted. So it is ok for me. Can you reproduce it on another service? Cheers, Peter -- http://sjamaan.ath.cx -- "The process of preparing programs for a digital computer is especially attractive, not only because it can be economically and scientifically rewarding, but also because it can be an aesthetic experience much like composing poetry or music." -- Donald Knuth _______________________________________________ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users