##
## Annotated patch file: eapi.patch
## Copyright (c) 1998-2001 Ralf S. Engelschall, All Rights Reserved.
-## Created on: 18-Mar-2003
+## Created on: 11-May-2004
##
## This file assembles changes to existing Apache source files
## between the original Apache and the patched variant. It can be
| patches and configured the shared memory support via the MM library.
+---------------------------------------------------------------------------
Index: src/Configuration.tmpl
---- src/Configuration.tmpl 28 Jan 2002 19:21:21 -0000 1.1.1.7
-+++ src/Configuration.tmpl 28 Jan 2002 19:40:56 -0000 1.23
+--- src/Configuration.tmpl 11 May 2004 18:28:09 -0000 1.1.1.8
++++ src/Configuration.tmpl 11 May 2004 18:32:15 -0000 1.24
@@ -68,6 +105,24 @@
#TARGET=
| Patch in implementation of the EAPI rule.
+---------------------------------------------------------------------------
Index: src/Configure
---- src/Configure 4 Oct 2002 11:50:12 -0000 1.1.1.20
-+++ src/Configure 4 Oct 2002 11:54:56 -0000 1.23
-@@ -1885,6 +1885,72 @@
+--- src/Configure 11 May 2004 18:28:09 -0000 1.1.1.23
++++ src/Configure 11 May 2004 18:32:15 -0000 1.26
+@@ -1855,6 +1855,72 @@
fi
####################################################################
| Add the build support for the ap_hook.c and ap_ctx.c sources (Win32)
+---------------------------------------------------------------------------
Index: src/ap/ap.mak
---- src/ap/ap.mak 16 Oct 2001 11:47:06 -0000 1.1.1.9
-+++ src/ap/ap.mak 16 Oct 2001 11:57:38 -0000 1.9
-@@ -50,6 +50,9 @@
+--- src/ap/ap.mak 18 Jul 2003 15:44:30 -0000 1.1.1.10
++++ src/ap/ap.mak 18 Jul 2003 15:56:58 -0000 1.10
+@@ -44,6 +44,9 @@
-@erase "$(INTDIR)\ap_cpystrn.obj"
-@erase "$(INTDIR)\ap_fnmatch.obj"
-@erase "$(INTDIR)\ap_md5c.obj"
-@erase "$(INTDIR)\ap_sha1.obj"
-@erase "$(INTDIR)\ap_signal.obj"
-@erase "$(INTDIR)\ap_slack.obj"
-@@ -108,6 +111,9 @@
+@@ -99,6 +102,9 @@
"$(INTDIR)\ap_cpystrn.obj" \
"$(INTDIR)\ap_fnmatch.obj" \
"$(INTDIR)\ap_md5c.obj" \
"$(INTDIR)\ap_sha1.obj" \
"$(INTDIR)\ap_signal.obj" \
"$(INTDIR)\ap_slack.obj" \
-@@ -144,6 +150,9 @@
+@@ -128,6 +134,9 @@
-@erase "$(INTDIR)\ap_cpystrn.obj"
-@erase "$(INTDIR)\ap_fnmatch.obj"
-@erase "$(INTDIR)\ap_md5c.obj"
-@erase "$(INTDIR)\ap_sha1.obj"
-@erase "$(INTDIR)\ap_signal.obj"
-@erase "$(INTDIR)\ap_slack.obj"
-@@ -202,6 +211,9 @@
+@@ -183,6 +192,9 @@
"$(INTDIR)\ap_cpystrn.obj" \
"$(INTDIR)\ap_fnmatch.obj" \
"$(INTDIR)\ap_md5c.obj" \
| EAPI-aware modules and standard modules.
+---------------------------------------------------------------------------
Index: src/include/ap_mmn.h
---- src/include/ap_mmn.h 19 Jun 2002 07:20:24 -0000 1.1.1.11
-+++ src/include/ap_mmn.h 19 Jun 2002 07:29:08 -0000 1.11
-@@ -239,7 +239,23 @@
- * 19990320.13 - add ap_strtol()
+--- src/include/ap_mmn.h 11 May 2004 18:28:12 -0000 1.1.1.13
++++ src/include/ap_mmn.h 11 May 2004 18:32:15 -0000 1.13
+@@ -205,7 +205,23 @@
+ * in core_dir_config.
*/
+/*
| shared memory pools.
+---------------------------------------------------------------------------
Index: src/include/ap_alloc.h
---- src/include/ap_alloc.h 27 Mar 2002 15:22:56 -0000 1.1.1.5
-+++ src/include/ap_alloc.h 27 Mar 2002 15:30:02 -0000 1.6
-@@ -95,6 +95,15 @@
+--- src/include/ap_alloc.h 11 May 2004 18:28:11 -0000 1.1.1.7
++++ src/include/ap_alloc.h 11 May 2004 18:32:15 -0000 1.8
+@@ -52,6 +52,15 @@
API_EXPORT(pool *) ap_init_alloc(void); /* Set up everything */
void ap_cleanup_alloc(void);
API_EXPORT(pool *) ap_make_sub_pool(pool *); /* All pools are subpools of permanent_pool */
| Add the additional context variable `ctx' for BUFF structures.
+---------------------------------------------------------------------------
Index: src/include/buff.h
---- src/include/buff.h 27 Mar 2002 15:22:57 -0000 1.1.1.6
-+++ src/include/buff.h 27 Mar 2002 15:30:02 -0000 1.10
-@@ -125,6 +125,10 @@
+--- src/include/buff.h 11 May 2004 18:28:12 -0000 1.1.1.8
++++ src/include/buff.h 11 May 2004 18:32:15 -0000 1.12
+@@ -82,6 +82,10 @@
/* transport handle, for RPC binding handle or some such */
void *t_handle;
#ifdef B_SFIO
Sfio_t *sf_in;
Sfio_t *sf_out;
-@@ -180,6 +184,10 @@
- /* Internal routines */
+@@ -138,6 +142,10 @@
API_EXPORT(int) ap_bflsbuf(int c, BUFF *fb);
API_EXPORT(int) ap_bfilbuf(BUFF *fb);
-+
+
+#ifdef EAPI
+#define ap_bpeekc(fb) ( ((fb)->incnt == 0) ? EOF : *((fb)->inptr) )
+#endif
-
++
#ifndef CHARSET_EBCDIC
+ #define ap_bgetc(fb) ( ((fb)->incnt == 0) ? ap_bfilbuf(fb) : \
+---------------------------------------------------------------------------
| Add the four additional Apache API module hooks.
+---------------------------------------------------------------------------
Index: src/include/http_config.h
---- src/include/http_config.h 27 Mar 2002 15:22:57 -0000 1.1.1.10
-+++ src/include/http_config.h 27 Mar 2002 15:30:02 -0000 1.12
-@@ -276,6 +276,65 @@
+--- src/include/http_config.h 11 May 2004 18:28:12 -0000 1.1.1.12
++++ src/include/http_config.h 11 May 2004 18:32:15 -0000 1.14
+@@ -233,6 +233,65 @@
void (*child_exit) (server_rec *, pool *);
#endif
int (*post_read_request) (request_rec *);
| global module context.
+---------------------------------------------------------------------------
Index: src/include/http_conf_globals.h
---- src/include/http_conf_globals.h 4 Oct 2002 11:50:14 -0000 1.1.1.12
-+++ src/include/http_conf_globals.h 4 Oct 2002 11:54:56 -0000 1.13
-@@ -95,6 +95,9 @@
+--- src/include/http_conf_globals.h 11 May 2004 18:28:12 -0000 1.1.1.14
++++ src/include/http_conf_globals.h 11 May 2004 18:32:15 -0000 1.15
+@@ -52,6 +52,9 @@
#endif
extern int ap_dump_settings;
extern API_VAR_EXPORT int ap_extended_status;
extern API_VAR_EXPORT char *ap_pid_fname;
extern API_VAR_EXPORT char *ap_scoreboard_fname;
-+---------------------------------------------------------------------------
-| Export the ap_set_callback_and_alarm() function because this
-| first is a useful thing and second we need it because all
-| other API/timeout functions deal with a request_rec while
-| some modules need a generic timeout mechanism.
-+---------------------------------------------------------------------------
-Index: src/include/http_main.h
-
+---------------------------------------------------------------------------
| First add support for the HTTPS protocol scheme via hooks,
| second add the additional context variable `ctx' for the
| add a prototype for the additional ap_add_config_define()
| function.
+---------------------------------------------------------------------------
-Index: src/main/buff.c
---- src/main/buff.c 27 Mar 2002 15:23:00 -0000 1.1.1.12
-+++ src/main/buff.c 27 Mar 2002 15:30:02 -0000 1.20
-@@ -293,6 +293,9 @@
- }
- else
- #endif
-+#ifdef EAPI
-+ if (!ap_hook_call("ap::buff::read", &rv, fb, buf, nbyte))
-+#endif /* EAPI */
- rv = read(fb->fd_in, buf, nbyte);
-
- return rv;
-@@ -304,6 +307,9 @@
+Index: src/include/httpd.h
+--- src/include/httpd.h 11 May 2004 18:28:12 -0000 1.1.1.23
++++ src/include/httpd.h 11 May 2004 18:32:15 -0000 1.33
+@@ -27,7 +27,19 @@
+ /* Headers in which EVERYONE has an interest... */
- #if defined (WIN32) || defined(NETWARE) || defined(CYGWIN_WINSOCK)
- if (fb->flags & B_SOCKET) {
+ #include "ap_config.h"
+#ifdef EAPI
-+ if (!ap_hook_call("ap::buff::recvwithtimeout", &rv, fb, buf, nbyte))
-+#endif /* EAPI */
- rv = ap_recvwithtimeout(fb->fd_in, buf, nbyte, 0);
- if (rv == SOCKET_ERROR)
- errno = WSAGetLastError();
-@@ -351,6 +357,9 @@
- }
- else
- #endif
++#include "ap_mm.h"
++#endif
+ #include "ap_alloc.h"
++/*
++ * Include the Extended API headers.
++ * Don't move the position. It has to be after ap_alloc.h because it uses the
++ * pool stuff but before buff.h because the buffer stuff uses the EAPI, too.
++ */
+#ifdef EAPI
-+ if (!ap_hook_call("ap::buff::write", &rv, fb, buf, nbyte))
++#include "ap_hook.h"
++#include "ap_ctx.h"
+#endif /* EAPI */
- #if defined (B_SFIO)
- rv = sfwrite(fb->sf_out, buf, nbyte);
+ #include "buff.h"
+ #include "ap.h"
+
+@@ -102,8 +114,13 @@
+ #define ap_http_method(r) ap_os_http_method((void*)r)
+ #define ap_default_port(r) ap_os_default_port((void*)r)
#else
-@@ -381,6 +390,9 @@
-
- #if defined(WIN32) || defined(NETWARE)
- if (fb->flags & B_SOCKET) {
+#ifdef EAPI
-+ if (!ap_hook_call("ap::buff::sendwithtimeout", &rv, fb, buf, nbyte))
++#define ap_http_method(r) (((r)->ctx != NULL && ap_ctx_get((r)->ctx, "ap::http::method") != NULL) ? ((char *)ap_ctx_get((r)->ctx, "ap::http::method")) : "http")
++#define ap_default_port(r) (((r)->ctx != NULL && ap_ctx_get((r)->ctx, "ap::default::port") != NULL) ? atoi((char *)ap_ctx_get((r)->ctx, "ap::default::port")) : DEFAULT_HTTP_PORT)
++#else /* EAPI */
+ #define ap_http_method(r) "http"
+ #define ap_default_port(r) DEFAULT_HTTP_PORT
+#endif /* EAPI */
- rv = ap_sendwithtimeout(fb->fd, buf, nbyte, 0);
- if (rv == SOCKET_ERROR)
- errno = WSAGetLastError();
-@@ -464,6 +476,10 @@
- fb->callback_data = NULL;
- fb->filter_callback = NULL;
+ #endif
-+#ifdef EAPI
-+ fb->ctx = ap_ctx_new(p);
-+#endif /* EAPI */
-+
- return fb;
- }
+ /* --------- Default user name and group name running standalone ---------- */
+@@ -312,6 +329,19 @@
+ #define SCOREBOARD_MAINTENANCE_INTERVAL 1000000
+ #endif
-@@ -1116,6 +1132,9 @@
- i = 0;
- while (i < nvec) {
- do
++/*
++ * Unix only:
++ * Path to Shared Memory Files
++ */
+#ifdef EAPI
-+ if (!ap_hook_call("ap::buff::writev", &rv, fb, &vec[i], nvec -i))
-+#endif /* EAPI */
- rv = writev(fb->fd, &vec[i], nvec - i);
- while (rv == -1 && (errno == EINTR || errno == EAGAIN)
- && !(fb->flags & B_EOUT));
-
-+---------------------------------------------------------------------------
-| Add the implementation of the additional `add_module' and
-| `rewrite_command' module hooks. Additionally the `ctx'
-| variables are initialized.
-+---------------------------------------------------------------------------
-Index: src/main/http_config.c
---- src/main/http_config.c 4 Oct 2002 11:50:15 -0000 1.1.1.15
-+++ src/main/http_config.c 4 Oct 2002 11:54:56 -0000 1.18
-@@ -600,6 +600,20 @@
- m->name = tmp;
- }
- #endif /*_OSD_POSIX*/
++#ifndef EAPI_MM_CORE_PATH
++#define EAPI_MM_CORE_PATH "logs/mm"
++#endif
++#ifndef EAPI_MM_CORE_MAXSIZE
++#define EAPI_MM_CORE_MAXSIZE 1024*1024*1 /* max. 1MB */
++#endif
++#endif
+
+ /* Number of requests to try to handle in a single process. If <= 0,
+ * the children don't die off. That's the default here, since I'm still
+ * interested in finding and stanching leaks.
+@@ -404,6 +434,9 @@
+ API_EXPORT(const char *) ap_get_server_version(void);
+ API_EXPORT(void) ap_add_version_component(const char *component);
+ API_EXPORT(const char *) ap_get_server_built(void);
+#ifdef EAPI
-+ /*
-+ * Invoke the `add_module' hook inside the now existing set
-+ * of modules to let them all now that this module was added.
-+ */
-+ {
-+ module *m2;
-+ for (m2 = top_module; m2 != NULL; m2 = m2->next)
-+ if (m2->magic == MODULE_MAGIC_COOKIE_EAPI)
-+ if (m2->add_module != NULL)
-+ (*m2->add_module)(m);
-+ }
++API_EXPORT(void) ap_add_config_define(const char *define);
+#endif /* EAPI */
- }
- /*
-@@ -614,6 +628,21 @@
- {
- module *modp;
-
-+#ifdef EAPI
-+ /*
-+ * Invoke the `remove_module' hook inside the now existing
-+ * set of modules to let them all now that this module is
-+ * beeing removed.
-+ */
-+ {
-+ module *m2;
-+ for (m2 = top_module; m2 != NULL; m2 = m2->next)
-+ if (m2->magic == MODULE_MAGIC_COOKIE_EAPI)
-+ if (m2->remove_module != NULL)
-+ (*m2->remove_module)(m);
-+ }
-+#endif /* EAPI */
+ /* Numeric release version identifier: MMNNFFRBB: major minor fix final beta
+ * Always increases along the same track as the source branch.
+@@ -807,6 +840,10 @@
+ * record to improve 64bit alignment the next time we need to break
+ * binary compatibility for some other reason.
+ */
+
- modp = top_module;
- if (modp == m) {
- /* We are the top module, special case */
-@@ -1007,6 +1036,27 @@
- const command_rec *cmd;
- module *mod = top_module;
-
+#ifdef EAPI
-+ /*
-+ * Invoke the `rewrite_command' of modules to allow
-+ * they to rewrite the directive line before we
-+ * process it.
-+ */
-+ {
-+ module *m;
-+ char *cp;
-+ for (m = top_module; m != NULL; m = m->next) {
-+ if (m->magic == MODULE_MAGIC_COOKIE_EAPI) {
-+ if (m->rewrite_command != NULL) {
-+ cp = (m->rewrite_command)(parms, config, l);
-+ if (cp != NULL)
-+ l = cp;
-+ }
-+ }
-+ }
-+ }
++ ap_ctx *ctx;
+#endif /* EAPI */
-+
- if ((l[0] == '#') || (!l[0]))
- return NULL;
+ };
-@@ -1467,6 +1517,10 @@
- s->limit_req_fieldsize = main_server->limit_req_fieldsize;
- s->limit_req_fields = main_server->limit_req_fields;
+@@ -855,6 +892,9 @@
+ char *local_host; /* used for ap_get_server_name when
+ * UseCanonicalName is set to DNS
+ * (ignores setting of HostnameLookups) */
+#ifdef EAPI
-+ s->ctx = ap_ctx_new(p);
++ ap_ctx *ctx;
+#endif /* EAPI */
-+
- *ps = s;
-
- return ap_parse_vhost_addrs(p, hostname, s);
-@@ -1577,6 +1631,10 @@
+ };
- s->module_config = create_server_config(p, s);
- s->lookup_defaults = create_default_per_dir_config(p);
+ /* Per-vhost config... */
+@@ -927,6 +967,10 @@
+ int limit_req_line; /* limit on size of the HTTP request line */
+ int limit_req_fieldsize; /* limit on size of any request header field */
+ int limit_req_fields; /* limit on number of request header fields */
+
+#ifdef EAPI
-+ s->ctx = ap_ctx_new(p);
++ ap_ctx *ctx;
+#endif /* EAPI */
+ };
- return s;
- }
+ /* These are more like real hosts than virtual hosts */
+---------------------------------------------------------------------------
-| Add the ap_global_ctx variable and the new
-| ap_add_config_define() function. Additionally the
-| implementation of the additional `new_connection' module hook
-| is added plus the initialization of one more `ctx' variable.
+| Patch the shared memory pool support into the Apache pool facility.
+---------------------------------------------------------------------------
-Index: src/main/http_main.c
---- src/main/http_main.c 4 Oct 2002 11:50:15 -0000 1.1.1.19
-+++ src/main/http_main.c 4 Oct 2002 11:54:56 -0000 1.41
-@@ -279,6 +279,9 @@
+Index: src/main/alloc.c
+--- src/main/alloc.c 11 May 2004 18:28:13 -0000 1.1.1.16
++++ src/main/alloc.c 11 May 2004 18:32:15 -0000 1.25
+@@ -21,6 +21,10 @@
+ */
- int ap_dump_settings = 0;
- API_VAR_EXPORT int ap_extended_status = 0;
+ #include "httpd.h"
+#ifdef EAPI
-+API_VAR_EXPORT ap_ctx *ap_global_ctx;
-+#endif /* EAPI */
-
- /*
- * The max child slot ever assigned, preserved across restarts. Necessary
-@@ -469,6 +472,30 @@
- }
- }
++#include "http_config.h"
++#include "http_conf_globals.h"
++#endif
+ #include "multithread.h"
+ #include "http_log.h"
-+#ifdef EAPI
-+API_EXPORT(void) ap_add_config_define(const char *define)
-+{
-+ char **var;
-+ var = (char **)ap_push_array(ap_server_config_defines);
-+ *var = ap_pstrdup(pcommands, define);
-+ return;
-+}
-+
-+/*
-+ * Invoke the `close_connection' hook of modules to let them do
-+ * some connection dependent actions before we close it.
-+ */
-+static void ap_call_close_connection_hook(conn_rec *c)
-+{
-+ module *m;
-+ for (m = top_module; m != NULL; m = m->next)
-+ if (m->magic == MODULE_MAGIC_COOKIE_EAPI)
-+ if (m->close_connection != NULL)
-+ (*m->close_connection)(c);
-+ return;
-+}
-+#endif /* EAPI */
-+
- #ifndef NETWARE
- static APACHE_TLS int volatile exit_after_unblock = 0;
+@@ -95,6 +99,10 @@
+ #define BLOCK_MINALLOC 0
#endif
-@@ -1523,6 +1550,10 @@
- ap_log_transaction(log_req);
- }
-+#ifdef EAPI
-+ ap_call_close_connection_hook(save_req->connection);
-+#endif /* EAPI */
++#if defined(EAPI) && defined(EAPI_MM)
++static AP_MM *mm = NULL;
++#endif
+
- ap_bsetflag(save_req->connection->client, B_EOUT, 1);
- ap_bclose(save_req->connection->client);
-
-@@ -1531,6 +1562,9 @@
- ap_longjmp(jmpbuffer, 1);
- }
- else { /* abort the connection */
-+#ifdef EAPI
-+ ap_call_close_connection_hook(current_conn);
-+#endif /* EAPI */
- ap_bsetflag(current_conn->client, B_EOUT, 1);
- ap_bclose(current_conn->client);
- current_conn->aborted = 1;
-@@ -1833,10 +1867,16 @@
- /* Send any leftover data to the client, but never try to again */
+ /*****************************************************************
+ *
+ * Managing free storage blocks...
+@@ -123,6 +131,9 @@
+ char *endp;
+ union block_hdr *next;
+ char *first_avail;
++#if defined(EAPI) && defined(EAPI_MM)
++ int is_shm;
++#endif
+ #ifdef POOL_DEBUG
+ union block_hdr *global_next;
+ struct pool *owning_pool;
+@@ -173,7 +184,11 @@
+ /* Get a completely new block from the system pool. Note that we rely on
+ malloc() to provide aligned memory. */
- if (ap_bflush(r->connection->client) == -1) {
-+#ifdef EAPI
-+ ap_call_close_connection_hook(r->connection);
-+#endif /* EAPI */
- ap_kill_timeout(r);
- ap_bclose(r->connection->client);
- return;
++#if defined(EAPI) && defined(EAPI_MM)
++static union block_hdr *malloc_block(int size, int is_shm)
++#else
+ static union block_hdr *malloc_block(int size)
++#endif
+ {
+ union block_hdr *blok;
+ int request_size;
+@@ -189,6 +204,11 @@
+ num_malloc_bytes += size + sizeof(union block_hdr);
+ #endif
+ request_size = size + sizeof(union block_hdr);
++#if defined(EAPI) && defined(EAPI_MM)
++ if (is_shm)
++ blok = (union block_hdr *)ap_mm_malloc(mm, request_size);
++ else
++#endif
+ blok = (union block_hdr *) malloc(request_size);
+ if (blok == NULL) {
+ fprintf(stderr, "Ouch! malloc(%d) failed in malloc_block()\n",
+@@ -196,6 +216,9 @@
+ exit(1);
}
-+#ifdef EAPI
-+ ap_call_close_connection_hook(r->connection);
-+#endif /* EAPI */
- ap_bsetflag(r->connection->client, B_EOUT, 1);
+ debug_fill(blok, size + sizeof(union block_hdr));
++#if defined(EAPI) && defined(EAPI_MM)
++ blok->h.is_shm = is_shm;
++#endif
+ blok->h.next = NULL;
+ blok->h.first_avail = (char *) (blok + 1);
+ blok->h.endp = size + blok->h.first_avail;
+@@ -256,6 +279,10 @@
+ if (blok == NULL)
+ return; /* Sanity check --- freeing empty pool? */
- /* Close our half of the connection --- send the client a FIN */
-@@ -2566,6 +2606,9 @@
- /* Clear the pool - including any registered cleanups */
- ap_destroy_pool(pglobal);
++#if defined(EAPI) && defined(EAPI_MM)
++ if (blok->h.is_shm)
++ (void)ap_mm_lock(mm, AP_MM_LOCK_RW);
++#endif
+ (void) ap_acquire_mutex(alloc_mutex);
+ old_free_list = block_freelist;
+ block_freelist = blok;
+@@ -302,6 +329,10 @@
#endif
-+#ifdef EAPI
-+ ap_kill_alloc_shared();
+
+ (void) ap_release_mutex(alloc_mutex);
++#if defined(EAPI) && defined(EAPI_MM)
++ if (blok->h.is_shm)
++ (void)ap_mm_unlock(mm);
+#endif
- exit(code);
+ #endif
}
-@@ -3577,6 +3620,24 @@
- conn->remote_addr = *remaddr;
- conn->remote_ip = ap_pstrdup(conn->pool,
- inet_ntoa(conn->remote_addr.sin_addr));
-+#ifdef EAPI
-+ conn->ctx = ap_ctx_new(conn->pool);
-+#endif /* EAPI */
-+
-+#ifdef EAPI
-+ /*
-+ * Invoke the `new_connection' hook of modules to let them do
-+ * some connection dependent actions before we go on with
-+ * processing the request on this connection.
-+ */
-+ {
-+ module *m;
-+ for (m = top_module; m != NULL; m = m->next)
-+ if (m->magic == MODULE_MAGIC_COOKIE_EAPI)
-+ if (m->new_connection != NULL)
-+ (*m->new_connection)(conn);
-+ }
-+#endif /* EAPI */
+@@ -310,7 +341,11 @@
+ * if necessary. Must be called with alarms blocked.
+ */
- return conn;
- }
-@@ -4005,6 +4066,15 @@
- printf("Server's Module Magic Number: %u:%u\n",
- MODULE_MAGIC_NUMBER_MAJOR, MODULE_MAGIC_NUMBER_MINOR);
- printf("Server compiled with....\n");
-+#ifdef EAPI
-+ printf(" -D EAPI\n");
++#if defined(EAPI) && defined(EAPI_MM)
++static union block_hdr *new_block(int min_size, int is_shm)
++#else
+ static union block_hdr *new_block(int min_size)
+#endif
-+#ifdef EAPI_MM
-+ printf(" -D EAPI_MM\n");
-+#ifdef EAPI_MM_CORE_PATH
-+ printf(" -D EAPI_MM_CORE_PATH=\"" EAPI_MM_CORE_PATH "\"\n");
+ {
+ union block_hdr **lastptr = &block_freelist;
+ union block_hdr *blok = block_freelist;
+@@ -320,7 +355,12 @@
+ */
+
+ while (blok != NULL) {
++#if defined(EAPI) && defined(EAPI_MM)
++ if (blok->h.is_shm == is_shm &&
++ min_size + BLOCK_MINFREE <= blok->h.endp - blok->h.first_avail) {
++#else
+ if (min_size + BLOCK_MINFREE <= blok->h.endp - blok->h.first_avail) {
+#endif
+ *lastptr = blok->h.next;
+ blok->h.next = NULL;
+ debug_verify_filled(blok->h.first_avail, blok->h.endp,
+@@ -336,7 +376,11 @@
+ /* Nope. */
+
+ min_size += BLOCK_MINFREE;
++#if defined(EAPI) && defined(EAPI_MM)
++ blok = malloc_block((min_size > BLOCK_MINALLOC) ? min_size : BLOCK_MINALLOC, is_shm);
++#else
+ blok = malloc_block((min_size > BLOCK_MINALLOC) ? min_size : BLOCK_MINALLOC);
+#endif
- #ifdef TPF
- show_os_specific_compile_settings();
- #endif
-@@ -4175,6 +4245,22 @@
- ap_server_pre_read_config = ap_make_array(pcommands, 1, sizeof(char *));
- ap_server_post_read_config = ap_make_array(pcommands, 1, sizeof(char *));
- ap_server_config_defines = ap_make_array(pcommands, 1, sizeof(char *));
-+
-+#ifdef EAPI
-+ ap_hook_init();
-+ ap_hook_configure("ap::buff::read",
-+ AP_HOOK_SIG4(int,ptr,ptr,int), AP_HOOK_TOPMOST);
-+ ap_hook_configure("ap::buff::write",
-+ AP_HOOK_SIG4(int,ptr,ptr,int), AP_HOOK_TOPMOST);
-+ ap_hook_configure("ap::buff::writev",
-+ AP_HOOK_SIG4(int,ptr,ptr,int), AP_HOOK_TOPMOST);
-+ ap_hook_configure("ap::buff::sendwithtimeout",
-+ AP_HOOK_SIG4(int,ptr,ptr,int), AP_HOOK_TOPMOST);
-+ ap_hook_configure("ap::buff::recvwithtimeout",
-+ AP_HOOK_SIG4(int,ptr,ptr,int), AP_HOOK_TOPMOST);
-+
-+ ap_global_ctx = ap_ctx_new(NULL);
-+#endif /* EAPI */
+ return blok;
}
- #ifndef MULTITHREAD
-@@ -4625,6 +4711,9 @@
+@@ -386,6 +430,9 @@
+ #ifdef POOL_DEBUG
+ struct pool *joined;
+ #endif
++#if defined(EAPI) && defined(EAPI_MM)
++ int is_shm;
++#endif
+ };
- ap_sync_scoreboard_image();
- if (ap_scoreboard_image->global.running_generation != ap_my_generation) {
-+#ifdef EAPI
-+ ap_call_close_connection_hook(current_conn);
-+#endif /* EAPI */
- ap_bclose(conn_io);
- clean_child_exit(0);
- }
-@@ -4653,6 +4742,9 @@
- */
+ static pool *permanent_pool;
+@@ -400,16 +447,28 @@
+ #define POOL_HDR_CLICKS (1 + ((sizeof(struct pool) - 1) / CLICK_SZ))
+ #define POOL_HDR_BYTES (POOL_HDR_CLICKS * CLICK_SZ)
- #ifdef NO_LINGCLOSE
-+#ifdef EAPI
-+ ap_call_close_connection_hook(current_conn);
-+#endif /* EAPI */
- ap_bclose(conn_io); /* just close it */
- #else
- if (r && r->connection
-@@ -4663,6 +4755,9 @@
- lingering_close(r);
- }
- else {
-+#ifdef EAPI
-+ ap_call_close_connection_hook(current_conn);
-+#endif /* EAPI */
- ap_bsetflag(conn_io, B_EOUT, 1);
- ap_bclose(conn_io);
- }
-@@ -5428,16 +5523,31 @@
- usage(argv[0]);
- }
- }
-+#ifdef EAPI
-+ ap_init_alloc_shared(TRUE);
++#if defined(EAPI) && defined(EAPI_MM)
++static struct pool *make_sub_pool_internal(struct pool *p, int is_shm)
++#else
+ API_EXPORT(struct pool *) ap_make_sub_pool(struct pool *p)
+#endif
+ {
+ union block_hdr *blok;
+ pool *new_pool;
- ap_suexec_enabled = init_suexec();
- server_conf = ap_read_config(pconf, ptrans, ap_server_confname);
+ ap_block_alarms();
-+#ifdef EAPI
-+ ap_init_alloc_shared(FALSE);
++#if defined(EAPI) && defined(EAPI_MM)
++ if (is_shm)
++ (void)ap_mm_lock(mm, AP_MM_LOCK_RW);
+#endif
-+
- if (ap_configtestonly) {
- fprintf(stderr, "Syntax OK\n");
-+#ifdef EAPI
-+ clean_parent_exit(0);
+ (void) ap_acquire_mutex(alloc_mutex);
+
++#if defined(EAPI) && defined(EAPI_MM)
++ blok = new_block(POOL_HDR_BYTES, is_shm);
+#else
- exit(0);
+ blok = new_block(POOL_HDR_BYTES);
+#endif
+ new_pool = (pool *) blok->h.first_avail;
+ blok->h.first_avail += POOL_HDR_BYTES;
+ #ifdef POOL_DEBUG
+@@ -428,12 +487,38 @@
+ p->sub_pools = new_pool;
}
- if (ap_dump_settings) {
-+#ifdef EAPI
-+ clean_parent_exit(0);
-+#else
- exit(0);
+
++#if defined(EAPI) && defined(EAPI_MM)
++ new_pool->is_shm = is_shm;
+#endif
- }
++
+ (void) ap_release_mutex(alloc_mutex);
++#if defined(EAPI) && defined(EAPI_MM)
++ if (is_shm)
++ (void)ap_mm_unlock(mm);
++#endif
+ ap_unblock_alarms();
- child_timeouts = !ap_standalone || one_process;
-@@ -5585,6 +5695,10 @@
- ap_destroy_pool(r->pool);
- }
+ return new_pool;
+ }
-+#ifdef EAPI
-+ ap_call_close_connection_hook(conn);
-+#endif /* EAPI */
-+
- ap_bclose(cio);
- }
- exit(0);
-@@ -5961,6 +6075,9 @@
- ap_kill_cleanups_for_socket(ptrans, csd);
-
- #ifdef NO_LINGCLOSE
-+#ifdef EAPI
-+ ap_call_close_connection_hook(current_conn);
-+#endif /* EAPI */
- ap_bclose(conn_io); /* just close it */
- #else
- if (r && r->connection
-@@ -5971,6 +6088,9 @@
- lingering_close(r);
- }
- else {
-+#ifdef EAPI
-+ ap_call_close_connection_hook(current_conn);
-+#endif /* EAPI */
- ap_bsetflag(conn_io, B_EOUT, 1);
- ap_bclose(conn_io);
- }
-@@ -7539,6 +7659,10 @@
- if (!conf_specified)
- ap_cpystrn(ap_server_confname, SERVER_CONFIG_FILE, sizeof(ap_server_confname));
-
-+#ifdef EAPI
-+ ap_init_alloc_shared(TRUE);
++#if defined(EAPI)
++#if defined(EAPI_MM)
++API_EXPORT(struct pool *) ap_make_sub_pool(struct pool *p)
++{
++ return make_sub_pool_internal(p, 0);
++}
++API_EXPORT(struct pool *) ap_make_shared_sub_pool(struct pool *p)
++{
++ return make_sub_pool_internal(p, 1);
++}
++#else
++API_EXPORT(struct pool *) ap_make_shared_sub_pool(struct pool *p)
++{
++ return NULL;
++}
+#endif
-+
- if (!ap_os_is_path_absolute(ap_server_confname))
- ap_cpystrn(ap_server_confname,
- ap_server_root_relative(pcommands, ap_server_confname),
-@@ -7578,6 +7702,9 @@
- }
- #else /* ndef WIN32 */
- server_conf = ap_read_config(pconf, ptrans, ap_server_confname);
+#endif
-+#ifdef EAPI
-+ ap_init_alloc_shared(FALSE);
++
+ #ifdef POOL_DEBUG
+ static void stack_var_init(char *s)
+ {
+@@ -448,6 +533,13 @@
+ }
#endif
- if (ap_configtestonly) {
-
-+---------------------------------------------------------------------------
-| Just add the initialization of the `ctx' variable for
-| conn_rec structures.
-+---------------------------------------------------------------------------
-Index: src/main/http_request.c
---- src/main/http_request.c 19 Jun 2002 07:20:26 -0000 1.1.1.15
-+++ src/main/http_request.c 19 Jun 2002 07:29:09 -0000 1.15
-@@ -1375,6 +1375,10 @@
-
- new->method = r->method;
- new->method_number = r->method_number;
-+#ifdef EAPI
-+ /* initialize context _BEFORE_ ap_parse_uri() call */
-+ new->ctx = r->ctx;
-+#endif /* EAPI */
- ap_parse_uri(new, new_uri);
- new->request_config = ap_create_request_config(r->pool);
- new->per_dir_config = r->server->lookup_defaults;
-
-+---------------------------------------------------------------------------
-| Just add the initialization of the `ctx' variable for
-| request_rec structures.
-+---------------------------------------------------------------------------
-Index: src/main/http_protocol.c
---- src/main/http_protocol.c 4 Oct 2002 11:50:15 -0000 1.1.1.18
-+++ src/main/http_protocol.c 4 Oct 2002 11:54:56 -0000 1.18
-@@ -1203,6 +1203,10 @@
- r->status = HTTP_REQUEST_TIME_OUT; /* Until we get a request */
- r->the_request = NULL;
-
-+#ifdef EAPI
-+ r->ctx = ap_ctx_new(r->pool);
-+#endif /* EAPI */
++#if defined(EAPI)
++int ap_shared_pool_possible(void)
++{
++ return ap_mm_useable();
++}
++#endif
+
- #ifdef CHARSET_EBCDIC
- ap_bsetflag(r->connection->client, B_ASCII2EBCDIC, r->ebcdic.conv_in = 1);
- ap_bsetflag(r->connection->client, B_EBCDIC2ASCII, r->ebcdic.conv_out = 1);
-@@ -1359,6 +1363,11 @@
- rnew->read_body = REQUEST_NO_BODY;
+ #ifdef ALLOC_STATS
+ static void dump_stats(void)
+ {
+@@ -480,6 +572,58 @@
+ return permanent_pool;
+ }
- rnew->main = (request_rec *) r;
++#if defined(EAPI)
++void ap_init_alloc_shared(int early)
++{
++#if defined(EAPI_MM)
++ int mm_size;
++ char *mm_path;
++ char *err1, *err2;
+
-+#ifdef EAPI
-+ rnew->ctx = r->ctx;
++ if (early) {
++ /* process very early on startup */
++ mm_size = ap_mm_maxsize();
++ if (mm_size > EAPI_MM_CORE_MAXSIZE)
++ mm_size = EAPI_MM_CORE_MAXSIZE;
++ mm_path = ap_server_root_relative(permanent_pool,
++ ap_psprintf(permanent_pool, "%s.%ld",
++ EAPI_MM_CORE_PATH, (long)getpid()));
++ if ((mm = ap_mm_create(mm_size, mm_path)) == NULL) {
++ fprintf(stderr, "Ouch! ap_mm_create(%d, \"%s\") failed\n", mm_size, mm_path);
++ err1 = ap_mm_error();
++ if (err1 == NULL)
++ err1 = "-unknown-";
++ err2 = strerror(errno);
++ if (err2 == NULL)
++ err2 = "-unknown-";
++ fprintf(stderr, "Error: MM: %s: OS: %s\n", err1, err2);
++ exit(1);
++ }
++ }
++ else {
++ /* process a lot later on startup */
++#ifdef WIN32
++ ap_mm_permission(mm, (_S_IREAD|_S_IWRITE), ap_user_id, -1);
++#else
++ ap_mm_permission(mm, (S_IRUSR|S_IWUSR), ap_user_id, -1);
++#endif
++ }
++#endif /* EAPI_MM */
++ return;
++}
++
++void ap_kill_alloc_shared(void)
++{
++#if defined(EAPI_MM)
++ if (mm != NULL) {
++ ap_mm_destroy(mm);
++ mm = NULL;
++ }
++#endif /* EAPI_MM */
++ return;
++}
+#endif /* EAPI */
+
- }
+ void ap_cleanup_alloc(void)
+ {
+ ap_destroy_mutex(alloc_mutex);
+@@ -490,10 +634,18 @@
+ {
+ ap_block_alarms();
- API_EXPORT(void) ap_finalize_sub_req_protocol(request_rec *sub)
-
-+---------------------------------------------------------------------------
-| Add support for loading both EAPI and AP13 modules.
-+---------------------------------------------------------------------------
-Index: src/modules/standard/mod_so.c
---- src/modules/standard/mod_so.c 27 Mar 2002 15:23:06 -0000 1.1.1.9
-+++ src/modules/standard/mod_so.c 27 Mar 2002 15:30:03 -0000 1.10
-@@ -269,11 +269,24 @@
- * Make sure the found module structure is really a module structure
- *
- */
-+#ifdef EAPI
-+ if ( modp->magic != MODULE_MAGIC_COOKIE_AP13
-+ && modp->magic != MODULE_MAGIC_COOKIE_EAPI) {
-+#else
- if (modp->magic != MODULE_MAGIC_COOKIE) {
++#if defined(EAPI) && defined(EAPI_MM)
++ if (a->is_shm)
++ (void)ap_mm_lock(mm, AP_MM_LOCK_RW);
+#endif
- return ap_pstrcat(cmd->pool, "API module structure `", modname,
- "' in file ", szModuleFile, " is garbled -"
- " perhaps this is not an Apache module DSO?", NULL);
- }
-+#ifdef EAPI
-+ if (modp->magic == MODULE_MAGIC_COOKIE_AP13) {
-+ ap_log_error(APLOG_MARK, APLOG_WARNING|APLOG_NOERRNO, NULL,
-+ "Loaded DSO %s uses plain Apache 1.3 API, "
-+ "this module might crash under EAPI! "
-+ "(please recompile it with -DEAPI)", filename);
-+ }
+ (void) ap_acquire_mutex(alloc_mutex);
+ while (a->sub_pools)
+ ap_destroy_pool(a->sub_pools);
+ (void) ap_release_mutex(alloc_mutex);
++#if defined(EAPI) && defined(EAPI_MM)
++ if (a->is_shm)
++ (void)ap_mm_unlock(mm);
+#endif
+ /* Don't hold the mutex during cleanups. */
+ run_cleanups(a->cleanups);
+ a->cleanups = NULL;
+@@ -527,6 +679,10 @@
+ ap_block_alarms();
+ ap_clear_pool(a);
- /*
- * Add this module to the Apache core structures
-
-+---------------------------------------------------------------------------
-| Add additional logging functions to the CustomLog directive
-| which can be used by other modules to create additional
-| logfile tags. Actually we add two types of hooks: One hook
-| for intercepting the new and generic %x (eXtension) tag and
-| one hook for creating new %x tags at all.
-+---------------------------------------------------------------------------
-Index: src/modules/standard/mod_log_config.c
---- src/modules/standard/mod_log_config.c 19 Jun 2002 07:20:30 -0000 1.1.1.13
-+++ src/modules/standard/mod_log_config.c 19 Jun 2002 07:29:09 -0000 1.26
-@@ -262,6 +262,9 @@
- typedef const char *(*item_key_func) (request_rec *, char *);
-
- typedef struct {
-+#ifdef EAPI
-+ char ch;
++#if defined(EAPI) && defined(EAPI_MM)
++ if (a->is_shm)
++ (void)ap_mm_lock(mm, AP_MM_LOCK_RW);
+#endif
- item_key_func func;
- char *arg;
- int condition_sense;
-@@ -580,15 +583,36 @@
+ (void) ap_acquire_mutex(alloc_mutex);
+ if (a->parent) {
+ if (a->parent->sub_pools == a)
+@@ -537,6 +693,10 @@
+ a->sub_next->sub_prev = a->sub_prev;
}
- };
-
-+#ifdef EAPI
-+static struct log_item_list *find_log_func(pool *p, char k)
-+#else /* EAPI */
- static struct log_item_list *find_log_func(char k)
-+#endif /* EAPI */
- {
- int i;
-+#ifdef EAPI
-+ struct log_item_list *lil;
-+#endif /* EAPI */
+ (void) ap_release_mutex(alloc_mutex);
++#if defined(EAPI) && defined(EAPI_MM)
++ if (a->is_shm)
++ (void)ap_mm_unlock(mm);
++#endif
- for (i = 0; log_item_keys[i].ch; ++i)
- if (k == log_item_keys[i].ch) {
- return &log_item_keys[i];
- }
+ free_blocks(a->first);
+ ap_unblock_alarms();
+@@ -551,6 +711,30 @@
+ return bytes_in_block_list(block_freelist);
+ }
-+#ifdef EAPI
-+ if (ap_hook_status(ap_psprintf(p, "ap::mod_log_config::log_%c", k))
-+ != AP_HOOK_STATE_NOTEXISTANT) {
-+ lil = (struct log_item_list *)
-+ ap_pcalloc(p, sizeof(struct log_item_list));
-+ if (lil == NULL)
-+ return NULL;
-+ lil->ch = k;
-+ lil->func = NULL;
-+ lil->want_orig_default = 0;
-+ return lil;
-+ }
++#if defined(EAPI)
++API_EXPORT(int) ap_acquire_pool(pool *p, ap_pool_lock_mode mode)
++{
++#if defined(EAPI_MM)
++ if (!p->is_shm)
++ return 1;
++ return ap_mm_lock(mm, mode == AP_POOL_RD ? AP_MM_LOCK_RD : AP_MM_LOCK_RW);
++#else
++ return 1;
++#endif
++}
++
++API_EXPORT(int) ap_release_pool(pool *p)
++{
++#if defined(EAPI_MM)
++ if (!p->is_shm)
++ return 1;
++ return ap_mm_unlock(mm);
++#else
++ return 1;
++#endif
++}
+#endif /* EAPI */
+
- return NULL;
- }
+ /*****************************************************************
+ * POOL_DEBUG support
+ */
+@@ -716,16 +900,31 @@
-@@ -714,7 +738,11 @@
- break;
+ ap_block_alarms();
- default:
-+#ifdef EAPI
-+ l = find_log_func(p, *s++);
-+#else /* EAPI */
- l = find_log_func(*s++);
-+#endif /* EAPI */
- if (!l) {
- char dummy[2];
++#if defined(EAPI) && defined(EAPI_MM)
++ if (a->is_shm)
++ (void)ap_mm_lock(mm, AP_MM_LOCK_RW);
++#endif
+ (void) ap_acquire_mutex(alloc_mutex);
-@@ -723,6 +751,9 @@
- return ap_pstrcat(p, "Unrecognized LogFormat directive %",
- dummy, NULL);
- }
-+#ifdef EAPI
-+ it->ch = s[-1];
++#if defined(EAPI) && defined(EAPI_MM)
++ blok = new_block(size, a->is_shm);
++#else
+ blok = new_block(size);
++#endif
+ a->last->h.next = blok;
+ a->last = blok;
+ #ifdef POOL_DEBUG
+ blok->h.owning_pool = a;
+ #endif
++#if defined(EAPI) && defined(EAPI_MM)
++ blok->h.is_shm = a->is_shm;
+#endif
- it->func = l->func;
- if (it->want_orig == -1) {
- it->want_orig = l->want_orig_default;
-@@ -784,6 +815,15 @@
- /* We do. Do it... */
+ (void) ap_release_mutex(alloc_mutex);
++#if defined(EAPI) && defined(EAPI_MM)
++ if (a->is_shm)
++ (void)ap_mm_unlock(mm);
++#endif
-+#ifdef EAPI
-+ if (item->func == NULL) {
-+ cp = NULL;
-+ ap_hook_use(ap_psprintf(r->pool, "ap::mod_log_config::log_%c", item->ch),
-+ AP_HOOK_SIG3(ptr,ptr,ptr), AP_HOOK_DECLINE(NULL),
-+ &cp, r, item->arg);
-+ }
+ ap_unblock_alarms();
+
+@@ -842,6 +1041,11 @@
+ size = cur_len << 1;
+ if (size < AP_PSPRINTF_MIN_SIZE)
+ size = AP_PSPRINTF_MIN_SIZE;
++#if defined(EAPI) && defined(EAPI_MM)
++ if (ps->block->h.is_shm)
++ ptr = ap_mm_realloc(ps->base, size);
+ else
+#endif
- cp = (*item->func) (item->want_orig ? orig : r, item->arg);
- return cp ? cp : "-";
- }
-
-+---------------------------------------------------------------------------
-| Allow RewriteCond and RewriteRule directives to lookup
-| variables from other modules.
-+---------------------------------------------------------------------------
-Index: src/modules/standard/mod_rewrite.c
---- src/modules/standard/mod_rewrite.c 4 Oct 2002 11:50:18 -0000 1.1.1.16
-+++ src/modules/standard/mod_rewrite.c 4 Oct 2002 11:54:56 -0000 1.14
-@@ -3691,6 +3691,15 @@
- }
- #endif /* ndef WIN32 && NETWARE*/
+ ptr = realloc(ps->base, size);
+ if (ptr == NULL) {
+ fputs("Ouch! Out of memory!\n", stderr);
+@@ -865,9 +1069,21 @@
+ size = AP_PSPRINTF_MIN_SIZE;
-+#ifdef EAPI
-+ else {
-+ ap_hook_use("ap::mod_rewrite::lookup_variable",
-+ AP_HOOK_SIG3(ptr,ptr,ptr),
-+ AP_HOOK_DECLINE(NULL),
-+ &result, r, var);
-+ }
+ /* must try another blok */
++#if defined(EAPI) && defined(EAPI_MM)
++ if (blok->h.is_shm)
++ (void)ap_mm_lock(mm, AP_MM_LOCK_RW);
++#endif
+ (void) ap_acquire_mutex(alloc_mutex);
++#if defined(EAPI) && defined(EAPI_MM)
++ nblok = new_block(size, blok->h.is_shm);
++#else
+ nblok = new_block(size);
++#endif
+ (void) ap_release_mutex(alloc_mutex);
++#if defined(EAPI) && defined(EAPI_MM)
++ if (blok->h.is_shm)
++ (void)ap_mm_unlock(mm);
++#endif
+ memcpy(nblok->h.first_avail, blok->h.first_avail, cur_len);
+ ps->vbuff.curpos = nblok->h.first_avail + cur_len;
+ /* save a byte for the NUL terminator */
+@@ -876,10 +1092,18 @@
+ /* did we allocate the current blok? if so free it up */
+ if (ps->got_a_new_block) {
+ debug_fill(blok->h.first_avail, blok->h.endp - blok->h.first_avail);
++#if defined(EAPI) && defined(EAPI_MM)
++ if (blok->h.is_shm)
++ (void)ap_mm_lock(mm, AP_MM_LOCK_RW);
++#endif
+ (void) ap_acquire_mutex(alloc_mutex);
+ blok->h.next = block_freelist;
+ block_freelist = blok;
+ (void) ap_release_mutex(alloc_mutex);
++#if defined(EAPI) && defined(EAPI_MM)
++ if (blok->h.is_shm)
++ (void)ap_mm_unlock(mm);
+#endif
-+
- if (result == NULL) {
- return ap_pstrdup(r->pool, "");
}
+ ps->blok = nblok;
+ ps->got_a_new_block = 1;
+@@ -898,6 +1122,11 @@
+ void *ptr;
+
+ ap_block_alarms();
++#if defined(EAPI) && defined(EAPI_MM)
++ if (p->is_shm)
++ ps.base = ap_mm_malloc(mm, 512);
++ else
++#endif
+ ps.base = malloc(512);
+ if (ps.base == NULL) {
+ fputs("Ouch! Out of memory!\n", stderr);
+@@ -910,6 +1139,11 @@
+ *ps.vbuff.curpos++ = '\0';
+ ptr = ps.base;
+ /* shrink */
++#if defined(EAPI) && defined(EAPI_MM)
++ if (p->is_shm)
++ ptr = ap_mm_realloc(ptr, (char *)ps.vbuff.curpos - (char *)ptr);
++ else
++#endif
+ ptr = realloc(ptr, (char *)ps.vbuff.curpos - (char *)ptr);
+ if (ptr == NULL) {
+ fputs("Ouch! Out of memory!\n", stderr);
+---------------------------------------------------------------------------
-| Add an EAPI hook to allow other modules to add content to
-| the status HTML page.
+| Patch the low-level buffer routines to additionally allow
+| modules to intercept the I/O processing via hooks.
+---------------------------------------------------------------------------
-Index: src/modules/standard/mod_status.c
---- src/modules/standard/mod_status.c 27 Mar 2002 15:23:06 -0000 1.1.1.14
-+++ src/modules/standard/mod_status.c 27 Mar 2002 15:30:03 -0000 1.11
-@@ -717,6 +754,12 @@
- </table>\n", r);
+Index: src/main/buff.c
+--- src/main/buff.c 11 May 2004 18:28:14 -0000 1.1.1.15
++++ src/main/buff.c 11 May 2004 18:32:15 -0000 1.23
+@@ -250,6 +250,9 @@
+ }
+ else
#endif
- }
-+
+#ifdef EAPI
-+ ap_hook_use("ap::mod_status::display",
-+ AP_HOOK_SIG4(void,ptr,int,int), AP_HOOK_ALL,
-+ r, no_table_report, short_report);
-+#endif
-
- } else {
++ if (!ap_hook_call("ap::buff::read", &rv, fb, buf, nbyte))
++#endif /* EAPI */
+ rv = read(fb->fd_in, buf, nbyte);
+
+ return rv;
+@@ -261,6 +264,9 @@
-
-+---------------------------------------------------------------------------
-| Add hooks to the scheme processing to allow other modules to
-| recognize more schemes by intercepting this processing.
-+---------------------------------------------------------------------------
-Index: src/modules/proxy/mod_proxy.c
---- src/modules/proxy/mod_proxy.c 19 Jun 2002 07:20:27 -0000 1.1.1.12
-+++ src/modules/proxy/mod_proxy.c 19 Jun 2002 07:29:09 -0000 1.19
-@@ -218,6 +218,9 @@
- static int proxy_fixup(request_rec *r)
- {
- char *url, *p;
+ #if defined (WIN32) || defined(NETWARE) || defined(CYGWIN_WINSOCK)
+ if (fb->flags & B_SOCKET) {
+#ifdef EAPI
-+ int rc;
++ if (!ap_hook_call("ap::buff::recvwithtimeout", &rv, fb, buf, nbyte))
+#endif /* EAPI */
-
- if (r->proxyreq == NOT_PROXY || strncmp(r->filename, "proxy:", 6) != 0)
- return DECLINED;
-@@ -225,6 +228,14 @@
- url = &r->filename[6];
-
- /* canonicalise each specific scheme */
+ rv = ap_recvwithtimeout(fb->fd_in, buf, nbyte, 0);
+ if (rv == SOCKET_ERROR)
+ errno = WSAGetLastError();
+@@ -308,6 +314,9 @@
+ }
+ else
+ #endif
+#ifdef EAPI
-+ if (ap_hook_use("ap::mod_proxy::canon",
-+ AP_HOOK_SIG3(int,ptr,ptr),
-+ AP_HOOK_DECLINE(DECLINED),
-+ &rc, r, url) && rc != DECLINED)
-+ return rc;
-+ else
++ if (!ap_hook_call("ap::buff::write", &rv, fb, buf, nbyte))
+#endif /* EAPI */
- if (strncasecmp(url, "http:", 5) == 0)
- return ap_proxy_http_canon(r, url + 5, "http", DEFAULT_HTTP_PORT);
- else if (strncasecmp(url, "ftp:", 4) == 0)
-@@ -240,9 +251,44 @@
- static void proxy_init(server_rec *r, pool *p)
- {
- ap_proxy_garbage_init(r, p);
+ #if defined (B_SFIO)
+ rv = sfwrite(fb->sf_out, buf, nbyte);
+ #else
+@@ -338,6 +347,9 @@
+
+ #if defined(WIN32) || defined(NETWARE)
+ if (fb->flags & B_SOCKET) {
+#ifdef EAPI
-+ ap_hook_use("ap::mod_proxy::init",
-+ AP_HOOK_SIG3(void,ptr,ptr), AP_HOOK_ALL, r, p);
-+#endif
- }
++ if (!ap_hook_call("ap::buff::sendwithtimeout", &rv, fb, buf, nbyte))
++#endif /* EAPI */
+ rv = ap_sendwithtimeout(fb->fd, buf, nbyte, 0);
+ if (rv == SOCKET_ERROR)
+ errno = WSAGetLastError();
+@@ -421,6 +433,10 @@
+ fb->callback_data = NULL;
+ fb->filter_callback = NULL;
--
+#ifdef EAPI
-+static void proxy_addmod(module *m)
-+{
-+ /* export: ap_proxy_http_canon() as `ap::mod_proxy::http::canon' */
-+ ap_hook_configure("ap::mod_proxy::http::canon",
-+ AP_HOOK_SIG5(int,ptr,ptr,ptr,int), AP_HOOK_TOPMOST);
-+ ap_hook_register("ap::mod_proxy::http::canon",
-+ ap_proxy_http_canon, AP_HOOK_NOCTX);
-+
-+ /* export: ap_proxy_http_handler() as `ap::mod_proxy::http::handler' */
-+ ap_hook_configure("ap::mod_proxy::http::handler",
-+ AP_HOOK_SIG6(int,ptr,ptr,ptr,ptr,int), AP_HOOK_TOPMOST);
-+ ap_hook_register("ap::mod_proxy::http::handler",
-+ ap_proxy_http_handler, AP_HOOK_NOCTX);
++ fb->ctx = ap_ctx_new(p);
++#endif /* EAPI */
+
-+ /* export: ap_proxyerror() as `ap::mod_proxy::error' */
-+ ap_hook_configure("ap::mod_proxy::error",
-+ AP_HOOK_SIG3(int,ptr,ptr), AP_HOOK_TOPMOST);
-+ ap_hook_register("ap::mod_proxy::error",
-+ ap_proxyerror, AP_HOOK_NOCTX);
-+ return;
-+}
-+
-+static void proxy_remmod(module *m)
-+{
-+ /* remove the hook references */
-+ ap_hook_unregister("ap::mod_proxy::http::canon", ap_proxy_http_canon);
-+ ap_hook_unregister("ap::mod_proxy::http::handler", ap_proxy_http_handler);
-+ ap_hook_unregister("ap::mod_proxy::error", ap_proxyerror);
-+ return;
-+}
-+#endif /* EAPI */
-
- /* Send a redirection if the request contains a hostname which is not */
- /* fully qualified, i.e. doesn't have a domain name appended. Some proxy */
-@@ -374,6 +420,14 @@
- * CONNECT is a special method that bypasses the normal proxy
- * code.
- */
-+#ifdef EAPI
-+ if (!ap_hook_use("ap::mod_proxy::handler",
-+ AP_HOOK_SIG7(int,ptr,ptr,ptr,ptr,int,ptr),
-+ AP_HOOK_DECLINE(DECLINED),
-+ &rc, r, cr, url,
-+ ents[i].hostname, ents[i].port,
-+ ents[i].protocol) || rc == DECLINED) {
-+#endif /* EAPI */
- if (r->method_number == M_CONNECT)
- rc = ap_proxy_connect_handler(r, cr, url, ents[i].hostname,
- ents[i].port);
-@@ -383,6 +437,9 @@
- ents[i].port);
- else
- rc = DECLINED;
-+#ifdef EAPI
-+ }
-+#endif /* EAPI */
-
- /* an error or success */
- if (rc != DECLINED && rc != HTTP_BAD_GATEWAY)
-@@ -397,6 +454,14 @@
- */
+ return fb;
+ }
- /* handle the scheme */
+@@ -1073,6 +1089,9 @@
+ i = 0;
+ while (i < nvec) {
+ do
+#ifdef EAPI
-+ if (ap_hook_use("ap::mod_proxy::handler",
-+ AP_HOOK_SIG7(int,ptr,ptr,ptr,ptr,int,ptr),
-+ AP_HOOK_DECLINE(DECLINED),
-+ &rc, r, cr, url,
-+ NULL, 0, scheme) && rc != DECLINED)
-+ return rc;
++ if (!ap_hook_call("ap::buff::writev", &rv, fb, &vec[i], nvec -i))
+#endif /* EAPI */
- if (r->method_number == M_CONNECT) {
- return ap_proxy_connect_handler(r, cr, url, NULL, 0);
- }
-@@ -994,4 +1059,10 @@
- NULL, /* child_init */
- NULL, /* child_exit */
- proxy_detect /* post read-request */
-+#ifdef EAPI
-+ ,proxy_addmod, /* EAPI: add_module */
-+ proxy_remmod, /* EAPI: remove_module */
-+ NULL, /* EAPI: rewrite_command */
-+ NULL /* EAPI: new_connection */
-+#endif
- };
+ rv = writev(fb->fd, &vec[i], nvec - i);
+ while (rv == -1 && (errno == EINTR || errno == EAGAIN)
+ && !(fb->flags & B_EOUT));
+---------------------------------------------------------------------------
-| Add hooks to the HTTP processing to allow other modules
-| to enhance it by intercepting this processing.
+| Add the implementation of the additional `add_module' and
+| `rewrite_command' module hooks. Additionally the `ctx'
+| variables are initialized.
+---------------------------------------------------------------------------
-Index: src/modules/proxy/proxy_http.c
---- src/modules/proxy/proxy_http.c 4 Oct 2002 11:50:16 -0000 1.1.1.15
-+++ src/modules/proxy/proxy_http.c 4 Oct 2002 11:54:56 -0000 1.23
-@@ -170,6 +170,9 @@
- const char *datestr, *urlstr;
- int result, major, minor;
- const char *content_length;
-+#ifdef EAPI
-+ char *peer;
-+#endif
-
- void *sconf = r->server->module_config;
- proxy_server_conf *conf =
-@@ -191,6 +194,12 @@
- return HTTP_BAD_REQUEST;
- urlptr += 3;
- destport = DEFAULT_HTTP_PORT;
-+#ifdef EAPI
-+ ap_hook_use("ap::mod_proxy::http::handler::set_destport",
-+ AP_HOOK_SIG2(int,ptr),
-+ AP_HOOK_TOPMOST,
-+ &destport, r);
-+#endif /* EAPI */
- strp = strchr(urlptr, '/');
- if (strp == NULL) {
- desthost = ap_pstrdup(p, urlptr);
-@@ -228,12 +237,18 @@
- err = ap_proxy_host2addr(proxyhost, &server_hp);
- if (err != NULL)
- return DECLINED; /* try another */
-+#ifdef EAPI
-+ peer = ap_psprintf(p, "%s:%u", proxyhost, proxyport);
-+#endif
+Index: src/main/http_config.c
+--- src/main/http_config.c 11 May 2004 18:28:14 -0000 1.1.1.17
++++ src/main/http_config.c 11 May 2004 18:32:15 -0000 1.20
+@@ -557,6 +557,20 @@
+ m->name = tmp;
}
- else {
- server.sin_port = htons((unsigned short)destport);
- err = ap_proxy_host2addr(desthost, &server_hp);
- if (err != NULL)
- return ap_proxyerror(r, HTTP_INTERNAL_SERVER_ERROR, err);
+ #endif /*_OSD_POSIX*/
++
+#ifdef EAPI
-+ peer = ap_psprintf(p, "%s:%u", desthost, destport);
-+#endif
- }
-
++ /*
++ * Invoke the `add_module' hook inside the now existing set
++ * of modules to let them all now that this module was added.
++ */
++ {
++ module *m2;
++ for (m2 = top_module; m2 != NULL; m2 = m2->next)
++ if (m2->magic == MODULE_MAGIC_COOKIE_EAPI)
++ if (m2->add_module != NULL)
++ (*m2->add_module)(m);
++ }
++#endif /* EAPI */
+ }
-@@ -308,14 +323,42 @@
- f = ap_bcreate(p, B_RDWR | B_SOCKET);
- ap_bpushfd(f, sock, sock);
+ /*
+@@ -571,6 +585,21 @@
+ {
+ module *modp;
+#ifdef EAPI
++ /*
++ * Invoke the `remove_module' hook inside the now existing
++ * set of modules to let them all now that this module is
++ * beeing removed.
++ */
+ {
-+ char *errmsg = NULL;
-+ ap_hook_use("ap::mod_proxy::http::handler::new_connection",
-+ AP_HOOK_SIG4(ptr,ptr,ptr,ptr),
-+ AP_HOOK_DECLINE(NULL),
-+ &errmsg, r, f, peer);
-+ if (errmsg != NULL)
-+ return ap_proxyerror(r, HTTP_BAD_GATEWAY, errmsg);
++ module *m2;
++ for (m2 = top_module; m2 != NULL; m2 = m2->next)
++ if (m2->magic == MODULE_MAGIC_COOKIE_EAPI)
++ if (m2->remove_module != NULL)
++ (*m2->remove_module)(m);
+ }
+#endif /* EAPI */
+
- ap_hard_timeout("proxy send", r);
- ap_bvputs(f, r->method, " ", proxyhost ? url : urlptr, " HTTP/1.1" CRLF,
- NULL);
+ modp = top_module;
+ if (modp == m) {
+ /* We are the top module, special case */
+@@ -964,6 +993,27 @@
+ const command_rec *cmd;
+ module *mod = top_module;
+
+#ifdef EAPI
++ /*
++ * Invoke the `rewrite_command' of modules to allow
++ * they to rewrite the directive line before we
++ * process it.
++ */
+ {
-+ int rc = DECLINED;
-+ ap_hook_use("ap::mod_proxy::http::handler::write_host_header",
-+ AP_HOOK_SIG6(int,ptr,ptr,ptr,int,ptr),
-+ AP_HOOK_DECLINE(DECLINED),
-+ &rc, r, f, desthost, destport, destportstr);
-+ if (rc == DECLINED) {
-+ if (destportstr != NULL && destport != DEFAULT_HTTP_PORT)
-+ ap_bvputs(f, "Host: ", desthost, ":", destportstr, CRLF, NULL);
-+ else
-+ ap_bvputs(f, "Host: ", desthost, CRLF, NULL);
++ module *m;
++ char *cp;
++ for (m = top_module; m != NULL; m = m->next) {
++ if (m->magic == MODULE_MAGIC_COOKIE_EAPI) {
++ if (m->rewrite_command != NULL) {
++ cp = (m->rewrite_command)(parms, config, l);
++ if (cp != NULL)
++ l = cp;
++ }
++ }
+ }
+ }
-+#else /* EAPI */
- /* Send Host: now, adding it to req_hdrs wouldn't be much better */
- if (destportstr != NULL && destport != DEFAULT_HTTP_PORT)
- ap_bvputs(f, "Host: ", desthost, ":", destportstr, CRLF, NULL);
- else
- ap_bvputs(f, "Host: ", desthost, CRLF, NULL);
+#endif /* EAPI */
++
+ if ((l[0] == '#') || (!l[0]))
+ return NULL;
+
+@@ -1424,6 +1474,10 @@
+ s->limit_req_fieldsize = main_server->limit_req_fieldsize;
+ s->limit_req_fields = main_server->limit_req_fields;
- if (conf->viaopt == via_block) {
- /* Block all outgoing Via: headers */
-
-+---------------------------------------------------------------------------
-| Add EAPI hooks in module structure for APXS generated samples.
-+---------------------------------------------------------------------------
-Index: src/support/apxs.pl
---- src/support/apxs.pl 19 Jun 2002 07:20:34 -0000 1.1.1.12
-+++ src/support/apxs.pl 19 Jun 2002 07:29:09 -0000 1.12
-@@ -711,5 +711,11 @@
- NULL, /* child_init */
- NULL, /* child_exit */
- NULL /* [#0] post read-request */
+#ifdef EAPI
-+ ,NULL, /* EAPI: add_module */
-+ NULL, /* EAPI: remove_module */
-+ NULL, /* EAPI: rewrite_command */
-+ NULL /* EAPI: new_connection */
-+#endif
- };
++ s->ctx = ap_ctx_new(p);
++#endif /* EAPI */
++
+ *ps = s;
+
+ return ap_parse_vhost_addrs(p, hostname, s);
+@@ -1535,6 +1589,10 @@
+ s->module_config = create_server_config(p, s);
+ s->lookup_defaults = create_default_per_dir_config(p);
+
++#ifdef EAPI
++ s->ctx = ap_ctx_new(p);
++#endif /* EAPI */
++
+ return s;
+ }
+---------------------------------------------------------------------------
-| Add the EAPI functions, so the stuff can be built under AIX
-| and similar braindead platforms as DSO.
+| Add the ap_global_ctx variable and the new
+| ap_add_config_define() function. Additionally the
+| implementation of the additional `new_connection' module hook
+| is added plus the initialization of one more `ctx' variable.
+---------------------------------------------------------------------------
-Index: src/support/httpd.exp
---- src/support/httpd.exp 19 Jun 2002 07:20:34 -0000 1.1.1.11
-+++ src/support/httpd.exp 19 Jun 2002 07:29:09 -0000 1.13
-@@ -427,3 +427,59 @@
- XML_SetUnparsedEntityDeclHandler
- XML_SetUserData
- XML_UseParserAsHandlerArg
-+ap_add_config_define
-+ap_make_shared_sub_pool
-+ap_global_ctx
-+ap_ctx_new
-+ap_ctx_get
-+ap_ctx_set
-+ap_hook_init
-+ap_hook_kill
-+ap_hook_configure
-+ap_hook_register_I
-+ap_hook_unregister_I
-+ap_hook_status
-+ap_hook_use
-+ap_hook_call
-+ap_mm_useable
-+ap_MM_create
-+ap_MM_permission
-+ap_MM_destroy
-+ap_MM_lock
-+ap_MM_unlock
-+ap_MM_malloc
-+ap_MM_realloc
-+ap_MM_free
-+ap_MM_calloc
-+ap_MM_strdup
-+ap_MM_sizeof
-+ap_MM_maxsize
-+ap_MM_available
-+ap_MM_error
-+ap_mm_create
-+ap_mm_permission
-+ap_mm_destroy
-+ap_mm_lock
-+ap_mm_unlock
-+ap_mm_malloc
-+ap_mm_realloc
-+ap_mm_free
-+ap_mm_calloc
-+ap_mm_strdup
-+ap_mm_sizeof
-+ap_mm_maxsize
-+ap_mm_available
-+ap_mm_error
-+ap_mm_display_info
-+ap_mm_core_create
-+ap_mm_core_permission
-+ap_mm_core_delete
-+ap_mm_core_size
-+ap_mm_core_lock
-+ap_mm_core_unlock
-+ap_mm_core_maxsegsize
-+ap_mm_core_align2page
-+ap_mm_core_align2word
-+ap_mm_lib_error_set
-+ap_mm_lib_error_get
-+ap_mm_lib_version
-
-+---------------------------------------------------------------------------
-| Add the EAPI functions, so the stuff can be built under
-| Windows 95 and similar braindead platforms as DDL.
-+---------------------------------------------------------------------------
-Index: src/ApacheCore.def
---- src/ApacheCore.def 19 Jun 2002 07:20:21 -0000 1.1.1.10
-+++ src/ApacheCore.def 19 Jun 2002 07:29:08 -0000 1.14
-@@ -447,3 +447,67 @@
- ap_getline @439
- ap_get_chunk_size @440
- ap_escape_logitem @441
-+
-+ ; EAPI extended symbols
-+ ; note; no ID's, so these all bind by name rather than ordinal since
-+ ; their ordinals would change with symbol changes in the distribution
-+ ap_add_config_define
-+ ap_global_ctx DATA
-+ ap_ctx_new
-+ ap_ctx_get
-+ ap_ctx_overlay
-+ ap_ctx_set
-+ ap_hook_init
-+ ap_hook_kill
-+ ap_hook_configure
-+ ap_hook_register_I
-+ ap_hook_unregister_I
-+ ap_hook_status
-+ ap_hook_use
-+ ap_hook_call
-+ ap_set_callback_and_alarm
-+ ap_acquire_pool
-+ ap_make_shared_sub_pool
-+ ap_release_pool
-+ ap_mm_useable
-+ ap_MM_create
-+ ap_MM_permission
-+ ap_MM_destroy
-+ ap_MM_lock
-+ ap_MM_unlock
-+ ap_MM_malloc
-+ ap_MM_realloc
-+ ap_MM_free
-+ ap_MM_calloc
-+ ap_MM_strdup
-+ ap_MM_sizeof
-+ ap_MM_maxsize
-+ ap_MM_available
-+ ap_MM_error
-+ ap_mm_create
-+ ap_mm_permission
-+ ap_mm_destroy
-+ ap_mm_lock
-+ ap_mm_unlock
-+ ap_mm_malloc
-+ ap_mm_realloc
-+ ap_mm_free
-+ ap_mm_calloc
-+ ap_mm_strdup
-+ ap_mm_sizeof
-+ ap_mm_maxsize
-+ ap_mm_available
-+ ap_mm_error
-+ ap_mm_display_info
-+ ap_mm_core_create
-+ ap_mm_core_permission
-+ ap_mm_core_delete
-+ ap_mm_core_size
-+ ap_mm_core_lock
-+ ap_mm_core_unlock
-+ ap_mm_core_align2page
-+ ap_mm_core_align2word
-+ ap_mm_lib_error_set
-+ ap_mm_lib_error_get
-+ ap_mm_lib_version
-+
---- src/include/httpd.h.orig 2003-07-16 22:20:26.000000000 +0200
-+++ src/include/httpd.h 2003-07-19 11:55:38.000000000 +0200
-@@ -70,7 +70,19 @@
- /* Headers in which EVERYONE has an interest... */
-
- #include "ap_config.h"
-+#ifdef EAPI
-+#include "ap_mm.h"
-+#endif
- #include "ap_alloc.h"
-+/*
-+ * Include the Extended API headers.
-+ * Don't move the position. It has to be after ap_alloc.h because it uses the
-+ * pool stuff but before buff.h because the buffer stuff uses the EAPI, too.
-+ */
-+#ifdef EAPI
-+#include "ap_hook.h"
-+#include "ap_ctx.h"
-+#endif /* EAPI */
- #include "buff.h"
- #include "ap.h"
+Index: src/main/http_main.c
+--- src/main/http_main.c 11 May 2004 18:28:14 -0000 1.1.1.22
++++ src/main/http_main.c 11 May 2004 18:32:15 -0000 1.44
+@@ -242,6 +242,9 @@
-@@ -141,6 +153,10 @@
- #define DEFAULT_HTTP_PORT 80
- #define DEFAULT_HTTPS_PORT 443
- #define ap_is_default_port(port,r) ((port) == ap_default_port(r))
+ int ap_dump_settings = 0;
+ API_VAR_EXPORT int ap_extended_status = 0;
+#ifdef EAPI
-+#define ap_http_method(r) (((r)->ctx != NULL && ap_ctx_get((r)->ctx, "ap::http::method") != NULL) ? ((char *)ap_ctx_get((r)->ctx, "ap::http::method")) : "http")
-+#define ap_default_port(r) (((r)->ctx != NULL && ap_ctx_get((r)->ctx, "ap::default::port") != NULL) ? atoi((char *)ap_ctx_get((r)->ctx, "ap::default::port")) : DEFAULT_HTTP_PORT)
-+#else /* EAPI */
- #ifdef NETWARE
- #define ap_http_method(r) ap_os_http_method((void*)r)
- #define ap_default_port(r) ap_os_default_port((void*)r)
-@@ -148,6 +164,7 @@
- #define ap_http_method(r) "http"
- #define ap_default_port(r) DEFAULT_HTTP_PORT
- #endif
++API_VAR_EXPORT ap_ctx *ap_global_ctx;
+#endif /* EAPI */
- /* --------- Default user name and group name running standalone ---------- */
- /* --- These may be specified as numbers by placing a # before a number --- */
-@@ -352,6 +369,19 @@
- #define SCOREBOARD_MAINTENANCE_INTERVAL 1000000
- #endif
+ /*
+ * The max child slot ever assigned, preserved across restarts. Necessary
+@@ -435,6 +438,30 @@
+ }
+ }
++#ifdef EAPI
++API_EXPORT(void) ap_add_config_define(const char *define)
++{
++ char **var;
++ var = (char **)ap_push_array(ap_server_config_defines);
++ *var = ap_pstrdup(pcommands, define);
++ return;
++}
++
+/*
-+ * Unix only:
-+ * Path to Shared Memory Files
++ * Invoke the `close_connection' hook of modules to let them do
++ * some connection dependent actions before we close it.
+ */
-+#ifdef EAPI
-+#ifndef EAPI_MM_CORE_PATH
-+#define EAPI_MM_CORE_PATH "logs/mm"
-+#endif
-+#ifndef EAPI_MM_CORE_MAXSIZE
-+#define EAPI_MM_CORE_MAXSIZE 1024*1024*1 /* max. 1MB */
-+#endif
-+#endif
++static void ap_call_close_connection_hook(conn_rec *c)
++{
++ module *m;
++ for (m = top_module; m != NULL; m = m->next)
++ if (m->magic == MODULE_MAGIC_COOKIE_EAPI)
++ if (m->close_connection != NULL)
++ (*m->close_connection)(c);
++ return;
++}
++#endif /* EAPI */
+
- /* Number of requests to try to handle in a single process. If <= 0,
- * the children don't die off. That's the default here, since I'm still
- * interested in finding and stanching leaks.
-@@ -444,6 +474,9 @@
- API_EXPORT(const char *) ap_get_server_version(void);
- API_EXPORT(void) ap_add_version_component(const char *component);
- API_EXPORT(const char *) ap_get_server_built(void);
+ #ifndef NETWARE
+ static APACHE_TLS int volatile exit_after_unblock = 0;
+ #endif
+@@ -1541,6 +1568,10 @@
+ ap_log_transaction(log_req);
+ }
+
+#ifdef EAPI
-+API_EXPORT(void) ap_add_config_define(const char *define);
++ ap_call_close_connection_hook(save_req->connection);
+#endif /* EAPI */
-
- /* Numeric release version identifier: MMNNFFRBB: major minor fix final beta
- * Always increases along the same track as the source branch.
-@@ -847,6 +880,10 @@
- * record to improve 64bit alignment the next time we need to break
- * binary compatibility for some other reason.
- */
+
+ ap_bsetflag(save_req->connection->client, B_EOUT, 1);
+ ap_bclose(save_req->connection->client);
+
+@@ -1549,6 +1580,9 @@
+ ap_longjmp(jmpbuffer, 1);
+ }
+ else { /* abort the connection */
+#ifdef EAPI
-+ ap_ctx *ctx;
++ ap_call_close_connection_hook(current_conn);
+#endif /* EAPI */
- };
-
+ ap_bsetflag(current_conn->client, B_EOUT, 1);
+ ap_bclose(current_conn->client);
+ current_conn->aborted = 1;
+@@ -1851,10 +1885,16 @@
+ /* Send any leftover data to the client, but never try to again */
-@@ -895,6 +932,9 @@
- char *local_host; /* used for ap_get_server_name when
- * UseCanonicalName is set to DNS
- * (ignores setting of HostnameLookups) */
+ if (ap_bflush(r->connection->client) == -1) {
+#ifdef EAPI
-+ ap_ctx *ctx;
++ ap_call_close_connection_hook(r->connection);
+#endif /* EAPI */
- };
-
- /* Per-vhost config... */
-@@ -967,6 +1007,10 @@
- int limit_req_line; /* limit on size of the HTTP request line */
- int limit_req_fieldsize; /* limit on size of any request header field */
- int limit_req_fields; /* limit on number of request header fields */
-+
+ ap_kill_timeout(r);
+ ap_bclose(r->connection->client);
+ return;
+ }
+#ifdef EAPI
-+ ap_ctx *ctx;
++ ap_call_close_connection_hook(r->connection);
+#endif /* EAPI */
- };
-
- /* These are more like real hosts than virtual hosts */
---- src/main/alloc.c.orig 2003-06-20 17:05:40.000000000 +0200
-+++ src/main/alloc.c 2003-07-19 11:59:07.000000000 +0200
-@@ -64,6 +64,10 @@
- */
+ ap_bsetflag(r->connection->client, B_EOUT, 1);
- #include "httpd.h"
+ /* Close our half of the connection --- send the client a FIN */
+@@ -2553,6 +2593,9 @@
+ /* Clear the pool - including any registered cleanups */
+ ap_destroy_pool(pglobal);
+ #endif
+#ifdef EAPI
-+#include "http_config.h"
-+#include "http_conf_globals.h"
++ ap_kill_alloc_shared();
+#endif
- #include "multithread.h"
- #include "http_log.h"
-
-@@ -138,6 +142,10 @@
- #define BLOCK_MINALLOC 0
- #endif
+ exit(code);
+ }
-+#if defined(EAPI) && defined(EAPI_MM)
-+static AP_MM *mm = NULL;
-+#endif
+@@ -3623,6 +3666,24 @@
+ conn->remote_addr = *remaddr;
+ conn->remote_ip = ap_pstrdup(conn->pool,
+ inet_ntoa(conn->remote_addr.sin_addr));
++#ifdef EAPI
++ conn->ctx = ap_ctx_new(conn->pool);
++#endif /* EAPI */
+
- /*****************************************************************
- *
- * Managing free storage blocks...
-@@ -166,6 +174,9 @@
- char *endp;
- union block_hdr *next;
- char *first_avail;
-+#if defined(EAPI) && defined(EAPI_MM)
-+ int is_shm;
-+#endif
- #ifdef POOL_DEBUG
- union block_hdr *global_next;
- struct pool *owning_pool;
-@@ -216,7 +227,11 @@
- /* Get a completely new block from the system pool. Note that we rely on
- malloc() to provide aligned memory. */
++#ifdef EAPI
++ /*
++ * Invoke the `new_connection' hook of modules to let them do
++ * some connection dependent actions before we go on with
++ * processing the request on this connection.
++ */
++ {
++ module *m;
++ for (m = top_module; m != NULL; m = m->next)
++ if (m->magic == MODULE_MAGIC_COOKIE_EAPI)
++ if (m->new_connection != NULL)
++ (*m->new_connection)(conn);
++ }
++#endif /* EAPI */
-+#if defined(EAPI) && defined(EAPI_MM)
-+static union block_hdr *malloc_block(int size, int is_shm)
-+#else
- static union block_hdr *malloc_block(int size)
-+#endif
- {
- union block_hdr *blok;
- int request_size;
-@@ -231,6 +246,11 @@
- ++num_malloc_calls;
- num_malloc_bytes += size + sizeof(union block_hdr);
- #endif
-+#if defined(EAPI) && defined(EAPI_MM)
-+ if (is_shm)
-+ blok = (union block_hdr *)ap_mm_malloc(mm, size + sizeof(union block_hdr));
-+ else
-+#endif
- request_size = size + sizeof(union block_hdr);
- blok = (union block_hdr *) malloc(request_size);
- if (blok == NULL) {
-@@ -239,6 +259,9 @@
- exit(1);
- }
- debug_fill(blok, size + sizeof(union block_hdr));
-+#if defined(EAPI) && defined(EAPI_MM)
-+ blok->h.is_shm = is_shm;
+ return conn;
+ }
+@@ -4133,6 +4194,15 @@
+ printf("Server's Module Magic Number: %u:%u\n",
+ MODULE_MAGIC_NUMBER_MAJOR, MODULE_MAGIC_NUMBER_MINOR);
+ printf("Server compiled with....\n");
++#ifdef EAPI
++ printf(" -D EAPI\n");
+#endif
- blok->h.next = NULL;
- blok->h.first_avail = (char *) (blok + 1);
- blok->h.endp = size + blok->h.first_avail;
-@@ -299,6 +322,10 @@
- if (blok == NULL)
- return; /* Sanity check --- freeing empty pool? */
-
-+#if defined(EAPI) && defined(EAPI_MM)
-+ if (blok->h.is_shm)
-+ (void)ap_mm_lock(mm, AP_MM_LOCK_RW);
++#ifdef EAPI_MM
++ printf(" -D EAPI_MM\n");
++#ifdef EAPI_MM_CORE_PATH
++ printf(" -D EAPI_MM_CORE_PATH=\"" EAPI_MM_CORE_PATH "\"\n");
+#endif
- (void) ap_acquire_mutex(alloc_mutex);
- old_free_list = block_freelist;
- block_freelist = blok;
-@@ -345,6 +372,10 @@
- #endif
-
- (void) ap_release_mutex(alloc_mutex);
-+#if defined(EAPI) && defined(EAPI_MM)
-+ if (blok->h.is_shm)
-+ (void)ap_mm_unlock(mm);
+#endif
+ #ifdef TPF
+ show_os_specific_compile_settings();
#endif
+@@ -4307,6 +4377,22 @@
+ ap_server_pre_read_config = ap_make_array(pcommands, 1, sizeof(char *));
+ ap_server_post_read_config = ap_make_array(pcommands, 1, sizeof(char *));
+ ap_server_config_defines = ap_make_array(pcommands, 1, sizeof(char *));
++
++#ifdef EAPI
++ ap_hook_init();
++ ap_hook_configure("ap::buff::read",
++ AP_HOOK_SIG4(int,ptr,ptr,int), AP_HOOK_TOPMOST);
++ ap_hook_configure("ap::buff::write",
++ AP_HOOK_SIG4(int,ptr,ptr,int), AP_HOOK_TOPMOST);
++ ap_hook_configure("ap::buff::writev",
++ AP_HOOK_SIG4(int,ptr,ptr,int), AP_HOOK_TOPMOST);
++ ap_hook_configure("ap::buff::sendwithtimeout",
++ AP_HOOK_SIG4(int,ptr,ptr,int), AP_HOOK_TOPMOST);
++ ap_hook_configure("ap::buff::recvwithtimeout",
++ AP_HOOK_SIG4(int,ptr,ptr,int), AP_HOOK_TOPMOST);
++
++ ap_global_ctx = ap_ctx_new(NULL);
++#endif /* EAPI */
}
-@@ -353,7 +384,11 @@
- * if necessary. Must be called with alarms blocked.
- */
+ #ifndef MULTITHREAD
+@@ -4808,6 +4894,9 @@
-+#if defined(EAPI) && defined(EAPI_MM)
-+static union block_hdr *new_block(int min_size, int is_shm)
-+#else
- static union block_hdr *new_block(int min_size)
-+#endif
- {
- union block_hdr **lastptr = &block_freelist;
- union block_hdr *blok = block_freelist;
-@@ -363,7 +398,12 @@
- */
+ ap_sync_scoreboard_image();
+ if (ap_scoreboard_image->global.running_generation != ap_my_generation) {
++#ifdef EAPI
++ ap_call_close_connection_hook(current_conn);
++#endif /* EAPI */
+ ap_bclose(conn_io);
+ clean_child_exit(0);
+ }
+@@ -4836,6 +4925,9 @@
+ */
- while (blok != NULL) {
-+#if defined(EAPI) && defined(EAPI_MM)
-+ if (blok->h.is_shm == is_shm &&
-+ min_size + BLOCK_MINFREE <= blok->h.endp - blok->h.first_avail) {
-+#else
- if (min_size + BLOCK_MINFREE <= blok->h.endp - blok->h.first_avail) {
+ #ifdef NO_LINGCLOSE
++#ifdef EAPI
++ ap_call_close_connection_hook(current_conn);
++#endif /* EAPI */
+ ap_bclose(conn_io); /* just close it */
+ #else
+ if (r && r->connection
+@@ -4846,6 +4938,9 @@
+ lingering_close(r);
+ }
+ else {
++#ifdef EAPI
++ ap_call_close_connection_hook(current_conn);
++#endif /* EAPI */
+ ap_bsetflag(conn_io, B_EOUT, 1);
+ ap_bclose(conn_io);
+ }
+@@ -5619,16 +5714,31 @@
+ usage(argv[0]);
+ }
+ }
++#ifdef EAPI
++ ap_init_alloc_shared(TRUE);
+#endif
- *lastptr = blok->h.next;
- blok->h.next = NULL;
- debug_verify_filled(blok->h.first_avail, blok->h.endp,
-@@ -379,7 +419,11 @@
- /* Nope. */
- min_size += BLOCK_MINFREE;
-+#if defined(EAPI) && defined(EAPI_MM)
-+ blok = malloc_block((min_size > BLOCK_MINALLOC) ? min_size : BLOCK_MINALLOC, is_shm);
-+#else
- blok = malloc_block((min_size > BLOCK_MINALLOC) ? min_size : BLOCK_MINALLOC);
-+#endif
- return blok;
- }
+ ap_suexec_enabled = init_suexec();
+ server_conf = ap_read_config(pconf, ptrans, ap_server_confname);
-@@ -429,6 +473,9 @@
- #ifdef POOL_DEBUG
- struct pool *joined;
- #endif
-+#if defined(EAPI) && defined(EAPI_MM)
-+ int is_shm;
++#ifdef EAPI
++ ap_init_alloc_shared(FALSE);
+#endif
- };
-
- static pool *permanent_pool;
-@@ -443,16 +490,28 @@
- #define POOL_HDR_CLICKS (1 + ((sizeof(struct pool) - 1) / CLICK_SZ))
- #define POOL_HDR_BYTES (POOL_HDR_CLICKS * CLICK_SZ)
-
-+#if defined(EAPI) && defined(EAPI_MM)
-+static struct pool *make_sub_pool_internal(struct pool *p, int is_shm)
++
+ if (ap_configtestonly) {
+ fprintf(stderr, "Syntax OK\n");
++#ifdef EAPI
++ clean_parent_exit(0);
+#else
- API_EXPORT(struct pool *) ap_make_sub_pool(struct pool *p)
-+#endif
- {
- union block_hdr *blok;
- pool *new_pool;
-
- ap_block_alarms();
-
-+#if defined(EAPI) && defined(EAPI_MM)
-+ if (is_shm)
-+ (void)ap_mm_lock(mm, AP_MM_LOCK_RW);
+ exit(0);
+#endif
- (void) ap_acquire_mutex(alloc_mutex);
-
-+#if defined(EAPI) && defined(EAPI_MM)
-+ blok = new_block(POOL_HDR_BYTES, is_shm);
+ }
+ if (ap_dump_settings) {
++#ifdef EAPI
++ clean_parent_exit(0);
+#else
- blok = new_block(POOL_HDR_BYTES);
+ exit(0);
+#endif
- new_pool = (pool *) blok->h.first_avail;
- blok->h.first_avail += POOL_HDR_BYTES;
- #ifdef POOL_DEBUG
-@@ -471,12 +530,38 @@
- p->sub_pools = new_pool;
}
-+#if defined(EAPI) && defined(EAPI_MM)
-+ new_pool->is_shm = is_shm;
-+#endif
+ child_timeouts = !ap_standalone || one_process;
+@@ -5776,6 +5886,10 @@
+ ap_destroy_pool(r->pool);
+ }
+
++#ifdef EAPI
++ ap_call_close_connection_hook(conn);
++#endif /* EAPI */
+
- (void) ap_release_mutex(alloc_mutex);
-+#if defined(EAPI) && defined(EAPI_MM)
-+ if (is_shm)
-+ (void)ap_mm_unlock(mm);
-+#endif
- ap_unblock_alarms();
+ ap_bclose(cio);
+ }
+ exit(0);
+@@ -6152,6 +6266,9 @@
+ ap_kill_cleanups_for_socket(ptrans, csd);
- return new_pool;
- }
+ #ifdef NO_LINGCLOSE
++#ifdef EAPI
++ ap_call_close_connection_hook(current_conn);
++#endif /* EAPI */
+ ap_bclose(conn_io); /* just close it */
+ #else
+ if (r && r->connection
+@@ -6162,6 +6279,9 @@
+ lingering_close(r);
+ }
+ else {
++#ifdef EAPI
++ ap_call_close_connection_hook(current_conn);
++#endif /* EAPI */
+ ap_bsetflag(conn_io, B_EOUT, 1);
+ ap_bclose(conn_io);
+ }
+@@ -7737,6 +7857,10 @@
+ if (!conf_specified)
+ ap_cpystrn(ap_server_confname, SERVER_CONFIG_FILE, sizeof(ap_server_confname));
-+#if defined(EAPI)
-+#if defined(EAPI_MM)
-+API_EXPORT(struct pool *) ap_make_sub_pool(struct pool *p)
-+{
-+ return make_sub_pool_internal(p, 0);
-+}
-+API_EXPORT(struct pool *) ap_make_shared_sub_pool(struct pool *p)
-+{
-+ return make_sub_pool_internal(p, 1);
-+}
-+#else
-+API_EXPORT(struct pool *) ap_make_shared_sub_pool(struct pool *p)
-+{
-+ return NULL;
-+}
-+#endif
++#ifdef EAPI
++ ap_init_alloc_shared(TRUE);
+#endif
+
- #ifdef POOL_DEBUG
- static void stack_var_init(char *s)
- {
-@@ -491,6 +576,13 @@
- }
+ if (!ap_os_is_path_absolute(ap_server_confname))
+ ap_cpystrn(ap_server_confname,
+ ap_server_root_relative(pcommands, ap_server_confname),
+@@ -7777,6 +7901,9 @@
+ #else /* ndef WIN32 */
+ server_conf = ap_read_config(pconf, ptrans, ap_server_confname);
#endif
-
-+#if defined(EAPI)
-+int ap_shared_pool_possible(void)
-+{
-+ return ap_mm_useable();
-+}
++#ifdef EAPI
++ ap_init_alloc_shared(FALSE);
+#endif
-+
- #ifdef ALLOC_STATS
- static void dump_stats(void)
- {
-@@ -523,6 +615,58 @@
- return permanent_pool;
- }
-+#if defined(EAPI)
-+void ap_init_alloc_shared(int early)
-+{
-+#if defined(EAPI_MM)
-+ int mm_size;
-+ char *mm_path;
-+ char *err1, *err2;
+ if (ap_configtestonly) {
+ fprintf(stderr, "%s: Syntax OK\n", ap_server_root_relative(pcommands, ap_server_confname));
+
++---------------------------------------------------------------------------
+| Just add the initialization of the `ctx' variable for
+| conn_rec structures.
++---------------------------------------------------------------------------
+Index: src/main/http_request.c
+--- src/main/http_request.c 11 May 2004 18:28:15 -0000 1.1.1.18
++++ src/main/http_request.c 11 May 2004 18:32:15 -0000 1.18
+@@ -1363,6 +1363,10 @@
+
+ new->method = r->method;
+ new->method_number = r->method_number;
++#ifdef EAPI
++ /* initialize context _BEFORE_ ap_parse_uri() call */
++ new->ctx = r->ctx;
++#endif /* EAPI */
+ ap_parse_uri(new, new_uri);
+ new->request_config = ap_create_request_config(r->pool);
+ new->per_dir_config = r->server->lookup_defaults;
+
++---------------------------------------------------------------------------
+| Just add the initialization of the `ctx' variable for
+| request_rec structures.
++---------------------------------------------------------------------------
+Index: src/main/http_protocol.c
+--- src/main/http_protocol.c 11 May 2004 18:28:15 -0000 1.1.1.20
++++ src/main/http_protocol.c 11 May 2004 18:32:15 -0000 1.20
+@@ -1160,6 +1160,10 @@
+ r->status = HTTP_REQUEST_TIME_OUT; /* Until we get a request */
+ r->the_request = NULL;
+
++#ifdef EAPI
++ r->ctx = ap_ctx_new(r->pool);
++#endif /* EAPI */
+
-+ if (early) {
-+ /* process very early on startup */
-+ mm_size = ap_mm_maxsize();
-+ if (mm_size > EAPI_MM_CORE_MAXSIZE)
-+ mm_size = EAPI_MM_CORE_MAXSIZE;
-+ mm_path = ap_server_root_relative(permanent_pool,
-+ ap_psprintf(permanent_pool, "%s.%ld",
-+ EAPI_MM_CORE_PATH, (long)getpid()));
-+ if ((mm = ap_mm_create(mm_size, mm_path)) == NULL) {
-+ fprintf(stderr, "Ouch! ap_mm_create(%d, \"%s\") failed\n", mm_size, mm_path);
-+ err1 = ap_mm_error();
-+ if (err1 == NULL)
-+ err1 = "-unknown-";
-+ err2 = strerror(errno);
-+ if (err2 == NULL)
-+ err2 = "-unknown-";
-+ fprintf(stderr, "Error: MM: %s: OS: %s\n", err1, err2);
-+ exit(1);
-+ }
-+ }
-+ else {
-+ /* process a lot later on startup */
-+#ifdef WIN32
-+ ap_mm_permission(mm, (_S_IREAD|_S_IWRITE), ap_user_id, -1);
-+#else
-+ ap_mm_permission(mm, (S_IRUSR|S_IWUSR), ap_user_id, -1);
-+#endif
-+ }
-+#endif /* EAPI_MM */
-+ return;
-+}
+ #ifdef CHARSET_EBCDIC
+ ap_bsetflag(r->connection->client, B_ASCII2EBCDIC, r->ebcdic.conv_in = 1);
+ ap_bsetflag(r->connection->client, B_EBCDIC2ASCII, r->ebcdic.conv_out = 1);
+@@ -1316,6 +1320,11 @@
+ rnew->read_body = REQUEST_NO_BODY;
+
+ rnew->main = (request_rec *) r;
+
-+void ap_kill_alloc_shared(void)
-+{
-+#if defined(EAPI_MM)
-+ if (mm != NULL) {
-+ ap_mm_destroy(mm);
-+ mm = NULL;
-+ }
-+#endif /* EAPI_MM */
-+ return;
-+}
++#ifdef EAPI
++ rnew->ctx = r->ctx;
+#endif /* EAPI */
+
- void ap_cleanup_alloc(void)
- {
- ap_destroy_mutex(alloc_mutex);
-@@ -533,10 +677,18 @@
- {
- ap_block_alarms();
-
-+#if defined(EAPI) && defined(EAPI_MM)
-+ if (a->is_shm)
-+ (void)ap_mm_lock(mm, AP_MM_LOCK_RW);
-+#endif
- (void) ap_acquire_mutex(alloc_mutex);
- while (a->sub_pools)
- ap_destroy_pool(a->sub_pools);
- (void) ap_release_mutex(alloc_mutex);
-+#if defined(EAPI) && defined(EAPI_MM)
-+ if (a->is_shm)
-+ (void)ap_mm_unlock(mm);
-+#endif
- /* Don't hold the mutex during cleanups. */
- run_cleanups(a->cleanups);
- a->cleanups = NULL;
-@@ -570,6 +722,10 @@
- ap_block_alarms();
- ap_clear_pool(a);
+ }
-+#if defined(EAPI) && defined(EAPI_MM)
-+ if (a->is_shm)
-+ (void)ap_mm_lock(mm, AP_MM_LOCK_RW);
+ API_EXPORT(void) ap_finalize_sub_req_protocol(request_rec *sub)
+
++---------------------------------------------------------------------------
+| Add support for loading both EAPI and AP13 modules.
++---------------------------------------------------------------------------
+Index: src/modules/standard/mod_so.c
+--- src/modules/standard/mod_so.c 11 May 2004 18:28:20 -0000 1.1.1.11
++++ src/modules/standard/mod_so.c 11 May 2004 18:32:16 -0000 1.12
+@@ -226,11 +226,24 @@
+ * Make sure the found module structure is really a module structure
+ *
+ */
++#ifdef EAPI
++ if ( modp->magic != MODULE_MAGIC_COOKIE_AP13
++ && modp->magic != MODULE_MAGIC_COOKIE_EAPI) {
++#else
+ if (modp->magic != MODULE_MAGIC_COOKIE) {
+#endif
- (void) ap_acquire_mutex(alloc_mutex);
- if (a->parent) {
- if (a->parent->sub_pools == a)
-@@ -580,6 +736,10 @@
- a->sub_next->sub_prev = a->sub_prev;
+ return ap_pstrcat(cmd->pool, "API module structure `", modname,
+ "' in file ", szModuleFile, " is garbled -"
+ " perhaps this is not an Apache module DSO?", NULL);
}
- (void) ap_release_mutex(alloc_mutex);
-+#if defined(EAPI) && defined(EAPI_MM)
-+ if (a->is_shm)
-+ (void)ap_mm_unlock(mm);
++#ifdef EAPI
++ if (modp->magic == MODULE_MAGIC_COOKIE_AP13) {
++ ap_log_error(APLOG_MARK, APLOG_WARNING|APLOG_NOERRNO, NULL,
++ "Loaded DSO %s uses plain Apache 1.3 API, "
++ "this module might crash under EAPI! "
++ "(please recompile it with -DEAPI)", filename);
++ }
+#endif
- free_blocks(a->first);
- ap_unblock_alarms();
-@@ -594,6 +754,30 @@
- return bytes_in_block_list(block_freelist);
- }
+ /*
+ * Add this module to the Apache core structures
+
++---------------------------------------------------------------------------
+| Add additional logging functions to the CustomLog directive
+| which can be used by other modules to create additional
+| logfile tags. Actually we add two types of hooks: One hook
+| for intercepting the new and generic %x (eXtension) tag and
+| one hook for creating new %x tags at all.
++---------------------------------------------------------------------------
+Index: src/modules/standard/mod_log_config.c
+--- src/modules/standard/mod_log_config.c 11 May 2004 18:28:20 -0000 1.1.1.15
++++ src/modules/standard/mod_log_config.c 11 May 2004 18:32:16 -0000 1.28
+@@ -220,6 +220,9 @@
+ typedef const char *(*item_key_func) (request_rec *, char *);
-+#if defined(EAPI)
-+API_EXPORT(int) ap_acquire_pool(pool *p, ap_pool_lock_mode mode)
-+{
-+#if defined(EAPI_MM)
-+ if (!p->is_shm)
-+ return 1;
-+ return ap_mm_lock(mm, mode == AP_POOL_RD ? AP_MM_LOCK_RD : AP_MM_LOCK_RW);
-+#else
-+ return 1;
-+#endif
-+}
-+
-+API_EXPORT(int) ap_release_pool(pool *p)
-+{
-+#if defined(EAPI_MM)
-+ if (!p->is_shm)
-+ return 1;
-+ return ap_mm_unlock(mm);
-+#else
-+ return 1;
+ typedef struct {
++#ifdef EAPI
++ char ch;
+#endif
-+}
-+#endif /* EAPI */
-+
- /*****************************************************************
- * POOL_DEBUG support
- */
-@@ -759,16 +943,31 @@
+ item_key_func func;
+ char *arg;
+ int condition_sense;
+@@ -541,15 +544,36 @@
+ }
+ };
- ap_block_alarms();
++#ifdef EAPI
++static struct log_item_list *find_log_func(pool *p, char k)
++#else /* EAPI */
+ static struct log_item_list *find_log_func(char k)
++#endif /* EAPI */
+ {
+ int i;
++#ifdef EAPI
++ struct log_item_list *lil;
++#endif /* EAPI */
-+#if defined(EAPI) && defined(EAPI_MM)
-+ if (a->is_shm)
-+ (void)ap_mm_lock(mm, AP_MM_LOCK_RW);
-+#endif
- (void) ap_acquire_mutex(alloc_mutex);
+ for (i = 0; log_item_keys[i].ch; ++i)
+ if (k == log_item_keys[i].ch) {
+ return &log_item_keys[i];
+ }
-+#if defined(EAPI) && defined(EAPI_MM)
-+ blok = new_block(size, a->is_shm);
-+#else
- blok = new_block(size);
-+#endif
- a->last->h.next = blok;
- a->last = blok;
- #ifdef POOL_DEBUG
- blok->h.owning_pool = a;
- #endif
-+#if defined(EAPI) && defined(EAPI_MM)
-+ blok->h.is_shm = a->is_shm;
-+#endif
++#ifdef EAPI
++ if (ap_hook_status(ap_psprintf(p, "ap::mod_log_config::log_%c", k))
++ != AP_HOOK_STATE_NOTEXISTANT) {
++ lil = (struct log_item_list *)
++ ap_pcalloc(p, sizeof(struct log_item_list));
++ if (lil == NULL)
++ return NULL;
++ lil->ch = k;
++ lil->func = NULL;
++ lil->want_orig_default = 0;
++ return lil;
++ }
++#endif /* EAPI */
++
+ return NULL;
+ }
- (void) ap_release_mutex(alloc_mutex);
-+#if defined(EAPI) && defined(EAPI_MM)
-+ if (a->is_shm)
-+ (void)ap_mm_unlock(mm);
+@@ -675,7 +699,11 @@
+ break;
+
+ default:
++#ifdef EAPI
++ l = find_log_func(p, *s++);
++#else /* EAPI */
+ l = find_log_func(*s++);
++#endif /* EAPI */
+ if (!l) {
+ char dummy[2];
+
+@@ -684,6 +712,9 @@
+ return ap_pstrcat(p, "Unrecognized LogFormat directive %",
+ dummy, NULL);
+ }
++#ifdef EAPI
++ it->ch = s[-1];
+#endif
+ it->func = l->func;
+ if (it->want_orig == -1) {
+ it->want_orig = l->want_orig_default;
+@@ -745,6 +776,15 @@
- ap_unblock_alarms();
+ /* We do. Do it... */
-@@ -885,6 +1084,11 @@
- size = cur_len << 1;
- if (size < AP_PSPRINTF_MIN_SIZE)
- size = AP_PSPRINTF_MIN_SIZE;
-+#if defined(EAPI) && defined(EAPI_MM)
-+ if (ps->block->h.is_shm)
-+ ptr = ap_mm_realloc(ps->base, size);
++#ifdef EAPI
++ if (item->func == NULL) {
++ cp = NULL;
++ ap_hook_use(ap_psprintf(r->pool, "ap::mod_log_config::log_%c", item->ch),
++ AP_HOOK_SIG3(ptr,ptr,ptr), AP_HOOK_DECLINE(NULL),
++ &cp, r, item->arg);
++ }
+ else
+#endif
- ptr = realloc(ps->base, size);
- if (ptr == NULL) {
- fputs("Ouch! Out of memory!\n", stderr);
-@@ -908,9 +1112,21 @@
- size = AP_PSPRINTF_MIN_SIZE;
+ cp = (*item->func) (item->want_orig ? orig : r, item->arg);
+ return cp ? cp : "-";
+ }
+
++---------------------------------------------------------------------------
+| Allow RewriteCond and RewriteRule directives to lookup
+| variables from other modules.
++---------------------------------------------------------------------------
+Index: src/modules/standard/mod_rewrite.c
+--- src/modules/standard/mod_rewrite.c 11 May 2004 18:28:20 -0000 1.1.1.19
++++ src/modules/standard/mod_rewrite.c 11 May 2004 18:32:16 -0000 1.17
+@@ -3848,6 +3848,15 @@
+ }
+ #endif /* ndef WIN32 && NETWARE*/
- /* must try another blok */
-+#if defined(EAPI) && defined(EAPI_MM)
-+ if (blok->h.is_shm)
-+ (void)ap_mm_lock(mm, AP_MM_LOCK_RW);
++#ifdef EAPI
++ else {
++ ap_hook_use("ap::mod_rewrite::lookup_variable",
++ AP_HOOK_SIG3(ptr,ptr,ptr),
++ AP_HOOK_DECLINE(NULL),
++ &result, r, var);
++ }
+#endif
- (void) ap_acquire_mutex(alloc_mutex);
-+#if defined(EAPI) && defined(EAPI_MM)
-+ nblok = new_block(size, blok->h.is_shm);
++
+ if (result == NULL) {
+ return ap_pstrdup(r->pool, "");
+ }
+
++---------------------------------------------------------------------------
+| Add an EAPI hook to allow other modules to add content to
+| the status HTML page.
++---------------------------------------------------------------------------
+Index: src/modules/standard/mod_status.c
+--- src/modules/standard/mod_status.c 11 May 2004 18:28:20 -0000 1.1.1.16
++++ src/modules/standard/mod_status.c 11 May 2004 18:32:16 -0000 1.13
+@@ -651,12 +677,23 @@
+ ap_rprintf(r,
+ "<td>?<td nowrap>?<td nowrap>..reading.. </tr>\n\n");
+ else
++#ifndef NO_PRETTYPRINT
++ ap_rprintf(r,
++ "<td nowrap><font face=\"Arial,Helvetica\" size=\"-1\">%s</font>"
++ "<td nowrap><font face=\"Arial,Helvetica\" size=\"-1\">%s</font>"
++ "<td nowrap><font face=\"Arial,Helvetica\" size=\"-1\">%s</font>"
++ "</tr>\n\n",
++ score_record.client,
++ vhost ? vhost->server_hostname : "(unavailable)",
++ ap_escape_html(r->pool, score_record.request));
+#else
- nblok = new_block(size);
-+#endif
- (void) ap_release_mutex(alloc_mutex);
-+#if defined(EAPI) && defined(EAPI_MM)
-+ if (blok->h.is_shm)
-+ (void)ap_mm_unlock(mm);
+ ap_rprintf(r,
+ "<td>%s<td nowrap>%s<td nowrap>%s</tr>\n\n",
+ ap_escape_html(r->pool, score_record.client),
+ vhost ? ap_escape_html(r->pool,
+ vhost->server_hostname) : "(unavailable)",
+ ap_escape_html(r->pool, score_record.request));
++#endif
+ } /* no_table_report */
+ } /* !short_report */
+ } /* if (<active child>) */
+
++---------------------------------------------------------------------------
+| Add hooks to the scheme processing to allow other modules to
+| recognize more schemes by intercepting this processing.
++---------------------------------------------------------------------------
+Index: src/modules/proxy/mod_proxy.c
+--- src/modules/proxy/mod_proxy.c 11 May 2004 18:28:16 -0000 1.1.1.14
++++ src/modules/proxy/mod_proxy.c 11 May 2004 18:32:15 -0000 1.21
+@@ -175,6 +175,9 @@
+ static int proxy_fixup(request_rec *r)
+ {
+ char *url, *p;
++#ifdef EAPI
++ int rc;
++#endif /* EAPI */
+
+ if (r->proxyreq == NOT_PROXY || strncmp(r->filename, "proxy:", 6) != 0)
+ return DECLINED;
+@@ -182,6 +185,14 @@
+ url = &r->filename[6];
+
+ /* canonicalise each specific scheme */
++#ifdef EAPI
++ if (ap_hook_use("ap::mod_proxy::canon",
++ AP_HOOK_SIG3(int,ptr,ptr),
++ AP_HOOK_DECLINE(DECLINED),
++ &rc, r, url) && rc != DECLINED)
++ return rc;
++ else
++#endif /* EAPI */
+ if (strncasecmp(url, "http:", 5) == 0)
+ return ap_proxy_http_canon(r, url + 5, "http", DEFAULT_HTTP_PORT);
+ else if (strncasecmp(url, "ftp:", 4) == 0)
+@@ -197,9 +208,44 @@
+ static void proxy_init(server_rec *r, pool *p)
+ {
+ ap_proxy_garbage_init(r, p);
++#ifdef EAPI
++ ap_hook_use("ap::mod_proxy::init",
++ AP_HOOK_SIG3(void,ptr,ptr), AP_HOOK_ALL, r, p);
+#endif
- memcpy(nblok->h.first_avail, blok->h.first_avail, cur_len);
- ps->vbuff.curpos = nblok->h.first_avail + cur_len;
- /* save a byte for the NUL terminator */
-@@ -919,10 +1135,18 @@
- /* did we allocate the current blok? if so free it up */
- if (ps->got_a_new_block) {
- debug_fill(blok->h.first_avail, blok->h.endp - blok->h.first_avail);
-+#if defined(EAPI) && defined(EAPI_MM)
-+ if (blok->h.is_shm)
-+ (void)ap_mm_lock(mm, AP_MM_LOCK_RW);
+ }
+
+-
++#ifdef EAPI
++static void proxy_addmod(module *m)
++{
++ /* export: ap_proxy_http_canon() as `ap::mod_proxy::http::canon' */
++ ap_hook_configure("ap::mod_proxy::http::canon",
++ AP_HOOK_SIG5(int,ptr,ptr,ptr,int), AP_HOOK_TOPMOST);
++ ap_hook_register("ap::mod_proxy::http::canon",
++ ap_proxy_http_canon, AP_HOOK_NOCTX);
++
++ /* export: ap_proxy_http_handler() as `ap::mod_proxy::http::handler' */
++ ap_hook_configure("ap::mod_proxy::http::handler",
++ AP_HOOK_SIG6(int,ptr,ptr,ptr,ptr,int), AP_HOOK_TOPMOST);
++ ap_hook_register("ap::mod_proxy::http::handler",
++ ap_proxy_http_handler, AP_HOOK_NOCTX);
++
++ /* export: ap_proxyerror() as `ap::mod_proxy::error' */
++ ap_hook_configure("ap::mod_proxy::error",
++ AP_HOOK_SIG3(int,ptr,ptr), AP_HOOK_TOPMOST);
++ ap_hook_register("ap::mod_proxy::error",
++ ap_proxyerror, AP_HOOK_NOCTX);
++ return;
++}
++
++static void proxy_remmod(module *m)
++{
++ /* remove the hook references */
++ ap_hook_unregister("ap::mod_proxy::http::canon", ap_proxy_http_canon);
++ ap_hook_unregister("ap::mod_proxy::http::handler", ap_proxy_http_handler);
++ ap_hook_unregister("ap::mod_proxy::error", ap_proxyerror);
++ return;
++}
++#endif /* EAPI */
+
+ /* Send a redirection if the request contains a hostname which is not */
+ /* fully qualified, i.e. doesn't have a domain name appended. Some proxy */
+@@ -331,6 +377,14 @@
+ * CONNECT is a special method that bypasses the normal proxy
+ * code.
+ */
++#ifdef EAPI
++ if (!ap_hook_use("ap::mod_proxy::handler",
++ AP_HOOK_SIG7(int,ptr,ptr,ptr,ptr,int,ptr),
++ AP_HOOK_DECLINE(DECLINED),
++ &rc, r, cr, url,
++ ents[i].hostname, ents[i].port,
++ ents[i].protocol) || rc == DECLINED) {
++#endif /* EAPI */
+ if (r->method_number == M_CONNECT)
+ rc = ap_proxy_connect_handler(r, cr, url, ents[i].hostname,
+ ents[i].port);
+@@ -340,6 +394,9 @@
+ ents[i].port);
+ else
+ rc = DECLINED;
++#ifdef EAPI
++ }
++#endif /* EAPI */
+
+ /* an error or success */
+ if (rc != DECLINED && rc != HTTP_BAD_GATEWAY)
+@@ -354,6 +411,14 @@
+ */
+
+ /* handle the scheme */
++#ifdef EAPI
++ if (ap_hook_use("ap::mod_proxy::handler",
++ AP_HOOK_SIG7(int,ptr,ptr,ptr,ptr,int,ptr),
++ AP_HOOK_DECLINE(DECLINED),
++ &rc, r, cr, url,
++ NULL, 0, scheme) && rc != DECLINED)
++ return rc;
++#endif /* EAPI */
+ if (r->method_number == M_CONNECT) {
+ return ap_proxy_connect_handler(r, cr, url, NULL, 0);
+ }
+@@ -951,4 +1016,10 @@
+ NULL, /* child_init */
+ NULL, /* child_exit */
+ proxy_detect /* post read-request */
++#ifdef EAPI
++ ,proxy_addmod, /* EAPI: add_module */
++ proxy_remmod, /* EAPI: remove_module */
++ NULL, /* EAPI: rewrite_command */
++ NULL /* EAPI: new_connection */
+#endif
- (void) ap_acquire_mutex(alloc_mutex);
- blok->h.next = block_freelist;
- block_freelist = blok;
- (void) ap_release_mutex(alloc_mutex);
-+#if defined(EAPI) && defined(EAPI_MM)
-+ if (blok->h.is_shm)
-+ (void)ap_mm_unlock(mm);
+ };
+
++---------------------------------------------------------------------------
+| Add hooks to the HTTP processing to allow other modules
+| to enhance it by intercepting this processing.
++---------------------------------------------------------------------------
+Index: src/modules/proxy/proxy_http.c
+--- src/modules/proxy/proxy_http.c 11 May 2004 18:28:18 -0000 1.1.1.17
++++ src/modules/proxy/proxy_http.c 11 May 2004 18:32:16 -0000 1.25
+@@ -127,6 +127,9 @@
+ const char *datestr, *urlstr;
+ int result, major, minor;
+ const char *content_length;
++#ifdef EAPI
++ char *peer;
+#endif
- }
- ps->blok = nblok;
- ps->got_a_new_block = 1;
-@@ -941,6 +1165,11 @@
- void *ptr;
- ap_block_alarms();
-+#if defined(EAPI) && defined(EAPI_MM)
-+ if (p->is_shm)
-+ ps.base = ap_mm_malloc(mm, 512);
-+ else
+ void *sconf = r->server->module_config;
+ proxy_server_conf *conf =
+@@ -148,6 +151,12 @@
+ return HTTP_BAD_REQUEST;
+ urlptr += 3;
+ destport = DEFAULT_HTTP_PORT;
++#ifdef EAPI
++ ap_hook_use("ap::mod_proxy::http::handler::set_destport",
++ AP_HOOK_SIG2(int,ptr),
++ AP_HOOK_TOPMOST,
++ &destport, r);
++#endif /* EAPI */
+ strp = strchr(urlptr, '/');
+ if (strp == NULL) {
+ desthost = ap_pstrdup(p, urlptr);
+@@ -185,12 +194,18 @@
+ err = ap_proxy_host2addr(proxyhost, &server_hp);
+ if (err != NULL)
+ return DECLINED; /* try another */
++#ifdef EAPI
++ peer = ap_psprintf(p, "%s:%u", proxyhost, proxyport);
+#endif
- ps.base = malloc(512);
- if (ps.base == NULL) {
- fputs("Ouch! Out of memory!\n", stderr);
-@@ -953,6 +1182,11 @@
- *ps.vbuff.curpos++ = '\0';
- ptr = ps.base;
- /* shrink */
-+#if defined(EAPI) && defined(EAPI_MM)
-+ if (p->is_shm)
-+ ptr = ap_mm_realloc(ptr, (char *)ps.vbuff.curpos - (char *)ptr);
-+ else
+ }
+ else {
+ server.sin_port = htons((unsigned short)destport);
+ err = ap_proxy_host2addr(desthost, &server_hp);
+ if (err != NULL)
+ return ap_proxyerror(r, HTTP_INTERNAL_SERVER_ERROR, err);
++#ifdef EAPI
++ peer = ap_psprintf(p, "%s:%u", desthost, destport);
+#endif
- ptr = realloc(ptr, (char *)ps.vbuff.curpos - (char *)ptr);
- if (ptr == NULL) {
- fputs("Ouch! Out of memory!\n", stderr);
-@@ -1780,6 +2014,9 @@
- cleanup_pool_for_exec(permanent_pool);
- ap_unblock_alarms();
- #endif /* ndef WIN32 */
+ }
+
+
+@@ -275,14 +290,42 @@
+ f = ap_bcreate(p, B_RDWR | B_SOCKET);
+ ap_bpushfd(f, sock, sock);
+
+#ifdef EAPI
-+ ap_kill_alloc_shared();
++ {
++ char *errmsg = NULL;
++ ap_hook_use("ap::mod_proxy::http::handler::new_connection",
++ AP_HOOK_SIG4(ptr,ptr,ptr,ptr),
++ AP_HOOK_DECLINE(NULL),
++ &errmsg, r, f, peer);
++ if (errmsg != NULL)
++ return ap_proxyerror(r, HTTP_BAD_GATEWAY, errmsg);
++ }
++#endif /* EAPI */
++
+ ap_hard_timeout("proxy send", r);
+ ap_bvputs(f, r->method, " ", proxyhost ? url : urlptr, " HTTP/1.1" CRLF,
+ NULL);
++#ifdef EAPI
++ {
++ int rc = DECLINED;
++ ap_hook_use("ap::mod_proxy::http::handler::write_host_header",
++ AP_HOOK_SIG6(int,ptr,ptr,ptr,int,ptr),
++ AP_HOOK_DECLINE(DECLINED),
++ &rc, r, f, desthost, destport, destportstr);
++ if (rc == DECLINED) {
++ if (destportstr != NULL && destport != DEFAULT_HTTP_PORT)
++ ap_bvputs(f, "Host: ", desthost, ":", destportstr, CRLF, NULL);
++ else
++ ap_bvputs(f, "Host: ", desthost, CRLF, NULL);
++ }
++ }
++#else /* EAPI */
+ /* Send Host: now, adding it to req_hdrs wouldn't be much better */
+ if (destportstr != NULL && destport != DEFAULT_HTTP_PORT)
+ ap_bvputs(f, "Host: ", desthost, ":", destportstr, CRLF, NULL);
+ else
+ ap_bvputs(f, "Host: ", desthost, CRLF, NULL);
++#endif /* EAPI */
+
+ if (conf->viaopt == via_block) {
+ /* Block all outgoing Via: headers */
+
++---------------------------------------------------------------------------
+| Add EAPI hooks in module structure for APXS generated samples.
++---------------------------------------------------------------------------
+Index: src/support/apxs.pl
+--- src/support/apxs.pl 11 May 2004 18:28:26 -0000 1.1.1.14
++++ src/support/apxs.pl 11 May 2004 18:32:16 -0000 1.14
+@@ -752,5 +752,11 @@
+ NULL, /* child_init */
+ NULL, /* child_exit */
+ NULL /* [#0] post read-request */
++#ifdef EAPI
++ ,NULL, /* EAPI: add_module */
++ NULL, /* EAPI: remove_module */
++ NULL, /* EAPI: rewrite_command */
++ NULL /* EAPI: new_connection */
+#endif
- }
+ };
- API_EXPORT_NONSTD(void) ap_null_cleanup(void *data)
+
++---------------------------------------------------------------------------
+| Add the EAPI functions, so the stuff can be built under AIX
+| and similar braindead platforms as DSO.
++---------------------------------------------------------------------------
+Index: src/support/httpd.exp
+--- src/support/httpd.exp 11 May 2004 18:28:26 -0000 1.1.1.13
++++ src/support/httpd.exp 11 May 2004 18:32:16 -0000 1.15
+@@ -431,3 +431,59 @@
+ XML_SetUnparsedEntityDeclHandler
+ XML_SetUserData
+ XML_UseParserAsHandlerArg
++ap_add_config_define
++ap_make_shared_sub_pool
++ap_global_ctx
++ap_ctx_new
++ap_ctx_get
++ap_ctx_set
++ap_hook_init
++ap_hook_kill
++ap_hook_configure
++ap_hook_register_I
++ap_hook_unregister_I
++ap_hook_status
++ap_hook_use
++ap_hook_call
++ap_mm_useable
++ap_MM_create
++ap_MM_permission
++ap_MM_destroy
++ap_MM_lock
++ap_MM_unlock
++ap_MM_malloc
++ap_MM_realloc
++ap_MM_free
++ap_MM_calloc
++ap_MM_strdup
++ap_MM_sizeof
++ap_MM_maxsize
++ap_MM_available
++ap_MM_error
++ap_mm_create
++ap_mm_permission
++ap_mm_destroy
++ap_mm_lock
++ap_mm_unlock
++ap_mm_malloc
++ap_mm_realloc
++ap_mm_free
++ap_mm_calloc
++ap_mm_strdup
++ap_mm_sizeof
++ap_mm_maxsize
++ap_mm_available
++ap_mm_error
++ap_mm_display_info
++ap_mm_core_create
++ap_mm_core_permission
++ap_mm_core_delete
++ap_mm_core_size
++ap_mm_core_lock
++ap_mm_core_unlock
++ap_mm_core_maxsegsize
++ap_mm_core_align2page
++ap_mm_core_align2word
++ap_mm_lib_error_set
++ap_mm_lib_error_get
++ap_mm_lib_version
+
++---------------------------------------------------------------------------
+| Add the EAPI functions, so the stuff can be built under
+| Windows 95 and similar braindead platforms as DDL.
++---------------------------------------------------------------------------
+Index: src/ApacheCore.def
+--- src/ApacheCore.def 11 May 2004 18:28:08 -0000 1.1.1.11
++++ src/ApacheCore.def 11 May 2004 18:32:15 -0000 1.15
+@@ -448,3 +448,67 @@
+ ap_get_chunk_size @440
+ ap_escape_logitem @441
+ ap_auth_nonce @442
++
++ ; EAPI extended symbols
++ ; note; no ID's, so these all bind by name rather than ordinal since
++ ; their ordinals would change with symbol changes in the distribution
++ ap_add_config_define
++ ap_global_ctx DATA
++ ap_ctx_new
++ ap_ctx_get
++ ap_ctx_overlay
++ ap_ctx_set
++ ap_hook_init
++ ap_hook_kill
++ ap_hook_configure
++ ap_hook_register_I
++ ap_hook_unregister_I
++ ap_hook_status
++ ap_hook_use
++ ap_hook_call
++ ap_set_callback_and_alarm
++ ap_acquire_pool
++ ap_make_shared_sub_pool
++ ap_release_pool
++ ap_mm_useable
++ ap_MM_create
++ ap_MM_permission
++ ap_MM_destroy
++ ap_MM_lock
++ ap_MM_unlock
++ ap_MM_malloc
++ ap_MM_realloc
++ ap_MM_free
++ ap_MM_calloc
++ ap_MM_strdup
++ ap_MM_sizeof
++ ap_MM_maxsize
++ ap_MM_available
++ ap_MM_error
++ ap_mm_create
++ ap_mm_permission
++ ap_mm_destroy
++ ap_mm_lock
++ ap_mm_unlock
++ ap_mm_malloc
++ ap_mm_realloc
++ ap_mm_free
++ ap_mm_calloc
++ ap_mm_strdup
++ ap_mm_sizeof
++ ap_mm_maxsize
++ ap_mm_available
++ ap_mm_error
++ ap_mm_display_info
++ ap_mm_core_create
++ ap_mm_core_permission
++ ap_mm_core_delete
++ ap_mm_core_size
++ ap_mm_core_lock
++ ap_mm_core_unlock
++ ap_mm_core_align2page
++ ap_mm_core_align2word
++ ap_mm_lib_error_set
++ ap_mm_lib_error_get
++ ap_mm_lib_version
++