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