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