Re: thread resource leaks if thread terminates with uncaught exception

Jens Thiele <[email protected]> Wed, 18 Dec 2024 09:05:31 +0100
Newsgroups gmane.lisp.scheme.gauche
Message-ID <[email protected]>
Shiro Kawai <[email protected]> writes:

> Ok, I reproduced it.  The threads leave the socket to the localhost:8081
> open  (You can see it with `lsof -p <pid>`), which consumes the fd pool.
> `thread-terminate!` doesn't give the thread to cleanup, so relying on it
> should generally be avoided.

The problem is how to avoid thread-terminate! in such cases. In this
example it is the http-get which has no timeout. I also tried a version
where the http-get is done in a child process and canceled with a
sys-alarm - but this is really slow and sys-alarm only accepts full
seconds as timeout. Maybe one could keep some worker processes around
and use select but I think this gets complicated.

Best regards
Jens