]> git.pld-linux.org Git - packages/apache.git/blame - apache-mod_ssl-eapi.patch
- be more verbose while adding/removing user/group
[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.
e48af075 10## Created on: 01-Feb-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
e48af075 27--- src/Configuration.tmpl 2002/01/28 19:21:21 1.1.1.7
28+++ src/Configuration.tmpl 2002/01/28 19:40:56 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
e48af075 59--- src/Configure 2002/01/28 19:21:21 1.1.1.17
60+++ src/Configure 2002/01/28 19:40:56 1.19
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
82+ EAPI_MM=`egrep '^EAPI_MM=' $file | tail -1 | awk -F= '{print $2}'`
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
7efaaee3 139--- src/ap/Makefile.tmpl 2001/05/20 08:16:15 1.1.1.7
140+++ src/ap/Makefile.tmpl 2001/05/20 08:23:01 1.7
bac1ef07 141@@ -6,7 +6,8 @@
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 \
7efaaee3 145- ap_slack.o ap_snprintf.o ap_sha1.o ap_checkpass.o ap_base64.o ap_ebcdic.o
146+ ap_slack.o ap_snprintf.o ap_sha1.o ap_checkpass.o ap_base64.o ap_ebcdic.o \
bac1ef07 147+ ap_hook.o ap_ctx.o ap_mm.o
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
c7f132e3
MK
156--- src/ap/ap.mak 2001/10/16 11:47:06 1.1.1.9
157+++ src/ap/ap.mak 2001/10/16 11:57:38 1.9
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
e48af075 204--- src/include/ap_mmn.h 2002/01/28 19:21:22 1.1.1.9
205+++ src/include/ap_mmn.h 2002/01/28 19:40:56 1.9
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
e48af075 236--- src/include/ap_alloc.h 2002/01/28 19:21:22 1.1.1.4
237+++ src/include/ap_alloc.h 2002/01/28 19:40:56 1.5
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
e48af075 259--- src/include/buff.h 2002/01/28 19:21:23 1.1.1.5
260+++ src/include/buff.h 2002/01/28 19:40:56 1.9
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
e48af075 288--- src/include/http_config.h 2002/01/28 19:21:23 1.1.1.9
289+++ src/include/http_config.h 2002/01/28 19:40:56 1.11
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
e48af075 362--- src/include/http_conf_globals.h 2002/01/28 19:21:22 1.1.1.10
363+++ src/include/http_conf_globals.h 2002/01/28 19:40:56 1.11
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
e48af075 391--- src/include/httpd.h 2002/01/28 19:21:23 1.1.1.17
392+++ src/include/httpd.h 2002/01/28 19:40:56 1.27
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
e48af075 498--- src/main/alloc.c 2002/01/28 19:21:24 1.1.1.11
499+++ src/main/alloc.c 2002/01/28 19:40:56 1.18
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;
576@@ -342,7 +369,11 @@
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);
583 #endif
584+#endif
585 }
586
587
588@@ -350,7 +381,11 @@
589 * if necessary. Must be called with alarms blocked.
590 */
591
592+#if defined(EAPI) && defined(EAPI_MM)
593+static union block_hdr *new_block(int min_size, int is_shm)
594+#else
595 static union block_hdr *new_block(int min_size)
596+#endif
597 {
598 union block_hdr **lastptr = &block_freelist;
599 union block_hdr *blok = block_freelist;
600@@ -360,7 +395,12 @@
601 */
602
603 while (blok != NULL) {
604+#if defined(EAPI) && defined(EAPI_MM)
605+ if (blok->h.is_shm == is_shm &&
606+ min_size + BLOCK_MINFREE <= blok->h.endp - blok->h.first_avail) {
607+#else
608 if (min_size + BLOCK_MINFREE <= blok->h.endp - blok->h.first_avail) {
609+#endif
610 *lastptr = blok->h.next;
611 blok->h.next = NULL;
612 debug_verify_filled(blok->h.first_avail, blok->h.endp,
613@@ -376,7 +416,11 @@
614 /* Nope. */
615
616 min_size += BLOCK_MINFREE;
617+#if defined(EAPI) && defined(EAPI_MM)
618+ blok = malloc_block((min_size > BLOCK_MINALLOC) ? min_size : BLOCK_MINALLOC, is_shm);
619+#else
620 blok = malloc_block((min_size > BLOCK_MINALLOC) ? min_size : BLOCK_MINALLOC);
621+#endif
622 return blok;
623 }
624
625@@ -426,6 +470,9 @@
626 #ifdef POOL_DEBUG
627 struct pool *joined;
628 #endif
629+#if defined(EAPI) && defined(EAPI_MM)
630+ int is_shm;
631+#endif
632 };
633
634 static pool *permanent_pool;
635@@ -440,16 +487,28 @@
636 #define POOL_HDR_CLICKS (1 + ((sizeof(struct pool) - 1) / CLICK_SZ))
637 #define POOL_HDR_BYTES (POOL_HDR_CLICKS * CLICK_SZ)
638
639+#if defined(EAPI) && defined(EAPI_MM)
640+static struct pool *make_sub_pool_internal(struct pool *p, int is_shm)
641+#else
642 API_EXPORT(struct pool *) ap_make_sub_pool(struct pool *p)
643+#endif
644 {
645 union block_hdr *blok;
646 pool *new_pool;
647
648 ap_block_alarms();
649
650+#if defined(EAPI) && defined(EAPI_MM)
651+ if (is_shm)
652+ (void)ap_mm_lock(mm, AP_MM_LOCK_RW);
653+#endif
654 (void) ap_acquire_mutex(alloc_mutex);
655
656+#if defined(EAPI) && defined(EAPI_MM)
657+ blok = new_block(POOL_HDR_BYTES, is_shm);
658+#else
659 blok = new_block(POOL_HDR_BYTES);
660+#endif
661 new_pool = (pool *) blok->h.first_avail;
662 blok->h.first_avail += POOL_HDR_BYTES;
663 #ifdef POOL_DEBUG
664@@ -468,12 +527,38 @@
665 p->sub_pools = new_pool;
666 }
667
668+#if defined(EAPI) && defined(EAPI_MM)
669+ new_pool->is_shm = is_shm;
670+#endif
671+
672 (void) ap_release_mutex(alloc_mutex);
673+#if defined(EAPI) && defined(EAPI_MM)
674+ if (is_shm)
675+ (void)ap_mm_unlock(mm);
676+#endif
677 ap_unblock_alarms();
678
679 return new_pool;
680 }
681
682+#if defined(EAPI)
683+#if defined(EAPI_MM)
684+API_EXPORT(struct pool *) ap_make_sub_pool(struct pool *p)
685+{
686+ return make_sub_pool_internal(p, 0);
687+}
688+API_EXPORT(struct pool *) ap_make_shared_sub_pool(struct pool *p)
689+{
690+ return make_sub_pool_internal(p, 1);
691+}
692+#else
693+API_EXPORT(struct pool *) ap_make_shared_sub_pool(struct pool *p)
694+{
695+ return NULL;
696+}
697+#endif
698+#endif
699+
700 #ifdef POOL_DEBUG
701 static void stack_var_init(char *s)
702 {
703@@ -488,6 +573,13 @@
704 }
705 #endif
706
707+#if defined(EAPI)
708+int ap_shared_pool_possible(void)
709+{
710+ return ap_mm_useable();
711+}
712+#endif
713+
714 #ifdef ALLOC_STATS
715 static void dump_stats(void)
716 {
717@@ -520,6 +612,58 @@
718 return permanent_pool;
719 }
720
721+#if defined(EAPI)
722+void ap_init_alloc_shared(int early)
723+{
724+#if defined(EAPI_MM)
725+ int mm_size;
726+ char *mm_path;
727+ char *err1, *err2;
728+
729+ if (early) {
730+ /* process very early on startup */
731+ mm_size = ap_mm_maxsize();
732+ if (mm_size > EAPI_MM_CORE_MAXSIZE)
733+ mm_size = EAPI_MM_CORE_MAXSIZE;
734+ mm_path = ap_server_root_relative(permanent_pool,
735+ ap_psprintf(permanent_pool, "%s.%ld",
736+ EAPI_MM_CORE_PATH, (long)getpid()));
737+ if ((mm = ap_mm_create(mm_size, mm_path)) == NULL) {
738+ fprintf(stderr, "Ouch! ap_mm_create(%d, \"%s\") failed\n", mm_size, mm_path);
739+ err1 = ap_mm_error();
740+ if (err1 == NULL)
741+ err1 = "-unknown-";
742+ err2 = strerror(errno);
743+ if (err2 == NULL)
744+ err2 = "-unknown-";
745+ fprintf(stderr, "Error: MM: %s: OS: %s\n", err1, err2);
746+ exit(1);
747+ }
748+ }
749+ else {
750+ /* process a lot later on startup */
751+#ifdef WIN32
752+ ap_mm_permission(mm, (_S_IREAD|_S_IWRITE), ap_user_id, -1);
753+#else
754+ ap_mm_permission(mm, (S_IRUSR|S_IWUSR), ap_user_id, -1);
755+#endif
756+ }
757+#endif /* EAPI_MM */
758+ return;
759+}
760+
761+void ap_kill_alloc_shared(void)
762+{
763+#if defined(EAPI_MM)
764+ if (mm != NULL) {
765+ ap_mm_destroy(mm);
766+ mm = NULL;
767+ }
768+#endif /* EAPI_MM */
769+ return;
770+}
771+#endif /* EAPI */
772+
773 void ap_cleanup_alloc(void)
774 {
775 ap_destroy_mutex(alloc_mutex);
776@@ -530,10 +674,18 @@
777 {
778 ap_block_alarms();
779
780+#if defined(EAPI) && defined(EAPI_MM)
781+ if (a->is_shm)
782+ (void)ap_mm_lock(mm, AP_MM_LOCK_RW);
783+#endif
784 (void) ap_acquire_mutex(alloc_mutex);
785 while (a->sub_pools)
786 ap_destroy_pool(a->sub_pools);
787 (void) ap_release_mutex(alloc_mutex);
788+#if defined(EAPI) && defined(EAPI_MM)
789+ if (a->is_shm)
790+ (void)ap_mm_unlock(mm);
791+#endif
792 /* Don't hold the mutex during cleanups. */
793 run_cleanups(a->cleanups);
794 a->cleanups = NULL;
795@@ -567,6 +719,10 @@
796 ap_block_alarms();
797 ap_clear_pool(a);
798
799+#if defined(EAPI) && defined(EAPI_MM)
800+ if (a->is_shm)
801+ (void)ap_mm_lock(mm, AP_MM_LOCK_RW);
802+#endif
803 (void) ap_acquire_mutex(alloc_mutex);
804 if (a->parent) {
805 if (a->parent->sub_pools == a)
806@@ -577,6 +733,10 @@
807 a->sub_next->sub_prev = a->sub_prev;
808 }
809 (void) ap_release_mutex(alloc_mutex);
810+#if defined(EAPI) && defined(EAPI_MM)
811+ if (a->is_shm)
812+ (void)ap_mm_unlock(mm);
813+#endif
814
815 free_blocks(a->first);
816 ap_unblock_alarms();
817@@ -591,6 +751,30 @@
818 return bytes_in_block_list(block_freelist);
819 }
820
821+#if defined(EAPI)
822+API_EXPORT(int) ap_acquire_pool(pool *p, ap_pool_lock_mode mode)
823+{
824+#if defined(EAPI_MM)
825+ if (!p->is_shm)
826+ return 1;
827+ return ap_mm_lock(mm, mode == AP_POOL_RD ? AP_MM_LOCK_RD : AP_MM_LOCK_RW);
828+#else
829+ return 1;
830+#endif
831+}
832+
833+API_EXPORT(int) ap_release_pool(pool *p)
834+{
835+#if defined(EAPI_MM)
836+ if (!p->is_shm)
837+ return 1;
838+ return ap_mm_unlock(mm);
839+#else
840+ return 1;
841+#endif
842+}
843+#endif /* EAPI */
844+
845 /*****************************************************************
846 * POOL_DEBUG support
847 */
848@@ -756,16 +940,31 @@
849
850 ap_block_alarms();
851
852+#if defined(EAPI) && defined(EAPI_MM)
853+ if (a->is_shm)
854+ (void)ap_mm_lock(mm, AP_MM_LOCK_RW);
855+#endif
856 (void) ap_acquire_mutex(alloc_mutex);
857
858+#if defined(EAPI) && defined(EAPI_MM)
859+ blok = new_block(size, a->is_shm);
860+#else
861 blok = new_block(size);
862+#endif
863 a->last->h.next = blok;
864 a->last = blok;
865 #ifdef POOL_DEBUG
866 blok->h.owning_pool = a;
867 #endif
868+#if defined(EAPI) && defined(EAPI_MM)
869+ blok->h.is_shm = a->is_shm;
870+#endif
871
872 (void) ap_release_mutex(alloc_mutex);
873+#if defined(EAPI) && defined(EAPI_MM)
874+ if (a->is_shm)
875+ (void)ap_mm_unlock(mm);
876+#endif
877
878 ap_unblock_alarms();
879
880@@ -877,6 +1076,11 @@
881 char *ptr;
882
883 size = (char *)ps->vbuff.curpos - ps->base;
884+#if defined(EAPI) && defined(EAPI_MM)
885+ if (ps->block->h.is_shm)
886+ ptr = ap_mm_realloc(ps->base, 2*size);
887+ else
888+#endif
889 ptr = realloc(ps->base, 2*size);
890 if (ptr == NULL) {
891 fputs("Ouch! Out of memory!\n", stderr);
892@@ -897,9 +1101,21 @@
893 cur_len = strp - blok->h.first_avail;
894
895 /* must try another blok */
896+#if defined(EAPI) && defined(EAPI_MM)
897+ if (blok->h.is_shm)
898+ (void)ap_mm_lock(mm, AP_MM_LOCK_RW);
899+#endif
900 (void) ap_acquire_mutex(alloc_mutex);
901+#if defined(EAPI) && defined(EAPI_MM)
902+ nblok = new_block(2 * cur_len, blok->h.is_shm);
903+#else
904 nblok = new_block(2 * cur_len);
905+#endif
906 (void) ap_release_mutex(alloc_mutex);
907+#if defined(EAPI) && defined(EAPI_MM)
908+ if (blok->h.is_shm)
909+ (void)ap_mm_unlock(mm);
910+#endif
911 memcpy(nblok->h.first_avail, blok->h.first_avail, cur_len);
912 ps->vbuff.curpos = nblok->h.first_avail + cur_len;
913 /* save a byte for the NUL terminator */
914@@ -908,10 +1124,18 @@
915 /* did we allocate the current blok? if so free it up */
916 if (ps->got_a_new_block) {
917 debug_fill(blok->h.first_avail, blok->h.endp - blok->h.first_avail);
918+#if defined(EAPI) && defined(EAPI_MM)
919+ if (blok->h.is_shm)
920+ (void)ap_mm_lock(mm, AP_MM_LOCK_RW);
921+#endif
922 (void) ap_acquire_mutex(alloc_mutex);
923 blok->h.next = block_freelist;
924 block_freelist = blok;
925 (void) ap_release_mutex(alloc_mutex);
926+#if defined(EAPI) && defined(EAPI_MM)
927+ if (blok->h.is_shm)
928+ (void)ap_mm_unlock(mm);
929+#endif
930 }
931 ps->blok = nblok;
932 ps->got_a_new_block = 1;
933@@ -930,6 +1154,11 @@
934 void *ptr;
935
936 ap_block_alarms();
937+#if defined(EAPI) && defined(EAPI_MM)
938+ if (p->is_shm)
939+ ps.base = ap_mm_malloc(mm, 512);
940+ else
941+#endif
942 ps.base = malloc(512);
943 if (ps.base == NULL) {
944 fputs("Ouch! Out of memory!\n", stderr);
945@@ -942,6 +1171,11 @@
946 *ps.vbuff.curpos++ = '\0';
947 ptr = ps.base;
948 /* shrink */
949+#if defined(EAPI) && defined(EAPI_MM)
950+ if (p->is_shm)
951+ ptr = ap_mm_realloc(ptr, (char *)ps.vbuff.curpos - (char *)ptr);
952+ else
953+#endif
954 ptr = realloc(ptr, (char *)ps.vbuff.curpos - (char *)ptr);
955 if (ptr == NULL) {
956 fputs("Ouch! Out of memory!\n", stderr);
957
958+---------------------------------------------------------------------------
959| Patch the low-level buffer routines to additionally allow
960| modules to intercept the I/O processing via hooks.
961+---------------------------------------------------------------------------
962Index: src/main/buff.c
e48af075 963--- src/main/buff.c 2002/01/28 19:21:24 1.1.1.11
964+++ src/main/buff.c 2002/01/28 19:40:57 1.19
965@@ -273,6 +273,9 @@
bac1ef07 966 }
967 else
968 #endif
969+#ifdef EAPI
970+ if (!ap_hook_call("ap::buff::read", &rv, fb, buf, nbyte))
971+#endif /* EAPI */
972 rv = read(fb->fd_in, buf, nbyte);
973
974 return rv;
e48af075 975@@ -284,6 +287,9 @@
bac1ef07 976
e48af075 977 #if defined (WIN32) || defined(NETWARE) || defined(CYGWIN_WINSOCK)
bac1ef07 978 if (fb->flags & B_SOCKET) {
979+#ifdef EAPI
980+ if (!ap_hook_call("ap::buff::recvwithtimeout", &rv, fb, buf, nbyte))
981+#endif /* EAPI */
e48af075 982 rv = ap_recvwithtimeout(fb->fd_in, buf, nbyte, 0);
bac1ef07 983 if (rv == SOCKET_ERROR)
984 errno = WSAGetLastError();
e48af075 985@@ -331,6 +337,9 @@
bac1ef07 986 }
987 else
988 #endif
989+#ifdef EAPI
990+ if (!ap_hook_call("ap::buff::write", &rv, fb, buf, nbyte))
991+#endif /* EAPI */
992 #if defined (B_SFIO)
993 rv = sfwrite(fb->sf_out, buf, nbyte);
994 #else
e48af075 995@@ -361,6 +370,9 @@
996
bac1ef07 997 #if defined(WIN32) || defined(NETWARE)
998 if (fb->flags & B_SOCKET) {
999+#ifdef EAPI
1000+ if (!ap_hook_call("ap::buff::sendwithtimeout", &rv, fb, buf, nbyte))
1001+#endif /* EAPI */
e48af075 1002 rv = ap_sendwithtimeout(fb->fd, buf, nbyte, 0);
bac1ef07 1003 if (rv == SOCKET_ERROR)
1004 errno = WSAGetLastError();
e48af075 1005@@ -444,6 +456,10 @@
1006 fb->callback_data = NULL;
1007 fb->filter_callback = NULL;
bac1ef07 1008
1009+#ifdef EAPI
1010+ fb->ctx = ap_ctx_new(p);
1011+#endif /* EAPI */
1012+
1013 return fb;
1014 }
1015
e48af075 1016@@ -1096,6 +1112,9 @@
bac1ef07 1017 i = 0;
1018 while (i < nvec) {
1019 do
1020+#ifdef EAPI
1021+ if (!ap_hook_call("ap::buff::writev", &rv, fb, &vec[i], nvec -i))
1022+#endif /* EAPI */
1023 rv = writev(fb->fd, &vec[i], nvec - i);
1024 while (rv == -1 && (errno == EINTR || errno == EAGAIN)
1025 && !(fb->flags & B_EOUT));
1026
1027+---------------------------------------------------------------------------
1028| Add the implementation of the additional `add_module' and
1029| `rewrite_command' module hooks. Additionally the `ctx'
1030| variables are initialized.
1031+---------------------------------------------------------------------------
1032Index: src/main/http_config.c
e48af075 1033--- src/main/http_config.c 2002/01/28 19:21:24 1.1.1.13
1034+++ src/main/http_config.c 2002/01/28 19:40:57 1.16
bac1ef07 1035@@ -599,6 +599,20 @@
1036 m->name = tmp;
1037 }
1038 #endif /*_OSD_POSIX*/
1039+
1040+#ifdef EAPI
1041+ /*
1042+ * Invoke the `add_module' hook inside the now existing set
1043+ * of modules to let them all now that this module was added.
1044+ */
1045+ {
1046+ module *m2;
1047+ for (m2 = top_module; m2 != NULL; m2 = m2->next)
1048+ if (m2->magic == MODULE_MAGIC_COOKIE_EAPI)
1049+ if (m2->add_module != NULL)
1050+ (*m2->add_module)(m);
1051+ }
1052+#endif /* EAPI */
1053 }
1054
1055 /*
1056@@ -613,6 +627,21 @@
1057 {
1058 module *modp;
1059
1060+#ifdef EAPI
1061+ /*
1062+ * Invoke the `remove_module' hook inside the now existing
1063+ * set of modules to let them all now that this module is
1064+ * beeing removed.
1065+ */
1066+ {
1067+ module *m2;
1068+ for (m2 = top_module; m2 != NULL; m2 = m2->next)
1069+ if (m2->magic == MODULE_MAGIC_COOKIE_EAPI)
1070+ if (m2->remove_module != NULL)
1071+ (*m2->remove_module)(m);
1072+ }
1073+#endif /* EAPI */
1074+
1075 modp = top_module;
1076 if (modp == m) {
1077 /* We are the top module, special case */
1078@@ -1006,6 +1035,27 @@
1079 const command_rec *cmd;
1080 module *mod = top_module;
1081
1082+#ifdef EAPI
1083+ /*
1084+ * Invoke the `rewrite_command' of modules to allow
1085+ * they to rewrite the directive line before we
1086+ * process it.
1087+ */
1088+ {
1089+ module *m;
1090+ char *cp;
1091+ for (m = top_module; m != NULL; m = m->next) {
1092+ if (m->magic == MODULE_MAGIC_COOKIE_EAPI) {
1093+ if (m->rewrite_command != NULL) {
1094+ cp = (m->rewrite_command)(parms, config, l);
1095+ if (cp != NULL)
1096+ l = cp;
1097+ }
1098+ }
1099+ }
1100+ }
1101+#endif /* EAPI */
1102+
1103 if ((l[0] == '#') || (!l[0]))
1104 return NULL;
1105
1106@@ -1440,6 +1490,10 @@
1107 s->limit_req_fieldsize = main_server->limit_req_fieldsize;
1108 s->limit_req_fields = main_server->limit_req_fields;
1109
1110+#ifdef EAPI
1111+ s->ctx = ap_ctx_new(p);
1112+#endif /* EAPI */
1113+
1114 *ps = s;
1115
1116 return ap_parse_vhost_addrs(p, hostname, s);
1117@@ -1550,6 +1604,10 @@
1118
1119 s->module_config = create_server_config(p, s);
1120 s->lookup_defaults = create_default_per_dir_config(p);
1121+
1122+#ifdef EAPI
1123+ s->ctx = ap_ctx_new(p);
1124+#endif /* EAPI */
1125
1126 return s;
1127 }
1128
1129+---------------------------------------------------------------------------
1130| Add the ap_global_ctx variable and the new
1131| ap_add_config_define() function. Additionally the
1132| implementation of the additional `new_connection' module hook
1133| is added plus the initialization of one more `ctx' variable.
1134+---------------------------------------------------------------------------
1135Index: src/main/http_main.c
e48af075 1136--- src/main/http_main.c 2002/01/28 19:21:24 1.1.1.16
1137+++ src/main/http_main.c 2002/01/28 19:40:57 1.38
1138@@ -279,6 +279,9 @@
c7f132e3 1139
bac1ef07 1140 int ap_dump_settings = 0;
1141 API_VAR_EXPORT int ap_extended_status = 0;
1142+#ifdef EAPI
1143+API_VAR_EXPORT ap_ctx *ap_global_ctx;
1144+#endif /* EAPI */
1145
1146 /*
1147 * The max child slot ever assigned, preserved across restarts. Necessary
e48af075 1148@@ -461,6 +464,30 @@
bac1ef07 1149 }
1150 }
1151
1152+#ifdef EAPI
1153+API_EXPORT(void) ap_add_config_define(const char *define)
1154+{
1155+ char **var;
1156+ var = (char **)ap_push_array(ap_server_config_defines);
1157+ *var = ap_pstrdup(pcommands, define);
1158+ return;
1159+}
1160+
1161+/*
1162+ * Invoke the `close_connection' hook of modules to let them do
1163+ * some connection dependent actions before we close it.
1164+ */
1165+static void ap_call_close_connection_hook(conn_rec *c)
1166+{
1167+ module *m;
1168+ for (m = top_module; m != NULL; m = m->next)
1169+ if (m->magic == MODULE_MAGIC_COOKIE_EAPI)
1170+ if (m->close_connection != NULL)
1171+ (*m->close_connection)(c);
1172+ return;
1173+}
1174+#endif /* EAPI */
1175+
1176 #ifndef NETWARE
1177 static APACHE_TLS int volatile exit_after_unblock = 0;
1178 #endif
e48af075 1179@@ -1509,6 +1536,10 @@
bac1ef07 1180 ap_log_transaction(log_req);
1181 }
1182
1183+#ifdef EAPI
1184+ ap_call_close_connection_hook(save_req->connection);
1185+#endif /* EAPI */
1186+
1187 ap_bsetflag(save_req->connection->client, B_EOUT, 1);
1188 ap_bclose(save_req->connection->client);
1189
e48af075 1190@@ -1517,6 +1548,9 @@
bac1ef07 1191 ap_longjmp(jmpbuffer, 1);
1192 }
1193 else { /* abort the connection */
1194+#ifdef EAPI
1195+ ap_call_close_connection_hook(current_conn);
1196+#endif /* EAPI */
1197 ap_bsetflag(current_conn->client, B_EOUT, 1);
1198 ap_bclose(current_conn->client);
1199 current_conn->aborted = 1;
e48af075 1200@@ -1818,10 +1852,16 @@
bac1ef07 1201 /* Send any leftover data to the client, but never try to again */
1202
1203 if (ap_bflush(r->connection->client) == -1) {
1204+#ifdef EAPI
1205+ ap_call_close_connection_hook(r->connection);
1206+#endif /* EAPI */
1207 ap_kill_timeout(r);
1208 ap_bclose(r->connection->client);
1209 return;
1210 }
1211+#ifdef EAPI
1212+ ap_call_close_connection_hook(r->connection);
1213+#endif /* EAPI */
1214 ap_bsetflag(r->connection->client, B_EOUT, 1);
1215
1216 /* Close our half of the connection --- send the client a FIN */
e48af075 1217@@ -2549,6 +2589,9 @@
bac1ef07 1218 /* Clear the pool - including any registered cleanups */
1219 ap_destroy_pool(pglobal);
1220 #endif
1221+#ifdef EAPI
1222+ ap_kill_alloc_shared();
1223+#endif
1224 exit(code);
1225 }
1226
e48af075 1227@@ -3544,7 +3587,25 @@
bac1ef07 1228 conn->remote_addr = *remaddr;
1229 conn->remote_ip = ap_pstrdup(conn->pool,
1230 inet_ntoa(conn->remote_addr.sin_addr));
1231+#ifdef EAPI
1232+ conn->ctx = ap_ctx_new(conn->pool);
1233+#endif /* EAPI */
e48af075 1234
bac1ef07 1235+#ifdef EAPI
1236+ /*
1237+ * Invoke the `new_connection' hook of modules to let them do
1238+ * some connection dependent actions before we go on with
1239+ * processing the request on this connection.
1240+ */
1241+ {
1242+ module *m;
1243+ for (m = top_module; m != NULL; m = m->next)
1244+ if (m->magic == MODULE_MAGIC_COOKIE_EAPI)
1245+ if (m->new_connection != NULL)
1246+ (*m->new_connection)(conn);
1247+ }
1248+#endif /* EAPI */
e48af075 1249+
bac1ef07 1250 return conn;
1251 }
e48af075 1252
1253@@ -3972,6 +4033,15 @@
bac1ef07 1254 printf("Server's Module Magic Number: %u:%u\n",
1255 MODULE_MAGIC_NUMBER_MAJOR, MODULE_MAGIC_NUMBER_MINOR);
1256 printf("Server compiled with....\n");
1257+#ifdef EAPI
1258+ printf(" -D EAPI\n");
1259+#endif
1260+#ifdef EAPI_MM
1261+ printf(" -D EAPI_MM\n");
1262+#ifdef EAPI_MM_CORE_PATH
1263+ printf(" -D EAPI_MM_CORE_PATH=\"" EAPI_MM_CORE_PATH "\"\n");
1264+#endif
1265+#endif
c7f132e3
MK
1266 #ifdef TPF
1267 show_os_specific_compile_settings();
bac1ef07 1268 #endif
e48af075 1269@@ -4144,6 +4214,22 @@
bac1ef07 1270 ap_server_pre_read_config = ap_make_array(pcommands, 1, sizeof(char *));
1271 ap_server_post_read_config = ap_make_array(pcommands, 1, sizeof(char *));
1272 ap_server_config_defines = ap_make_array(pcommands, 1, sizeof(char *));
1273+
1274+#ifdef EAPI
1275+ ap_hook_init();
1276+ ap_hook_configure("ap::buff::read",
1277+ AP_HOOK_SIG4(int,ptr,ptr,int), AP_HOOK_TOPMOST);
1278+ ap_hook_configure("ap::buff::write",
1279+ AP_HOOK_SIG4(int,ptr,ptr,int), AP_HOOK_TOPMOST);
1280+ ap_hook_configure("ap::buff::writev",
1281+ AP_HOOK_SIG4(int,ptr,ptr,int), AP_HOOK_TOPMOST);
1282+ ap_hook_configure("ap::buff::sendwithtimeout",
1283+ AP_HOOK_SIG4(int,ptr,ptr,int), AP_HOOK_TOPMOST);
1284+ ap_hook_configure("ap::buff::recvwithtimeout",
1285+ AP_HOOK_SIG4(int,ptr,ptr,int), AP_HOOK_TOPMOST);
1286+
1287+ ap_global_ctx = ap_ctx_new(NULL);
1288+#endif /* EAPI */
1289 }
1290
1291 #ifndef MULTITHREAD
e48af075 1292@@ -4576,6 +4662,9 @@
bac1ef07 1293
1294 ap_sync_scoreboard_image();
1295 if (ap_scoreboard_image->global.running_generation != ap_my_generation) {
1296+#ifdef EAPI
1297+ ap_call_close_connection_hook(current_conn);
1298+#endif /* EAPI */
1299 ap_bclose(conn_io);
1300 clean_child_exit(0);
1301 }
e48af075 1302@@ -4604,6 +4693,9 @@
bac1ef07 1303 */
1304
1305 #ifdef NO_LINGCLOSE
1306+#ifdef EAPI
1307+ ap_call_close_connection_hook(current_conn);
1308+#endif /* EAPI */
1309 ap_bclose(conn_io); /* just close it */
1310 #else
1311 if (r && r->connection
e48af075 1312@@ -4614,6 +4706,9 @@
bac1ef07 1313 lingering_close(r);
1314 }
1315 else {
1316+#ifdef EAPI
1317+ ap_call_close_connection_hook(current_conn);
1318+#endif /* EAPI */
1319 ap_bsetflag(conn_io, B_EOUT, 1);
1320 ap_bclose(conn_io);
1321 }
e48af075 1322@@ -5373,16 +5468,31 @@
bac1ef07 1323 usage(argv[0]);
1324 }
1325 }
1326+#ifdef EAPI
1327+ ap_init_alloc_shared(TRUE);
1328+#endif
1329
1330 ap_suexec_enabled = init_suexec();
1331 server_conf = ap_read_config(pconf, ptrans, ap_server_confname);
1332
1333+#ifdef EAPI
1334+ ap_init_alloc_shared(FALSE);
1335+#endif
1336+
1337 if (ap_configtestonly) {
1338 fprintf(stderr, "Syntax OK\n");
1339+#ifdef EAPI
1340+ clean_parent_exit(0);
1341+#else
1342 exit(0);
1343+#endif
1344 }
1345 if (ap_dump_settings) {
1346+#ifdef EAPI
1347+ clean_parent_exit(0);
1348+#else
1349 exit(0);
1350+#endif
1351 }
1352
1353 child_timeouts = !ap_standalone || one_process;
e48af075 1354@@ -5513,6 +5623,10 @@
bac1ef07 1355 ap_destroy_pool(r->pool);
1356 }
1357
1358+#ifdef EAPI
1359+ ap_call_close_connection_hook(conn);
1360+#endif /* EAPI */
1361+
1362 ap_bclose(cio);
1363 }
1364 exit(0);
e48af075 1365@@ -5889,6 +6003,9 @@
bac1ef07 1366 ap_kill_cleanups_for_socket(ptrans, csd);
1367
1368 #ifdef NO_LINGCLOSE
1369+#ifdef EAPI
1370+ ap_call_close_connection_hook(current_conn);
1371+#endif /* EAPI */
1372 ap_bclose(conn_io); /* just close it */
1373 #else
1374 if (r && r->connection
e48af075 1375@@ -5899,6 +6016,9 @@
bac1ef07 1376 lingering_close(r);
1377 }
1378 else {
1379+#ifdef EAPI
1380+ ap_call_close_connection_hook(current_conn);
1381+#endif /* EAPI */
1382 ap_bsetflag(conn_io, B_EOUT, 1);
1383 ap_bclose(conn_io);
1384 }
e48af075 1385@@ -7444,6 +7564,10 @@
66314f26 1386 if (!conf_specified)
1387 ap_cpystrn(ap_server_confname, SERVER_CONFIG_FILE, sizeof(ap_server_confname));
1388
bac1ef07 1389+#ifdef EAPI
1390+ ap_init_alloc_shared(TRUE);
1391+#endif
66314f26 1392+
1393 if (!ap_os_is_path_absolute(ap_server_confname))
1394 ap_cpystrn(ap_server_confname,
1395 ap_server_root_relative(pcommands, ap_server_confname),
e48af075 1396@@ -7483,6 +7607,9 @@
bac1ef07 1397 }
1398 #else /* ndef WIN32 */
1399 server_conf = ap_read_config(pconf, ptrans, ap_server_confname);
1400+#endif
1401+#ifdef EAPI
1402+ ap_init_alloc_shared(FALSE);
1403 #endif
1404
1405 if (ap_configtestonly) {
1406
1407+---------------------------------------------------------------------------
1408| Just add the initialization of the `ctx' variable for
1409| conn_rec structures.
1410+---------------------------------------------------------------------------
1411Index: src/main/http_request.c
e48af075 1412--- src/main/http_request.c 2002/01/28 19:21:25 1.1.1.13
1413+++ src/main/http_request.c 2002/01/28 19:40:57 1.13
1414@@ -1375,6 +1375,10 @@
7efaaee3 1415
1416 new->method = r->method;
1417 new->method_number = r->method_number;
bac1ef07 1418+#ifdef EAPI
7efaaee3 1419+ /* initialize context _BEFORE_ ap_parse_uri() call */
bac1ef07 1420+ new->ctx = r->ctx;
1421+#endif /* EAPI */
7efaaee3 1422 ap_parse_uri(new, new_uri);
1423 new->request_config = ap_create_request_config(r->pool);
1424 new->per_dir_config = r->server->lookup_defaults;
bac1ef07 1425
1426+---------------------------------------------------------------------------
1427| Just add the initialization of the `ctx' variable for
1428| request_rec structures.
1429+---------------------------------------------------------------------------
1430Index: src/main/http_protocol.c
e48af075 1431--- src/main/http_protocol.c 2002/01/28 19:21:25 1.1.1.15
1432+++ src/main/http_protocol.c 2002/01/28 19:40:57 1.15
1433@@ -1151,6 +1151,10 @@
bac1ef07 1434 r->status = HTTP_REQUEST_TIME_OUT; /* Until we get a request */
1435 r->the_request = NULL;
1436
1437+#ifdef EAPI
1438+ r->ctx = ap_ctx_new(r->pool);
1439+#endif /* EAPI */
1440+
1441 #ifdef CHARSET_EBCDIC
7efaaee3 1442 ap_bsetflag(r->connection->client, B_ASCII2EBCDIC, r->ebcdic.conv_in = 1);
1443 ap_bsetflag(r->connection->client, B_EBCDIC2ASCII, r->ebcdic.conv_out = 1);
e48af075 1444@@ -1299,6 +1303,11 @@
bac1ef07 1445 rnew->read_body = REQUEST_NO_BODY;
1446
1447 rnew->main = (request_rec *) r;
1448+
1449+#ifdef EAPI
1450+ rnew->ctx = r->ctx;
1451+#endif /* EAPI */
1452+
1453 }
1454
e48af075 1455 API_EXPORT(void) ap_finalize_sub_req_protocol(request_rec *sub)
bac1ef07 1456
1457+---------------------------------------------------------------------------
1458| Add support for loading both EAPI and AP13 modules.
1459+---------------------------------------------------------------------------
1460Index: src/modules/standard/mod_so.c
e48af075 1461--- src/modules/standard/mod_so.c 2002/01/28 19:21:28 1.1.1.8
1462+++ src/modules/standard/mod_so.c 2002/01/28 19:40:57 1.9
1463@@ -269,11 +269,24 @@
bac1ef07 1464 * Make sure the found module structure is really a module structure
1465 *
1466 */
1467+#ifdef EAPI
1468+ if ( modp->magic != MODULE_MAGIC_COOKIE_AP13
1469+ && modp->magic != MODULE_MAGIC_COOKIE_EAPI) {
1470+#else
1471 if (modp->magic != MODULE_MAGIC_COOKIE) {
1472+#endif
1473 return ap_pstrcat(cmd->pool, "API module structure `", modname,
1474 "' in file ", szModuleFile, " is garbled -"
1475 " perhaps this is not an Apache module DSO?", NULL);
1476 }
1477+#ifdef EAPI
1478+ if (modp->magic == MODULE_MAGIC_COOKIE_AP13) {
1479+ ap_log_error(APLOG_MARK, APLOG_WARNING|APLOG_NOERRNO, NULL,
1480+ "Loaded DSO %s uses plain Apache 1.3 API, "
1481+ "this module might crash under EAPI! "
1482+ "(please recompile it with -DEAPI)", filename);
1483+ }
1484+#endif
1485
1486 /*
1487 * Add this module to the Apache core structures
1488
1489+---------------------------------------------------------------------------
1490| Add additional logging functions to the CustomLog directive
1491| which can be used by other modules to create additional
1492| logfile tags. Actually we add two types of hooks: One hook
1493| for intercepting the new and generic %x (eXtension) tag and
1494| one hook for creating new %x tags at all.
1495+---------------------------------------------------------------------------
1496Index: src/modules/standard/mod_log_config.c
1497--- src/modules/standard/mod_log_config.c 2001/01/23 11:35:12 1.1.1.11
1498+++ src/modules/standard/mod_log_config.c 2001/01/23 11:48:08 1.24
1499@@ -262,6 +262,9 @@
1500 typedef const char *(*item_key_func) (request_rec *, char *);
1501
1502 typedef struct {
1503+#ifdef EAPI
1504+ char ch;
1505+#endif
1506 item_key_func func;
1507 char *arg;
1508 int condition_sense;
1509@@ -573,15 +576,36 @@
1510 }
1511 };
1512
1513+#ifdef EAPI
1514+static struct log_item_list *find_log_func(pool *p, char k)
1515+#else /* EAPI */
1516 static struct log_item_list *find_log_func(char k)
1517+#endif /* EAPI */
1518 {
1519 int i;
1520+#ifdef EAPI
1521+ struct log_item_list *lil;
1522+#endif /* EAPI */
1523
1524 for (i = 0; log_item_keys[i].ch; ++i)
1525 if (k == log_item_keys[i].ch) {
1526 return &log_item_keys[i];
1527 }
1528
1529+#ifdef EAPI
1530+ if (ap_hook_status(ap_psprintf(p, "ap::mod_log_config::log_%c", k))
1531+ != AP_HOOK_STATE_NOTEXISTANT) {
1532+ lil = (struct log_item_list *)
1533+ ap_pcalloc(p, sizeof(struct log_item_list));
1534+ if (lil == NULL)
1535+ return NULL;
1536+ lil->ch = k;
1537+ lil->func = NULL;
1538+ lil->want_orig_default = 0;
1539+ return lil;
1540+ }
1541+#endif /* EAPI */
1542+
1543 return NULL;
1544 }
1545
1546@@ -707,7 +731,11 @@
1547 break;
1548
1549 default:
1550+#ifdef EAPI
1551+ l = find_log_func(p, *s++);
1552+#else /* EAPI */
1553 l = find_log_func(*s++);
1554+#endif /* EAPI */
1555 if (!l) {
1556 char dummy[2];
1557
1558@@ -716,6 +744,9 @@
1559 return ap_pstrcat(p, "Unrecognized LogFormat directive %",
1560 dummy, NULL);
1561 }
1562+#ifdef EAPI
1563+ it->ch = s[-1];
1564+#endif
1565 it->func = l->func;
1566 if (it->want_orig == -1) {
1567 it->want_orig = l->want_orig_default;
1568@@ -777,6 +808,15 @@
1569
1570 /* We do. Do it... */
1571
1572+#ifdef EAPI
1573+ if (item->func == NULL) {
1574+ cp = NULL;
1575+ ap_hook_use(ap_psprintf(r->pool, "ap::mod_log_config::log_%c", item->ch),
1576+ AP_HOOK_SIG3(ptr,ptr,ptr), AP_HOOK_DECLINE(NULL),
1577+ &cp, r, item->arg);
1578+ }
1579+ else
1580+#endif
1581 cp = (*item->func) (item->want_orig ? orig : r, item->arg);
1582 return cp ? cp : "-";
1583 }
1584
1585+---------------------------------------------------------------------------
1586| Allow RewriteCond and RewriteRule directives to lookup
1587| variables from other modules.
1588+---------------------------------------------------------------------------
1589Index: src/modules/standard/mod_rewrite.c
e48af075 1590--- src/modules/standard/mod_rewrite.c 2002/01/28 19:21:27 1.1.1.13
1591+++ src/modules/standard/mod_rewrite.c 2002/01/28 19:40:57 1.11
7efaaee3 1592@@ -3678,6 +3678,15 @@
bac1ef07 1593 }
1594 #endif /* ndef WIN32 && NETWARE*/
1595
1596+#ifdef EAPI
1597+ else {
1598+ ap_hook_use("ap::mod_rewrite::lookup_variable",
1599+ AP_HOOK_SIG3(ptr,ptr,ptr),
1600+ AP_HOOK_DECLINE(NULL),
1601+ &result, r, var);
1602+ }
1603+#endif
1604+
1605 if (result == NULL) {
1606 return ap_pstrdup(r->pool, "");
1607 }
1608
1609+---------------------------------------------------------------------------
1610| Add an EAPI hook to allow other modules to add content to
1611| the status HTML page.
1612+---------------------------------------------------------------------------
1613Index: src/modules/standard/mod_status.c
e48af075 1614--- src/modules/standard/mod_status.c 2002/01/28 19:21:28 1.1.1.13
1615+++ src/modules/standard/mod_status.c 2002/01/28 19:40:57 1.10
1616@@ -717,6 +754,12 @@
bac1ef07 1617 </table>\n", r);
1618 #endif
1619 }
1620+
1621+#ifdef EAPI
1622+ ap_hook_use("ap::mod_status::display",
1623+ AP_HOOK_SIG4(void,ptr,int,int), AP_HOOK_ALL,
1624+ r, no_table_report, short_report);
1625+#endif
1626
1627 } else {
1628
1629
1630+---------------------------------------------------------------------------
1631| Add hooks to the scheme processing to allow other modules to
1632| recognize more schemes by intercepting this processing.
1633+---------------------------------------------------------------------------
1634Index: src/modules/proxy/mod_proxy.c
e48af075 1635--- src/modules/proxy/mod_proxy.c 2002/01/28 19:21:26 1.1.1.10
1636+++ src/modules/proxy/mod_proxy.c 2002/01/28 19:40:57 1.17
bac1ef07 1637@@ -215,6 +215,9 @@
1638 static int proxy_fixup(request_rec *r)
1639 {
1640 char *url, *p;
1641+#ifdef EAPI
1642+ int rc;
1643+#endif /* EAPI */
1644
1645 if (r->proxyreq == NOT_PROXY || strncmp(r->filename, "proxy:", 6) != 0)
e48af075 1646 return DECLINED;
bac1ef07 1647@@ -222,6 +225,14 @@
1648 url = &r->filename[6];
1649
1650 /* canonicalise each specific scheme */
1651+#ifdef EAPI
1652+ if (ap_hook_use("ap::mod_proxy::canon",
1653+ AP_HOOK_SIG3(int,ptr,ptr),
1654+ AP_HOOK_DECLINE(DECLINED),
1655+ &rc, r, url) && rc != DECLINED)
1656+ return rc;
1657+ else
1658+#endif /* EAPI */
1659 if (strncasecmp(url, "http:", 5) == 0)
e48af075 1660 return ap_proxy_http_canon(r, url + 5, "http", DEFAULT_HTTP_PORT);
bac1ef07 1661 else if (strncasecmp(url, "ftp:", 4) == 0)
1662@@ -237,9 +248,44 @@
1663 static void proxy_init(server_rec *r, pool *p)
1664 {
1665 ap_proxy_garbage_init(r, p);
1666+#ifdef EAPI
1667+ ap_hook_use("ap::mod_proxy::init",
1668+ AP_HOOK_SIG3(void,ptr,ptr), AP_HOOK_ALL, r, p);
1669+#endif
1670 }
bac1ef07 1671
e48af075 1672-
bac1ef07 1673+#ifdef EAPI
1674+static void proxy_addmod(module *m)
1675+{
1676+ /* export: ap_proxy_http_canon() as `ap::mod_proxy::http::canon' */
1677+ ap_hook_configure("ap::mod_proxy::http::canon",
1678+ AP_HOOK_SIG5(int,ptr,ptr,ptr,int), AP_HOOK_TOPMOST);
1679+ ap_hook_register("ap::mod_proxy::http::canon",
1680+ ap_proxy_http_canon, AP_HOOK_NOCTX);
1681+
1682+ /* export: ap_proxy_http_handler() as `ap::mod_proxy::http::handler' */
1683+ ap_hook_configure("ap::mod_proxy::http::handler",
1684+ AP_HOOK_SIG6(int,ptr,ptr,ptr,ptr,int), AP_HOOK_TOPMOST);
1685+ ap_hook_register("ap::mod_proxy::http::handler",
1686+ ap_proxy_http_handler, AP_HOOK_NOCTX);
1687+
1688+ /* export: ap_proxyerror() as `ap::mod_proxy::error' */
1689+ ap_hook_configure("ap::mod_proxy::error",
1690+ AP_HOOK_SIG3(int,ptr,ptr), AP_HOOK_TOPMOST);
1691+ ap_hook_register("ap::mod_proxy::error",
1692+ ap_proxyerror, AP_HOOK_NOCTX);
1693+ return;
1694+}
1695+
1696+static void proxy_remmod(module *m)
1697+{
1698+ /* remove the hook references */
1699+ ap_hook_unregister("ap::mod_proxy::http::canon", ap_proxy_http_canon);
1700+ ap_hook_unregister("ap::mod_proxy::http::handler", ap_proxy_http_handler);
1701+ ap_hook_unregister("ap::mod_proxy::error", ap_proxyerror);
1702+ return;
1703+}
1704+#endif /* EAPI */
1705
1706 /* Send a redirection if the request contains a hostname which is not */
1707 /* fully qualified, i.e. doesn't have a domain name appended. Some proxy */
e48af075 1708@@ -370,6 +416,14 @@
1709 /* CONNECT is a special method that bypasses the normal
1710 * proxy code.
1711 */
bac1ef07 1712+#ifdef EAPI
1713+ if (!ap_hook_use("ap::mod_proxy::handler",
1714+ AP_HOOK_SIG7(int,ptr,ptr,ptr,ptr,int,ptr),
1715+ AP_HOOK_DECLINE(DECLINED),
1716+ &rc, r, cr, url,
1717+ ents[i].hostname, ents[i].port,
1718+ ents[i].protocol) || rc == DECLINED) {
1719+#endif /* EAPI */
e48af075 1720 if (r->method_number == M_CONNECT)
1721 rc = ap_proxy_connect_handler(r, cr, url, ents[i].hostname,
1722 ents[i].port);
1723@@ -379,6 +433,9 @@
1724 ents[i].port);
1725 else
1726 rc = DECLINED;
bac1ef07 1727+#ifdef EAPI
1728+ }
1729+#endif /* EAPI */
1730
e48af075 1731 /* an error or success */
1732 if (rc != DECLINED && rc != HTTP_BAD_GATEWAY)
1733@@ -392,6 +449,14 @@
bac1ef07 1734 * give up??
1735 */
1736 /* handle the scheme */
1737+#ifdef EAPI
1738+ if (ap_hook_use("ap::mod_proxy::handler",
1739+ AP_HOOK_SIG7(int,ptr,ptr,ptr,ptr,int,ptr),
1740+ AP_HOOK_DECLINE(DECLINED),
1741+ &rc, r, cr, url,
1742+ NULL, 0, scheme) && rc != DECLINED)
1743+ return rc;
1744+#endif /* EAPI */
1745 if (r->method_number == M_CONNECT)
e48af075 1746 return ap_proxy_connect_handler(r, cr, url, NULL, 0);
bac1ef07 1747 if (strcasecmp(scheme, "http") == 0)
e48af075 1748@@ -956,6 +1021,12 @@
1749 NULL, /* child_init */
1750 NULL, /* child_exit */
1751 proxy_detect /* post read-request */
bac1ef07 1752+#ifdef EAPI
1753+ ,proxy_addmod, /* EAPI: add_module */
1754+ proxy_remmod, /* EAPI: remove_module */
1755+ NULL, /* EAPI: rewrite_command */
1756+ NULL /* EAPI: new_connection */
1757+#endif
1758 };
1759
1760
1761
1762+---------------------------------------------------------------------------
1763| Add hooks to the HTTP processing to allow other modules
1764| to enhance it by intercepting this processing.
1765+---------------------------------------------------------------------------
1766Index: src/modules/proxy/proxy_http.c
e48af075 1767--- src/modules/proxy/proxy_http.c 2002/01/28 19:21:26 1.1.1.12
1768+++ src/modules/proxy/proxy_http.c 2002/01/28 19:40:57 1.20
1769@@ -166,6 +166,9 @@
1770 char *destportstr = NULL;
bac1ef07 1771 const char *urlptr = NULL;
e48af075 1772 const char *datestr, *urlstr;
bac1ef07 1773+#ifdef EAPI
1774+ char *peer;
1775+#endif
1776
1777 void *sconf = r->server->module_config;
1778 proxy_server_conf *conf =
e48af075 1779@@ -186,6 +189,12 @@
1780 return HTTP_BAD_REQUEST;
bac1ef07 1781 urlptr += 3;
1782 destport = DEFAULT_HTTP_PORT;
1783+#ifdef EAPI
1784+ ap_hook_use("ap::mod_proxy::http::handler::set_destport",
1785+ AP_HOOK_SIG2(int,ptr),
1786+ AP_HOOK_TOPMOST,
1787+ &destport, r);
1788+#endif /* EAPI */
1789 strp = strchr(urlptr, '/');
1790 if (strp == NULL) {
e48af075 1791 desthost = ap_pstrdup(p, urlptr);
1792@@ -223,12 +232,18 @@
1793 err = ap_proxy_host2addr(proxyhost, &server_hp);
1794 if (err != NULL)
1795 return DECLINED; /* try another */
bac1ef07 1796+#ifdef EAPI
1797+ peer = ap_psprintf(p, "%s:%u", proxyhost, proxyport);
1798+#endif
1799 }
1800 else {
e48af075 1801 server.sin_port = htons((unsigned short)destport);
1802 err = ap_proxy_host2addr(desthost, &server_hp);
1803 if (err != NULL)
1804 return ap_proxyerror(r, HTTP_INTERNAL_SERVER_ERROR, err);
bac1ef07 1805+#ifdef EAPI
1806+ peer = ap_psprintf(p, "%s:%u", desthost, destport);
1807+#endif
1808 }
1809
e48af075 1810
1811@@ -301,14 +316,42 @@
bac1ef07 1812 f = ap_bcreate(p, B_RDWR | B_SOCKET);
1813 ap_bpushfd(f, sock, sock);
1814
1815+#ifdef EAPI
1816+ {
1817+ char *errmsg = NULL;
1818+ ap_hook_use("ap::mod_proxy::http::handler::new_connection",
1819+ AP_HOOK_SIG4(ptr,ptr,ptr,ptr),
1820+ AP_HOOK_DECLINE(NULL),
1821+ &errmsg, r, f, peer);
1822+ if (errmsg != NULL)
1823+ return ap_proxyerror(r, HTTP_BAD_GATEWAY, errmsg);
1824+ }
1825+#endif /* EAPI */
1826+
1827 ap_hard_timeout("proxy send", r);
1828 ap_bvputs(f, r->method, " ", proxyhost ? url : urlptr, " HTTP/1.0" CRLF,
e48af075 1829 NULL);
bac1ef07 1830+#ifdef EAPI
1831+ {
1832+ int rc = DECLINED;
1833+ ap_hook_use("ap::mod_proxy::http::handler::write_host_header",
1834+ AP_HOOK_SIG6(int,ptr,ptr,ptr,int,ptr),
1835+ AP_HOOK_DECLINE(DECLINED),
1836+ &rc, r, f, desthost, destport, destportstr);
1837+ if (rc == DECLINED) {
1838+ if (destportstr != NULL && destport != DEFAULT_HTTP_PORT)
1839+ ap_bvputs(f, "Host: ", desthost, ":", destportstr, CRLF, NULL);
1840+ else
1841+ ap_bvputs(f, "Host: ", desthost, CRLF, NULL);
1842+ }
1843+ }
1844+#else /* EAPI */
e48af075 1845 /* Send Host: now, adding it to req_hdrs wouldn't be much better */
bac1ef07 1846 if (destportstr != NULL && destport != DEFAULT_HTTP_PORT)
e48af075 1847 ap_bvputs(f, "Host: ", desthost, ":", destportstr, CRLF, NULL);
bac1ef07 1848 else
e48af075 1849 ap_bvputs(f, "Host: ", desthost, CRLF, NULL);
bac1ef07 1850+#endif /* EAPI */
1851
1852 if (conf->viaopt == via_block) {
e48af075 1853 /* Block all outgoing Via: headers */
bac1ef07 1854
1855+---------------------------------------------------------------------------
1856| Add EAPI hooks in module structure for APXS generated samples.
1857+---------------------------------------------------------------------------
1858Index: src/support/apxs.pl
7efaaee3 1859--- src/support/apxs.pl 2001/05/20 08:16:25 1.1.1.10
1860+++ src/support/apxs.pl 2001/05/20 08:23:03 1.10
1861@@ -703,5 +703,11 @@
bac1ef07 1862 NULL, /* child_init */
1863 NULL, /* child_exit */
1864 NULL /* [#0] post read-request */
1865+#ifdef EAPI
1866+ ,NULL, /* EAPI: add_module */
1867+ NULL, /* EAPI: remove_module */
1868+ NULL, /* EAPI: rewrite_command */
1869+ NULL /* EAPI: new_connection */
1870+#endif
1871 };
1872
1873
1874+---------------------------------------------------------------------------
1875| Add the EAPI functions, so the stuff can be built under AIX
1876| and similar braindead platforms as DSO.
1877+---------------------------------------------------------------------------
1878Index: src/support/httpd.exp
66314f26 1879--- src/support/httpd.exp 2001/02/28 19:40:56 1.1.1.9
1880+++ src/support/httpd.exp 2001/02/28 19:44:35 1.11
1881@@ -422,3 +422,59 @@
bac1ef07 1882 XML_SetUnparsedEntityDeclHandler
1883 XML_SetUserData
1884 XML_UseParserAsHandlerArg
1885+ap_add_config_define
1886+ap_make_shared_sub_pool
1887+ap_global_ctx
1888+ap_ctx_new
1889+ap_ctx_get
1890+ap_ctx_set
1891+ap_hook_init
1892+ap_hook_kill
1893+ap_hook_configure
1894+ap_hook_register_I
1895+ap_hook_unregister_I
1896+ap_hook_status
1897+ap_hook_use
1898+ap_hook_call
1899+ap_mm_useable
1900+ap_MM_create
1901+ap_MM_permission
1902+ap_MM_destroy
1903+ap_MM_lock
1904+ap_MM_unlock
1905+ap_MM_malloc
1906+ap_MM_realloc
1907+ap_MM_free
1908+ap_MM_calloc
1909+ap_MM_strdup
1910+ap_MM_sizeof
1911+ap_MM_maxsize
1912+ap_MM_available
1913+ap_MM_error
1914+ap_mm_create
1915+ap_mm_permission
1916+ap_mm_destroy
1917+ap_mm_lock
1918+ap_mm_unlock
1919+ap_mm_malloc
1920+ap_mm_realloc
1921+ap_mm_free
1922+ap_mm_calloc
1923+ap_mm_strdup
1924+ap_mm_sizeof
1925+ap_mm_maxsize
1926+ap_mm_available
1927+ap_mm_error
1928+ap_mm_display_info
1929+ap_mm_core_create
1930+ap_mm_core_permission
1931+ap_mm_core_delete
1932+ap_mm_core_size
1933+ap_mm_core_lock
1934+ap_mm_core_unlock
1935+ap_mm_core_maxsegsize
1936+ap_mm_core_align2page
1937+ap_mm_core_align2word
1938+ap_mm_lib_error_set
1939+ap_mm_lib_error_get
1940+ap_mm_lib_version
1941
1942+---------------------------------------------------------------------------
1943| Add the EAPI functions, so the stuff can be built under
1944| Windows 95 and similar braindead platforms as DDL.
1945+---------------------------------------------------------------------------
1946Index: src/ApacheCore.def
e48af075 1947--- src/ApacheCore.def 2002/01/28 19:21:21 1.1.1.8
1948+++ src/ApacheCore.def 2002/01/28 19:40:56 1.12
1949@@ -442,3 +442,67 @@
1950 ap_update_child_status @434
1951 ap_sendwithtimeout @435
1952 ap_recvwithtimeout @436
bac1ef07 1953+
1954+ ; EAPI extended symbols
1955+ ; note; no ID's, so these all bind by name rather than ordinal since
1956+ ; their ordinals would change with symbol changes in the distribution
1957+ ap_add_config_define
1958+ ap_global_ctx DATA
1959+ ap_ctx_new
1960+ ap_ctx_get
1961+ ap_ctx_overlay
1962+ ap_ctx_set
1963+ ap_hook_init
1964+ ap_hook_kill
1965+ ap_hook_configure
1966+ ap_hook_register_I
1967+ ap_hook_unregister_I
1968+ ap_hook_status
1969+ ap_hook_use
1970+ ap_hook_call
1971+ ap_set_callback_and_alarm
66314f26 1972+ ap_acquire_pool
bac1ef07 1973+ ap_make_shared_sub_pool
1974+ ap_release_pool
1975+ ap_mm_useable
1976+ ap_MM_create
1977+ ap_MM_permission
1978+ ap_MM_destroy
1979+ ap_MM_lock
1980+ ap_MM_unlock
1981+ ap_MM_malloc
1982+ ap_MM_realloc
1983+ ap_MM_free
1984+ ap_MM_calloc
1985+ ap_MM_strdup
1986+ ap_MM_sizeof
1987+ ap_MM_maxsize
1988+ ap_MM_available
1989+ ap_MM_error
1990+ ap_mm_create
1991+ ap_mm_permission
1992+ ap_mm_destroy
1993+ ap_mm_lock
1994+ ap_mm_unlock
1995+ ap_mm_malloc
1996+ ap_mm_realloc
1997+ ap_mm_free
1998+ ap_mm_calloc
1999+ ap_mm_strdup
2000+ ap_mm_sizeof
2001+ ap_mm_maxsize
2002+ ap_mm_available
2003+ ap_mm_error
2004+ ap_mm_display_info
2005+ ap_mm_core_create
2006+ ap_mm_core_permission
2007+ ap_mm_core_delete
2008+ ap_mm_core_size
2009+ ap_mm_core_lock
2010+ ap_mm_core_unlock
2011+ ap_mm_core_align2page
2012+ ap_mm_core_align2word
2013+ ap_mm_lib_error_set
2014+ ap_mm_lib_error_get
2015+ ap_mm_lib_version
2016+
This page took 0.355137 seconds and 4 git commands to generate.