[plt-scheme] Limiting Concurrent Connections to Web Server

From: Jay McCarthy (jay.mccarthy at gmail.com)
Date: Fri Jan 16 10:33:29 EST 2009

Hmm, I see. So, now I have

 (if (< i num)
                   (wrap-evt in-ch
                             (lambda (req)
                               (channel-put (in-req-reply-ch req) #t)
                               (loop (add1 i)
                                     (list* (in-req-partner req) partners))))
                   never-evt)

but you are suggesting something like:

 (if (< i num)
                   (wrap-evt in-ch
                             (lambda (req)
                               (channel-put (in-req-reply-ch req) #t)
                               (loop (add1 i)
                                     (list* (in-req-partner req) partners))))
                   (wrap-evt in-ch
                             (lambda (req)
                               (channel-put (in-req-reply-ch req) #f)
                               (loop i partners))))

where if the requester gets #f, then they error, and thus close the connection?

That makes sense. Perhaps I will make it an option...

Jay

On Fri, Jan 16, 2009 at 8:30 AM, Robby Findler
<robby at eecs.northwestern.edu> wrote:
> On Fri, Jan 16, 2009 at 9:17 AM, Jay McCarthy <jay.mccarthy at gmail.com> wrote:
>> On Fri, Jan 16, 2009 at 8:02 AM, Henk Boom <lunarc.lists at gmail.com> wrote:
>>> 2009/1/16 Robby Findler <robby at eecs.northwestern.edu>:
>>>> Perhaps I misunderstood, but I think Henk was looking for a different
>>>> behavior, ie when there are too many connections in session that the
>>>> webserver would just close and forget about the other connections.
>>
>> I'm not sure how to do this... with semaphores I could use
>> semaphore-try-wait?, but I don't know how to recreate that with the
>> manager.
>
> Oh, I was thinking of something where you'd hold onto a few
> connections (like you're doing), but after some limit there, the
> manager thread would just respond immediately with "close the
> connection" and the thread that got the connection wouldn't block, but
> would instead just shutdown the ports and die. Something like that.
>
> Robby
>



-- 
Jay McCarthy <jay at cs.byu.edu>
Assistant Professor / Brigham Young University
http://teammccarthy.org/jay

"The glory of God is Intelligence" - D&C 93


Posted on the users mailing list.