Ryan Bloom wrote:
>On Saturday 15 September 2001 02:59 pm, [EMAIL PROTECTED] wrote:
>
>>In a message dated 01-09-15 17:23:07 EDT, you write:
>>
>>>>[Light comes on] Ahhh... guess I should have looked more closely at
>>>>
>>> >mod_log_config and I would have realized that you can configure it to
>>> >write certain notes to the log file. Duh. My fault.
>>>
>>> Wasn't the concensus a while back that request_rec->notes should be
>>> removed, because the more efficient 'userdata' functions on r->pool
>>> had made the notes table obsolete?
>>>
>>> --Brian
>>>
>>It was 'discussed' but never played out.
>>
>>I wouldn't say there was anything near a 'consensus' on
>>anything. Only a few people even responsed.
>>
>>FWIW: I think the 'notes' stuff should stay, for now anyway.
>>Any discussion of removing it ( at this time ) is going to
>>ignite the 'why don't we just get this Server finished first
>>so people can at least start using it' debate.
>>
>
>Actually, a consensus was reached. I believe that we even tried to do that
>work, but it isn't as easy as it should be, because it is easy to merge a table,
>but hard to merge a hash.
>
I decided to make another attempt at removing the notes table this
afternoon.
Here's the patch...
--Brian
Index: include/httpd.h
===================================================================
RCS file: /home/cvspublic/httpd-2.0/include/httpd.h,v
retrieving revision 1.165
diff -u -r1.165 httpd.h
--- include/httpd.h 2001/09/14 23:30:41 1.165
+++ include/httpd.h 2001/09/16 03:04:37
@@ -733,9 +733,6 @@
* The difference between headers_out and err_headers_out is that the
* latter are printed even on error, and persist across internal redirects
* (so the headers printed for ErrorDocument handlers will have them).
- *
- * The 'notes' apr_table_t is for notes from one module to another, with no
- * other set purpose in mind...
*/
/** MIME header environment from the request */
@@ -747,8 +744,6 @@
apr_table_t *err_headers_out;
/** Array of environment variables to be used for sub processes */
apr_table_t *subprocess_env;
- /** Notes from one module to another */
- apr_table_t *notes;
/* content_type, handler, content_encoding, content_language, and all
* content_languages MUST be lowercased strings. They may be pointers
Index: modules/generators/mod_cgi.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/modules/generators/mod_cgi.c,v
retrieving revision 1.103
diff -u -r1.103 mod_cgi.c
--- modules/generators/mod_cgi.c 2001/08/27 20:25:42 1.103
+++ modules/generators/mod_cgi.c 2001/09/16 03:04:38
@@ -122,8 +122,11 @@
static int is_scriptaliased(request_rec *r)
{
- const char *t = apr_table_get(r->notes, "alias-forced-type");
- return t && (!strcasecmp(t, "cgi-script"));
+ const char *t;
+ return APR_STATUS_IS_SUCCESS(apr_pool_userdata_get((void **)&t,
+ "alias-forced-type",
+ r->pool))
+ && t && (!strcasecmp(t, "cgi-script"));
}
/* Configuration stuff */
Index: modules/http/http_protocol.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/modules/http/http_protocol.c,v
retrieving revision 1.361
diff -u -r1.361 http_protocol.c
--- modules/http/http_protocol.c 2001/09/02 03:21:47 1.361
+++ modules/http/http_protocol.c 2001/09/16 03:04:40
@@ -1626,7 +1626,8 @@
{
const char *notes, *result;
- if ((notes = apr_table_get(r->notes, key)) == NULL) {
+ if (!APR_STATUS_IS_SUCCESS(apr_pool_userdata_get((void**)¬es, key,
+ r->pool)) || !notes) {
result = apr_pstrcat(r->pool, prefix, suffix, NULL);
}
else {
@@ -1818,8 +1819,14 @@
* that is totally safe for any user to see (ie lacks paths,
* database passwords, etc.)
*/
- if (((error_notes = apr_table_get(r->notes, "error-notes")) != NULL)
- && (h1 = apr_table_get(r->notes, "verbose-error-to")) != NULL
+ if (APR_STATUS_IS_SUCCESS(apr_pool_userdata_get((void **)&error_notes,
+ "error_notes",
+ r->pool))
+ && error_notes
+ && APR_STATUS_IS_SUCCESS(apr_pool_userdata_get((void **)&h1,
+ "verbose-error-to",
+ r->pool))
+ && h1
&& (strcmp(h1, "*") == 0)) {
return(apr_pstrcat(p, error_notes, "<p />\n", NULL));
}
Index: modules/http/http_request.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/modules/http/http_request.c,v
retrieving revision 1.113
diff -u -r1.113 http_request.c
--- modules/http/http_request.c 2001/08/31 03:49:42 1.113
+++ modules/http/http_request.c 2001/09/16 03:04:40
@@ -204,8 +204,12 @@
* more informative (than the plain canned) messages to us.
* Propagate them to ErrorDocuments via the ERROR_NOTES variable:
*/
- if ((error_notes = apr_table_get(r->notes, "error-notes")) != NULL) {
- apr_table_setn(r->subprocess_env, "ERROR_NOTES", error_notes);
+ if (APR_STATUS_IS_SUCCESS(apr_pool_userdata_get((void **)&error_notes,
+ "error-notes",
+ r->pool))
+ && error_notes) {
+ apr_pool_userdata_set(error_notes, "error-notes", NULL,
+ r->pool);
}
r->method = apr_pstrdup(r->pool, "GET");
r->method_number = M_GET;
@@ -373,7 +377,6 @@
new->headers_out = apr_table_make(r->pool, 12);
new->err_headers_out = r->err_headers_out;
new->subprocess_env = rename_original_env(r->pool, r->subprocess_env);
- new->notes = apr_table_make(r->pool, 5);
new->allowed_methods = ap_make_method_list(new->pool, 2);
new->htaccess = r->htaccess;
@@ -424,7 +427,7 @@
r->finfo = rr->finfo;
r->per_dir_config = rr->per_dir_config;
/* copy output headers from subrequest, but leave negotiation headers */
- r->notes = apr_table_overlay(r->pool, rr->notes, r->notes);
+ apr_pool_userdata_overlay(r->pool, rr->pool);
r->headers_out = apr_table_overlay(r->pool, rr->headers_out,
r->headers_out);
r->err_headers_out = apr_table_overlay(r->pool, rr->err_headers_out,
Index: modules/http/mod_mime.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/modules/http/mod_mime.c,v
retrieving revision 1.63
diff -u -r1.63 mod_mime.c
--- modules/http/mod_mime.c 2001/09/08 05:50:12 1.63
+++ modules/http/mod_mime.c 2001/09/16 03:04:41
@@ -814,8 +814,8 @@
* skip the notes to alert mod_negotiation we are clueless.
*/
if (found_metadata) {
- apr_table_setn(r->notes, "ap-mime-exceptions-list",
- (void *)exception_list);
+ apr_pool_userdata_set((void *)exception_list,
+ "ap-mime-exceptions-list", NULL, r->pool);
}
if (r->content_type) {
Index: modules/loggers/mod_log_config.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/modules/loggers/mod_log_config.c,v
retrieving revision 1.68
diff -u -r1.68 mod_log_config.c
--- modules/loggers/mod_log_config.c 2001/08/27 20:50:01 1.68
+++ modules/loggers/mod_log_config.c 2001/09/16 03:04:42
@@ -417,7 +417,13 @@
static const char *log_note(request_rec *r, char *a)
{
- return apr_table_get(r->notes, a);
+ void* data;
+ if (!APR_STATUS_IS_SUCCESS(apr_pool_userdata_get(&data, a, r->pool))) {
+ return NULL;
+ }
+ else {
+ return (const char*)data;
+ }
}
static const char *log_env_var(request_rec *r, char *a)
{
Index: modules/mappers/mod_alias.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/modules/mappers/mod_alias.c,v
retrieving revision 1.31
diff -u -r1.31 mod_alias.c
--- modules/mappers/mod_alias.c 2001/08/23 18:49:55 1.31
+++ modules/mappers/mod_alias.c 2001/09/16 03:04:42
@@ -372,7 +372,8 @@
if (found) {
if (p->handler) { /* Set handler, and leave a note for mod_cgi */
r->handler = p->handler;
- apr_table_setn(r->notes, "alias-forced-type", r->handler);
+ apr_pool_userdata_set(r->handler, "alias-forced-type",
+ NULL, r->pool);
}
/* XXX This is as SLOW as can be, next step, we optimize
* and merge to whatever part of the found path was already
Index: modules/mappers/mod_dir.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/modules/mappers/mod_dir.c,v
retrieving revision 1.34
diff -u -r1.34 mod_dir.c
--- modules/mappers/mod_dir.c 2001/08/23 21:05:42 1.34
+++ modules/mappers/mod_dir.c 2001/09/16 03:04:42
@@ -203,7 +203,7 @@
apr_pool_join(r->pool, rr->pool);
error_notfound = rr->status;
- r->notes = apr_table_overlay(r->pool, r->notes, rr->notes);
+ apr_pool_userdata_overlay(r->pool, rr->pool);
r->headers_out = apr_table_overlay(r->pool, r->headers_out,
rr->headers_out);
r->err_headers_out = apr_table_overlay(r->pool, r->err_headers_out,
Index: modules/mappers/mod_negotiation.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/modules/mappers/mod_negotiation.c,v
retrieving revision 1.81
diff -u -r1.81 mod_negotiation.c
--- modules/mappers/mod_negotiation.c 2001/08/30 13:37:16 1.81
+++ modules/mappers/mod_negotiation.c 2001/09/16 03:04:44
@@ -1091,11 +1091,10 @@
* it's an insignificant file (e.g. did not identify a
* language, charset, encoding, content type or handler,)
*/
- exception_list =
- (apr_array_header_t *)apr_table_get(sub_req->notes,
- "ap-mime-exceptions-list");
-
- if (!exception_list) {
+ if (!APR_STATUS_IS_SUCCESS(apr_pool_userdata_get((void **)&exception_list,
+ "ap-mime-exceptions-list",
+ sub_req->pool))
+ || !exception_list) {
ap_destroy_sub_req(sub_req);
continue;
}
@@ -2476,11 +2475,12 @@
static void store_variant_list(request_rec *r, negotiation_state *neg)
{
if (r->main == NULL) {
- apr_table_setn(r->notes, "variant-list", make_variant_list(r, neg));
+ apr_pool_userdata_set(make_variant_list(r, neg), "variant-list",
+ NULL, r->pool);
}
else {
- apr_table_setn(r->main->notes, "variant-list",
- make_variant_list(r->main, neg));
+ apr_pool_userdata_set(make_variant_list(r->main, neg), "variant-list",
+ NULL, r->main->pool);
}
}
Index: modules/mappers/mod_userdir.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/modules/mappers/mod_userdir.c,v
retrieving revision 1.40
diff -u -r1.40 mod_userdir.c
--- modules/mappers/mod_userdir.c 2001/09/07 14:52:00 1.40
+++ modules/mappers/mod_userdir.c 2001/09/16 03:04:45
@@ -345,7 +345,7 @@
r->finfo = statbuf;
/* For use in the get_suexec_identity phase */
- apr_table_setn(r->notes, "mod_userdir_user", w);
+ apr_pool_userdata_set(w, "mod_userdir_user", NULL, r->pool);
return OK;
}
@@ -359,9 +359,12 @@
{
ap_unix_identity_t *ugid = NULL;
#if APR_HAS_USER
- const char *username = apr_table_get(r->notes, "mod_userdir_user");
+ const char *username;
- if (username == NULL) {
+ if (!APR_STATUS_IS_SUCCESS(apr_pool_userdata_get((void **)&username,
+ "mod_userdir_user",
+ r->pool))
+ || !username) {
return NULL;
}
Index: modules/metadata/mod_setenvif.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/modules/metadata/mod_setenvif.c,v
retrieving revision 1.30
diff -u -r1.30 mod_setenvif.c
--- modules/metadata/mod_setenvif.c 2001/06/12 17:06:01 1.30
+++ modules/metadata/mod_setenvif.c 2001/09/16 03:04:45
@@ -404,6 +404,7 @@
*/
static int match_headers(request_rec *r)
{
+ void *data;
sei_cfg_rec *sconf;
sei_entry *entries;
apr_table_entry_t *elts;
@@ -411,8 +412,10 @@
int i, j;
char *last_name;
- if (apr_table_get(r->notes, SEI_MAGIC_HEIRLOOM) == NULL) {
- apr_table_set(r->notes, SEI_MAGIC_HEIRLOOM, "post-read done");
+ if (!APR_STATUS_IS_SUCCESS(apr_pool_userdata_get(&data, SEI_MAGIC_HEIRLOOM,
+ r->pool)) || !data) {
+ apr_pool_userdata_set("post-read-done", SEI_MAGIC_HEIRLOOM,
+ NULL, r->pool);
sconf = (sei_cfg_rec *) ap_get_module_config(r->server->module_config,
&setenvif_module);
}
Index: server/config.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/server/config.c,v
retrieving revision 1.134
diff -u -r1.134 config.c
--- server/config.c 2001/08/23 19:13:53 1.134
+++ server/config.c 2001/09/16 03:04:46
@@ -1525,9 +1525,9 @@
"%s pcfg_openfile: unable to check htaccess file, "
"ensure it is readable",
filename);
- apr_table_setn(r->notes, "error-notes",
- "Server unable to read htaccess file, denying "
- "access to be safe");
+ apr_pool_userdata_set("Server unable to read htaccess file, "
+ "denying access to be safe",
+ "error-notes", NULL, r->pool);
return HTTP_FORBIDDEN;
}
}
Index: server/log.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/server/log.c,v
retrieving revision 1.96
diff -u -r1.96 log.c
--- server/log.c 2001/07/30 17:55:38 1.96
+++ server/log.c 2001/09/16 03:04:47
@@ -490,6 +490,7 @@
const char *fmt, ...)
{
va_list args;
+ void *data;
va_start(args, fmt);
log_error_core(file, line, level, status, r->server, r, NULL, fmt, args);
@@ -504,10 +505,13 @@
va_end(args);
va_start(args,fmt);
if (((level & APLOG_LEVELMASK) <= APLOG_WARNING)
- && (apr_table_get(r->notes, "error-notes") == NULL)) {
- apr_table_setn(r->notes, "error-notes",
- ap_escape_html(r->pool, apr_pvsprintf(r->pool, fmt,
- args)));
+ &&
+ (!APR_STATUS_IS_SUCCESS(apr_pool_userdata_get(&data, "error-notes",
+ r->pool)) || !data)) {
+ apr_pool_userdata_set(ap_escape_html(r->pool,
+ apr_pvsprintf(r->pool, fmt,
+ args)),
+ "error-notes", NULL, r->pool);
}
va_end(args);
}
Index: server/protocol.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/server/protocol.c,v
retrieving revision 1.44
diff -u -r1.44 protocol.c
--- server/protocol.c 2001/09/11 18:38:21 1.44
+++ server/protocol.c 2001/09/16 03:04:48
@@ -498,9 +498,10 @@
if (r->server->limit_req_fields &&
(++fields_read > r->server->limit_req_fields)) {
r->status = HTTP_BAD_REQUEST;
- apr_table_setn(r->notes, "error-notes",
- "The number of request header fields exceeds "
- "this server's limit.");
+ apr_pool_userdata_set("error-notes",
+ "The number of request header fields "
+ "exceeds this server's limit.",
+ NULL, r->pool);
return;
}
/* ap_getline returns (size of max buffer - 1) if it fills up the
@@ -509,13 +510,13 @@
*/
if (len > r->server->limit_req_fieldsize) {
r->status = HTTP_BAD_REQUEST;
- apr_table_setn(r->notes, "error-notes",
- apr_pstrcat(r->pool,
- "Size of a request header field "
- "exceeds server limit.<br />\n"
- "<pre>\n",
- ap_escape_html(r->pool, field),
- "</pre>\n", NULL));
+ apr_pool_userdata_set(apr_pstrcat(r->pool,
+ "Size of a request header field "
+ "exceeds server limit.<br />\n"
+ "<pre>\n",
+ ap_escape_html(r->pool, field),
+ "</pre>\n", NULL),
+ "error-notes", NULL, r->pool);
return;
}
copy = apr_palloc(r->pool, len + 1);
@@ -523,13 +524,13 @@
if (!(value = strchr(copy, ':'))) { /* Find the colon separator */
r->status = HTTP_BAD_REQUEST; /* or abort the bad request */
- apr_table_setn(r->notes, "error-notes",
- apr_pstrcat(r->pool,
- "Request header field is missing "
- "colon separator.<br />\n"
- "<pre>\n",
- ap_escape_html(r->pool, copy),
- "</pre>\n", NULL));
+ apr_pool_userdata_set(apr_pstrcat(r->pool,
+ "Request header field is "
+ "missing colon separator."
+ "<br />\n<pre>\n",
+ ap_escape_html(r->pool, copy),
+ "</pre>\n", NULL),
+ "error-notes", NULL, r->pool);
return;
}
@@ -570,7 +571,6 @@
r->subprocess_env = apr_table_make(r->pool, 50);
r->headers_out = apr_table_make(r->pool, 12);
r->err_headers_out = apr_table_make(r->pool, 5);
- r->notes = apr_table_make(r->pool, 5);
r->request_config = ap_create_request_config(r->pool);
ap_run_create_request(r);
@@ -720,7 +720,6 @@
rnew->subprocess_env = apr_table_copy(rnew->pool, r->subprocess_env);
rnew->headers_out = apr_table_make(rnew->pool, 5);
rnew->err_headers_out = apr_table_make(rnew->pool, 5);
- rnew->notes = apr_table_make(rnew->pool, 5);
rnew->expecting_100 = r->expecting_100;
rnew->read_length = r->read_length;
Index: srclib/apr/include/apr_pools.h
===================================================================
RCS file: /home/cvspublic/apr/include/apr_pools.h,v
retrieving revision 1.59
diff -u -r1.59 apr_pools.h
--- srclib/apr/include/apr_pools.h 2001/08/15 21:02:53 1.59
+++ srclib/apr/include/apr_pools.h 2001/09/16 03:04:49
@@ -298,6 +298,14 @@
apr_pool_t *cont);
/**
+ * Overlay a copy of one pool's userdata onto another
+ * @param base The target pool
+ * @param add The source pool
+ */
+APR_DECLARE(apr_status_t) apr_pool_userdata_overlay(apr_pool_t *base,
+ const apr_pool_t *add);
+
+/**
* Clear all memory in the pool and run all the cleanups. This also clears all
* subpools.
* @param p The pool to clear
Index: srclib/apr/memory/unix/apr_pools.c
===================================================================
RCS file: /home/cvspublic/apr/memory/unix/apr_pools.c,v
retrieving revision 1.109
diff -u -r1.109 apr_pools.c
--- srclib/apr/memory/unix/apr_pools.c 2001/09/02 18:11:33 1.109
+++ srclib/apr/memory/unix/apr_pools.c 2001/09/16 03:04:50
@@ -1201,7 +1201,9 @@
apr_hash_set(cont->prog_data, key, keylen, data);
}
- apr_pool_cleanup_register(cont, data, cleanup, cleanup);
+ if (cleanup) {
+ apr_pool_cleanup_register(cont, data, cleanup, cleanup);
+ }
return APR_SUCCESS;
}
@@ -1211,6 +1213,38 @@
*data = NULL;
else
*data = apr_hash_get(cont->prog_data, key, strlen(key));
+ return APR_SUCCESS;
+}
+
+APR_DECLARE(apr_status_t) apr_pool_userdata_overlay(apr_pool_t *base,
+ const apr_pool_t *add)
+{
+ apr_hash_index_t *iter;
+ const void *key;
+ apr_ssize_t klen;
+ void *val;
+
+#ifdef POOL_DEBUG
+ if (!apr_pool_is_ancestor(base, add)) {
+ fprintf(stderr, "apr_pool_userdata_overlay: base is not ancestor of add\n");
+ return APR_EGENERAL;
+ }
+#endif /* POOL_DEBUG */
+
+ if (add->prog_data == NULL) {
+ return APR_SUCCESS;
+ }
+
+ if (base->prog_data == NULL) {
+ base->prog_data = apr_hash_make(base);
+ }
+
+ for (iter = apr_hash_first(base, add->prog_data); iter;
+ iter = apr_hash_next(iter)) {
+ apr_hash_this(iter, &key, &klen, &val);
+ apr_hash_set(base->prog_data, key, klen, val);
+ }
+
return APR_SUCCESS;
}