views:

150

answers:

0

Hello,

We'd like to have a more fine-grained control on the connections we serve in a C++ Apache 2.2 module (on CentOS 5).

One of the connections needs to stay alive for a few multiple requests, so we set "KeepAlive" to "On" and set a short keep-alive period.

But for every such connection we have a few more connections from the browser which we don't need to leave behind and instead want to force them to close after a single request.

Some of these connections are on different ports (so we can distinguish them by port, since KeepAlive can be set per virtual host) and some request a different URL (so we can tell from the path and parameters that we don't want to leave them behind).

Also for the one we do want to keep alive, we know that after a certain request we'd like to close it too.

But so far the only way we found to "cancel" the keep-alive is to send a polite "Connection: close" header to the client. If the client is not well behaved, or malicious, then they can keep it open and waste our resources.

Is there a way to tell Apache to close the connection from the server side? The documentation advises against just plain close(2) call on the socket since Apache needs to do some clean up before that's done. But is there some API or a trick to "override" the static "KeepAlive On" configuration dynamically (and convince Apache to call close(2))?

Thanks.