You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Ronald Park <ro...@cnet.com> on 2008/01/30 21:57:39 UTC

Apache Server behavior for Connection: close

Hello,

I am testing a module I wrote which does some lengthy processing
during the the 'log_transaction' hook of a request when I noticed
some peculiar behavior with the Flood testing tool as compared to
tools like wget and curl.

Namely, Flood, despite receiving a 'Connection: close' header, a
'Content-Length' header and the entire contents of the response
does not close the connection at that time and send the next request;
instead, it waits for the server to close.

I looked up the HTTP specification and it seems like this is one
of those things left up to implementation and I guess Flood has
a different one than both wget and curl.

The result is that, clients like Flood, have really lousy response
times while those like wget and curl get good response times.

Further, in looking in server/connection.c and server/core.c and,
for my build, server/mpm/worker/worker.c, I can clearly see that
the connection will not possibly be closed until all the hooks
are run. :/

I think this because of the following code from worker.c:

static void process_socket(apr_pool_t *p, apr_socket_t *sock, int
my_child_num,
                           int my_thread_num, apr_bucket_alloc_t
*bucket_alloc)
{
    conn_rec *current_conn;
    long conn_id = ID_FROM_CHILD_THREAD(my_child_num, my_thread_num);
    int csd;
    ap_sb_handle_t *sbh;

    ap_create_sb_handle(&sbh, p, my_child_num, my_thread_num);
    apr_os_sock_get(&csd, sock);

    current_conn = ap_run_create_connection(p, ap_server_conf, sock,
                                            conn_id, sbh, bucket_alloc);
    if (current_conn) {
        ap_process_connection(current_conn, sock);
        ap_lingering_close(current_conn);
    }
}


Is there a way to:

a) get Apache to actually close the connection *right after* having
sent the entirety of the response that included a 'Connection: close'

-or-

b) perform my lengthy processing in a hook that runs after the call
to ap_lingering_close().

One other note: My config has 'KeepAlive off'.

Thanks
Ron