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