[plt-scheme] Resource management in the web server

From: Jay McCarthy (jay.mccarthy at gmail.com)
Date: Wed Oct 11 12:22:18 EDT 2006

Here's the custodian hierarchy in the web server:

root custodian
|--- server custodian
       |--- connection custodian
       |--- ...
       |--- servlet custodian
                   |--- instance custodian
                   |--- ...
       |--- ....

When mzscheme starts there is a custodian. When the server starts, it
creates a new custodian. Every time a connection is initiated, a new
custodian handles all resources of that connection (for example, if
the connection opens a file.) When the connection contains a request
to a servlet that has not yet been initialized, a new custodian is
started for the servlet. When a new instance is to be started (whether
or not the servlet is new), a new custodian is started. All
continuations associated with that instance are tied to that instance
custodian.

What this means to you is that any allocation that is caused by
loading your module is accounted to the servlet custodian. Any
allocation that you do in the dynamic extent of `start' is accounted
to the instance custodian. Reaping all the continuations of an
instance kills the custodian of the instance. Killing all the
instances of a servlet does NOT kill the custodian of the servlet.

So, where are you allocating your port?

Jay

On 10/11/06, Noel Welsh <noelwelsh at yahoo.com> wrote:
> Hi all,
>
> I'm dealing with a resource (port) leak in a servlet I'm writing.  Can I hook into the web server in some way to ensure resources are freed on continuation expiry?  The obvious thing to do is setup a custodian that the web server kills.  So, is the current custoidian in scope of a servlet the custodian that the web server uses to clean up resources on continuation expiry?  If not, is there another way I should use?
>
> Thanks,
> Noel
>
> Email: noelwelsh  yahoo  com   noel  untyped  com
> AIM: noelhwelsh
> Blogs: http://monospaced.blogspot.com/  http://www.untyped.com/untyping/
>
>
>
>
> _________________________________________________
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>


-- 
Jay McCarthy <jay.mccarthy at gmail.com>
http://jay.teammccarthy.org


Posted on the users mailing list.