Max # of sockets
I'd been using lhttpc (great work!) with a minor patch that limits the number of simultaneous requests to a given endpoint. It has worked fine so far, but isn't really well tested outside my specific scenario.
Anyway, I thought it might come handy for others, or perhaps to include it on lhttpc if the patch is good enough.
The idea was to modify lhttpc_manager to delay the return of gen_server:calls for sockets if there are > MAX active clients at a given endpoint. It will return (either a valid socket or inform the client that is allowed to continue and open a new connection) only when one of the active clients finish.
The tricky part is how to detect that a client has finished the requests. The attached patch don't rely on 'done' messages (those are used to return a socket to the pool), but instead links to the client and uses the 'EXIT' messages to detect a finished client process.