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