[plt-scheme] Cleanup on servlet timeout
On 2008-07-26, Robby Findler <robby at cs.uchicago.edu> wrote:
> No, but that's because it doesn't GC anything.
>
> custodian-shutdown-all kills all tcp connections, closes all files,
> kills all threads -- that kind of thing. It essentially revokes any
> resource utilization (for the custodian in question), where the CPU is
> considered a resource (one that you create threads to use).
>
Good to know, thanks!
> So, if Henk's post-thunks are doing somethign at the C-level, probably
> the right fix is to add that cleanup to the custodian shutdown, also
> at the C level.
>
> If the dynamic-winds are doing something else that just preserves
> Scheme invariants, then he can rewrite the code to make it kill-safe
> (which it apparently isn't). The best pointer I have to explaining
> these ideas and giving an example is our PLDI 2004 paper. I hope
> that's a good start.
Thank you, I have started reading this paper.
There are a couple of things I need to clean up. The first is the
locks I am using to control different threads accessing my database.
They allow any number of readers to access it at once, but only one
writer. In addition, any reader can request to be changed to a writer,
at which point they wait for the other readers to finish before
writing (if two want to be promoted, the second one retries from
scratch as a new reader using an escape continuation).
I enforce this with a couple of semaphores, and I think that I can
protect this logic from terminating threads using the technique
described in the above paper. In fact, this will force me to hide all
of the synchronization logic which is a good idea anyway =).
The second, however, is sqlite stuff, including freeing prepared
statements and aborting transactions (I'm using a modified version of
the sqlite bindings from PLaneT). These are kept on a per-response
basis, so I think it would be tricky to put them all in the resource
thread. Failing to do this stuff can make the database inaccessible
until I restart the server, so I really need to make it reliable. Any
ideas, or am I not giving enough information?
Henk