#if APR_HAS_SHARED_MEMORY
apr_status_t rv;
char *fname = NULL;
- apr_pool_t *global_pool;
-
- /* We don't want to have to recreate the scoreboard after
- * restarts, so we'll create a global pool and never clean it.
- */
- rv = apr_pool_create(&global_pool, NULL);
- if (rv != APR_SUCCESS) {
- ap_log_error(APLOG_MARK, APLOG_CRIT, rv, ap_server_conf, APLOGNO(00002)
- "Fatal error: unable to create global pool "
- "for use by the scoreboard");
- return rv;
- }
+ apr_pool_t *global_pool = apr_pool_parent_get(pconf);
+ /* If this is not passed pconf, or pconf is no longer a direct
+ * child of a global pool, this should change... */
+ AP_DEBUG_ASSERT(apr_pool_parent_get(global_pool) == NULL);
+
/* The config says to create a name-based shmem */
if (ap_scoreboard_fname) {
/* make sure it's an absolute pathname */
return (ap_scoreboard_image ? 1 : 0);
}
+AP_DECLARE(void) ap_set_conn_count(ap_sb_handle_t *sb, request_rec *r,
+ unsigned short conn_count)
+{
+ worker_score *ws;
+
+ if (!sb)
+ return;
+
+ ws = &ap_scoreboard_image->servers[sb->child_num][sb->thread_num];
+ ws->conn_count = conn_count;
+}
+
AP_DECLARE(void) ap_increment_counts(ap_sb_handle_t *sb, request_rec *r)
{
worker_score *ws;
return -1;
}
+AP_DECLARE(void) ap_update_sb_handle(ap_sb_handle_t *sbh,
+ int child_num, int thread_num)
+{
+ sbh->child_num = child_num;
+ sbh->thread_num = thread_num;
+}
+
AP_DECLARE(void) ap_create_sb_handle(ap_sb_handle_t **new_sbh, apr_pool_t *p,
int child_num, int thread_num)
{
*new_sbh = (ap_sb_handle_t *)apr_palloc(p, sizeof(ap_sb_handle_t));
- (*new_sbh)->child_num = child_num;
- (*new_sbh)->thread_num = thread_num;
+ ap_update_sb_handle(*new_sbh, child_num, thread_num);
}
static void copy_request(char *rbuf, apr_size_t rbuflen, request_rec *r)
if (status == SERVER_DEAD) {
ws->my_access_count = 0L;
ws->my_bytes_served = 0L;
+#ifdef HAVE_TIMES
+ ws->times.tms_utime = 0;
+ ws->times.tms_stime = 0;
+ ws->times.tms_cutime = 0;
+ ws->times.tms_cstime = 0;
+#endif
}
ws->conn_count = 0;
ws->conn_bytes = 0;
ws->last_used = apr_time_now();
}
- /* Keep existing values until working again */
if (descr) {
apr_cpystrn(ws->request, descr, sizeof(ws->request));
}
else if (r) {
copy_request(ws->request, sizeof(ws->request), r);
}
+ else if (c) {
+ ws->request[0]='\0';
+ }
- 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));
+ if (r && r->useragent_ip) {
+ if (!(val = ap_get_useragent_host(r, REMOTE_NOLOOKUP, NULL))) {
+ apr_cpystrn(ws->client, r->useragent_ip, sizeof(ws->client)); /* DEPRECATE */
+ apr_cpystrn(ws->client64, r->useragent_ip, sizeof(ws->client64));
+ }
+ else {
+ apr_cpystrn(ws->client, val, sizeof(ws->client)); /* DEPRECATE */
+ apr_cpystrn(ws->client64, val, sizeof(ws->client64));
+ }
}
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));
+ REMOTE_NOLOOKUP, NULL))) {
+ apr_cpystrn(ws->client, c->client_ip, sizeof(ws->client)); /* DEPRECATE */
+ apr_cpystrn(ws->client64, c->client_ip, sizeof(ws->client64));
+ }
+ else {
+ apr_cpystrn(ws->client, val, sizeof(ws->client)); /* DEPRECATE */
+ apr_cpystrn(ws->client64, val, sizeof(ws->client64));
+ }
}
if (s) {
apr_cpystrn(ws->vhost, s->server_hostname, sizeof(ws->vhost));
}
}
+ else if (c) {
+ ws->vhost[0]='\0';
+ }
if (c) {
val = ap_get_protocol(c);
}
else if (status == STOP_PREQUEST) {
ws->stop_time = ws->last_used = apr_time_now();
+ if (ap_extended_status) {
+ ws->duration += ws->stop_time - ws->start_time;
+ }
+ }
+}
+
+AP_DECLARE(int) ap_update_global_status()
+{
+#ifdef HAVE_TIMES
+ if (ap_scoreboard_image == NULL) {
+ return APR_SUCCESS;
}
+ times(&ap_scoreboard_image->global->times);
+#endif
+ return APR_SUCCESS;
}
AP_DECLARE(worker_score *) ap_get_scoreboard_worker_from_indexes(int x, int y)
/* For extra safety, NUL-terminate the strings returned, though it
* should be true those last bytes are always zero anyway. */
dest->client[sizeof(dest->client) - 1] = '\0';
+ dest->client64[sizeof(dest->client64) - 1] = '\0';
dest->request[sizeof(dest->request) - 1] = '\0';
dest->vhost[sizeof(dest->vhost) - 1] = '\0';
dest->protocol[sizeof(dest->protocol) - 1] = '\0';