ben 99/07/05 06:00:47
Modified: mpm/src CHANGES
mpm/src/include http_config.h http_connection.h
mpm/src/main http_config.c http_connection.c http_main.c
Added: mpm/src/include ap_hooks.h
Log:
Strawman hooks implementation (beginning of).
Revision Changes Path
1.12 +7 -0 apache-2.0/mpm/src/CHANGES
Index: CHANGES
===================================================================
RCS file: /export/home/cvs/apache-2.0/mpm/src/CHANGES,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- CHANGES 1999/06/24 01:57:43 1.11
+++ CHANGES 1999/07/05 13:00:39 1.12
@@ -1,5 +1,12 @@
Changes with MPM
+ * Start to implement module-defined hooks that are a) fast and b)
typesafe.
+ Replace pre_connection module call with a register_hook call and
+ implement pre_connection as a hook. The intent is that these hooks will
+ be extended to allow Apache to be multi-protocol, and also to allow the
+ calling order to be specified on a per-hook/per-module basis.
+ [Ben Laurie]
+
* Implement mpm_* methods as "modules". Each method gets it's own
subdir in src/modules (eg: src/modules/prefork). Selection
of method uses Rule MPM_METHOD. [Jim Jagielski]
1.4 +1 -1 apache-2.0/mpm/src/include/http_config.h
Index: http_config.h
===================================================================
RCS file: /export/home/cvs/apache-2.0/mpm/src/include/http_config.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- http_config.h 1999/06/29 09:00:08 1.3
+++ http_config.h 1999/07/05 13:00:42 1.4
@@ -249,7 +249,7 @@
int (*logger) (request_rec *);
int (*header_parser) (request_rec *);
int (*post_read_request) (request_rec *);
- int (*pre_connection) (conn_rec *);
+ void (*register_hooks) (void);
} module;
/* Initializer for the first few module slots, which are only
1.4 +5 -0 apache-2.0/mpm/src/include/http_connection.h
Index: http_connection.h
===================================================================
RCS file: /export/home/cvs/apache-2.0/mpm/src/include/http_connection.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- http_connection.h 1999/07/02 18:22:24 1.3
+++ http_connection.h 1999/07/05 13:00:42 1.4
@@ -58,6 +58,8 @@
#ifndef APACHE_HTTP_CONNECTION_H
#define APACHE_HTTP_CONNECTION_H
+#include "ap_hooks.h"
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -67,6 +69,9 @@
const struct sockaddr_in *saddr,
int child_num, int thread_num);
CORE_EXPORT(void) ap_process_connection(conn_rec *);
+
+ /* Hooks */
+DECLARE_HOOK(void,pre_connection,(conn_rec *))
#ifdef __cplusplus
}
1.1 apache-2.0/mpm/src/include/ap_hooks.h
Index: ap_hooks.h
===================================================================
#define DECLARE_HOOK(ret,name,args) \
typedef ret HOOK_##name args; \
void hook_##name(HOOK_##name *pf); \
typedef struct _LINK_##name \
{ \
HOOK_##name *pFunc; \
struct _LINK_##name *pNext; \
} LINK_##name;
#define HOOK_STRUCT(members) \
static struct { members } _hooks;
#define HOOK_LINK(name) \
LINK_##name *link_##name;
#define
IMPLEMENT_HOOK_BASE(ret,rv_decl,sv,rv,name,args,args2,run_all,terminate) \
void hook_##name(HOOK_##name *pf) \
{ \
LINK_##name *pHook=ap_palloc(g_pHookPool,sizeof(LINK_##name)); \
pHook->pNext=_hooks.link_##name; \
pHook->pFunc=pf; \
_hooks.link_##name=pHook; \
} \
ret run_##name args \
{ \
LINK_##name *pHook; \
rv_decl \
\
for(pHook=_hooks.link_##name ; pHook ; pHook=pHook->pNext) \
{ \
sv pHook->pFunc args2; \
\
if(!run_all terminate) \
return rv; \
} \
return rv; \
}
#define IMPLEMENT_HOOK(ret,name,args,args2,run_all,finish) \
IMPLEMENT_HOOK_BASE(ret,ret r;,r=,r,name,args,args2,run_all,&& r ==
finish)
#define IMPLEMENT_VOID_HOOK(name,args,args2,run_all) \
IMPLEMENT_HOOK_BASE(void,,,,name,args,args2,run_all,)
extern pool *g_pHookPool;
1.5 +5 -9 apache-2.0/mpm/src/main/http_config.c
Index: http_config.c
===================================================================
RCS file: /export/home/cvs/apache-2.0/mpm/src/main/http_config.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- http_config.c 1999/06/29 09:00:16 1.4
+++ http_config.c 1999/07/05 13:00:44 1.5
@@ -281,8 +281,7 @@
XtOffsetOf(module, fixer_upper),
XtOffsetOf(module, logger),
XtOffsetOf(module, header_parser),
- XtOffsetOf(module, post_read_request),
- XtOffsetOf(module, pre_connection)
+ XtOffsetOf(module, post_read_request)
};
#define NMETHODS (sizeof (method_offsets)/sizeof (method_offsets[0]))
@@ -296,7 +295,6 @@
int logger;
int header_parser;
int post_read_request;
- int pre_connection;
} offsets_into_method_ptrs;
/*
@@ -409,12 +407,6 @@
return run_method(r, offsets_into_method_ptrs.post_read_request, 1);
}
-int ap_run_pre_connection(conn_rec *c)
-{
-/* FIXME: either make run_method take a void * or do something nicer */
- return run_method((request_rec *)c,
offsets_into_method_ptrs.pre_connection, 1);
-}
-
/* Auth stuff --- anything that defines one of these will presumably
* want to define something for the other. Note that check_auth is
* separate from check_access to make catching some config errors easier.
@@ -596,6 +588,10 @@
m->name = tmp;
}
#endif /*_OSD_POSIX*/
+
+ /* FIXME: is this the right place to call this? */
+ if(m->register_hooks)
+ m->register_hooks();
}
/*
1.7 +7 -1 apache-2.0/mpm/src/main/http_connection.c
Index: http_connection.c
===================================================================
RCS file: /export/home/cvs/apache-2.0/mpm/src/main/http_connection.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- http_connection.c 1999/07/02 18:22:25 1.6
+++ http_connection.c 1999/07/05 13:00:45 1.7
@@ -64,6 +64,12 @@
#include "http_config.h"
#include "http_vhost.h"
+HOOK_STRUCT(
+ HOOK_LINK(pre_connection)
+);
+
+IMPLEMENT_VOID_HOOK(pre_connection,(conn_rec *c),(c),1)
+
/* TODO: re-implement the lingering close stuff */
#define NO_LINGCLOSE
@@ -188,7 +194,7 @@
ap_update_vhost_given_ip(c);
- ap_run_pre_connection(c);
+ run_pre_connection(c);
/*
* Read and process each request found on our connection
1.3 +5 -1 apache-2.0/mpm/src/main/http_main.c
Index: http_main.c
===================================================================
RCS file: /export/home/cvs/apache-2.0/mpm/src/main/http_main.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- http_main.c 1999/06/24 17:48:26 1.2
+++ http_main.c 1999/07/05 13:00:45 1.3
@@ -231,6 +231,8 @@
exit(1);
}
+pool *g_pHookPool;
+
int main(int argc, char **argv)
{
int c;
@@ -258,9 +260,11 @@
ap_util_init();
ap_util_uri_init();
- ap_setup_prelinked_modules();
pglobal = ap_init_alloc();
+ g_pHookPool=pglobal;
+
+ ap_setup_prelinked_modules();
pcommands = ap_make_sub_pool(pglobal);
ap_server_pre_read_config = ap_make_array(pcommands, 1, sizeof(char *));