[racket] tcp exceptions and connection reestablishment...

From: Neil Van Dyke (neil at neilvandyke.org)
Date: Tue Jul 3 15:18:49 EDT 2012

Matthew Flatt wrote at 07/02/2012 02:07 PM:
> Another approach is to use a custodian, which makes it easy to release
> resources without having a binding to each resource:

(D'oh; I forgot to mention custodians.)  One thing to add: custodians 
used this way are useful for more than just closing your TCP ports in 
that networking loop.  My little Web SCGI package creates a custodian 
for each HTTP request that comes through, which will make sure that 
resources like files that were opened in the course of servicing the 
request are freed.  If it didn't do this, there is a not-unlikely 
scenario of an unusual but pretty benign exception while handling a 
request tickles a lapse in programming robustness, which then results in 
a file descriptor or something not being freed, and after a bunch of 
these pretty benign exceptions occur, suddenly the entire Web site goes 
down.  (There are additional things you can do to mitigate this risk, 
but custodians are a good one.)

Neil V.


Posted on the users mailing list.