--- include/httpd.h (revision 1741062) +++ include/httpd.h (working copy) @@ -1083,6 +1083,9 @@ typedef enum { AP_CONN_KEEPALIVE } ap_conn_keepalive_e; +/* AP_SB_*_SIZE needed by conn_rec */ +#include "scoreboard.h" + /** * @brief Structure to store things which are per connection */ @@ -1183,6 +1186,10 @@ struct conn_rec { /** The "real" master connection. NULL if I am the master. */ conn_rec *master; + + /** Preserve scoreboard's worker last request infos */ + char sb_lastreq[AP_SB_REQ_SIZE]; + char sb_lastvhost[AP_SB_VHOST_SIZE]; }; /** --- include/scoreboard.h (revision 1741062) +++ include/scoreboard.h (working copy) @@ -85,6 +85,9 @@ typedef enum { SB_SHARED = 2 } ap_scoreboard_e; +#define AP_SB_REQ_SIZE 64 +#define AP_SB_VHOST_SIZE 32 + /* stuff which is worker specific */ typedef struct worker_score worker_score; struct worker_score { @@ -113,8 +116,8 @@ struct worker_score { struct tms times; #endif char client[32]; /* Keep 'em small... */ - char request[64]; /* We just want an idea... */ - char vhost[32]; /* What virtual host is being accessed? */ + char request[AP_SB_REQ_SIZE]; /* We just want an idea... */ + char vhost[AP_SB_VHOST_SIZE]; /* What virtual host is being accessed? */ char protocol[16]; /* What protocol is used on the connection? */ }; --- server/scoreboard.c (revision 1741062) +++ server/scoreboard.c (working copy) @@ -464,22 +464,18 @@ static int update_child_status_internal(int child_ { int old_status; worker_score *ws; - process_score *ps; int mpm_generation; ws = &ap_scoreboard_image->servers[child_num][thread_num]; old_status = ws->status; - if (status >= 0) { - ws->status = status; - - ps = &ap_scoreboard_image->parent[child_num]; - - if (status == SERVER_READY - && old_status == SERVER_STARTING) { - ws->thread_num = child_num * thread_limit + thread_num; - ap_mpm_query(AP_MPMQ_GENERATION, &mpm_generation); - ps->generation = mpm_generation; - } + ws->status = status; + + if (status == SERVER_READY + && old_status == SERVER_STARTING) { + process_score *ps = &ap_scoreboard_image->parent[child_num]; + ws->thread_num = child_num * thread_limit + thread_num; + ap_mpm_query(AP_MPMQ_GENERATION, &mpm_generation); + ps->generation = mpm_generation; } if (ap_extended_status) { @@ -497,45 +493,56 @@ static int update_child_status_internal(int child_ ws->conn_bytes = 0; ws->last_used = apr_time_now(); } - if (status == SERVER_READY) { - ws->client[0]='\0'; - ws->vhost[0]='\0'; - ws->request[0]='\0'; - ws->protocol[0]='\0'; + + if (descr) { + apr_cpystrn(ws->request, descr, sizeof(ws->request)); } - else { - if (descr) { - apr_cpystrn(ws->request, descr, sizeof(ws->request)); + else if (r) { + copy_request(ws->request, sizeof(ws->request), r); + } + else if (c && old_status == SERVER_READY) { + apr_cpystrn(ws->request, c->sb_lastreq, + sizeof(ws->request)); + } + + if (r) { + if (!(val = ap_get_useragent_host(r, REMOTE_NOLOOKUP, NULL))) + apr_cpystrn(ws->client, r->useragent_ip, sizeof(ws->client)); + else + apr_cpystrn(ws->client, val, sizeof(ws->client)); + } + else if (c) { + if (!(val = ap_get_remote_host(c, c->base_server->lookup_defaults, + REMOTE_NOLOOKUP, NULL))) + apr_cpystrn(ws->client, c->client_ip, sizeof(ws->client)); + else + apr_cpystrn(ws->client, val, sizeof(ws->client)); + } + + if (s) { + if (c) { + apr_snprintf(ws->vhost, sizeof(ws->vhost), "%s:%d", + s->server_hostname, c->local_addr->port); } - else if (r) { - copy_request(ws->request, sizeof(ws->request), r); + else { + apr_cpystrn(ws->vhost, s->server_hostname, sizeof(ws->vhost)); } - if (r) { - if (!(val = ap_get_useragent_host(r, REMOTE_NOLOOKUP, NULL))) - apr_cpystrn(ws->client, r->useragent_ip, sizeof(ws->client)); - else - apr_cpystrn(ws->client, val, sizeof(ws->client)); + } + else if (c && old_status == SERVER_READY) { + apr_cpystrn(ws->vhost, c->sb_lastvhost, + sizeof(ws->vhost)); + } + + if (c) { + val = ap_get_protocol(c); + apr_cpystrn(ws->protocol, val, sizeof(ws->protocol)); + + if (status == SERVER_BUSY_LOG) { + apr_cpystrn(c->sb_lastreq, ws->request, + sizeof(c->sb_lastreq)); + apr_cpystrn(c->sb_lastvhost, ws->vhost, + sizeof(c->sb_lastreq)); } - else if (c) { - if (!(val = ap_get_remote_host(c, c->base_server->lookup_defaults, - REMOTE_NOLOOKUP, NULL))) - apr_cpystrn(ws->client, c->client_ip, sizeof(ws->client)); - else - apr_cpystrn(ws->client, val, sizeof(ws->client)); - } - if (s) { - if (c) { - apr_snprintf(ws->vhost, sizeof(ws->vhost), "%s:%d", - s->server_hostname, c->local_addr->port); - } - else { - apr_cpystrn(ws->vhost, s->server_hostname, sizeof(ws->vhost)); - } - } - if (c) { - val = ap_get_protocol(c); - apr_cpystrn(ws->protocol, val, sizeof(ws->protocol)); - } } }