2 ## | ____| / \ | _ \_ _|
3 ## | _| / _ \ | |_) | |
4 ## | |__ / ___ \| __/| |
5 ## |____/_/ \_\_| |___| Extended API for Apache
6 ## ____________________________________________________________________________
8 ## Annotated patch file: eapi.patch
9 ## Copyright (c) 1998-2001 Ralf S. Engelschall, All Rights Reserved.
10 ## Created on: 19-Jun-2002
12 ## This file assembles changes to existing Apache source files
13 ## between the original Apache and the patched variant. It can be
14 ## automatically applied to a vanilla Apache source tree with the
15 ## 'patch' tool to upgrade those files. Each patch snippet is
16 ## annotated with a short description.
18 ## This file contains all patches to the Apache source
19 ## tree which add the Extended API (EAPI) support.
22 # updated for apache 1.3.27 on 04-Oct-2002
24 +---------------------------------------------------------------------------
25 | Add the EAPI and EAPI_MM configuration entries which triggers the EAPI
26 | patches and configured the shared memory support via the MM library.
27 +---------------------------------------------------------------------------
28 Index: src/Configuration.tmpl
29 --- src/Configuration.tmpl 28 Jan 2002 19:21:21 -0000 1.1.1.7
30 +++ src/Configuration.tmpl 28 Jan 2002 19:40:56 -0000 1.23
34 ################################################################
35 +# Extended API (EAPI) support:
38 +# The EAPI rule enables more module hooks, a generic low-level hook
39 +# mechanism, a generic context mechanism and shared memory based pools.
42 +# Set the EAPI_MM variable to either the directory of a MM Shared Memory
43 +# Library source tree or the installation tree of MM. Alternatively you can
44 +# also use the value 'SYSTEM' which then indicates that MM is installed
45 +# under various system locations. When the MM library files cannot be found
46 +# the EAPI still can be built, but without shared memory pool support, of
52 +################################################################
53 # Dynamic Shared Object (DSO) support
55 # There is experimental support for compiling the Apache core and
57 +---------------------------------------------------------------------------
58 | Patch in implementation of the EAPI rule.
59 +---------------------------------------------------------------------------
61 --- src/Configure 19 Jun 2002 07:20:22 -0000 1.1.1.19
62 +++ src/Configure 19 Jun 2002 07:29:08 -0000 1.22
63 @@ -1869,6 +1869,72 @@
66 ####################################################################
67 +## Extended API (EAPI) support:
69 +if [ "x$RULE_EAPI" = "x" ]; then
70 + RULE_EAPI=`./helpers/CutRule EAPI $file`
72 +if [ "x$RULE_EAPI" = "xyes" ]; then
73 + echo " + enabling Extended API (EAPI)"
74 + CFLAGS="$CFLAGS -DEAPI"
75 + # some vendor compilers are too restrictive
76 + # for our ap_hook and ap_ctx sources.
78 + *IRIX-32*:*/cc|*IRIX-32*:cc )
79 + CFLAGS="$CFLAGS -woff 1048,1110,1164"
82 + # MM Shared Memory Library support for EAPI
83 + if [ "x$EAPI_MM" = "x" ]; then
84 + EAPI_MM=`egrep '^EAPI_MM=' $file | sed -n -e '$p' | awk -F= '{print $2}'`
86 + if [ "x$EAPI_MM" != "x" ]; then
89 + * ) for p in . .. ../..; do
90 + if [ -d "$p/$EAPI_MM" ]; then
91 + EAPI_MM="`echo $p/$EAPI_MM | sed -e 's;/\./;/;g'`"
97 + if [ "x$EAPI_MM" = "xSYSTEM" ]; then
98 + echo " using MM library for EAPI: (system-wide)"
99 + CFLAGS="$CFLAGS -DEAPI_MM"
100 + __INCLUDES="`mm-config --cflags`"
101 + if [ "x$__INCLUDES" != "x-I/usr/include" ]; then
102 + INCLUDES="$INCLUDES $__INCLUDES"
104 + LDFLAGS="$LDFLAGS `mm-config --ldflags`"
105 + LIBS="$LIBS `mm-config --libs`"
107 + if [ -f "$EAPI_MM/.libs/libmm.a" -a -f "$EAPI_MM/mm.h" ]; then
108 + echo " using MM library: $EAPI_MM (source-tree only)"
111 + * ) EAPI_MM="\$(SRCDIR)/$EAPI_MM" ;;
113 + CFLAGS="$CFLAGS -DEAPI_MM"
114 + INCLUDES="$INCLUDES -I$EAPI_MM"
115 + LDFLAGS="$LDFLAGS -L$EAPI_MM/.libs"
117 + elif [ -f "$EAPI_MM/bin/mm-config" ]; then
118 + echo " using MM library: $EAPI_MM (installed)"
119 + CFLAGS="$CFLAGS -DEAPI_MM"
120 + INCLUDES="$INCLUDES `$EAPI_MM/bin/mm-config --cflags`"
121 + LDFLAGS="$LDFLAGS `$EAPI_MM/bin/mm-config --ldflags`"
122 + LIBS="$LIBS `$EAPI_MM/bin/mm-config --libs`"
124 + echo "Configure:Error: Cannot find MM library under $EAPI_MM" 1>&2
132 +####################################################################
133 ## Add in the Expat library if needed/wanted.
137 +---------------------------------------------------------------------------
138 | Add the build support for the ap_hook.c and ap_ctx.c sources (Unix)
139 +---------------------------------------------------------------------------
140 Index: src/ap/Makefile.tmpl
141 --- src/ap/Makefile.tmpl 19 Jun 2002 07:20:22 -0000 1.1.1.8
142 +++ src/ap/Makefile.tmpl 19 Jun 2002 07:29:08 -0000 1.8
145 OBJS=ap_cpystrn.o ap_execve.o ap_fnmatch.o ap_getpass.o ap_md5c.o ap_signal.o \
146 ap_slack.o ap_snprintf.o ap_sha1.o ap_checkpass.o ap_base64.o ap_ebcdic.o \
148 + ap_strtol.o ap_hook.o ap_ctx.o ap_mm.o
151 $(CC) -c $(INCLUDES) $(CFLAGS) $<
153 +---------------------------------------------------------------------------
154 | Add the build support for the ap_hook.c and ap_ctx.c sources (Win32)
155 +---------------------------------------------------------------------------
157 --- src/ap/ap.mak 16 Oct 2001 11:47:06 -0000 1.1.1.9
158 +++ src/ap/ap.mak 16 Oct 2001 11:57:38 -0000 1.9
160 -@erase "$(INTDIR)\ap_cpystrn.obj"
161 -@erase "$(INTDIR)\ap_fnmatch.obj"
162 -@erase "$(INTDIR)\ap_md5c.obj"
163 + -@erase "$(INTDIR)\ap_hook.obj"
164 + -@erase "$(INTDIR)\ap_ctx.obj"
165 + -@erase "$(INTDIR)\ap_mm.obj"
166 -@erase "$(INTDIR)\ap_sha1.obj"
167 -@erase "$(INTDIR)\ap_signal.obj"
168 -@erase "$(INTDIR)\ap_slack.obj"
170 "$(INTDIR)\ap_cpystrn.obj" \
171 "$(INTDIR)\ap_fnmatch.obj" \
172 "$(INTDIR)\ap_md5c.obj" \
173 + "$(INTDIR)\ap_hook.obj" \
174 + "$(INTDIR)\ap_ctx.obj" \
175 + "$(INTDIR)\ap_mm.obj" \
176 "$(INTDIR)\ap_sha1.obj" \
177 "$(INTDIR)\ap_signal.obj" \
178 "$(INTDIR)\ap_slack.obj" \
180 -@erase "$(INTDIR)\ap_cpystrn.obj"
181 -@erase "$(INTDIR)\ap_fnmatch.obj"
182 -@erase "$(INTDIR)\ap_md5c.obj"
183 + -@erase "$(INTDIR)\ap_hook.obj"
184 + -@erase "$(INTDIR)\ap_ctx.obj"
185 + -@erase "$(INTDIR)\ap_mm.obj"
186 -@erase "$(INTDIR)\ap_sha1.obj"
187 -@erase "$(INTDIR)\ap_signal.obj"
188 -@erase "$(INTDIR)\ap_slack.obj"
190 "$(INTDIR)\ap_cpystrn.obj" \
191 "$(INTDIR)\ap_fnmatch.obj" \
192 "$(INTDIR)\ap_md5c.obj" \
193 + "$(INTDIR)\ap_hook.obj" \
194 + "$(INTDIR)\ap_ctx.obj" \
195 + "$(INTDIR)\ap_mm.obj" \
196 "$(INTDIR)\ap_sha1.obj" \
197 "$(INTDIR)\ap_signal.obj" \
198 "$(INTDIR)\ap_slack.obj" \
200 +---------------------------------------------------------------------------
201 | Replace the MODULE_MAGIC_COOKIE to allow us to distinguish between
202 | EAPI-aware modules and standard modules.
203 +---------------------------------------------------------------------------
204 Index: src/include/ap_mmn.h
205 --- src/include/ap_mmn.h 19 Jun 2002 07:20:24 -0000 1.1.1.11
206 +++ src/include/ap_mmn.h 19 Jun 2002 07:29:08 -0000 1.11
208 * 19990320.13 - add ap_strtol()
212 + * Under Extended API situations we replace the magic cookie "AP13" with
213 + * "EAPI" to let us distinguish between the EAPI module structure (which
214 + * contain additional pointers at the end) and standard module structures
215 + * (which lack at least NULL's for the pointers at the end). This is
216 + * important because standard ("AP13") modules would dump core when we
217 + * dispatch over the additional hooks because NULL's are missing at the end of
218 + * the module structure. See also the code in mod_so for details on loading
219 + * (we accept both "AP13" and "EAPI").
222 +#define MODULE_MAGIC_COOKIE_AP13 0x41503133UL /* "AP13" */
223 +#define MODULE_MAGIC_COOKIE_EAPI 0x45415049UL /* "EAPI" */
224 +#define MODULE_MAGIC_COOKIE MODULE_MAGIC_COOKIE_EAPI
226 #define MODULE_MAGIC_COOKIE 0x41503133UL /* "AP13" */
229 #ifndef MODULE_MAGIC_NUMBER_MAJOR
230 #define MODULE_MAGIC_NUMBER_MAJOR 19990320
232 +---------------------------------------------------------------------------
233 | Add the additional prototypes and defines for the
234 | shared memory pools.
235 +---------------------------------------------------------------------------
236 Index: src/include/ap_alloc.h
237 --- src/include/ap_alloc.h 27 Mar 2002 15:22:56 -0000 1.1.1.5
238 +++ src/include/ap_alloc.h 27 Mar 2002 15:30:02 -0000 1.6
240 API_EXPORT(pool *) ap_init_alloc(void); /* Set up everything */
241 void ap_cleanup_alloc(void);
242 API_EXPORT(pool *) ap_make_sub_pool(pool *); /* All pools are subpools of permanent_pool */
244 +typedef enum { AP_POOL_RD, AP_POOL_RW } ap_pool_lock_mode;
245 +int ap_shared_pool_possible(void);
246 +void ap_init_alloc_shared(int);
247 +void ap_kill_alloc_shared(void);
248 +API_EXPORT(pool *) ap_make_shared_sub_pool(pool *);
249 +API_EXPORT(int) ap_acquire_pool(pool *, ap_pool_lock_mode);
250 +API_EXPORT(int) ap_release_pool(pool *);
252 API_EXPORT(void) ap_destroy_pool(pool *);
254 /* pools have nested lifetimes -- sub_pools are destroyed when the
256 +---------------------------------------------------------------------------
257 | Add the additional context variable `ctx' for BUFF structures.
258 +---------------------------------------------------------------------------
259 Index: src/include/buff.h
260 --- src/include/buff.h 27 Mar 2002 15:22:57 -0000 1.1.1.6
261 +++ src/include/buff.h 27 Mar 2002 15:30:02 -0000 1.10
263 /* transport handle, for RPC binding handle or some such */
274 /* Internal routines */
275 API_EXPORT(int) ap_bflsbuf(int c, BUFF *fb);
276 API_EXPORT(int) ap_bfilbuf(BUFF *fb);
279 +#define ap_bpeekc(fb) ( ((fb)->incnt == 0) ? EOF : *((fb)->inptr) )
282 #ifndef CHARSET_EBCDIC
285 +---------------------------------------------------------------------------
286 | Add the four additional Apache API module hooks.
287 +---------------------------------------------------------------------------
288 Index: src/include/http_config.h
289 --- src/include/http_config.h 27 Mar 2002 15:22:57 -0000 1.1.1.10
290 +++ src/include/http_config.h 27 Mar 2002 15:30:02 -0000 1.12
292 void (*child_exit) (server_rec *, pool *);
294 int (*post_read_request) (request_rec *);
298 + * ANSI C guarantees us that we can at least _extend_ the module structure
299 + * with additional hooks without the need to change all existing modules.
300 + * Because: ``If there are fewer initializers in the list than members of
301 + * the structure, the trailing members are initialized with 0.'' (The C
302 + * Programming Language, 2nd Ed., A8.7 Initialization). So we just
303 + * have to put our additional hooks here:
306 + * Called from within ap_add_module() right after the module structure
307 + * was linked into the Apache internal module list. It is mainly
308 + * intended to be used to define configuration defines (<IfDefine>)
309 + * which have to be available directly after a LoadModule/AddModule.
310 + * Actually this is the earliest possible hook a module can use.
313 + * Called from within ap_remove_module() right before the module
314 + * structure is kicked out from the Apache internal module list.
315 + * Actually this is last possible hook a module can use and exists for
316 + * consistency with the add_module hook.
319 + * Called right after a configuration directive line was read and
320 + * before it is processed. It is mainly intended to be used for
321 + * rewriting directives in order to provide backward compatibility to
322 + * old directive variants.
325 + * Called from within the internal new_connection() function, right
326 + * after the conn_rec structure for the new established connection was
327 + * created and before Apache starts processing the request with
328 + * ap_read_request(). It is mainly intended to be used to setup/run
329 + * connection dependent things like sending start headers for
330 + * on-the-fly compression, etc.
332 + * close_connection:
333 + * Called from within the Apache dispatching loop just before any
334 + * ap_bclose() is performed on the socket connection, but a long time
335 + * before any pool cleanups are done for the connection (which can be
336 + * too late for some applications). It is mainly intended to be used
337 + * to close/finalize connection dependent things like sending end
338 + * headers for on-the-fly compression, etc.
340 +#ifdef ULTRIX_BRAIN_DEATH
341 + void (*add_module) ();
342 + void (*remove_module) ();
343 + char *(*rewrite_command) ();
344 + void (*new_connection) ();
345 + void (*close_connection) ();
347 + void (*add_module) (struct module_struct *);
348 + void (*remove_module) (struct module_struct *);
349 + char *(*rewrite_command) (cmd_parms *, void *config, const char *);
350 + void (*new_connection) (conn_rec *);
351 + void (*close_connection) (conn_rec *);
356 /* Initializer for the first few module slots, which are only
358 +---------------------------------------------------------------------------
359 | Add the additional variable `ap_global_ctx' for holding
360 | global module context.
361 +---------------------------------------------------------------------------
362 Index: src/include/http_conf_globals.h
363 --- src/include/http_conf_globals.h 27 Mar 2002 15:22:57 -0000 1.1.1.11
364 +++ src/include/http_conf_globals.h 27 Mar 2002 15:30:02 -0000 1.12
367 extern int ap_dump_settings;
368 extern API_VAR_EXPORT int ap_extended_status;
370 +extern API_VAR_EXPORT ap_ctx *ap_global_ctx;
373 extern API_VAR_EXPORT char *ap_pid_fname;
374 extern API_VAR_EXPORT char *ap_scoreboard_fname;
376 +---------------------------------------------------------------------------
377 | Export the ap_set_callback_and_alarm() function because this
378 | first is a useful thing and second we need it because all
379 | other API/timeout functions deal with a request_rec while
380 | some modules need a generic timeout mechanism.
381 +---------------------------------------------------------------------------
382 Index: src/include/http_main.h
384 +---------------------------------------------------------------------------
385 | First add support for the HTTPS protocol scheme via hooks,
386 | second add the additional context variable `ctx' for the
387 | conn_rec, server_rec and request_rec structures. And third
388 | add a prototype for the additional ap_add_config_define()
390 +---------------------------------------------------------------------------
391 Index: src/include/httpd.h
392 --- src/include/httpd.h 19 Jun 2002 07:20:24 -0000 1.1.1.19
393 +++ src/include/httpd.h 19 Jun 2002 07:29:08 -0000 1.29
395 /* Headers in which EVERYONE has an interest... */
397 #include "ap_config.h"
401 #include "ap_alloc.h"
403 + * Include the Extended API headers.
404 + * Don't move the position. It has to be after ap_alloc.h because it uses the
405 + * pool stuff but before buff.h because the buffer stuff uses the EAPI, too.
408 +#include "ap_hook.h"
414 @@ -141,12 +153,17 @@
415 #define DEFAULT_HTTP_PORT 80
416 #define DEFAULT_HTTPS_PORT 443
417 #define ap_is_default_port(port,r) ((port) == ap_default_port(r))
419 +#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")
420 +#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)
423 #define ap_http_method(r) ap_os_http_method(r)
425 #define ap_http_method(r) "http"
427 #define ap_default_port(r) DEFAULT_HTTP_PORT
430 /* --------- Default user name and group name running standalone ---------- */
431 /* --- These may be specified as numbers by placing a # before a number --- */
433 #define SCOREBOARD_MAINTENANCE_INTERVAL 1000000
438 + * Path to Shared Memory Files
441 +#ifndef EAPI_MM_CORE_PATH
442 +#define EAPI_MM_CORE_PATH "logs/mm"
444 +#ifndef EAPI_MM_CORE_MAXSIZE
445 +#define EAPI_MM_CORE_MAXSIZE 1024*1024*1 /* max. 1MB */
449 /* Number of requests to try to handle in a single process. If <= 0,
450 * the children don't die off. That's the default here, since I'm still
451 * interested in finding and stanching leaks.
453 API_EXPORT(const char *) ap_get_server_version(void);
454 API_EXPORT(void) ap_add_version_component(const char *component);
455 API_EXPORT(const char *) ap_get_server_built(void);
457 +API_EXPORT(void) ap_add_config_define(const char *define);
460 /* Numeric release version identifier: MMNNFFRBB: major minor fix final beta
461 * Always increases along the same track as the source branch.
463 * record to improve 64bit alignment the next time we need to break
464 * binary compatibility for some other reason.
474 char *local_host; /* used for ap_get_server_name when
475 * UseCanonicalName is set to DNS
476 * (ignores setting of HostnameLookups) */
482 /* Per-vhost config... */
483 @@ -966,6 +1006,10 @@
484 int limit_req_line; /* limit on size of the HTTP request line */
485 int limit_req_fieldsize; /* limit on size of any request header field */
486 int limit_req_fields; /* limit on number of request header fields */
493 /* These are more like real hosts than virtual hosts */
495 +---------------------------------------------------------------------------
496 | Patch the shared memory pool support into the Apache pool facility.
497 +---------------------------------------------------------------------------
498 Index: src/main/alloc.c
499 --- src/main/alloc.c 27 Mar 2002 15:23:00 -0000 1.1.1.12
500 +++ src/main/alloc.c 27 Mar 2002 15:30:02 -0000 1.19
506 +#include "http_config.h"
507 +#include "http_conf_globals.h"
509 #include "multithread.h"
510 #include "http_log.h"
513 #define BLOCK_MINALLOC 0
516 +#if defined(EAPI) && defined(EAPI_MM)
517 +static AP_MM *mm = NULL;
520 /*****************************************************************
522 * Managing free storage blocks...
525 union block_hdr *next;
527 +#if defined(EAPI) && defined(EAPI_MM)
531 union block_hdr *global_next;
532 struct pool *owning_pool;
534 /* Get a completely new block from the system pool. Note that we rely on
535 malloc() to provide aligned memory. */
537 +#if defined(EAPI) && defined(EAPI_MM)
538 +static union block_hdr *malloc_block(int size, int is_shm)
540 static union block_hdr *malloc_block(int size)
543 union block_hdr *blok;
545 @@ -230,12 +245,20 @@
547 num_malloc_bytes += size + sizeof(union block_hdr);
549 +#if defined(EAPI) && defined(EAPI_MM)
551 + blok = (union block_hdr *)ap_mm_malloc(mm, size + sizeof(union block_hdr));
554 blok = (union block_hdr *) malloc(size + sizeof(union block_hdr));
556 fprintf(stderr, "Ouch! malloc failed in malloc_block()\n");
559 debug_fill(blok, size + sizeof(union block_hdr));
560 +#if defined(EAPI) && defined(EAPI_MM)
561 + blok->h.is_shm = is_shm;
564 blok->h.first_avail = (char *) (blok + 1);
565 blok->h.endp = size + blok->h.first_avail;
568 return; /* Sanity check --- freeing empty pool? */
570 +#if defined(EAPI) && defined(EAPI_MM)
571 + if (blok->h.is_shm)
572 + (void)ap_mm_lock(mm, AP_MM_LOCK_RW);
574 (void) ap_acquire_mutex(alloc_mutex);
575 old_free_list = block_freelist;
576 block_freelist = blok;
580 (void) ap_release_mutex(alloc_mutex);
581 +#if defined(EAPI) && defined(EAPI_MM)
582 + if (blok->h.is_shm)
583 + (void)ap_mm_unlock(mm);
589 * if necessary. Must be called with alarms blocked.
592 +#if defined(EAPI) && defined(EAPI_MM)
593 +static union block_hdr *new_block(int min_size, int is_shm)
595 static union block_hdr *new_block(int min_size)
598 union block_hdr **lastptr = &block_freelist;
599 union block_hdr *blok = block_freelist;
603 while (blok != NULL) {
604 +#if defined(EAPI) && defined(EAPI_MM)
605 + if (blok->h.is_shm == is_shm &&
606 + min_size + BLOCK_MINFREE <= blok->h.endp - blok->h.first_avail) {
608 if (min_size + BLOCK_MINFREE <= blok->h.endp - blok->h.first_avail) {
610 *lastptr = blok->h.next;
612 debug_verify_filled(blok->h.first_avail, blok->h.endp,
616 min_size += BLOCK_MINFREE;
617 +#if defined(EAPI) && defined(EAPI_MM)
618 + blok = malloc_block((min_size > BLOCK_MINALLOC) ? min_size : BLOCK_MINALLOC, is_shm);
620 blok = malloc_block((min_size > BLOCK_MINALLOC) ? min_size : BLOCK_MINALLOC);
629 +#if defined(EAPI) && defined(EAPI_MM)
634 static pool *permanent_pool;
635 @@ -440,16 +487,28 @@
636 #define POOL_HDR_CLICKS (1 + ((sizeof(struct pool) - 1) / CLICK_SZ))
637 #define POOL_HDR_BYTES (POOL_HDR_CLICKS * CLICK_SZ)
639 +#if defined(EAPI) && defined(EAPI_MM)
640 +static struct pool *make_sub_pool_internal(struct pool *p, int is_shm)
642 API_EXPORT(struct pool *) ap_make_sub_pool(struct pool *p)
645 union block_hdr *blok;
650 +#if defined(EAPI) && defined(EAPI_MM)
652 + (void)ap_mm_lock(mm, AP_MM_LOCK_RW);
654 (void) ap_acquire_mutex(alloc_mutex);
656 +#if defined(EAPI) && defined(EAPI_MM)
657 + blok = new_block(POOL_HDR_BYTES, is_shm);
659 blok = new_block(POOL_HDR_BYTES);
661 new_pool = (pool *) blok->h.first_avail;
662 blok->h.first_avail += POOL_HDR_BYTES;
664 @@ -468,12 +527,38 @@
665 p->sub_pools = new_pool;
668 +#if defined(EAPI) && defined(EAPI_MM)
669 + new_pool->is_shm = is_shm;
672 (void) ap_release_mutex(alloc_mutex);
673 +#if defined(EAPI) && defined(EAPI_MM)
675 + (void)ap_mm_unlock(mm);
683 +#if defined(EAPI_MM)
684 +API_EXPORT(struct pool *) ap_make_sub_pool(struct pool *p)
686 + return make_sub_pool_internal(p, 0);
688 +API_EXPORT(struct pool *) ap_make_shared_sub_pool(struct pool *p)
690 + return make_sub_pool_internal(p, 1);
693 +API_EXPORT(struct pool *) ap_make_shared_sub_pool(struct pool *p)
701 static void stack_var_init(char *s)
708 +int ap_shared_pool_possible(void)
710 + return ap_mm_useable();
715 static void dump_stats(void)
718 return permanent_pool;
722 +void ap_init_alloc_shared(int early)
724 +#if defined(EAPI_MM)
730 + /* process very early on startup */
731 + mm_size = ap_mm_maxsize();
732 + if (mm_size > EAPI_MM_CORE_MAXSIZE)
733 + mm_size = EAPI_MM_CORE_MAXSIZE;
734 + mm_path = ap_server_root_relative(permanent_pool,
735 + ap_psprintf(permanent_pool, "%s.%ld",
736 + EAPI_MM_CORE_PATH, (long)getpid()));
737 + if ((mm = ap_mm_create(mm_size, mm_path)) == NULL) {
738 + fprintf(stderr, "Ouch! ap_mm_create(%d, \"%s\") failed\n", mm_size, mm_path);
739 + err1 = ap_mm_error();
741 + err1 = "-unknown-";
742 + err2 = strerror(errno);
744 + err2 = "-unknown-";
745 + fprintf(stderr, "Error: MM: %s: OS: %s\n", err1, err2);
750 + /* process a lot later on startup */
752 + ap_mm_permission(mm, (_S_IREAD|_S_IWRITE), ap_user_id, -1);
754 + ap_mm_permission(mm, (S_IRUSR|S_IWUSR), ap_user_id, -1);
757 +#endif /* EAPI_MM */
761 +void ap_kill_alloc_shared(void)
763 +#if defined(EAPI_MM)
768 +#endif /* EAPI_MM */
773 void ap_cleanup_alloc(void)
775 ap_destroy_mutex(alloc_mutex);
776 @@ -530,10 +674,18 @@
780 +#if defined(EAPI) && defined(EAPI_MM)
782 + (void)ap_mm_lock(mm, AP_MM_LOCK_RW);
784 (void) ap_acquire_mutex(alloc_mutex);
786 ap_destroy_pool(a->sub_pools);
787 (void) ap_release_mutex(alloc_mutex);
788 +#if defined(EAPI) && defined(EAPI_MM)
790 + (void)ap_mm_unlock(mm);
792 /* Don't hold the mutex during cleanups. */
793 run_cleanups(a->cleanups);
799 +#if defined(EAPI) && defined(EAPI_MM)
801 + (void)ap_mm_lock(mm, AP_MM_LOCK_RW);
803 (void) ap_acquire_mutex(alloc_mutex);
805 if (a->parent->sub_pools == a)
807 a->sub_next->sub_prev = a->sub_prev;
809 (void) ap_release_mutex(alloc_mutex);
810 +#if defined(EAPI) && defined(EAPI_MM)
812 + (void)ap_mm_unlock(mm);
815 free_blocks(a->first);
818 return bytes_in_block_list(block_freelist);
822 +API_EXPORT(int) ap_acquire_pool(pool *p, ap_pool_lock_mode mode)
824 +#if defined(EAPI_MM)
827 + return ap_mm_lock(mm, mode == AP_POOL_RD ? AP_MM_LOCK_RD : AP_MM_LOCK_RW);
833 +API_EXPORT(int) ap_release_pool(pool *p)
835 +#if defined(EAPI_MM)
838 + return ap_mm_unlock(mm);
845 /*****************************************************************
848 @@ -756,16 +940,31 @@
852 +#if defined(EAPI) && defined(EAPI_MM)
854 + (void)ap_mm_lock(mm, AP_MM_LOCK_RW);
856 (void) ap_acquire_mutex(alloc_mutex);
858 +#if defined(EAPI) && defined(EAPI_MM)
859 + blok = new_block(size, a->is_shm);
861 blok = new_block(size);
863 a->last->h.next = blok;
866 blok->h.owning_pool = a;
868 +#if defined(EAPI) && defined(EAPI_MM)
869 + blok->h.is_shm = a->is_shm;
872 (void) ap_release_mutex(alloc_mutex);
873 +#if defined(EAPI) && defined(EAPI_MM)
875 + (void)ap_mm_unlock(mm);
880 @@ -877,6 +1076,11 @@
882 if (size < AP_PSPRINTF_MIN_SIZE)
883 size = AP_PSPRINTF_MIN_SIZE;
884 +#if defined(EAPI) && defined(EAPI_MM)
885 + if (ps->block->h.is_shm)
886 + ptr = ap_mm_realloc(ps->base, size);
889 ptr = realloc(ps->base, size);
891 fputs("Ouch! Out of memory!\n", stderr);
892 @@ -897,9 +1101,21 @@
893 size = AP_PSPRINTF_MIN_SIZE;
895 /* must try another blok */
896 +#if defined(EAPI) && defined(EAPI_MM)
897 + if (blok->h.is_shm)
898 + (void)ap_mm_lock(mm, AP_MM_LOCK_RW);
900 (void) ap_acquire_mutex(alloc_mutex);
901 +#if defined(EAPI) && defined(EAPI_MM)
902 + nblok = new_block(size, blok->h.is_shm);
904 nblok = new_block(size);
906 (void) ap_release_mutex(alloc_mutex);
907 +#if defined(EAPI) && defined(EAPI_MM)
908 + if (blok->h.is_shm)
909 + (void)ap_mm_unlock(mm);
911 memcpy(nblok->h.first_avail, blok->h.first_avail, cur_len);
912 ps->vbuff.curpos = nblok->h.first_avail + cur_len;
913 /* save a byte for the NUL terminator */
914 @@ -908,10 +1124,18 @@
915 /* did we allocate the current blok? if so free it up */
916 if (ps->got_a_new_block) {
917 debug_fill(blok->h.first_avail, blok->h.endp - blok->h.first_avail);
918 +#if defined(EAPI) && defined(EAPI_MM)
919 + if (blok->h.is_shm)
920 + (void)ap_mm_lock(mm, AP_MM_LOCK_RW);
922 (void) ap_acquire_mutex(alloc_mutex);
923 blok->h.next = block_freelist;
924 block_freelist = blok;
925 (void) ap_release_mutex(alloc_mutex);
926 +#if defined(EAPI) && defined(EAPI_MM)
927 + if (blok->h.is_shm)
928 + (void)ap_mm_unlock(mm);
932 ps->got_a_new_block = 1;
933 @@ -930,6 +1154,11 @@
937 +#if defined(EAPI) && defined(EAPI_MM)
939 + ps.base = ap_mm_malloc(mm, 512);
942 ps.base = malloc(512);
943 if (ps.base == NULL) {
944 fputs("Ouch! Out of memory!\n", stderr);
945 @@ -942,6 +1171,11 @@
946 *ps.vbuff.curpos++ = '\0';
949 +#if defined(EAPI) && defined(EAPI_MM)
951 + ptr = ap_mm_realloc(ptr, (char *)ps.vbuff.curpos - (char *)ptr);
954 ptr = realloc(ptr, (char *)ps.vbuff.curpos - (char *)ptr);
956 fputs("Ouch! Out of memory!\n", stderr);
958 +---------------------------------------------------------------------------
959 | Patch the low-level buffer routines to additionally allow
960 | modules to intercept the I/O processing via hooks.
961 +---------------------------------------------------------------------------
962 Index: src/main/buff.c
963 --- src/main/buff.c 27 Mar 2002 15:23:00 -0000 1.1.1.12
964 +++ src/main/buff.c 27 Mar 2002 15:30:02 -0000 1.20
970 + if (!ap_hook_call("ap::buff::read", &rv, fb, buf, nbyte))
972 rv = read(fb->fd_in, buf, nbyte);
977 #if defined (WIN32) || defined(NETWARE) || defined(CYGWIN_WINSOCK)
978 if (fb->flags & B_SOCKET) {
980 + if (!ap_hook_call("ap::buff::recvwithtimeout", &rv, fb, buf, nbyte))
982 rv = ap_recvwithtimeout(fb->fd_in, buf, nbyte, 0);
983 if (rv == SOCKET_ERROR)
984 errno = WSAGetLastError();
990 + if (!ap_hook_call("ap::buff::write", &rv, fb, buf, nbyte))
993 rv = sfwrite(fb->sf_out, buf, nbyte);
997 #if defined(WIN32) || defined(NETWARE)
998 if (fb->flags & B_SOCKET) {
1000 + if (!ap_hook_call("ap::buff::sendwithtimeout", &rv, fb, buf, nbyte))
1002 rv = ap_sendwithtimeout(fb->fd, buf, nbyte, 0);
1003 if (rv == SOCKET_ERROR)
1004 errno = WSAGetLastError();
1005 @@ -464,6 +476,10 @@
1006 fb->callback_data = NULL;
1007 fb->filter_callback = NULL;
1010 + fb->ctx = ap_ctx_new(p);
1016 @@ -1116,6 +1132,9 @@
1021 + if (!ap_hook_call("ap::buff::writev", &rv, fb, &vec[i], nvec -i))
1023 rv = writev(fb->fd, &vec[i], nvec - i);
1024 while (rv == -1 && (errno == EINTR || errno == EAGAIN)
1025 && !(fb->flags & B_EOUT));
1027 +---------------------------------------------------------------------------
1028 | Add the implementation of the additional `add_module' and
1029 | `rewrite_command' module hooks. Additionally the `ctx'
1030 | variables are initialized.
1031 +---------------------------------------------------------------------------
1032 Index: src/main/http_config.c
1033 --- src/main/http_config.c 27 Mar 2002 15:23:00 -0000 1.1.1.14
1034 +++ src/main/http_config.c 27 Mar 2002 15:30:02 -0000 1.17
1035 @@ -599,6 +599,20 @@
1038 #endif /*_OSD_POSIX*/
1042 + * Invoke the `add_module' hook inside the now existing set
1043 + * of modules to let them all now that this module was added.
1047 + for (m2 = top_module; m2 != NULL; m2 = m2->next)
1048 + if (m2->magic == MODULE_MAGIC_COOKIE_EAPI)
1049 + if (m2->add_module != NULL)
1050 + (*m2->add_module)(m);
1056 @@ -613,6 +627,21 @@
1062 + * Invoke the `remove_module' hook inside the now existing
1063 + * set of modules to let them all now that this module is
1068 + for (m2 = top_module; m2 != NULL; m2 = m2->next)
1069 + if (m2->magic == MODULE_MAGIC_COOKIE_EAPI)
1070 + if (m2->remove_module != NULL)
1071 + (*m2->remove_module)(m);
1077 /* We are the top module, special case */
1078 @@ -1006,6 +1035,27 @@
1079 const command_rec *cmd;
1080 module *mod = top_module;
1084 + * Invoke the `rewrite_command' of modules to allow
1085 + * they to rewrite the directive line before we
1091 + for (m = top_module; m != NULL; m = m->next) {
1092 + if (m->magic == MODULE_MAGIC_COOKIE_EAPI) {
1093 + if (m->rewrite_command != NULL) {
1094 + cp = (m->rewrite_command)(parms, config, l);
1103 if ((l[0] == '#') || (!l[0]))
1106 @@ -1440,6 +1490,10 @@
1107 s->limit_req_fieldsize = main_server->limit_req_fieldsize;
1108 s->limit_req_fields = main_server->limit_req_fields;
1111 + s->ctx = ap_ctx_new(p);
1116 return ap_parse_vhost_addrs(p, hostname, s);
1117 @@ -1550,6 +1604,10 @@
1119 s->module_config = create_server_config(p, s);
1120 s->lookup_defaults = create_default_per_dir_config(p);
1123 + s->ctx = ap_ctx_new(p);
1129 +---------------------------------------------------------------------------
1130 | Add the ap_global_ctx variable and the new
1131 | ap_add_config_define() function. Additionally the
1132 | implementation of the additional `new_connection' module hook
1133 | is added plus the initialization of one more `ctx' variable.
1134 +---------------------------------------------------------------------------
1135 Index: src/main/http_main.c
1136 --- src/main/http_main.c 19 Jun 2002 07:20:25 -0000 1.1.1.18
1137 +++ src/main/http_main.c 19 Jun 2002 07:29:08 -0000 1.40
1140 int ap_dump_settings = 0;
1141 API_VAR_EXPORT int ap_extended_status = 0;
1143 +API_VAR_EXPORT ap_ctx *ap_global_ctx;
1147 * The max child slot ever assigned, preserved across restarts. Necessary
1148 @@ -463,6 +466,30 @@
1153 +API_EXPORT(void) ap_add_config_define(const char *define)
1156 + var = (char **)ap_push_array(ap_server_config_defines);
1157 + *var = ap_pstrdup(pcommands, define);
1162 + * Invoke the `close_connection' hook of modules to let them do
1163 + * some connection dependent actions before we close it.
1165 +static void ap_call_close_connection_hook(conn_rec *c)
1168 + for (m = top_module; m != NULL; m = m->next)
1169 + if (m->magic == MODULE_MAGIC_COOKIE_EAPI)
1170 + if (m->close_connection != NULL)
1171 + (*m->close_connection)(c);
1177 static APACHE_TLS int volatile exit_after_unblock = 0;
1179 @@ -1518,6 +1545,10 @@
1180 ap_log_transaction(log_req);
1184 + ap_call_close_connection_hook(save_req->connection);
1187 ap_bsetflag(save_req->connection->client, B_EOUT, 1);
1188 ap_bclose(save_req->connection->client);
1190 @@ -1526,6 +1557,9 @@
1191 ap_longjmp(jmpbuffer, 1);
1193 else { /* abort the connection */
1195 + ap_call_close_connection_hook(current_conn);
1197 ap_bsetflag(current_conn->client, B_EOUT, 1);
1198 ap_bclose(current_conn->client);
1199 current_conn->aborted = 1;
1200 @@ -1828,10 +1862,16 @@
1201 /* Send any leftover data to the client, but never try to again */
1203 if (ap_bflush(r->connection->client) == -1) {
1205 + ap_call_close_connection_hook(r->connection);
1208 ap_bclose(r->connection->client);
1212 + ap_call_close_connection_hook(r->connection);
1214 ap_bsetflag(r->connection->client, B_EOUT, 1);
1216 /* Close our half of the connection --- send the client a FIN */
1217 @@ -2559,6 +2599,9 @@
1218 /* Clear the pool - including any registered cleanups */
1219 ap_destroy_pool(pglobal);
1222 + ap_kill_alloc_shared();
1227 @@ -3570,6 +3613,24 @@
1228 conn->remote_addr = *remaddr;
1229 conn->remote_ip = ap_pstrdup(conn->pool,
1230 inet_ntoa(conn->remote_addr.sin_addr));
1232 + conn->ctx = ap_ctx_new(conn->pool);
1237 + * Invoke the `new_connection' hook of modules to let them do
1238 + * some connection dependent actions before we go on with
1239 + * processing the request on this connection.
1243 + for (m = top_module; m != NULL; m = m->next)
1244 + if (m->magic == MODULE_MAGIC_COOKIE_EAPI)
1245 + if (m->new_connection != NULL)
1246 + (*m->new_connection)(conn);
1252 @@ -3998,6 +4059,15 @@
1253 printf("Server's Module Magic Number: %u:%u\n",
1254 MODULE_MAGIC_NUMBER_MAJOR, MODULE_MAGIC_NUMBER_MINOR);
1255 printf("Server compiled with....\n");
1257 + printf(" -D EAPI\n");
1260 + printf(" -D EAPI_MM\n");
1261 +#ifdef EAPI_MM_CORE_PATH
1262 + printf(" -D EAPI_MM_CORE_PATH=\"" EAPI_MM_CORE_PATH "\"\n");
1266 show_os_specific_compile_settings();
1268 @@ -4167,6 +4237,22 @@
1269 ap_server_pre_read_config = ap_make_array(pcommands, 1, sizeof(char *));
1270 ap_server_post_read_config = ap_make_array(pcommands, 1, sizeof(char *));
1271 ap_server_config_defines = ap_make_array(pcommands, 1, sizeof(char *));
1275 + ap_hook_configure("ap::buff::read",
1276 + AP_HOOK_SIG4(int,ptr,ptr,int), AP_HOOK_TOPMOST);
1277 + ap_hook_configure("ap::buff::write",
1278 + AP_HOOK_SIG4(int,ptr,ptr,int), AP_HOOK_TOPMOST);
1279 + ap_hook_configure("ap::buff::writev",
1280 + AP_HOOK_SIG4(int,ptr,ptr,int), AP_HOOK_TOPMOST);
1281 + ap_hook_configure("ap::buff::sendwithtimeout",
1282 + AP_HOOK_SIG4(int,ptr,ptr,int), AP_HOOK_TOPMOST);
1283 + ap_hook_configure("ap::buff::recvwithtimeout",
1284 + AP_HOOK_SIG4(int,ptr,ptr,int), AP_HOOK_TOPMOST);
1286 + ap_global_ctx = ap_ctx_new(NULL);
1291 @@ -4617,6 +4703,9 @@
1293 ap_sync_scoreboard_image();
1294 if (ap_scoreboard_image->global.running_generation != ap_my_generation) {
1296 + ap_call_close_connection_hook(current_conn);
1299 clean_child_exit(0);
1301 @@ -4645,6 +4734,9 @@
1306 + ap_call_close_connection_hook(current_conn);
1308 ap_bclose(conn_io); /* just close it */
1310 if (r && r->connection
1311 @@ -4655,6 +4747,9 @@
1316 + ap_call_close_connection_hook(current_conn);
1318 ap_bsetflag(conn_io, B_EOUT, 1);
1321 @@ -5420,16 +5515,31 @@
1326 + ap_init_alloc_shared(TRUE);
1329 ap_suexec_enabled = init_suexec();
1330 server_conf = ap_read_config(pconf, ptrans, ap_server_confname);
1333 + ap_init_alloc_shared(FALSE);
1336 if (ap_configtestonly) {
1337 fprintf(stderr, "Syntax OK\n");
1339 + clean_parent_exit(0);
1344 if (ap_dump_settings) {
1346 + clean_parent_exit(0);
1352 child_timeouts = !ap_standalone || one_process;
1353 @@ -5576,6 +5686,10 @@
1354 ap_destroy_pool(r->pool);
1358 + ap_call_close_connection_hook(conn);
1364 @@ -5952,6 +6066,9 @@
1365 ap_kill_cleanups_for_socket(ptrans, csd);
1369 + ap_call_close_connection_hook(current_conn);
1371 ap_bclose(conn_io); /* just close it */
1373 if (r && r->connection
1374 @@ -5962,6 +6079,9 @@
1379 + ap_call_close_connection_hook(current_conn);
1381 ap_bsetflag(conn_io, B_EOUT, 1);
1384 @@ -7530,6 +7650,10 @@
1385 if (!conf_specified)
1386 ap_cpystrn(ap_server_confname, SERVER_CONFIG_FILE, sizeof(ap_server_confname));
1389 + ap_init_alloc_shared(TRUE);
1392 if (!ap_os_is_path_absolute(ap_server_confname))
1393 ap_cpystrn(ap_server_confname,
1394 ap_server_root_relative(pcommands, ap_server_confname),
1395 @@ -7569,6 +7693,9 @@
1397 #else /* ndef WIN32 */
1398 server_conf = ap_read_config(pconf, ptrans, ap_server_confname);
1401 + ap_init_alloc_shared(FALSE);
1404 if (ap_configtestonly) {
1406 +---------------------------------------------------------------------------
1407 | Just add the initialization of the `ctx' variable for
1408 | conn_rec structures.
1409 +---------------------------------------------------------------------------
1410 Index: src/main/http_request.c
1411 --- src/main/http_request.c 19 Jun 2002 07:20:26 -0000 1.1.1.15
1412 +++ src/main/http_request.c 19 Jun 2002 07:29:09 -0000 1.15
1413 @@ -1375,6 +1375,10 @@
1415 new->method = r->method;
1416 new->method_number = r->method_number;
1418 + /* initialize context _BEFORE_ ap_parse_uri() call */
1419 + new->ctx = r->ctx;
1421 ap_parse_uri(new, new_uri);
1422 new->request_config = ap_create_request_config(r->pool);
1423 new->per_dir_config = r->server->lookup_defaults;
1425 +---------------------------------------------------------------------------
1426 | Just add the initialization of the `ctx' variable for
1427 | request_rec structures.
1428 +---------------------------------------------------------------------------
1429 Index: src/main/http_protocol.c
1430 --- src/main/http_protocol.c 19 Jun 2002 07:20:26 -0000 1.1.1.17
1431 +++ src/main/http_protocol.c 19 Jun 2002 07:29:09 -0000 1.17
1432 @@ -1167,6 +1167,10 @@
1433 r->status = HTTP_REQUEST_TIME_OUT; /* Until we get a request */
1434 r->the_request = NULL;
1437 + r->ctx = ap_ctx_new(r->pool);
1440 #ifdef CHARSET_EBCDIC
1441 ap_bsetflag(r->connection->client, B_ASCII2EBCDIC, r->ebcdic.conv_in = 1);
1442 ap_bsetflag(r->connection->client, B_EBCDIC2ASCII, r->ebcdic.conv_out = 1);
1443 @@ -1323,6 +1327,11 @@
1444 rnew->read_body = REQUEST_NO_BODY;
1446 rnew->main = (request_rec *) r;
1449 + rnew->ctx = r->ctx;
1454 API_EXPORT(void) ap_finalize_sub_req_protocol(request_rec *sub)
1456 +---------------------------------------------------------------------------
1457 | Add support for loading both EAPI and AP13 modules.
1458 +---------------------------------------------------------------------------
1459 Index: src/modules/standard/mod_so.c
1460 --- src/modules/standard/mod_so.c 27 Mar 2002 15:23:06 -0000 1.1.1.9
1461 +++ src/modules/standard/mod_so.c 27 Mar 2002 15:30:03 -0000 1.10
1462 @@ -269,11 +269,24 @@
1463 * Make sure the found module structure is really a module structure
1467 + if ( modp->magic != MODULE_MAGIC_COOKIE_AP13
1468 + && modp->magic != MODULE_MAGIC_COOKIE_EAPI) {
1470 if (modp->magic != MODULE_MAGIC_COOKIE) {
1472 return ap_pstrcat(cmd->pool, "API module structure `", modname,
1473 "' in file ", szModuleFile, " is garbled -"
1474 " perhaps this is not an Apache module DSO?", NULL);
1477 + if (modp->magic == MODULE_MAGIC_COOKIE_AP13) {
1478 + ap_log_error(APLOG_MARK, APLOG_WARNING|APLOG_NOERRNO, NULL,
1479 + "Loaded DSO %s uses plain Apache 1.3 API, "
1480 + "this module might crash under EAPI! "
1481 + "(please recompile it with -DEAPI)", filename);
1486 * Add this module to the Apache core structures
1488 +---------------------------------------------------------------------------
1489 | Add additional logging functions to the CustomLog directive
1490 | which can be used by other modules to create additional
1491 | logfile tags. Actually we add two types of hooks: One hook
1492 | for intercepting the new and generic %x (eXtension) tag and
1493 | one hook for creating new %x tags at all.
1494 +---------------------------------------------------------------------------
1495 Index: src/modules/standard/mod_log_config.c
1496 --- src/modules/standard/mod_log_config.c 19 Jun 2002 07:20:30 -0000 1.1.1.13
1497 +++ src/modules/standard/mod_log_config.c 19 Jun 2002 07:29:09 -0000 1.26
1499 typedef const char *(*item_key_func) (request_rec *, char *);
1507 int condition_sense;
1508 @@ -580,15 +583,36 @@
1513 +static struct log_item_list *find_log_func(pool *p, char k)
1515 static struct log_item_list *find_log_func(char k)
1520 + struct log_item_list *lil;
1523 for (i = 0; log_item_keys[i].ch; ++i)
1524 if (k == log_item_keys[i].ch) {
1525 return &log_item_keys[i];
1529 + if (ap_hook_status(ap_psprintf(p, "ap::mod_log_config::log_%c", k))
1530 + != AP_HOOK_STATE_NOTEXISTANT) {
1531 + lil = (struct log_item_list *)
1532 + ap_pcalloc(p, sizeof(struct log_item_list));
1537 + lil->want_orig_default = 0;
1545 @@ -714,7 +738,11 @@
1550 + l = find_log_func(p, *s++);
1552 l = find_log_func(*s++);
1558 return ap_pstrcat(p, "Unrecognized LogFormat directive %",
1565 if (it->want_orig == -1) {
1566 it->want_orig = l->want_orig_default;
1567 @@ -784,6 +815,15 @@
1569 /* We do. Do it... */
1572 + if (item->func == NULL) {
1574 + ap_hook_use(ap_psprintf(r->pool, "ap::mod_log_config::log_%c", item->ch),
1575 + AP_HOOK_SIG3(ptr,ptr,ptr), AP_HOOK_DECLINE(NULL),
1576 + &cp, r, item->arg);
1580 cp = (*item->func) (item->want_orig ? orig : r, item->arg);
1581 return cp ? cp : "-";
1584 +---------------------------------------------------------------------------
1585 | Allow RewriteCond and RewriteRule directives to lookup
1586 | variables from other modules.
1587 +---------------------------------------------------------------------------
1588 Index: src/modules/standard/mod_rewrite.c
1589 --- src/modules/standard/mod_rewrite.c 19 Jun 2002 07:20:30 -0000 1.1.1.15
1590 +++ src/modules/standard/mod_rewrite.c 19 Jun 2002 07:29:09 -0000 1.13
1591 @@ -3678,6 +3678,15 @@
1593 #endif /* ndef WIN32 && NETWARE*/
1597 + ap_hook_use("ap::mod_rewrite::lookup_variable",
1598 + AP_HOOK_SIG3(ptr,ptr,ptr),
1599 + AP_HOOK_DECLINE(NULL),
1604 if (result == NULL) {
1605 return ap_pstrdup(r->pool, "");
1608 +---------------------------------------------------------------------------
1609 | Add an EAPI hook to allow other modules to add content to
1610 | the status HTML page.
1611 +---------------------------------------------------------------------------
1612 Index: src/modules/standard/mod_status.c
1613 --- src/modules/standard/mod_status.c 27 Mar 2002 15:23:06 -0000 1.1.1.14
1614 +++ src/modules/standard/mod_status.c 27 Mar 2002 15:30:03 -0000 1.11
1615 @@ -717,6 +754,12 @@
1621 + ap_hook_use("ap::mod_status::display",
1622 + AP_HOOK_SIG4(void,ptr,int,int), AP_HOOK_ALL,
1623 + r, no_table_report, short_report);
1629 +---------------------------------------------------------------------------
1630 | Add hooks to the scheme processing to allow other modules to
1631 | recognize more schemes by intercepting this processing.
1632 +---------------------------------------------------------------------------
1633 Index: src/modules/proxy/mod_proxy.c
1634 --- src/modules/proxy/mod_proxy.c 19 Jun 2002 07:20:27 -0000 1.1.1.12
1635 +++ src/modules/proxy/mod_proxy.c 19 Jun 2002 07:29:09 -0000 1.19
1637 static int proxy_fixup(request_rec *r)
1644 if (r->proxyreq == NOT_PROXY || strncmp(r->filename, "proxy:", 6) != 0)
1646 @@ -225,6 +228,14 @@
1647 url = &r->filename[6];
1649 /* canonicalise each specific scheme */
1651 + if (ap_hook_use("ap::mod_proxy::canon",
1652 + AP_HOOK_SIG3(int,ptr,ptr),
1653 + AP_HOOK_DECLINE(DECLINED),
1654 + &rc, r, url) && rc != DECLINED)
1658 if (strncasecmp(url, "http:", 5) == 0)
1659 return ap_proxy_http_canon(r, url + 5, "http", DEFAULT_HTTP_PORT);
1660 else if (strncasecmp(url, "ftp:", 4) == 0)
1661 @@ -240,9 +251,44 @@
1662 static void proxy_init(server_rec *r, pool *p)
1664 ap_proxy_garbage_init(r, p);
1666 + ap_hook_use("ap::mod_proxy::init",
1667 + AP_HOOK_SIG3(void,ptr,ptr), AP_HOOK_ALL, r, p);
1673 +static void proxy_addmod(module *m)
1675 + /* export: ap_proxy_http_canon() as `ap::mod_proxy::http::canon' */
1676 + ap_hook_configure("ap::mod_proxy::http::canon",
1677 + AP_HOOK_SIG5(int,ptr,ptr,ptr,int), AP_HOOK_TOPMOST);
1678 + ap_hook_register("ap::mod_proxy::http::canon",
1679 + ap_proxy_http_canon, AP_HOOK_NOCTX);
1681 + /* export: ap_proxy_http_handler() as `ap::mod_proxy::http::handler' */
1682 + ap_hook_configure("ap::mod_proxy::http::handler",
1683 + AP_HOOK_SIG6(int,ptr,ptr,ptr,ptr,int), AP_HOOK_TOPMOST);
1684 + ap_hook_register("ap::mod_proxy::http::handler",
1685 + ap_proxy_http_handler, AP_HOOK_NOCTX);
1687 + /* export: ap_proxyerror() as `ap::mod_proxy::error' */
1688 + ap_hook_configure("ap::mod_proxy::error",
1689 + AP_HOOK_SIG3(int,ptr,ptr), AP_HOOK_TOPMOST);
1690 + ap_hook_register("ap::mod_proxy::error",
1691 + ap_proxyerror, AP_HOOK_NOCTX);
1695 +static void proxy_remmod(module *m)
1697 + /* remove the hook references */
1698 + ap_hook_unregister("ap::mod_proxy::http::canon", ap_proxy_http_canon);
1699 + ap_hook_unregister("ap::mod_proxy::http::handler", ap_proxy_http_handler);
1700 + ap_hook_unregister("ap::mod_proxy::error", ap_proxyerror);
1705 /* Send a redirection if the request contains a hostname which is not */
1706 /* fully qualified, i.e. doesn't have a domain name appended. Some proxy */
1707 @@ -374,6 +420,14 @@
1708 * CONNECT is a special method that bypasses the normal proxy
1712 + if (!ap_hook_use("ap::mod_proxy::handler",
1713 + AP_HOOK_SIG7(int,ptr,ptr,ptr,ptr,int,ptr),
1714 + AP_HOOK_DECLINE(DECLINED),
1716 + ents[i].hostname, ents[i].port,
1717 + ents[i].protocol) || rc == DECLINED) {
1719 if (r->method_number == M_CONNECT)
1720 rc = ap_proxy_connect_handler(r, cr, url, ents[i].hostname,
1730 /* an error or success */
1731 if (rc != DECLINED && rc != HTTP_BAD_GATEWAY)
1732 @@ -397,6 +454,14 @@
1735 /* handle the scheme */
1737 + if (ap_hook_use("ap::mod_proxy::handler",
1738 + AP_HOOK_SIG7(int,ptr,ptr,ptr,ptr,int,ptr),
1739 + AP_HOOK_DECLINE(DECLINED),
1741 + NULL, 0, scheme) && rc != DECLINED)
1744 if (r->method_number == M_CONNECT) {
1745 return ap_proxy_connect_handler(r, cr, url, NULL, 0);
1747 @@ -994,4 +1059,10 @@
1748 NULL, /* child_init */
1749 NULL, /* child_exit */
1750 proxy_detect /* post read-request */
1752 + ,proxy_addmod, /* EAPI: add_module */
1753 + proxy_remmod, /* EAPI: remove_module */
1754 + NULL, /* EAPI: rewrite_command */
1755 + NULL /* EAPI: new_connection */
1759 +---------------------------------------------------------------------------
1760 | Add hooks to the HTTP processing to allow other modules
1761 | to enhance it by intercepting this processing.
1762 +---------------------------------------------------------------------------
1763 Index: src/modules/proxy/proxy_http.c
1764 --- src/modules/proxy/proxy_http.c 19 Jun 2002 07:20:27 -0000 1.1.1.14
1765 +++ src/modules/proxy/proxy_http.c 19 Jun 2002 07:29:09 -0000 1.22
1767 const char *datestr, *urlstr;
1768 int result, major, minor;
1769 const char *content_length;
1774 void *sconf = r->server->module_config;
1775 proxy_server_conf *conf =
1776 @@ -191,6 +194,12 @@
1777 return HTTP_BAD_REQUEST;
1779 destport = DEFAULT_HTTP_PORT;
1781 + ap_hook_use("ap::mod_proxy::http::handler::set_destport",
1782 + AP_HOOK_SIG2(int,ptr),
1786 strp = strchr(urlptr, '/');
1788 desthost = ap_pstrdup(p, urlptr);
1789 @@ -228,12 +237,18 @@
1790 err = ap_proxy_host2addr(proxyhost, &server_hp);
1792 return DECLINED; /* try another */
1794 + peer = ap_psprintf(p, "%s:%u", proxyhost, proxyport);
1798 server.sin_port = htons((unsigned short)destport);
1799 err = ap_proxy_host2addr(desthost, &server_hp);
1801 return ap_proxyerror(r, HTTP_INTERNAL_SERVER_ERROR, err);
1803 + peer = ap_psprintf(p, "%s:%u", desthost, destport);
1808 @@ -308,14 +323,42 @@
1809 f = ap_bcreate(p, B_RDWR | B_SOCKET);
1810 ap_bpushfd(f, sock, sock);
1814 + char *errmsg = NULL;
1815 + ap_hook_use("ap::mod_proxy::http::handler::new_connection",
1816 + AP_HOOK_SIG4(ptr,ptr,ptr,ptr),
1817 + AP_HOOK_DECLINE(NULL),
1818 + &errmsg, r, f, peer);
1819 + if (errmsg != NULL)
1820 + return ap_proxyerror(r, HTTP_BAD_GATEWAY, errmsg);
1824 ap_hard_timeout("proxy send", r);
1825 ap_bvputs(f, r->method, " ", proxyhost ? url : urlptr, " HTTP/1.1" CRLF,
1829 + int rc = DECLINED;
1830 + ap_hook_use("ap::mod_proxy::http::handler::write_host_header",
1831 + AP_HOOK_SIG6(int,ptr,ptr,ptr,int,ptr),
1832 + AP_HOOK_DECLINE(DECLINED),
1833 + &rc, r, f, desthost, destport, destportstr);
1834 + if (rc == DECLINED) {
1835 + if (destportstr != NULL && destport != DEFAULT_HTTP_PORT)
1836 + ap_bvputs(f, "Host: ", desthost, ":", destportstr, CRLF, NULL);
1838 + ap_bvputs(f, "Host: ", desthost, CRLF, NULL);
1842 /* Send Host: now, adding it to req_hdrs wouldn't be much better */
1843 if (destportstr != NULL && destport != DEFAULT_HTTP_PORT)
1844 ap_bvputs(f, "Host: ", desthost, ":", destportstr, CRLF, NULL);
1846 ap_bvputs(f, "Host: ", desthost, CRLF, NULL);
1849 if (conf->viaopt == via_block) {
1850 /* Block all outgoing Via: headers */
1852 +---------------------------------------------------------------------------
1853 | Add EAPI hooks in module structure for APXS generated samples.
1854 +---------------------------------------------------------------------------
1855 Index: src/support/apxs.pl
1856 --- src/support/apxs.pl 19 Jun 2002 07:20:34 -0000 1.1.1.12
1857 +++ src/support/apxs.pl 19 Jun 2002 07:29:09 -0000 1.12
1858 @@ -711,5 +711,11 @@
1859 NULL, /* child_init */
1860 NULL, /* child_exit */
1861 NULL /* [#0] post read-request */
1863 + ,NULL, /* EAPI: add_module */
1864 + NULL, /* EAPI: remove_module */
1865 + NULL, /* EAPI: rewrite_command */
1866 + NULL /* EAPI: new_connection */
1871 +---------------------------------------------------------------------------
1872 | Add the EAPI functions, so the stuff can be built under AIX
1873 | and similar braindead platforms as DSO.
1874 +---------------------------------------------------------------------------
1875 Index: src/support/httpd.exp
1876 --- src/support/httpd.exp 19 Jun 2002 07:20:34 -0000 1.1.1.11
1877 +++ src/support/httpd.exp 19 Jun 2002 07:29:09 -0000 1.13
1878 @@ -427,3 +427,59 @@
1879 XML_SetUnparsedEntityDeclHandler
1881 XML_UseParserAsHandlerArg
1882 +ap_add_config_define
1883 +ap_make_shared_sub_pool
1892 +ap_hook_unregister_I
1927 +ap_mm_core_permission
1932 +ap_mm_core_maxsegsize
1933 +ap_mm_core_align2page
1934 +ap_mm_core_align2word
1935 +ap_mm_lib_error_set
1936 +ap_mm_lib_error_get
1939 +---------------------------------------------------------------------------
1940 | Add the EAPI functions, so the stuff can be built under
1941 | Windows 95 and similar braindead platforms as DDL.
1942 +---------------------------------------------------------------------------
1943 Index: src/ApacheCore.def
1944 --- src/ApacheCore.def 19 Jun 2002 07:20:21 -0000 1.1.1.10
1945 +++ src/ApacheCore.def 19 Jun 2002 07:29:08 -0000 1.14
1946 @@ -447,3 +447,67 @@
1948 ap_get_chunk_size @440
1949 ap_escape_logitem @441
1951 + ; EAPI extended symbols
1952 + ; note; no ID's, so these all bind by name rather than ordinal since
1953 + ; their ordinals would change with symbol changes in the distribution
1954 + ap_add_config_define
1955 + ap_global_ctx DATA
1963 + ap_hook_register_I
1964 + ap_hook_unregister_I
1968 + ap_set_callback_and_alarm
1970 + ap_make_shared_sub_pool
2001 + ap_mm_display_info
2003 + ap_mm_core_permission
2008 + ap_mm_core_align2page
2009 + ap_mm_core_align2word
2010 + ap_mm_lib_error_set
2011 + ap_mm_lib_error_get