]> git.pld-linux.org Git - packages/apache.git/blame - apache-mod_ssl-eapi.patch
- manually updated mod_ssl-eapi patch (there is no new mod_ssl yet)
[packages/apache.git] / apache-mod_ssl-eapi.patch
CommitLineData
bac1ef07 1## _____ _ ____ ___
2## | ____| / \ | _ \_ _|
3## | _| / _ \ | |_) | |
4## | |__ / ___ \| __/| |
5## |____/_/ \_\_| |___| Extended API for Apache
6## ____________________________________________________________________________
7##
8## Annotated patch file: eapi.patch
9## Copyright (c) 1998-2001 Ralf S. Engelschall, All Rights Reserved.
4812ab25 10## Created on: 27-Mar-2002
bac1ef07 11##
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.
17##
18## This file contains all patches to the Apache source
19## tree which add the Extended API (EAPI) support.
20##
21
22+---------------------------------------------------------------------------
23| Add the EAPI and EAPI_MM configuration entries which triggers the EAPI
24| patches and configured the shared memory support via the MM library.
25+---------------------------------------------------------------------------
26Index: src/Configuration.tmpl
4812ab25
JB
27--- src/Configuration.tmpl 28 Jan 2002 19:21:21 -0000 1.1.1.7
28+++ src/Configuration.tmpl 28 Jan 2002 19:40:56 -0000 1.23
bac1ef07 29@@ -68,6 +105,24 @@
30 #TARGET=
31
32 ################################################################
33+# Extended API (EAPI) support:
34+#
35+# EAPI:
36+# The EAPI rule enables more module hooks, a generic low-level hook
37+# mechanism, a generic context mechanism and shared memory based pools.
38+#
39+# EAPI_MM:
40+# Set the EAPI_MM variable to either the directory of a MM Shared Memory
41+# Library source tree or the installation tree of MM. Alternatively you can
42+# also use the value 'SYSTEM' which then indicates that MM is installed
43+# under various system locations. When the MM library files cannot be found
44+# the EAPI still can be built, but without shared memory pool support, of
45+# course.
46+
47+Rule EAPI=no
48+#EAPI_MM=SYSTEM
49+
50+################################################################
51 # Dynamic Shared Object (DSO) support
52 #
53 # There is experimental support for compiling the Apache core and
54
55+---------------------------------------------------------------------------
56| Patch in implementation of the EAPI rule.
57+---------------------------------------------------------------------------
58Index: src/Configure
4812ab25
JB
59--- src/Configure 27 Mar 2002 15:22:54 -0000 1.1.1.18
60+++ src/Configure 27 Mar 2002 15:30:02 -0000 1.21
e48af075 61@@ -1866,6 +1866,72 @@
bac1ef07 62 fi
63
64 ####################################################################
65+## Extended API (EAPI) support:
66+##
67+if [ "x$RULE_EAPI" = "x" ]; then
68+ RULE_EAPI=`./helpers/CutRule EAPI $file`
69+fi
70+if [ "x$RULE_EAPI" = "xyes" ]; then
71+ echo " + enabling Extended API (EAPI)"
72+ CFLAGS="$CFLAGS -DEAPI"
73+ # some vendor compilers are too restrictive
74+ # for our ap_hook and ap_ctx sources.
75+ case "$OS:$CC" in
76+ *IRIX-32*:*/cc|*IRIX-32*:cc )
77+ CFLAGS="$CFLAGS -woff 1048,1110,1164"
78+ ;;
79+ esac
80+ # MM Shared Memory Library support for EAPI
81+ if [ "x$EAPI_MM" = "x" ]; then
4812ab25 82+ EAPI_MM=`egrep '^EAPI_MM=' $file | sed -n -e '$p' | awk -F= '{print $2}'`
bac1ef07 83+ fi
84+ if [ "x$EAPI_MM" != "x" ]; then
85+ case $EAPI_MM in
86+ SYSTEM|/* ) ;;
87+ * ) for p in . .. ../..; do
88+ if [ -d "$p/$EAPI_MM" ]; then
89+ EAPI_MM="`echo $p/$EAPI_MM | sed -e 's;/\./;/;g'`"
90+ break
91+ fi
92+ done
93+ ;;
94+ esac
95+ if [ "x$EAPI_MM" = "xSYSTEM" ]; then
96+ echo " using MM library for EAPI: (system-wide)"
97+ CFLAGS="$CFLAGS -DEAPI_MM"
98+ __INCLUDES="`mm-config --cflags`"
99+ if [ "x$__INCLUDES" != "x-I/usr/include" ]; then
100+ INCLUDES="$INCLUDES $__INCLUDES"
101+ fi
102+ LDFLAGS="$LDFLAGS `mm-config --ldflags`"
103+ LIBS="$LIBS `mm-config --libs`"
104+ else
105+ if [ -f "$EAPI_MM/.libs/libmm.a" -a -f "$EAPI_MM/mm.h" ]; then
106+ echo " using MM library: $EAPI_MM (source-tree only)"
107+ case $EAPI_MM in
108+ /* ) ;;
109+ * ) EAPI_MM="\$(SRCDIR)/$EAPI_MM" ;;
110+ esac
111+ CFLAGS="$CFLAGS -DEAPI_MM"
112+ INCLUDES="$INCLUDES -I$EAPI_MM"
113+ LDFLAGS="$LDFLAGS -L$EAPI_MM/.libs"
114+ LIBS="$LIBS -lmm"
115+ elif [ -f "$EAPI_MM/bin/mm-config" ]; then
116+ echo " using MM library: $EAPI_MM (installed)"
117+ CFLAGS="$CFLAGS -DEAPI_MM"
118+ INCLUDES="$INCLUDES `$EAPI_MM/bin/mm-config --cflags`"
119+ LDFLAGS="$LDFLAGS `$EAPI_MM/bin/mm-config --ldflags`"
120+ LIBS="$LIBS `$EAPI_MM/bin/mm-config --libs`"
121+ else
122+ echo "Configure:Error: Cannot find MM library under $EAPI_MM" 1>&2
123+ exit 1
124+ fi
125+ fi
126+ fi
127+fi
128+
129+
130+####################################################################
131 ## Add in the Expat library if needed/wanted.
132 ##
c7f132e3 133
bac1ef07 134
135+---------------------------------------------------------------------------
136| Add the build support for the ap_hook.c and ap_ctx.c sources (Unix)
137+---------------------------------------------------------------------------
138Index: src/ap/Makefile.tmpl
4812ab25
JB
139--- src/ap/Makefile.tmpl 20 May 2001 08:16:15 -0000 1.1.1.7
140+++ src/ap/Makefile.tmpl 20 May 2001 08:23:01 -0000 1.7
141@@ -6,8 +6,8 @@
bac1ef07 142 LIB=libap.a
143
144 OBJS=ap_cpystrn.o ap_execve.o ap_fnmatch.o ap_getpass.o ap_md5c.o ap_signal.o \
4812ab25
JB
145 ap_slack.o ap_snprintf.o ap_sha1.o ap_checkpass.o ap_base64.o ap_ebcdic.o \
146- ap_strtol.o
147+ ap_strtol.o ap_hook.o ap_ctx.o ap_mm.o
bac1ef07 148
149 .c.o:
150 $(CC) -c $(INCLUDES) $(CFLAGS) $<
151
152+---------------------------------------------------------------------------
153| Add the build support for the ap_hook.c and ap_ctx.c sources (Win32)
154+---------------------------------------------------------------------------
155Index: src/ap/ap.mak
4812ab25
JB
156--- src/ap/ap.mak 16 Oct 2001 11:47:06 -0000 1.1.1.9
157+++ src/ap/ap.mak 16 Oct 2001 11:57:38 -0000 1.9
c7f132e3 158@@ -50,6 +50,9 @@
bac1ef07 159 -@erase "$(INTDIR)\ap_cpystrn.obj"
160 -@erase "$(INTDIR)\ap_fnmatch.obj"
161 -@erase "$(INTDIR)\ap_md5c.obj"
162+ -@erase "$(INTDIR)\ap_hook.obj"
163+ -@erase "$(INTDIR)\ap_ctx.obj"
164+ -@erase "$(INTDIR)\ap_mm.obj"
165 -@erase "$(INTDIR)\ap_sha1.obj"
166 -@erase "$(INTDIR)\ap_signal.obj"
167 -@erase "$(INTDIR)\ap_slack.obj"
c7f132e3 168@@ -108,6 +111,9 @@
bac1ef07 169 "$(INTDIR)\ap_cpystrn.obj" \
170 "$(INTDIR)\ap_fnmatch.obj" \
171 "$(INTDIR)\ap_md5c.obj" \
172+ "$(INTDIR)\ap_hook.obj" \
173+ "$(INTDIR)\ap_ctx.obj" \
174+ "$(INTDIR)\ap_mm.obj" \
175 "$(INTDIR)\ap_sha1.obj" \
176 "$(INTDIR)\ap_signal.obj" \
177 "$(INTDIR)\ap_slack.obj" \
c7f132e3 178@@ -144,6 +150,9 @@
bac1ef07 179 -@erase "$(INTDIR)\ap_cpystrn.obj"
180 -@erase "$(INTDIR)\ap_fnmatch.obj"
181 -@erase "$(INTDIR)\ap_md5c.obj"
182+ -@erase "$(INTDIR)\ap_hook.obj"
183+ -@erase "$(INTDIR)\ap_ctx.obj"
184+ -@erase "$(INTDIR)\ap_mm.obj"
185 -@erase "$(INTDIR)\ap_sha1.obj"
186 -@erase "$(INTDIR)\ap_signal.obj"
187 -@erase "$(INTDIR)\ap_slack.obj"
c7f132e3 188@@ -202,6 +211,9 @@
bac1ef07 189 "$(INTDIR)\ap_cpystrn.obj" \
190 "$(INTDIR)\ap_fnmatch.obj" \
191 "$(INTDIR)\ap_md5c.obj" \
192+ "$(INTDIR)\ap_hook.obj" \
193+ "$(INTDIR)\ap_ctx.obj" \
194+ "$(INTDIR)\ap_mm.obj" \
195 "$(INTDIR)\ap_sha1.obj" \
196 "$(INTDIR)\ap_signal.obj" \
197 "$(INTDIR)\ap_slack.obj" \
198
199+---------------------------------------------------------------------------
200| Replace the MODULE_MAGIC_COOKIE to allow us to distinguish between
201| EAPI-aware modules and standard modules.
202+---------------------------------------------------------------------------
203Index: src/include/ap_mmn.h
4812ab25
JB
204--- src/include/ap_mmn.h 27 Mar 2002 15:22:57 -0000 1.1.1.10
205+++ src/include/ap_mmn.h 27 Mar 2002 15:30:02 -0000 1.10
e48af075 206@@ -237,7 +237,23 @@
207 * structure
bac1ef07 208 */
209
210+/*
211+ * Under Extended API situations we replace the magic cookie "AP13" with
212+ * "EAPI" to let us distinguish between the EAPI module structure (which
213+ * contain additional pointers at the end) and standard module structures
214+ * (which lack at least NULL's for the pointers at the end). This is
215+ * important because standard ("AP13") modules would dump core when we
216+ * dispatch over the additional hooks because NULL's are missing at the end of
217+ * the module structure. See also the code in mod_so for details on loading
218+ * (we accept both "AP13" and "EAPI").
219+ */
220+#ifdef EAPI
221+#define MODULE_MAGIC_COOKIE_AP13 0x41503133UL /* "AP13" */
222+#define MODULE_MAGIC_COOKIE_EAPI 0x45415049UL /* "EAPI" */
223+#define MODULE_MAGIC_COOKIE MODULE_MAGIC_COOKIE_EAPI
224+#else
225 #define MODULE_MAGIC_COOKIE 0x41503133UL /* "AP13" */
226+#endif
227
228 #ifndef MODULE_MAGIC_NUMBER_MAJOR
229 #define MODULE_MAGIC_NUMBER_MAJOR 19990320
230
231+---------------------------------------------------------------------------
232| Add the additional prototypes and defines for the
233| shared memory pools.
234+---------------------------------------------------------------------------
235Index: src/include/ap_alloc.h
4812ab25
JB
236--- src/include/ap_alloc.h 27 Mar 2002 15:22:56 -0000 1.1.1.5
237+++ src/include/ap_alloc.h 27 Mar 2002 15:30:02 -0000 1.6
bac1ef07 238@@ -95,6 +95,15 @@
e48af075 239 API_EXPORT(pool *) ap_init_alloc(void); /* Set up everything */
bac1ef07 240 void ap_cleanup_alloc(void);
241 API_EXPORT(pool *) ap_make_sub_pool(pool *); /* All pools are subpools of permanent_pool */
242+#if defined(EAPI)
243+typedef enum { AP_POOL_RD, AP_POOL_RW } ap_pool_lock_mode;
244+int ap_shared_pool_possible(void);
245+void ap_init_alloc_shared(int);
246+void ap_kill_alloc_shared(void);
247+API_EXPORT(pool *) ap_make_shared_sub_pool(pool *);
248+API_EXPORT(int) ap_acquire_pool(pool *, ap_pool_lock_mode);
249+API_EXPORT(int) ap_release_pool(pool *);
250+#endif
251 API_EXPORT(void) ap_destroy_pool(pool *);
252
253 /* pools have nested lifetimes -- sub_pools are destroyed when the
254
255+---------------------------------------------------------------------------
256| Add the additional context variable `ctx' for BUFF structures.
257+---------------------------------------------------------------------------
258Index: src/include/buff.h
4812ab25
JB
259--- src/include/buff.h 27 Mar 2002 15:22:57 -0000 1.1.1.6
260+++ src/include/buff.h 27 Mar 2002 15:30:02 -0000 1.10
bac1ef07 261@@ -125,6 +125,10 @@
262 /* transport handle, for RPC binding handle or some such */
263 void *t_handle;
264
265+#ifdef EAPI
266+ ap_ctx *ctx;
267+#endif /* EAPI */
268+
269 #ifdef B_SFIO
270 Sfio_t *sf_in;
271 Sfio_t *sf_out;
e48af075 272@@ -180,6 +184,10 @@
bac1ef07 273 /* Internal routines */
274 API_EXPORT(int) ap_bflsbuf(int c, BUFF *fb);
275 API_EXPORT(int) ap_bfilbuf(BUFF *fb);
276+
277+#ifdef EAPI
278+#define ap_bpeekc(fb) ( ((fb)->incnt == 0) ? EOF : *((fb)->inptr) )
279+#endif
280
281 #ifndef CHARSET_EBCDIC
282
283
284+---------------------------------------------------------------------------
285| Add the four additional Apache API module hooks.
286+---------------------------------------------------------------------------
287Index: src/include/http_config.h
4812ab25
JB
288--- src/include/http_config.h 27 Mar 2002 15:22:57 -0000 1.1.1.10
289+++ src/include/http_config.h 27 Mar 2002 15:30:02 -0000 1.12
bac1ef07 290@@ -276,6 +276,65 @@
291 void (*child_exit) (server_rec *, pool *);
292 #endif
293 int (*post_read_request) (request_rec *);
294+
295+#ifdef EAPI
296+ /*
297+ * ANSI C guarantees us that we can at least _extend_ the module structure
298+ * with additional hooks without the need to change all existing modules.
299+ * Because: ``If there are fewer initializers in the list than members of
300+ * the structure, the trailing members are initialized with 0.'' (The C
301+ * Programming Language, 2nd Ed., A8.7 Initialization). So we just
302+ * have to put our additional hooks here:
303+ *
304+ * add_module:
305+ * Called from within ap_add_module() right after the module structure
306+ * was linked into the Apache internal module list. It is mainly
307+ * intended to be used to define configuration defines (<IfDefine>)
308+ * which have to be available directly after a LoadModule/AddModule.
309+ * Actually this is the earliest possible hook a module can use.
310+ *
311+ * remove_module:
312+ * Called from within ap_remove_module() right before the module
313+ * structure is kicked out from the Apache internal module list.
314+ * Actually this is last possible hook a module can use and exists for
315+ * consistency with the add_module hook.
316+ *
317+ * rewrite_command:
318+ * Called right after a configuration directive line was read and
319+ * before it is processed. It is mainly intended to be used for
320+ * rewriting directives in order to provide backward compatibility to
321+ * old directive variants.
322+ *
323+ * new_connection:
324+ * Called from within the internal new_connection() function, right
325+ * after the conn_rec structure for the new established connection was
326+ * created and before Apache starts processing the request with
327+ * ap_read_request(). It is mainly intended to be used to setup/run
328+ * connection dependent things like sending start headers for
329+ * on-the-fly compression, etc.
330+ *
331+ * close_connection:
332+ * Called from within the Apache dispatching loop just before any
333+ * ap_bclose() is performed on the socket connection, but a long time
334+ * before any pool cleanups are done for the connection (which can be
335+ * too late for some applications). It is mainly intended to be used
336+ * to close/finalize connection dependent things like sending end
337+ * headers for on-the-fly compression, etc.
338+ */
339+#ifdef ULTRIX_BRAIN_DEATH
340+ void (*add_module) ();
341+ void (*remove_module) ();
342+ char *(*rewrite_command) ();
343+ void (*new_connection) ();
344+ void (*close_connection) ();
345+#else
346+ void (*add_module) (struct module_struct *);
347+ void (*remove_module) (struct module_struct *);
348+ char *(*rewrite_command) (cmd_parms *, void *config, const char *);
349+ void (*new_connection) (conn_rec *);
350+ void (*close_connection) (conn_rec *);
351+#endif
352+#endif /* EAPI */
353 } module;
354
355 /* Initializer for the first few module slots, which are only
356
357+---------------------------------------------------------------------------
358| Add the additional variable `ap_global_ctx' for holding
359| global module context.
360+---------------------------------------------------------------------------
361Index: src/include/http_conf_globals.h
4812ab25
JB
362--- src/include/http_conf_globals.h 27 Mar 2002 15:22:57 -0000 1.1.1.11
363+++ src/include/http_conf_globals.h 27 Mar 2002 15:30:02 -0000 1.12
c7f132e3
MK
364@@ -95,6 +95,9 @@
365 #endif
bac1ef07 366 extern int ap_dump_settings;
367 extern API_VAR_EXPORT int ap_extended_status;
368+#ifdef EAPI
369+extern API_VAR_EXPORT ap_ctx *ap_global_ctx;
370+#endif /* EAPI */
371
372 extern API_VAR_EXPORT char *ap_pid_fname;
373 extern API_VAR_EXPORT char *ap_scoreboard_fname;
374
375+---------------------------------------------------------------------------
376| Export the ap_set_callback_and_alarm() function because this
377| first is a useful thing and second we need it because all
378| other API/timeout functions deal with a request_rec while
379| some modules need a generic timeout mechanism.
380+---------------------------------------------------------------------------
381Index: src/include/http_main.h
bac1ef07 382
383+---------------------------------------------------------------------------
384| First add support for the HTTPS protocol scheme via hooks,
385| second add the additional context variable `ctx' for the
386| conn_rec, server_rec and request_rec structures. And third
387| add a prototype for the additional ap_add_config_define()
388| function.
389+---------------------------------------------------------------------------
390Index: src/include/httpd.h
4812ab25
JB
391--- src/include/httpd.h 27 Mar 2002 15:22:59 -0000 1.1.1.18
392+++ src/include/httpd.h 27 Mar 2002 15:30:02 -0000 1.28
bac1ef07 393@@ -70,7 +70,19 @@
394 /* Headers in which EVERYONE has an interest... */
395
396 #include "ap_config.h"
397+#ifdef EAPI
398+#include "ap_mm.h"
399+#endif
400 #include "ap_alloc.h"
401+/*
402+ * Include the Extended API headers.
403+ * Don't move the position. It has to be after ap_alloc.h because it uses the
404+ * pool stuff but before buff.h because the buffer stuff uses the EAPI, too.
405+ */
406+#ifdef EAPI
407+#include "ap_hook.h"
408+#include "ap_ctx.h"
409+#endif /* EAPI */
410 #include "buff.h"
411 #include "ap.h"
412
c7f132e3 413@@ -141,12 +153,17 @@
bac1ef07 414 #define DEFAULT_HTTP_PORT 80
415 #define DEFAULT_HTTPS_PORT 443
416 #define ap_is_default_port(port,r) ((port) == ap_default_port(r))
417+#ifdef EAPI
7efaaee3 418+#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")
419+#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)
bac1ef07 420+#else /* EAPI */
c7f132e3
MK
421 #ifdef NETWARE
422 #define ap_http_method(r) ap_os_http_method(r)
423 #else
bac1ef07 424 #define ap_http_method(r) "http"
c7f132e3 425 #endif
bac1ef07 426 #define ap_default_port(r) DEFAULT_HTTP_PORT
427+#endif /* EAPI */
428
429 /* --------- Default user name and group name running standalone ---------- */
430 /* --- These may be specified as numbers by placing a # before a number --- */
c7f132e3 431@@ -360,6 +377,19 @@
bac1ef07 432 #define SCOREBOARD_MAINTENANCE_INTERVAL 1000000
433 #endif
434
435+/*
436+ * Unix only:
437+ * Path to Shared Memory Files
438+ */
439+#ifdef EAPI
440+#ifndef EAPI_MM_CORE_PATH
441+#define EAPI_MM_CORE_PATH "logs/mm"
442+#endif
443+#ifndef EAPI_MM_CORE_MAXSIZE
444+#define EAPI_MM_CORE_MAXSIZE 1024*1024*1 /* max. 1MB */
445+#endif
446+#endif
447+
448 /* Number of requests to try to handle in a single process. If <= 0,
449 * the children don't die off. That's the default here, since I'm still
450 * interested in finding and stanching leaks.
c7f132e3 451@@ -452,6 +482,9 @@
bac1ef07 452 API_EXPORT(const char *) ap_get_server_version(void);
453 API_EXPORT(void) ap_add_version_component(const char *component);
454 API_EXPORT(const char *) ap_get_server_built(void);
455+#ifdef EAPI
456+API_EXPORT(void) ap_add_config_define(const char *define);
457+#endif /* EAPI */
458
459 /* Numeric release version identifier: MMNNFFRBB: major minor fix final beta
460 * Always increases along the same track as the source branch.
c7f132e3 461@@ -855,6 +888,10 @@
bac1ef07 462 * record to improve 64bit alignment the next time we need to break
463 * binary compatibility for some other reason.
464 */
465+
466+#ifdef EAPI
467+ ap_ctx *ctx;
468+#endif /* EAPI */
469 };
470
471
c7f132e3 472@@ -903,6 +940,9 @@
bac1ef07 473 char *local_host; /* used for ap_get_server_name when
474 * UseCanonicalName is set to DNS
475 * (ignores setting of HostnameLookups) */
476+#ifdef EAPI
477+ ap_ctx *ctx;
478+#endif /* EAPI */
479 };
480
481 /* Per-vhost config... */
c7f132e3 482@@ -975,6 +1015,10 @@
bac1ef07 483 int limit_req_line; /* limit on size of the HTTP request line */
484 int limit_req_fieldsize; /* limit on size of any request header field */
485 int limit_req_fields; /* limit on number of request header fields */
486+
487+#ifdef EAPI
488+ ap_ctx *ctx;
489+#endif /* EAPI */
490 };
491
492 /* These are more like real hosts than virtual hosts */
493
494+---------------------------------------------------------------------------
495| Patch the shared memory pool support into the Apache pool facility.
496+---------------------------------------------------------------------------
497Index: src/main/alloc.c
4812ab25
JB
498--- src/main/alloc.c 27 Mar 2002 15:23:00 -0000 1.1.1.12
499+++ src/main/alloc.c 27 Mar 2002 15:30:02 -0000 1.19
bac1ef07 500@@ -64,6 +64,10 @@
501 */
502
503 #include "httpd.h"
504+#ifdef EAPI
505+#include "http_config.h"
506+#include "http_conf_globals.h"
507+#endif
508 #include "multithread.h"
509 #include "http_log.h"
510
511@@ -138,6 +142,10 @@
512 #define BLOCK_MINALLOC 0
513 #endif
514
515+#if defined(EAPI) && defined(EAPI_MM)
516+static AP_MM *mm = NULL;
517+#endif
518+
519 /*****************************************************************
520 *
521 * Managing free storage blocks...
522@@ -166,6 +174,9 @@
523 char *endp;
524 union block_hdr *next;
525 char *first_avail;
526+#if defined(EAPI) && defined(EAPI_MM)
527+ int is_shm;
528+#endif
529 #ifdef POOL_DEBUG
530 union block_hdr *global_next;
531 struct pool *owning_pool;
532@@ -216,7 +227,11 @@
533 /* Get a completely new block from the system pool. Note that we rely on
534 malloc() to provide aligned memory. */
535
536+#if defined(EAPI) && defined(EAPI_MM)
537+static union block_hdr *malloc_block(int size, int is_shm)
538+#else
539 static union block_hdr *malloc_block(int size)
540+#endif
541 {
542 union block_hdr *blok;
543
544@@ -230,12 +245,20 @@
545 ++num_malloc_calls;
546 num_malloc_bytes += size + sizeof(union block_hdr);
547 #endif
548+#if defined(EAPI) && defined(EAPI_MM)
549+ if (is_shm)
550+ blok = (union block_hdr *)ap_mm_malloc(mm, size + sizeof(union block_hdr));
551+ else
552+#endif
553 blok = (union block_hdr *) malloc(size + sizeof(union block_hdr));
554 if (blok == NULL) {
555 fprintf(stderr, "Ouch! malloc failed in malloc_block()\n");
556 exit(1);
557 }
558 debug_fill(blok, size + sizeof(union block_hdr));
559+#if defined(EAPI) && defined(EAPI_MM)
560+ blok->h.is_shm = is_shm;
561+#endif
562 blok->h.next = NULL;
563 blok->h.first_avail = (char *) (blok + 1);
564 blok->h.endp = size + blok->h.first_avail;
565@@ -296,6 +319,10 @@
566 if (blok == NULL)
567 return; /* Sanity check --- freeing empty pool? */
568
569+#if defined(EAPI) && defined(EAPI_MM)
570+ if (blok->h.is_shm)
571+ (void)ap_mm_lock(mm, AP_MM_LOCK_RW);
572+#endif
573 (void) ap_acquire_mutex(alloc_mutex);
574 old_free_list = block_freelist;
575 block_freelist = blok;
4812ab25 576@@ -342,6 +369,10 @@
bac1ef07 577 #endif
578
579 (void) ap_release_mutex(alloc_mutex);
580+#if defined(EAPI) && defined(EAPI_MM)
581+ if (blok->h.is_shm)
582+ (void)ap_mm_unlock(mm);
bac1ef07 583+#endif
4812ab25 584 #endif
bac1ef07 585 }
586
bac1ef07 587@@ -350,7 +381,11 @@
588 * if necessary. Must be called with alarms blocked.
589 */
590
591+#if defined(EAPI) && defined(EAPI_MM)
592+static union block_hdr *new_block(int min_size, int is_shm)
593+#else
594 static union block_hdr *new_block(int min_size)
595+#endif
596 {
597 union block_hdr **lastptr = &block_freelist;
598 union block_hdr *blok = block_freelist;
599@@ -360,7 +395,12 @@
600 */
601
602 while (blok != NULL) {
603+#if defined(EAPI) && defined(EAPI_MM)
604+ if (blok->h.is_shm == is_shm &&
605+ min_size + BLOCK_MINFREE <= blok->h.endp - blok->h.first_avail) {
606+#else
607 if (min_size + BLOCK_MINFREE <= blok->h.endp - blok->h.first_avail) {
608+#endif
609 *lastptr = blok->h.next;
610 blok->h.next = NULL;
611 debug_verify_filled(blok->h.first_avail, blok->h.endp,
612@@ -376,7 +416,11 @@
613 /* Nope. */
614
615 min_size += BLOCK_MINFREE;
616+#if defined(EAPI) && defined(EAPI_MM)
617+ blok = malloc_block((min_size > BLOCK_MINALLOC) ? min_size : BLOCK_MINALLOC, is_shm);
618+#else
619 blok = malloc_block((min_size > BLOCK_MINALLOC) ? min_size : BLOCK_MINALLOC);
620+#endif
621 return blok;
622 }
623
624@@ -426,6 +470,9 @@
625 #ifdef POOL_DEBUG
626 struct pool *joined;
627 #endif
628+#if defined(EAPI) && defined(EAPI_MM)
629+ int is_shm;
630+#endif
631 };
632
633 static pool *permanent_pool;
634@@ -440,16 +487,28 @@
635 #define POOL_HDR_CLICKS (1 + ((sizeof(struct pool) - 1) / CLICK_SZ))
636 #define POOL_HDR_BYTES (POOL_HDR_CLICKS * CLICK_SZ)
637
638+#if defined(EAPI) && defined(EAPI_MM)
639+static struct pool *make_sub_pool_internal(struct pool *p, int is_shm)
640+#else
641 API_EXPORT(struct pool *) ap_make_sub_pool(struct pool *p)
642+#endif
643 {
644 union block_hdr *blok;
645 pool *new_pool;
646
647 ap_block_alarms();
648
649+#if defined(EAPI) && defined(EAPI_MM)
650+ if (is_shm)
651+ (void)ap_mm_lock(mm, AP_MM_LOCK_RW);
652+#endif
653 (void) ap_acquire_mutex(alloc_mutex);
654
655+#if defined(EAPI) && defined(EAPI_MM)
656+ blok = new_block(POOL_HDR_BYTES, is_shm);
657+#else
658 blok = new_block(POOL_HDR_BYTES);
659+#endif
660 new_pool = (pool *) blok->h.first_avail;
661 blok->h.first_avail += POOL_HDR_BYTES;
662 #ifdef POOL_DEBUG
663@@ -468,12 +527,38 @@
664 p->sub_pools = new_pool;
665 }
666
667+#if defined(EAPI) && defined(EAPI_MM)
668+ new_pool->is_shm = is_shm;
669+#endif
670+
671 (void) ap_release_mutex(alloc_mutex);
672+#if defined(EAPI) && defined(EAPI_MM)
673+ if (is_shm)
674+ (void)ap_mm_unlock(mm);
675+#endif
676 ap_unblock_alarms();
677
678 return new_pool;
679 }
680
681+#if defined(EAPI)
682+#if defined(EAPI_MM)
683+API_EXPORT(struct pool *) ap_make_sub_pool(struct pool *p)
684+{
685+ return make_sub_pool_internal(p, 0);
686+}
687+API_EXPORT(struct pool *) ap_make_shared_sub_pool(struct pool *p)
688+{
689+ return make_sub_pool_internal(p, 1);
690+}
691+#else
692+API_EXPORT(struct pool *) ap_make_shared_sub_pool(struct pool *p)
693+{
694+ return NULL;
695+}
696+#endif
697+#endif
698+
699 #ifdef POOL_DEBUG
700 static void stack_var_init(char *s)
701 {
702@@ -488,6 +573,13 @@
703 }
704 #endif
705
706+#if defined(EAPI)
707+int ap_shared_pool_possible(void)
708+{
709+ return ap_mm_useable();
710+}
711+#endif
712+
713 #ifdef ALLOC_STATS
714 static void dump_stats(void)
715 {
716@@ -520,6 +612,58 @@
717 return permanent_pool;
718 }
719
720+#if defined(EAPI)
721+void ap_init_alloc_shared(int early)
722+{
723+#if defined(EAPI_MM)
724+ int mm_size;
725+ char *mm_path;
726+ char *err1, *err2;
727+
728+ if (early) {
729+ /* process very early on startup */
730+ mm_size = ap_mm_maxsize();
731+ if (mm_size > EAPI_MM_CORE_MAXSIZE)
732+ mm_size = EAPI_MM_CORE_MAXSIZE;
733+ mm_path = ap_server_root_relative(permanent_pool,
734+ ap_psprintf(permanent_pool, "%s.%ld",
735+ EAPI_MM_CORE_PATH, (long)getpid()));
736+ if ((mm = ap_mm_create(mm_size, mm_path)) == NULL) {
737+ fprintf(stderr, "Ouch! ap_mm_create(%d, \"%s\") failed\n", mm_size, mm_path);
738+ err1 = ap_mm_error();
739+ if (err1 == NULL)
740+ err1 = "-unknown-";
741+ err2 = strerror(errno);
742+ if (err2 == NULL)
743+ err2 = "-unknown-";
744+ fprintf(stderr, "Error: MM: %s: OS: %s\n", err1, err2);
745+ exit(1);
746+ }
747+ }
748+ else {
749+ /* process a lot later on startup */
750+#ifdef WIN32
751+ ap_mm_permission(mm, (_S_IREAD|_S_IWRITE), ap_user_id, -1);
752+#else
753+ ap_mm_permission(mm, (S_IRUSR|S_IWUSR), ap_user_id, -1);
754+#endif
755+ }
756+#endif /* EAPI_MM */
757+ return;
758+}
759+
760+void ap_kill_alloc_shared(void)
761+{
762+#if defined(EAPI_MM)
763+ if (mm != NULL) {
764+ ap_mm_destroy(mm);
765+ mm = NULL;
766+ }
767+#endif /* EAPI_MM */
768+ return;
769+}
770+#endif /* EAPI */
771+
772 void ap_cleanup_alloc(void)
773 {
774 ap_destroy_mutex(alloc_mutex);
775@@ -530,10 +674,18 @@
776 {
777 ap_block_alarms();
778
779+#if defined(EAPI) && defined(EAPI_MM)
780+ if (a->is_shm)
781+ (void)ap_mm_lock(mm, AP_MM_LOCK_RW);
782+#endif
783 (void) ap_acquire_mutex(alloc_mutex);
784 while (a->sub_pools)
785 ap_destroy_pool(a->sub_pools);
786 (void) ap_release_mutex(alloc_mutex);
787+#if defined(EAPI) && defined(EAPI_MM)
788+ if (a->is_shm)
789+ (void)ap_mm_unlock(mm);
790+#endif
791 /* Don't hold the mutex during cleanups. */
792 run_cleanups(a->cleanups);
793 a->cleanups = NULL;
794@@ -567,6 +719,10 @@
795 ap_block_alarms();
796 ap_clear_pool(a);
797
798+#if defined(EAPI) && defined(EAPI_MM)
799+ if (a->is_shm)
800+ (void)ap_mm_lock(mm, AP_MM_LOCK_RW);
801+#endif
802 (void) ap_acquire_mutex(alloc_mutex);
803 if (a->parent) {
804 if (a->parent->sub_pools == a)
805@@ -577,6 +733,10 @@
806 a->sub_next->sub_prev = a->sub_prev;
807 }
808 (void) ap_release_mutex(alloc_mutex);
809+#if defined(EAPI) && defined(EAPI_MM)
810+ if (a->is_shm)
811+ (void)ap_mm_unlock(mm);
812+#endif
813
814 free_blocks(a->first);
815 ap_unblock_alarms();
816@@ -591,6 +751,30 @@
817 return bytes_in_block_list(block_freelist);
818 }
819
820+#if defined(EAPI)
821+API_EXPORT(int) ap_acquire_pool(pool *p, ap_pool_lock_mode mode)
822+{
823+#if defined(EAPI_MM)
824+ if (!p->is_shm)
825+ return 1;
826+ return ap_mm_lock(mm, mode == AP_POOL_RD ? AP_MM_LOCK_RD : AP_MM_LOCK_RW);
827+#else
828+ return 1;
829+#endif
830+}
831+
832+API_EXPORT(int) ap_release_pool(pool *p)
833+{
834+#if defined(EAPI_MM)
835+ if (!p->is_shm)
836+ return 1;
837+ return ap_mm_unlock(mm);
838+#else
839+ return 1;
840+#endif
841+}
842+#endif /* EAPI */
843+
844 /*****************************************************************
845 * POOL_DEBUG support
846 */
847@@ -756,16 +940,31 @@
848
849 ap_block_alarms();
850
851+#if defined(EAPI) && defined(EAPI_MM)
852+ if (a->is_shm)
853+ (void)ap_mm_lock(mm, AP_MM_LOCK_RW);
854+#endif
855 (void) ap_acquire_mutex(alloc_mutex);
856
857+#if defined(EAPI) && defined(EAPI_MM)
858+ blok = new_block(size, a->is_shm);
859+#else
860 blok = new_block(size);
861+#endif
862 a->last->h.next = blok;
863 a->last = blok;
864 #ifdef POOL_DEBUG
865 blok->h.owning_pool = a;
866 #endif
867+#if defined(EAPI) && defined(EAPI_MM)
868+ blok->h.is_shm = a->is_shm;
869+#endif
870
871 (void) ap_release_mutex(alloc_mutex);
872+#if defined(EAPI) && defined(EAPI_MM)
873+ if (a->is_shm)
874+ (void)ap_mm_unlock(mm);
875+#endif
876
877 ap_unblock_alarms();
878
879@@ -877,6 +1076,11 @@
880 char *ptr;
881
882 size = (char *)ps->vbuff.curpos - ps->base;
883+#if defined(EAPI) && defined(EAPI_MM)
884+ if (ps->block->h.is_shm)
885+ ptr = ap_mm_realloc(ps->base, 2*size);
886+ else
887+#endif
888 ptr = realloc(ps->base, 2*size);
889 if (ptr == NULL) {
890 fputs("Ouch! Out of memory!\n", stderr);
891@@ -897,9 +1101,21 @@
892 cur_len = strp - blok->h.first_avail;
893
894 /* must try another blok */
895+#if defined(EAPI) && defined(EAPI_MM)
896+ if (blok->h.is_shm)
897+ (void)ap_mm_lock(mm, AP_MM_LOCK_RW);
898+#endif
899 (void) ap_acquire_mutex(alloc_mutex);
900+#if defined(EAPI) && defined(EAPI_MM)
901+ nblok = new_block(2 * cur_len, blok->h.is_shm);
902+#else
903 nblok = new_block(2 * cur_len);
904+#endif
905 (void) ap_release_mutex(alloc_mutex);
906+#if defined(EAPI) && defined(EAPI_MM)
907+ if (blok->h.is_shm)
908+ (void)ap_mm_unlock(mm);
909+#endif
910 memcpy(nblok->h.first_avail, blok->h.first_avail, cur_len);
911 ps->vbuff.curpos = nblok->h.first_avail + cur_len;
912 /* save a byte for the NUL terminator */
913@@ -908,10 +1124,18 @@
914 /* did we allocate the current blok? if so free it up */
915 if (ps->got_a_new_block) {
916 debug_fill(blok->h.first_avail, blok->h.endp - blok->h.first_avail);
917+#if defined(EAPI) && defined(EAPI_MM)
918+ if (blok->h.is_shm)
919+ (void)ap_mm_lock(mm, AP_MM_LOCK_RW);
920+#endif
921 (void) ap_acquire_mutex(alloc_mutex);
922 blok->h.next = block_freelist;
923 block_freelist = blok;
924 (void) ap_release_mutex(alloc_mutex);
925+#if defined(EAPI) && defined(EAPI_MM)
926+ if (blok->h.is_shm)
927+ (void)ap_mm_unlock(mm);
928+#endif
929 }
930 ps->blok = nblok;
931 ps->got_a_new_block = 1;
932@@ -930,6 +1154,11 @@
933 void *ptr;
934
935 ap_block_alarms();
936+#if defined(EAPI) && defined(EAPI_MM)
937+ if (p->is_shm)
938+ ps.base = ap_mm_malloc(mm, 512);
939+ else
940+#endif
941 ps.base = malloc(512);
942 if (ps.base == NULL) {
943 fputs("Ouch! Out of memory!\n", stderr);
944@@ -942,6 +1171,11 @@
945 *ps.vbuff.curpos++ = '\0';
946 ptr = ps.base;
947 /* shrink */
948+#if defined(EAPI) && defined(EAPI_MM)
949+ if (p->is_shm)
950+ ptr = ap_mm_realloc(ptr, (char *)ps.vbuff.curpos - (char *)ptr);
951+ else
952+#endif
953 ptr = realloc(ptr, (char *)ps.vbuff.curpos - (char *)ptr);
954 if (ptr == NULL) {
955 fputs("Ouch! Out of memory!\n", stderr);
956
957+---------------------------------------------------------------------------
958| Patch the low-level buffer routines to additionally allow
959| modules to intercept the I/O processing via hooks.
960+---------------------------------------------------------------------------
961Index: src/main/buff.c
4812ab25
JB
962--- src/main/buff.c 27 Mar 2002 15:23:00 -0000 1.1.1.12
963+++ src/main/buff.c 27 Mar 2002 15:30:02 -0000 1.20
964@@ -293,6 +293,9 @@
bac1ef07 965 }
966 else
967 #endif
968+#ifdef EAPI
969+ if (!ap_hook_call("ap::buff::read", &rv, fb, buf, nbyte))
970+#endif /* EAPI */
971 rv = read(fb->fd_in, buf, nbyte);
972
973 return rv;
4812ab25 974@@ -304,6 +307,9 @@
bac1ef07 975
e48af075 976 #if defined (WIN32) || defined(NETWARE) || defined(CYGWIN_WINSOCK)
bac1ef07 977 if (fb->flags & B_SOCKET) {
978+#ifdef EAPI
979+ if (!ap_hook_call("ap::buff::recvwithtimeout", &rv, fb, buf, nbyte))
980+#endif /* EAPI */
e48af075 981 rv = ap_recvwithtimeout(fb->fd_in, buf, nbyte, 0);
bac1ef07 982 if (rv == SOCKET_ERROR)
983 errno = WSAGetLastError();
4812ab25 984@@ -351,6 +357,9 @@
bac1ef07 985 }
986 else
987 #endif
988+#ifdef EAPI
989+ if (!ap_hook_call("ap::buff::write", &rv, fb, buf, nbyte))
990+#endif /* EAPI */
991 #if defined (B_SFIO)
992 rv = sfwrite(fb->sf_out, buf, nbyte);
993 #else
4812ab25 994@@ -381,6 +390,9 @@
e48af075 995
bac1ef07 996 #if defined(WIN32) || defined(NETWARE)
997 if (fb->flags & B_SOCKET) {
998+#ifdef EAPI
999+ if (!ap_hook_call("ap::buff::sendwithtimeout", &rv, fb, buf, nbyte))
1000+#endif /* EAPI */
e48af075 1001 rv = ap_sendwithtimeout(fb->fd, buf, nbyte, 0);
bac1ef07 1002 if (rv == SOCKET_ERROR)
1003 errno = WSAGetLastError();
4812ab25 1004@@ -464,6 +476,10 @@
e48af075 1005 fb->callback_data = NULL;
1006 fb->filter_callback = NULL;
bac1ef07 1007
1008+#ifdef EAPI
1009+ fb->ctx = ap_ctx_new(p);
1010+#endif /* EAPI */
1011+
1012 return fb;
1013 }
1014
4812ab25 1015@@ -1116,6 +1132,9 @@
bac1ef07 1016 i = 0;
1017 while (i < nvec) {
1018 do
1019+#ifdef EAPI
1020+ if (!ap_hook_call("ap::buff::writev", &rv, fb, &vec[i], nvec -i))
1021+#endif /* EAPI */
1022 rv = writev(fb->fd, &vec[i], nvec - i);
1023 while (rv == -1 && (errno == EINTR || errno == EAGAIN)
1024 && !(fb->flags & B_EOUT));
1025
1026+---------------------------------------------------------------------------
1027| Add the implementation of the additional `add_module' and
1028| `rewrite_command' module hooks. Additionally the `ctx'
1029| variables are initialized.
1030+---------------------------------------------------------------------------
1031Index: src/main/http_config.c
4812ab25
JB
1032--- src/main/http_config.c 27 Mar 2002 15:23:00 -0000 1.1.1.14
1033+++ src/main/http_config.c 27 Mar 2002 15:30:02 -0000 1.17
bac1ef07 1034@@ -599,6 +599,20 @@
1035 m->name = tmp;
1036 }
1037 #endif /*_OSD_POSIX*/
1038+
1039+#ifdef EAPI
1040+ /*
1041+ * Invoke the `add_module' hook inside the now existing set
1042+ * of modules to let them all now that this module was added.
1043+ */
1044+ {
1045+ module *m2;
1046+ for (m2 = top_module; m2 != NULL; m2 = m2->next)
1047+ if (m2->magic == MODULE_MAGIC_COOKIE_EAPI)
1048+ if (m2->add_module != NULL)
1049+ (*m2->add_module)(m);
1050+ }
1051+#endif /* EAPI */
1052 }
1053
1054 /*
1055@@ -613,6 +627,21 @@
1056 {
1057 module *modp;
1058
1059+#ifdef EAPI
1060+ /*
1061+ * Invoke the `remove_module' hook inside the now existing
1062+ * set of modules to let them all now that this module is
1063+ * beeing removed.
1064+ */
1065+ {
1066+ module *m2;
1067+ for (m2 = top_module; m2 != NULL; m2 = m2->next)
1068+ if (m2->magic == MODULE_MAGIC_COOKIE_EAPI)
1069+ if (m2->remove_module != NULL)
1070+ (*m2->remove_module)(m);
1071+ }
1072+#endif /* EAPI */
1073+
1074 modp = top_module;
1075 if (modp == m) {
1076 /* We are the top module, special case */
1077@@ -1006,6 +1035,27 @@
1078 const command_rec *cmd;
1079 module *mod = top_module;
1080
1081+#ifdef EAPI
1082+ /*
1083+ * Invoke the `rewrite_command' of modules to allow
1084+ * they to rewrite the directive line before we
1085+ * process it.
1086+ */
1087+ {
1088+ module *m;
1089+ char *cp;
1090+ for (m = top_module; m != NULL; m = m->next) {
1091+ if (m->magic == MODULE_MAGIC_COOKIE_EAPI) {
1092+ if (m->rewrite_command != NULL) {
1093+ cp = (m->rewrite_command)(parms, config, l);
1094+ if (cp != NULL)
1095+ l = cp;
1096+ }
1097+ }
1098+ }
1099+ }
1100+#endif /* EAPI */
1101+
1102 if ((l[0] == '#') || (!l[0]))
1103 return NULL;
1104
1105@@ -1440,6 +1490,10 @@
1106 s->limit_req_fieldsize = main_server->limit_req_fieldsize;
1107 s->limit_req_fields = main_server->limit_req_fields;
1108
1109+#ifdef EAPI
1110+ s->ctx = ap_ctx_new(p);
1111+#endif /* EAPI */
1112+
1113 *ps = s;
1114
1115 return ap_parse_vhost_addrs(p, hostname, s);
1116@@ -1550,6 +1604,10 @@
1117
1118 s->module_config = create_server_config(p, s);
1119 s->lookup_defaults = create_default_per_dir_config(p);
1120+
1121+#ifdef EAPI
1122+ s->ctx = ap_ctx_new(p);
1123+#endif /* EAPI */
1124
1125 return s;
1126 }
1127
1128+---------------------------------------------------------------------------
1129| Add the ap_global_ctx variable and the new
1130| ap_add_config_define() function. Additionally the
1131| implementation of the additional `new_connection' module hook
1132| is added plus the initialization of one more `ctx' variable.
1133+---------------------------------------------------------------------------
1134Index: src/main/http_main.c
4812ab25
JB
1135--- src/main/http_main.c 27 Mar 2002 15:23:01 -0000 1.1.1.17
1136+++ src/main/http_main.c 27 Mar 2002 15:30:02 -0000 1.39
e48af075 1137@@ -279,6 +279,9 @@
c7f132e3 1138
bac1ef07 1139 int ap_dump_settings = 0;
1140 API_VAR_EXPORT int ap_extended_status = 0;
1141+#ifdef EAPI
1142+API_VAR_EXPORT ap_ctx *ap_global_ctx;
1143+#endif /* EAPI */
1144
1145 /*
1146 * The max child slot ever assigned, preserved across restarts. Necessary
e48af075 1147@@ -461,6 +464,30 @@
bac1ef07 1148 }
1149 }
1150
1151+#ifdef EAPI
1152+API_EXPORT(void) ap_add_config_define(const char *define)
1153+{
1154+ char **var;
1155+ var = (char **)ap_push_array(ap_server_config_defines);
1156+ *var = ap_pstrdup(pcommands, define);
1157+ return;
1158+}
1159+
1160+/*
1161+ * Invoke the `close_connection' hook of modules to let them do
1162+ * some connection dependent actions before we close it.
1163+ */
1164+static void ap_call_close_connection_hook(conn_rec *c)
1165+{
1166+ module *m;
1167+ for (m = top_module; m != NULL; m = m->next)
1168+ if (m->magic == MODULE_MAGIC_COOKIE_EAPI)
1169+ if (m->close_connection != NULL)
1170+ (*m->close_connection)(c);
1171+ return;
1172+}
1173+#endif /* EAPI */
1174+
1175 #ifndef NETWARE
1176 static APACHE_TLS int volatile exit_after_unblock = 0;
1177 #endif
4812ab25 1178@@ -1513,6 +1540,10 @@
bac1ef07 1179 ap_log_transaction(log_req);
1180 }
1181
1182+#ifdef EAPI
1183+ ap_call_close_connection_hook(save_req->connection);
1184+#endif /* EAPI */
1185+
1186 ap_bsetflag(save_req->connection->client, B_EOUT, 1);
1187 ap_bclose(save_req->connection->client);
1188
4812ab25 1189@@ -1521,6 +1552,9 @@
bac1ef07 1190 ap_longjmp(jmpbuffer, 1);
1191 }
1192 else { /* abort the connection */
1193+#ifdef EAPI
1194+ ap_call_close_connection_hook(current_conn);
1195+#endif /* EAPI */
1196 ap_bsetflag(current_conn->client, B_EOUT, 1);
1197 ap_bclose(current_conn->client);
1198 current_conn->aborted = 1;
4812ab25 1199@@ -1823,10 +1857,16 @@
bac1ef07 1200 /* Send any leftover data to the client, but never try to again */
1201
1202 if (ap_bflush(r->connection->client) == -1) {
1203+#ifdef EAPI
1204+ ap_call_close_connection_hook(r->connection);
1205+#endif /* EAPI */
1206 ap_kill_timeout(r);
1207 ap_bclose(r->connection->client);
1208 return;
1209 }
1210+#ifdef EAPI
1211+ ap_call_close_connection_hook(r->connection);
1212+#endif /* EAPI */
1213 ap_bsetflag(r->connection->client, B_EOUT, 1);
1214
1215 /* Close our half of the connection --- send the client a FIN */
4812ab25 1216@@ -2554,6 +2594,9 @@
bac1ef07 1217 /* Clear the pool - including any registered cleanups */
1218 ap_destroy_pool(pglobal);
1219 #endif
1220+#ifdef EAPI
1221+ ap_kill_alloc_shared();
1222+#endif
1223 exit(code);
1224 }
1225
4812ab25 1226@@ -3549,6 +3592,24 @@
bac1ef07 1227 conn->remote_addr = *remaddr;
1228 conn->remote_ip = ap_pstrdup(conn->pool,
1229 inet_ntoa(conn->remote_addr.sin_addr));
1230+#ifdef EAPI
1231+ conn->ctx = ap_ctx_new(conn->pool);
1232+#endif /* EAPI */
4812ab25 1233+
bac1ef07 1234+#ifdef EAPI
1235+ /*
1236+ * Invoke the `new_connection' hook of modules to let them do
1237+ * some connection dependent actions before we go on with
1238+ * processing the request on this connection.
1239+ */
1240+ {
1241+ module *m;
1242+ for (m = top_module; m != NULL; m = m->next)
1243+ if (m->magic == MODULE_MAGIC_COOKIE_EAPI)
1244+ if (m->new_connection != NULL)
1245+ (*m->new_connection)(conn);
1246+ }
1247+#endif /* EAPI */
4812ab25 1248
bac1ef07 1249 return conn;
1250 }
4812ab25 1251@@ -3977,6 +4038,15 @@
bac1ef07 1252 printf("Server's Module Magic Number: %u:%u\n",
1253 MODULE_MAGIC_NUMBER_MAJOR, MODULE_MAGIC_NUMBER_MINOR);
1254 printf("Server compiled with....\n");
1255+#ifdef EAPI
1256+ printf(" -D EAPI\n");
1257+#endif
1258+#ifdef EAPI_MM
1259+ printf(" -D EAPI_MM\n");
1260+#ifdef EAPI_MM_CORE_PATH
1261+ printf(" -D EAPI_MM_CORE_PATH=\"" EAPI_MM_CORE_PATH "\"\n");
1262+#endif
1263+#endif
c7f132e3
MK
1264 #ifdef TPF
1265 show_os_specific_compile_settings();
bac1ef07 1266 #endif
4812ab25 1267@@ -4149,6 +4219,22 @@
bac1ef07 1268 ap_server_pre_read_config = ap_make_array(pcommands, 1, sizeof(char *));
1269 ap_server_post_read_config = ap_make_array(pcommands, 1, sizeof(char *));
1270 ap_server_config_defines = ap_make_array(pcommands, 1, sizeof(char *));
1271+
1272+#ifdef EAPI
1273+ ap_hook_init();
1274+ ap_hook_configure("ap::buff::read",
1275+ AP_HOOK_SIG4(int,ptr,ptr,int), AP_HOOK_TOPMOST);
1276+ ap_hook_configure("ap::buff::write",
1277+ AP_HOOK_SIG4(int,ptr,ptr,int), AP_HOOK_TOPMOST);
1278+ ap_hook_configure("ap::buff::writev",
1279+ AP_HOOK_SIG4(int,ptr,ptr,int), AP_HOOK_TOPMOST);
1280+ ap_hook_configure("ap::buff::sendwithtimeout",
1281+ AP_HOOK_SIG4(int,ptr,ptr,int), AP_HOOK_TOPMOST);
1282+ ap_hook_configure("ap::buff::recvwithtimeout",
1283+ AP_HOOK_SIG4(int,ptr,ptr,int), AP_HOOK_TOPMOST);
1284+
1285+ ap_global_ctx = ap_ctx_new(NULL);
1286+#endif /* EAPI */
1287 }
1288
1289 #ifndef MULTITHREAD
4812ab25 1290@@ -4592,6 +4678,9 @@
bac1ef07 1291
1292 ap_sync_scoreboard_image();
1293 if (ap_scoreboard_image->global.running_generation != ap_my_generation) {
1294+#ifdef EAPI
1295+ ap_call_close_connection_hook(current_conn);
1296+#endif /* EAPI */
1297 ap_bclose(conn_io);
1298 clean_child_exit(0);
1299 }
4812ab25 1300@@ -4620,6 +4709,9 @@
bac1ef07 1301 */
1302
1303 #ifdef NO_LINGCLOSE
1304+#ifdef EAPI
1305+ ap_call_close_connection_hook(current_conn);
1306+#endif /* EAPI */
1307 ap_bclose(conn_io); /* just close it */
1308 #else
1309 if (r && r->connection
4812ab25 1310@@ -4630,6 +4722,9 @@
bac1ef07 1311 lingering_close(r);
1312 }
1313 else {
1314+#ifdef EAPI
1315+ ap_call_close_connection_hook(current_conn);
1316+#endif /* EAPI */
1317 ap_bsetflag(conn_io, B_EOUT, 1);
1318 ap_bclose(conn_io);
1319 }
4812ab25 1320@@ -5389,16 +5484,31 @@
bac1ef07 1321 usage(argv[0]);
1322 }
1323 }
1324+#ifdef EAPI
1325+ ap_init_alloc_shared(TRUE);
1326+#endif
1327
1328 ap_suexec_enabled = init_suexec();
1329 server_conf = ap_read_config(pconf, ptrans, ap_server_confname);
1330
1331+#ifdef EAPI
1332+ ap_init_alloc_shared(FALSE);
1333+#endif
1334+
1335 if (ap_configtestonly) {
1336 fprintf(stderr, "Syntax OK\n");
1337+#ifdef EAPI
1338+ clean_parent_exit(0);
1339+#else
1340 exit(0);
1341+#endif
1342 }
1343 if (ap_dump_settings) {
1344+#ifdef EAPI
1345+ clean_parent_exit(0);
1346+#else
1347 exit(0);
1348+#endif
1349 }
1350
1351 child_timeouts = !ap_standalone || one_process;
4812ab25 1352@@ -5529,6 +5639,10 @@
bac1ef07 1353 ap_destroy_pool(r->pool);
1354 }
1355
1356+#ifdef EAPI
1357+ ap_call_close_connection_hook(conn);
1358+#endif /* EAPI */
1359+
1360 ap_bclose(cio);
1361 }
1362 exit(0);
4812ab25 1363@@ -5905,6 +6019,9 @@
bac1ef07 1364 ap_kill_cleanups_for_socket(ptrans, csd);
1365
1366 #ifdef NO_LINGCLOSE
1367+#ifdef EAPI
1368+ ap_call_close_connection_hook(current_conn);
1369+#endif /* EAPI */
1370 ap_bclose(conn_io); /* just close it */
1371 #else
1372 if (r && r->connection
4812ab25 1373@@ -5915,6 +6032,9 @@
bac1ef07 1374 lingering_close(r);
1375 }
1376 else {
1377+#ifdef EAPI
1378+ ap_call_close_connection_hook(current_conn);
1379+#endif /* EAPI */
1380 ap_bsetflag(conn_io, B_EOUT, 1);
1381 ap_bclose(conn_io);
1382 }
4812ab25 1383@@ -7478,6 +7598,10 @@
66314f26 1384 if (!conf_specified)
1385 ap_cpystrn(ap_server_confname, SERVER_CONFIG_FILE, sizeof(ap_server_confname));
1386
bac1ef07 1387+#ifdef EAPI
1388+ ap_init_alloc_shared(TRUE);
1389+#endif
66314f26 1390+
1391 if (!ap_os_is_path_absolute(ap_server_confname))
1392 ap_cpystrn(ap_server_confname,
1393 ap_server_root_relative(pcommands, ap_server_confname),
4812ab25 1394@@ -7517,6 +7641,9 @@
bac1ef07 1395 }
1396 #else /* ndef WIN32 */
1397 server_conf = ap_read_config(pconf, ptrans, ap_server_confname);
1398+#endif
1399+#ifdef EAPI
1400+ ap_init_alloc_shared(FALSE);
1401 #endif
1402
1403 if (ap_configtestonly) {
1404
1405+---------------------------------------------------------------------------
1406| Just add the initialization of the `ctx' variable for
1407| conn_rec structures.
1408+---------------------------------------------------------------------------
1409Index: src/main/http_request.c
4812ab25
JB
1410--- src/main/http_request.c 27 Mar 2002 15:23:02 -0000 1.1.1.14
1411+++ src/main/http_request.c 27 Mar 2002 15:30:02 -0000 1.14
e48af075 1412@@ -1375,6 +1375,10 @@
7efaaee3 1413
1414 new->method = r->method;
1415 new->method_number = r->method_number;
bac1ef07 1416+#ifdef EAPI
7efaaee3 1417+ /* initialize context _BEFORE_ ap_parse_uri() call */
bac1ef07 1418+ new->ctx = r->ctx;
1419+#endif /* EAPI */
7efaaee3 1420 ap_parse_uri(new, new_uri);
1421 new->request_config = ap_create_request_config(r->pool);
1422 new->per_dir_config = r->server->lookup_defaults;
bac1ef07 1423
1424+---------------------------------------------------------------------------
1425| Just add the initialization of the `ctx' variable for
1426| request_rec structures.
1427+---------------------------------------------------------------------------
1428Index: src/main/http_protocol.c
4812ab25
JB
1429--- src/main/http_protocol.c 27 Mar 2002 15:23:02 -0000 1.1.1.16
1430+++ src/main/http_protocol.c 27 Mar 2002 15:30:02 -0000 1.16
e48af075 1431@@ -1151,6 +1151,10 @@
bac1ef07 1432 r->status = HTTP_REQUEST_TIME_OUT; /* Until we get a request */
1433 r->the_request = NULL;
1434
1435+#ifdef EAPI
1436+ r->ctx = ap_ctx_new(r->pool);
1437+#endif /* EAPI */
1438+
1439 #ifdef CHARSET_EBCDIC
7efaaee3 1440 ap_bsetflag(r->connection->client, B_ASCII2EBCDIC, r->ebcdic.conv_in = 1);
1441 ap_bsetflag(r->connection->client, B_EBCDIC2ASCII, r->ebcdic.conv_out = 1);
e48af075 1442@@ -1299,6 +1303,11 @@
bac1ef07 1443 rnew->read_body = REQUEST_NO_BODY;
1444
1445 rnew->main = (request_rec *) r;
1446+
1447+#ifdef EAPI
1448+ rnew->ctx = r->ctx;
1449+#endif /* EAPI */
1450+
1451 }
1452
e48af075 1453 API_EXPORT(void) ap_finalize_sub_req_protocol(request_rec *sub)
bac1ef07 1454
1455+---------------------------------------------------------------------------
1456| Add support for loading both EAPI and AP13 modules.
1457+---------------------------------------------------------------------------
1458Index: src/modules/standard/mod_so.c
4812ab25
JB
1459--- src/modules/standard/mod_so.c 27 Mar 2002 15:23:06 -0000 1.1.1.9
1460+++ src/modules/standard/mod_so.c 27 Mar 2002 15:30:03 -0000 1.10
e48af075 1461@@ -269,11 +269,24 @@
bac1ef07 1462 * Make sure the found module structure is really a module structure
1463 *
1464 */
1465+#ifdef EAPI
1466+ if ( modp->magic != MODULE_MAGIC_COOKIE_AP13
1467+ && modp->magic != MODULE_MAGIC_COOKIE_EAPI) {
1468+#else
1469 if (modp->magic != MODULE_MAGIC_COOKIE) {
1470+#endif
1471 return ap_pstrcat(cmd->pool, "API module structure `", modname,
1472 "' in file ", szModuleFile, " is garbled -"
1473 " perhaps this is not an Apache module DSO?", NULL);
1474 }
1475+#ifdef EAPI
1476+ if (modp->magic == MODULE_MAGIC_COOKIE_AP13) {
1477+ ap_log_error(APLOG_MARK, APLOG_WARNING|APLOG_NOERRNO, NULL,
1478+ "Loaded DSO %s uses plain Apache 1.3 API, "
1479+ "this module might crash under EAPI! "
1480+ "(please recompile it with -DEAPI)", filename);
1481+ }
1482+#endif
1483
1484 /*
1485 * Add this module to the Apache core structures
1486
1487+---------------------------------------------------------------------------
1488| Add additional logging functions to the CustomLog directive
1489| which can be used by other modules to create additional
1490| logfile tags. Actually we add two types of hooks: One hook
1491| for intercepting the new and generic %x (eXtension) tag and
1492| one hook for creating new %x tags at all.
1493+---------------------------------------------------------------------------
1494Index: src/modules/standard/mod_log_config.c
4812ab25
JB
1495--- src/modules/standard/mod_log_config.c 27 Mar 2002 15:23:05 -0000 1.1.1.12
1496+++ src/modules/standard/mod_log_config.c 27 Mar 2002 15:30:03 -0000 1.25
bac1ef07 1497@@ -262,6 +262,9 @@
1498 typedef const char *(*item_key_func) (request_rec *, char *);
1499
1500 typedef struct {
1501+#ifdef EAPI
1502+ char ch;
1503+#endif
1504 item_key_func func;
1505 char *arg;
1506 int condition_sense;
1507@@ -573,15 +576,36 @@
1508 }
1509 };
1510
1511+#ifdef EAPI
1512+static struct log_item_list *find_log_func(pool *p, char k)
1513+#else /* EAPI */
1514 static struct log_item_list *find_log_func(char k)
1515+#endif /* EAPI */
1516 {
1517 int i;
1518+#ifdef EAPI
1519+ struct log_item_list *lil;
1520+#endif /* EAPI */
1521
1522 for (i = 0; log_item_keys[i].ch; ++i)
1523 if (k == log_item_keys[i].ch) {
1524 return &log_item_keys[i];
1525 }
1526
1527+#ifdef EAPI
1528+ if (ap_hook_status(ap_psprintf(p, "ap::mod_log_config::log_%c", k))
1529+ != AP_HOOK_STATE_NOTEXISTANT) {
1530+ lil = (struct log_item_list *)
1531+ ap_pcalloc(p, sizeof(struct log_item_list));
1532+ if (lil == NULL)
1533+ return NULL;
1534+ lil->ch = k;
1535+ lil->func = NULL;
1536+ lil->want_orig_default = 0;
1537+ return lil;
1538+ }
1539+#endif /* EAPI */
1540+
1541 return NULL;
1542 }
1543
1544@@ -707,7 +731,11 @@
1545 break;
1546
1547 default:
1548+#ifdef EAPI
1549+ l = find_log_func(p, *s++);
1550+#else /* EAPI */
1551 l = find_log_func(*s++);
1552+#endif /* EAPI */
1553 if (!l) {
1554 char dummy[2];
1555
1556@@ -716,6 +744,9 @@
1557 return ap_pstrcat(p, "Unrecognized LogFormat directive %",
1558 dummy, NULL);
1559 }
1560+#ifdef EAPI
1561+ it->ch = s[-1];
1562+#endif
1563 it->func = l->func;
1564 if (it->want_orig == -1) {
1565 it->want_orig = l->want_orig_default;
1566@@ -777,6 +808,15 @@
1567
1568 /* We do. Do it... */
1569
1570+#ifdef EAPI
1571+ if (item->func == NULL) {
1572+ cp = NULL;
1573+ ap_hook_use(ap_psprintf(r->pool, "ap::mod_log_config::log_%c", item->ch),
1574+ AP_HOOK_SIG3(ptr,ptr,ptr), AP_HOOK_DECLINE(NULL),
1575+ &cp, r, item->arg);
1576+ }
1577+ else
1578+#endif
1579 cp = (*item->func) (item->want_orig ? orig : r, item->arg);
1580 return cp ? cp : "-";
1581 }
1582
1583+---------------------------------------------------------------------------
1584| Allow RewriteCond and RewriteRule directives to lookup
1585| variables from other modules.
1586+---------------------------------------------------------------------------
1587Index: src/modules/standard/mod_rewrite.c
4812ab25
JB
1588--- src/modules/standard/mod_rewrite.c 27 Mar 2002 15:23:06 -0000 1.1.1.14
1589+++ src/modules/standard/mod_rewrite.c 27 Mar 2002 15:30:03 -0000 1.12
7efaaee3 1590@@ -3678,6 +3678,15 @@
bac1ef07 1591 }
1592 #endif /* ndef WIN32 && NETWARE*/
1593
1594+#ifdef EAPI
1595+ else {
1596+ ap_hook_use("ap::mod_rewrite::lookup_variable",
1597+ AP_HOOK_SIG3(ptr,ptr,ptr),
1598+ AP_HOOK_DECLINE(NULL),
1599+ &result, r, var);
1600+ }
1601+#endif
1602+
1603 if (result == NULL) {
1604 return ap_pstrdup(r->pool, "");
1605 }
1606
1607+---------------------------------------------------------------------------
1608| Add an EAPI hook to allow other modules to add content to
1609| the status HTML page.
1610+---------------------------------------------------------------------------
1611Index: src/modules/standard/mod_status.c
4812ab25
JB
1612--- src/modules/standard/mod_status.c 27 Mar 2002 15:23:06 -0000 1.1.1.14
1613+++ src/modules/standard/mod_status.c 27 Mar 2002 15:30:03 -0000 1.11
e48af075 1614@@ -717,6 +754,12 @@
bac1ef07 1615 </table>\n", r);
1616 #endif
1617 }
1618+
1619+#ifdef EAPI
1620+ ap_hook_use("ap::mod_status::display",
1621+ AP_HOOK_SIG4(void,ptr,int,int), AP_HOOK_ALL,
1622+ r, no_table_report, short_report);
1623+#endif
1624
1625 } else {
1626
1627
1628+---------------------------------------------------------------------------
1629| Add hooks to the scheme processing to allow other modules to
1630| recognize more schemes by intercepting this processing.
1631+---------------------------------------------------------------------------
1632Index: src/modules/proxy/mod_proxy.c
4812ab25
JB
1633--- src/modules/proxy/mod_proxy.c 27 Mar 2002 15:23:03 -0000 1.1.1.11
1634+++ src/modules/proxy/mod_proxy.c 27 Mar 2002 15:30:03 -0000 1.18
bac1ef07 1635@@ -215,6 +215,9 @@
1636 static int proxy_fixup(request_rec *r)
1637 {
1638 char *url, *p;
1639+#ifdef EAPI
1640+ int rc;
1641+#endif /* EAPI */
1642
1643 if (r->proxyreq == NOT_PROXY || strncmp(r->filename, "proxy:", 6) != 0)
e48af075 1644 return DECLINED;
bac1ef07 1645@@ -222,6 +225,14 @@
1646 url = &r->filename[6];
1647
1648 /* canonicalise each specific scheme */
1649+#ifdef EAPI
1650+ if (ap_hook_use("ap::mod_proxy::canon",
1651+ AP_HOOK_SIG3(int,ptr,ptr),
1652+ AP_HOOK_DECLINE(DECLINED),
1653+ &rc, r, url) && rc != DECLINED)
1654+ return rc;
1655+ else
1656+#endif /* EAPI */
1657 if (strncasecmp(url, "http:", 5) == 0)
e48af075 1658 return ap_proxy_http_canon(r, url + 5, "http", DEFAULT_HTTP_PORT);
bac1ef07 1659 else if (strncasecmp(url, "ftp:", 4) == 0)
1660@@ -237,9 +248,44 @@
1661 static void proxy_init(server_rec *r, pool *p)
1662 {
1663 ap_proxy_garbage_init(r, p);
1664+#ifdef EAPI
1665+ ap_hook_use("ap::mod_proxy::init",
1666+ AP_HOOK_SIG3(void,ptr,ptr), AP_HOOK_ALL, r, p);
1667+#endif
1668 }
bac1ef07 1669
e48af075 1670-
bac1ef07 1671+#ifdef EAPI
1672+static void proxy_addmod(module *m)
1673+{
1674+ /* export: ap_proxy_http_canon() as `ap::mod_proxy::http::canon' */
1675+ ap_hook_configure("ap::mod_proxy::http::canon",
1676+ AP_HOOK_SIG5(int,ptr,ptr,ptr,int), AP_HOOK_TOPMOST);
1677+ ap_hook_register("ap::mod_proxy::http::canon",
1678+ ap_proxy_http_canon, AP_HOOK_NOCTX);
1679+
1680+ /* export: ap_proxy_http_handler() as `ap::mod_proxy::http::handler' */
1681+ ap_hook_configure("ap::mod_proxy::http::handler",
1682+ AP_HOOK_SIG6(int,ptr,ptr,ptr,ptr,int), AP_HOOK_TOPMOST);
1683+ ap_hook_register("ap::mod_proxy::http::handler",
1684+ ap_proxy_http_handler, AP_HOOK_NOCTX);
1685+
1686+ /* export: ap_proxyerror() as `ap::mod_proxy::error' */
1687+ ap_hook_configure("ap::mod_proxy::error",
1688+ AP_HOOK_SIG3(int,ptr,ptr), AP_HOOK_TOPMOST);
1689+ ap_hook_register("ap::mod_proxy::error",
1690+ ap_proxyerror, AP_HOOK_NOCTX);
1691+ return;
1692+}
1693+
1694+static void proxy_remmod(module *m)
1695+{
1696+ /* remove the hook references */
1697+ ap_hook_unregister("ap::mod_proxy::http::canon", ap_proxy_http_canon);
1698+ ap_hook_unregister("ap::mod_proxy::http::handler", ap_proxy_http_handler);
1699+ ap_hook_unregister("ap::mod_proxy::error", ap_proxyerror);
1700+ return;
1701+}
1702+#endif /* EAPI */
1703
1704 /* Send a redirection if the request contains a hostname which is not */
1705 /* fully qualified, i.e. doesn't have a domain name appended. Some proxy */
e48af075 1706@@ -370,6 +416,14 @@
1707 /* CONNECT is a special method that bypasses the normal
1708 * proxy code.
1709 */
bac1ef07 1710+#ifdef EAPI
1711+ if (!ap_hook_use("ap::mod_proxy::handler",
1712+ AP_HOOK_SIG7(int,ptr,ptr,ptr,ptr,int,ptr),
1713+ AP_HOOK_DECLINE(DECLINED),
1714+ &rc, r, cr, url,
1715+ ents[i].hostname, ents[i].port,
1716+ ents[i].protocol) || rc == DECLINED) {
1717+#endif /* EAPI */
e48af075 1718 if (r->method_number == M_CONNECT)
1719 rc = ap_proxy_connect_handler(r, cr, url, ents[i].hostname,
1720 ents[i].port);
1721@@ -379,6 +433,9 @@
1722 ents[i].port);
1723 else
1724 rc = DECLINED;
bac1ef07 1725+#ifdef EAPI
1726+ }
1727+#endif /* EAPI */
1728
e48af075 1729 /* an error or success */
1730 if (rc != DECLINED && rc != HTTP_BAD_GATEWAY)
1731@@ -392,6 +449,14 @@
4812ab25
JB
1732 */
1733
bac1ef07 1734 /* handle the scheme */
1735+#ifdef EAPI
1736+ if (ap_hook_use("ap::mod_proxy::handler",
1737+ AP_HOOK_SIG7(int,ptr,ptr,ptr,ptr,int,ptr),
1738+ AP_HOOK_DECLINE(DECLINED),
1739+ &rc, r, cr, url,
1740+ NULL, 0, scheme) && rc != DECLINED)
1741+ return rc;
1742+#endif /* EAPI */
4812ab25 1743 if (r->method_number == M_CONNECT) {
e48af075 1744 return ap_proxy_connect_handler(r, cr, url, NULL, 0);
4812ab25
JB
1745 }
1746@@ -973,6 +1038,12 @@
e48af075 1747 NULL, /* child_init */
1748 NULL, /* child_exit */
1749 proxy_detect /* post read-request */
bac1ef07 1750+#ifdef EAPI
1751+ ,proxy_addmod, /* EAPI: add_module */
1752+ proxy_remmod, /* EAPI: remove_module */
1753+ NULL, /* EAPI: rewrite_command */
1754+ NULL /* EAPI: new_connection */
1755+#endif
1756 };
1757
1758
1759
1760+---------------------------------------------------------------------------
1761| Add hooks to the HTTP processing to allow other modules
1762| to enhance it by intercepting this processing.
1763+---------------------------------------------------------------------------
1764Index: src/modules/proxy/proxy_http.c
4812ab25
JB
1765--- src/modules/proxy/proxy_http.c 27 Mar 2002 15:23:04 -0000 1.1.1.13
1766+++ src/modules/proxy/proxy_http.c 27 Mar 2002 15:30:03 -0000 1.21
e48af075 1767@@ -166,6 +166,9 @@
bac1ef07 1768 const char *urlptr = NULL;
e48af075 1769 const char *datestr, *urlstr;
4812ab25 1770 const char *content_length;
bac1ef07 1771+#ifdef EAPI
1772+ char *peer;
1773+#endif
1774
1775 void *sconf = r->server->module_config;
1776 proxy_server_conf *conf =
e48af075 1777@@ -186,6 +189,12 @@
1778 return HTTP_BAD_REQUEST;
bac1ef07 1779 urlptr += 3;
1780 destport = DEFAULT_HTTP_PORT;
1781+#ifdef EAPI
1782+ ap_hook_use("ap::mod_proxy::http::handler::set_destport",
1783+ AP_HOOK_SIG2(int,ptr),
1784+ AP_HOOK_TOPMOST,
1785+ &destport, r);
1786+#endif /* EAPI */
1787 strp = strchr(urlptr, '/');
1788 if (strp == NULL) {
e48af075 1789 desthost = ap_pstrdup(p, urlptr);
1790@@ -223,12 +232,18 @@
1791 err = ap_proxy_host2addr(proxyhost, &server_hp);
1792 if (err != NULL)
1793 return DECLINED; /* try another */
bac1ef07 1794+#ifdef EAPI
1795+ peer = ap_psprintf(p, "%s:%u", proxyhost, proxyport);
1796+#endif
1797 }
1798 else {
e48af075 1799 server.sin_port = htons((unsigned short)destport);
1800 err = ap_proxy_host2addr(desthost, &server_hp);
1801 if (err != NULL)
1802 return ap_proxyerror(r, HTTP_INTERNAL_SERVER_ERROR, err);
bac1ef07 1803+#ifdef EAPI
1804+ peer = ap_psprintf(p, "%s:%u", desthost, destport);
1805+#endif
1806 }
1807
e48af075 1808
1809@@ -301,14 +316,42 @@
bac1ef07 1810 f = ap_bcreate(p, B_RDWR | B_SOCKET);
1811 ap_bpushfd(f, sock, sock);
1812
1813+#ifdef EAPI
1814+ {
1815+ char *errmsg = NULL;
1816+ ap_hook_use("ap::mod_proxy::http::handler::new_connection",
1817+ AP_HOOK_SIG4(ptr,ptr,ptr,ptr),
1818+ AP_HOOK_DECLINE(NULL),
1819+ &errmsg, r, f, peer);
1820+ if (errmsg != NULL)
1821+ return ap_proxyerror(r, HTTP_BAD_GATEWAY, errmsg);
1822+ }
1823+#endif /* EAPI */
1824+
1825 ap_hard_timeout("proxy send", r);
4812ab25
JB
1826 ap_bvputs(f, r->method, " ", proxyhost ? url : urlptr, " HTTP/1.1" CRLF,
1827 NULL);
bac1ef07 1828+#ifdef EAPI
1829+ {
1830+ int rc = DECLINED;
1831+ ap_hook_use("ap::mod_proxy::http::handler::write_host_header",
1832+ AP_HOOK_SIG6(int,ptr,ptr,ptr,int,ptr),
1833+ AP_HOOK_DECLINE(DECLINED),
1834+ &rc, r, f, desthost, destport, destportstr);
1835+ if (rc == DECLINED) {
1836+ if (destportstr != NULL && destport != DEFAULT_HTTP_PORT)
1837+ ap_bvputs(f, "Host: ", desthost, ":", destportstr, CRLF, NULL);
1838+ else
1839+ ap_bvputs(f, "Host: ", desthost, CRLF, NULL);
1840+ }
1841+ }
1842+#else /* EAPI */
e48af075 1843 /* Send Host: now, adding it to req_hdrs wouldn't be much better */
bac1ef07 1844 if (destportstr != NULL && destport != DEFAULT_HTTP_PORT)
e48af075 1845 ap_bvputs(f, "Host: ", desthost, ":", destportstr, CRLF, NULL);
bac1ef07 1846 else
e48af075 1847 ap_bvputs(f, "Host: ", desthost, CRLF, NULL);
bac1ef07 1848+#endif /* EAPI */
1849
1850 if (conf->viaopt == via_block) {
e48af075 1851 /* Block all outgoing Via: headers */
bac1ef07 1852
1853+---------------------------------------------------------------------------
1854| Add EAPI hooks in module structure for APXS generated samples.
1855+---------------------------------------------------------------------------
1856Index: src/support/apxs.pl
4812ab25
JB
1857--- src/support/apxs.pl 27 Mar 2002 15:23:11 -0000 1.1.1.11
1858+++ src/support/apxs.pl 27 Mar 2002 15:30:03 -0000 1.11
1859@@ -704,5 +704,11 @@
bac1ef07 1860 NULL, /* child_init */
1861 NULL, /* child_exit */
1862 NULL /* [#0] post read-request */
1863+#ifdef EAPI
1864+ ,NULL, /* EAPI: add_module */
1865+ NULL, /* EAPI: remove_module */
1866+ NULL, /* EAPI: rewrite_command */
1867+ NULL /* EAPI: new_connection */
1868+#endif
1869 };
1870
1871
1872+---------------------------------------------------------------------------
1873| Add the EAPI functions, so the stuff can be built under AIX
1874| and similar braindead platforms as DSO.
1875+---------------------------------------------------------------------------
1876Index: src/support/httpd.exp
4812ab25
JB
1877--- src/support/httpd.exp 27 Mar 2002 15:23:12 -0000 1.1.1.10
1878+++ src/support/httpd.exp 27 Mar 2002 15:30:03 -0000 1.12
1879@@ -423,3 +423,59 @@
bac1ef07 1880 XML_SetUnparsedEntityDeclHandler
1881 XML_SetUserData
1882 XML_UseParserAsHandlerArg
1883+ap_add_config_define
1884+ap_make_shared_sub_pool
1885+ap_global_ctx
1886+ap_ctx_new
1887+ap_ctx_get
1888+ap_ctx_set
1889+ap_hook_init
1890+ap_hook_kill
1891+ap_hook_configure
1892+ap_hook_register_I
1893+ap_hook_unregister_I
1894+ap_hook_status
1895+ap_hook_use
1896+ap_hook_call
1897+ap_mm_useable
1898+ap_MM_create
1899+ap_MM_permission
1900+ap_MM_destroy
1901+ap_MM_lock
1902+ap_MM_unlock
1903+ap_MM_malloc
1904+ap_MM_realloc
1905+ap_MM_free
1906+ap_MM_calloc
1907+ap_MM_strdup
1908+ap_MM_sizeof
1909+ap_MM_maxsize
1910+ap_MM_available
1911+ap_MM_error
1912+ap_mm_create
1913+ap_mm_permission
1914+ap_mm_destroy
1915+ap_mm_lock
1916+ap_mm_unlock
1917+ap_mm_malloc
1918+ap_mm_realloc
1919+ap_mm_free
1920+ap_mm_calloc
1921+ap_mm_strdup
1922+ap_mm_sizeof
1923+ap_mm_maxsize
1924+ap_mm_available
1925+ap_mm_error
1926+ap_mm_display_info
1927+ap_mm_core_create
1928+ap_mm_core_permission
1929+ap_mm_core_delete
1930+ap_mm_core_size
1931+ap_mm_core_lock
1932+ap_mm_core_unlock
1933+ap_mm_core_maxsegsize
1934+ap_mm_core_align2page
1935+ap_mm_core_align2word
1936+ap_mm_lib_error_set
1937+ap_mm_lib_error_get
1938+ap_mm_lib_version
1939
1940+---------------------------------------------------------------------------
1941| Add the EAPI functions, so the stuff can be built under
1942| Windows 95 and similar braindead platforms as DDL.
1943+---------------------------------------------------------------------------
1944Index: src/ApacheCore.def
4812ab25
JB
1945--- src/ApacheCore.def 27 Mar 2002 15:22:53 -0000 1.1.1.9
1946+++ src/ApacheCore.def 27 Mar 2002 15:30:02 -0000 1.13
1947@@ -444,3 +444,67 @@
1948 ap_getline @439
1949 ap_get_chunk_size @440
1950 ap_escape_logitem @441
bac1ef07 1951+
1952+ ; EAPI extended symbols
1953+ ; note; no ID's, so these all bind by name rather than ordinal since
1954+ ; their ordinals would change with symbol changes in the distribution
1955+ ap_add_config_define
1956+ ap_global_ctx DATA
1957+ ap_ctx_new
1958+ ap_ctx_get
1959+ ap_ctx_overlay
1960+ ap_ctx_set
1961+ ap_hook_init
1962+ ap_hook_kill
1963+ ap_hook_configure
1964+ ap_hook_register_I
1965+ ap_hook_unregister_I
1966+ ap_hook_status
1967+ ap_hook_use
1968+ ap_hook_call
1969+ ap_set_callback_and_alarm
66314f26 1970+ ap_acquire_pool
bac1ef07 1971+ ap_make_shared_sub_pool
1972+ ap_release_pool
1973+ ap_mm_useable
1974+ ap_MM_create
1975+ ap_MM_permission
1976+ ap_MM_destroy
1977+ ap_MM_lock
1978+ ap_MM_unlock
1979+ ap_MM_malloc
1980+ ap_MM_realloc
1981+ ap_MM_free
1982+ ap_MM_calloc
1983+ ap_MM_strdup
1984+ ap_MM_sizeof
1985+ ap_MM_maxsize
1986+ ap_MM_available
1987+ ap_MM_error
1988+ ap_mm_create
1989+ ap_mm_permission
1990+ ap_mm_destroy
1991+ ap_mm_lock
1992+ ap_mm_unlock
1993+ ap_mm_malloc
1994+ ap_mm_realloc
1995+ ap_mm_free
1996+ ap_mm_calloc
1997+ ap_mm_strdup
1998+ ap_mm_sizeof
1999+ ap_mm_maxsize
2000+ ap_mm_available
2001+ ap_mm_error
2002+ ap_mm_display_info
2003+ ap_mm_core_create
2004+ ap_mm_core_permission
2005+ ap_mm_core_delete
2006+ ap_mm_core_size
2007+ ap_mm_core_lock
2008+ ap_mm_core_unlock
2009+ ap_mm_core_align2page
2010+ ap_mm_core_align2word
2011+ ap_mm_lib_error_set
2012+ ap_mm_lib_error_get
2013+ ap_mm_lib_version
2014+
This page took 0.290361 seconds and 4 git commands to generate.