for use with mod_noloris.c Add some logic protection, for
NULL ref, which shoulda be there in any case.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@821307
13f79535-47bb-0310-9956-
ffa450edef68
AP_DECLARE(int) ap_update_child_status(ap_sb_handle_t *sbh, int status, request_rec *r);
AP_DECLARE(int) ap_update_child_status_from_indexes(int child_num, int thread_num,
int status, request_rec *r);
+AP_DECLARE(int) ap_update_child_status_from_conn(ap_sb_handle_t *sbh, int status, conn_rec *c);
AP_DECLARE(void) ap_time_process_request(ap_sb_handle_t *sbh, int status);
AP_DECLARE(worker_score *) ap_get_scoreboard_worker(ap_sb_handle_t *sbh);
static int noloris_conn(conn_rec *conn)
{
- /*** FIXME
- * This is evil: we're assuming info that's private to the scoreboard
- * We need to do that because there's no API to update the scoreboard
- * on a connection, only with a request (or NULL to say not processing
- * any request). We need a version of ap_update_child_status that
- * accepts a conn_rec.
- */
struct { int child_num; int thread_num; } *sbh = conn->sbh;
char *shm_rec;
- worker_score *ws;
if (shm == NULL) {
return DECLINED; /* we're disabled */
}
}
/* store this client IP for the monitor to pick up */
- /* under traditional scoreboard, none of this happens until
- * there's a request_rec. This is where we use the illegally-
- * obtained private info from the scoreboard.
- */
-
- ws = &ap_scoreboard_image->servers[sbh->child_num][sbh->thread_num];
- strcpy(ws->client, conn->remote_ip);
+
+ ap_update_child_status_from_conn(conn->sbh, SERVER_READY, conn);
return DECLINED;
}
apr_cpystrn(ws->client, ap_get_remote_host(c, r->per_dir_config,
REMOTE_NOLOOKUP, NULL), sizeof(ws->client));
copy_request(ws->request, sizeof(ws->request), r);
- apr_cpystrn(ws->vhost, r->server->server_hostname,
- sizeof(ws->vhost));
+ if (r->server) {
+ apr_cpystrn(ws->vhost, r->server->server_hostname,
+ sizeof(ws->vhost));
+ }
}
}
status, r);
}
+AP_DECLARE(int) ap_update_child_status_from_conn(ap_sb_handle_t *sbh, int status,
+ conn_rec *c)
+{
+ if (!sbh)
+ return -1;
+
+ request_rec fake_rec;
+ fake_rec.connection = c;
+
+ return ap_update_child_status_from_indexes(sbh->child_num, sbh->thread_num,
+ status, &fake_rec);
+}
+
AP_DECLARE(void) ap_time_process_request(ap_sb_handle_t *sbh, int status)
{
worker_score *ws;