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