You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by be...@hyperreal.org on 1999/07/10 15:32:48 UTC
cvs commit: apache-2.0/mpm/src/main http_config.c http_main.c
ben 99/07/10 06:32:48
Modified: mpm/src/include ap_hooks.h
mpm/src/main http_config.c http_main.c
Log:
Rudimentary debugging for hooks.
Revision Changes Path
1.3 +4 -0 apache-2.0/mpm/src/include/ap_hooks.h
Index: ap_hooks.h
===================================================================
RCS file: /export/home/cvs/apache-2.0/mpm/src/include/ap_hooks.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ap_hooks.h 1999/07/06 21:32:08 1.2
+++ ap_hooks.h 1999/07/10 13:32:46 1.3
@@ -1,6 +1,8 @@
#ifndef APACHE_AP_HOOKS_H
#define APACHE_AP_HOOKS_H
+extern int g_bDebugHooks;
+
#define DECLARE_HOOK(ret,name,args) \
typedef ret HOOK_##name args; \
void ap_hook_##name(HOOK_##name *pf); \
@@ -24,6 +26,8 @@
pHook->pNext=_hooks.link_##name; \
pHook->pFunc=pf; \
_hooks.link_##name=pHook; \
+ if(g_bDebugHooks) \
+ puts(" Hooked " #name); \
} \
ret ap_run_##name args \
{ \
1.7 +16 -2 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.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- http_config.c 1999/07/06 21:32:10 1.6
+++ http_config.c 1999/07/10 13:32:47 1.7
@@ -529,6 +529,21 @@
return HTTP_INTERNAL_SERVER_ERROR;
}
+int g_bDebugHooks;
+
+static void register_hooks(module *m)
+ {
+ if(m->register_hooks)
+ {
+ if(ap_exists_config_define("SHOW_HOOKS"))
+ {
+ printf("Registering hooks for %s\n",m->name);
+ g_bDebugHooks=1;
+ }
+ m->register_hooks();
+ }
+ }
+
/* One-time setup for precompiled modules --- NOT to be done on restart */
API_EXPORT(void) ap_add_module(module *m)
@@ -582,8 +597,7 @@
#endif /*_OSD_POSIX*/
/* FIXME: is this the right place to call this? */
- if(m->register_hooks)
- m->register_hooks();
+ register_hooks(m);
}
/*
1.4 +15 -6 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.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- http_main.c 1999/07/05 13:00:45 1.3
+++ http_main.c 1999/07/10 13:32:47 1.4
@@ -247,6 +247,7 @@
pool *ptemp; /* Pool for temporart config stuff */
pool *pcommands; /* Pool for -C and -c switches */
extern char *optarg;
+ extern int optind,optreset;
/* TODO: PATHSEPARATOR should be one of the os defines */
@@ -264,14 +265,26 @@
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 *));
ap_server_post_read_config = ap_make_array(pcommands, 1, sizeof(char *));
ap_server_config_defines = ap_make_array(pcommands, 1, sizeof(char *));
+
+ while ((c = getopt(argc, argv, "D:C:c:Xd:f:vVlLR:th")) != -1) {
+ char **new;
+ switch (c) {
+ case 'D':
+ new = (char **)ap_push_array(ap_server_config_defines);
+ *new = ap_pstrdup(pcommands, optarg);
+ break;
+ }
+ }
+
+ ap_setup_prelinked_modules();
+
ap_pre_command_line_hook(pcommands);
+ optind=optreset=1;
while ((c = getopt(argc, argv, "D:C:c:Xd:f:vVlLR:th")) != -1) {
char **new;
switch (c) {
@@ -281,10 +294,6 @@
break;
case 'C':
new = (char **)ap_push_array(ap_server_pre_read_config);
- *new = ap_pstrdup(pcommands, optarg);
- break;
- case 'D':
- new = (char **)ap_push_array(ap_server_config_defines);
*new = ap_pstrdup(pcommands, optarg);
break;
case 'd':
Re: cvs commit: apache-2.0/mpm/src/main http_config.c http_main.c
Posted by Ben Laurie <be...@algroup.co.uk>.
Dean Gaudet wrote:
>
> On Mon, 12 Jul 1999, Ben Laurie wrote:
>
> > Dean Gaudet wrote:
> > >
> > > On Sun, 11 Jul 1999, Ben Laurie wrote:
> > >
> > > > Well, if I'm going to preserve the original behaviour as much as I can,
> > > > yes. The reason being that hooks are defined early on, but I need
> > > > -DSHOW_HOOKS before they are, but there's also a pre-command-line hook
> > > > that has to come _after_ hooks have been hooked (obviously).
> > >
> > > Maybe the pre_command_line hook shouldn't be there. I forget exactly why
> > > I wanted it, I think in many ways what I wanted was a hook to initialize
> > > modules just after they first load... in case they have any memory that
> > > needs initializing.
> >
> > You use it in prefork.c (I think) ... if that's all it's for, you could
> > do it in register_hooks?
>
> Yeah, it just calls INIT_SIGLIST(). Totally -- if register_hooks is
> guaranteed to be called just once for each module as its loaded, before
> anything else in the module is called, then that's just about exactly what
> I was thinking of for pre_command_line. So just do a name change :)
Hmm. Perhaps I should call register_hooks something more general. OTOH,
perhaps we should keep the two things separate.
Cheers,
Ben.
--
http://www.apache-ssl.org/ben.html
"My grandfather once told me that there are two kinds of people: those
who work and those who take the credit. He told me to try to be in the
first group; there was less competition there."
- Indira Gandhi
Re: cvs commit: apache-2.0/mpm/src/main http_config.c http_main.c
Posted by Dean Gaudet <dg...@arctic.org>.
On Mon, 12 Jul 1999, Ben Laurie wrote:
> Dean Gaudet wrote:
> >
> > On Sun, 11 Jul 1999, Ben Laurie wrote:
> >
> > > Well, if I'm going to preserve the original behaviour as much as I can,
> > > yes. The reason being that hooks are defined early on, but I need
> > > -DSHOW_HOOKS before they are, but there's also a pre-command-line hook
> > > that has to come _after_ hooks have been hooked (obviously).
> >
> > Maybe the pre_command_line hook shouldn't be there. I forget exactly why
> > I wanted it, I think in many ways what I wanted was a hook to initialize
> > modules just after they first load... in case they have any memory that
> > needs initializing.
>
> You use it in prefork.c (I think) ... if that's all it's for, you could
> do it in register_hooks?
Yeah, it just calls INIT_SIGLIST(). Totally -- if register_hooks is
guaranteed to be called just once for each module as its loaded, before
anything else in the module is called, then that's just about exactly what
I was thinking of for pre_command_line. So just do a name change :)
Dean
Re: cvs commit: apache-2.0/mpm/src/main http_config.c http_main.c
Posted by Ben Laurie <be...@algroup.co.uk>.
Dean Gaudet wrote:
>
> On Sun, 11 Jul 1999, Ben Laurie wrote:
>
> > Well, if I'm going to preserve the original behaviour as much as I can,
> > yes. The reason being that hooks are defined early on, but I need
> > -DSHOW_HOOKS before they are, but there's also a pre-command-line hook
> > that has to come _after_ hooks have been hooked (obviously).
>
> Maybe the pre_command_line hook shouldn't be there. I forget exactly why
> I wanted it, I think in many ways what I wanted was a hook to initialize
> modules just after they first load... in case they have any memory that
> needs initializing.
You use it in prefork.c (I think) ... if that's all it's for, you could
do it in register_hooks?
:->
Cheers,
Ben.
--
http://www.apache-ssl.org/ben.html
"My grandfather once told me that there are two kinds of people: those
who work and those who take the credit. He told me to try to be in the
first group; there was less competition there."
- Indira Gandhi
Re: cvs commit: apache-2.0/mpm/src/main http_config.c http_main.c
Posted by Dean Gaudet <dg...@arctic.org>.
On Sun, 11 Jul 1999, Ben Laurie wrote:
> Well, if I'm going to preserve the original behaviour as much as I can,
> yes. The reason being that hooks are defined early on, but I need
> -DSHOW_HOOKS before they are, but there's also a pre-command-line hook
> that has to come _after_ hooks have been hooked (obviously).
Maybe the pre_command_line hook shouldn't be there. I forget exactly why
I wanted it, I think in many ways what I wanted was a hook to initialize
modules just after they first load... in case they have any memory that
needs initializing.
Dean
Re: cvs commit: apache-2.0/mpm/src/main http_config.c http_main.c
Posted by Brian Havard <br...@kheldar.apana.org.au>.
On Sun, 11 Jul 1999 19:28:02 +0100, Ben Laurie wrote:
>Brian Havard wrote:
>> To quote the man page: "To reinitialize getopt(), that is, to restart parsing
>> options, set optind to zero."
>
>Well, that's fun. On platforms with optreset, you have to set optind to
>1. Sigh.
>
>>
>> And I don't think it's just OS/2. My (admittedly rather old) linux machine
>> doesn't mention optreset on its man page either. Just
>
>And it is resettable, too?
Doesn't say so on the man page but setting optind=0 seems to work.
--
______________________________________________________________________________
| Brian Havard | "He is not the messiah! |
| brianh@kheldar.apana.org.au | He's a very naughty boy!" - Life of Brian |
------------------------------------------------------------------------------
Re: cvs commit: apache-2.0/mpm/src/main http_config.c http_main.c
Posted by Ben Laurie <be...@algroup.co.uk>.
Brian Havard wrote:
>
> On Sun, 11 Jul 1999 17:29:23 +0100, Ben Laurie wrote:
>
> >Brian Havard wrote:
> >>
> >> I don't know about anyone else but my getopt doesn't have this optreset. Is
> >> it important?
> >
> >Well, if I'm going to preserve the original behaviour as much as I can,
> >yes. The reason being that hooks are defined early on, but I need
> >-DSHOW_HOOKS before they are, but there's also a pre-command-line hook
> >that has to come _after_ hooks have been hooked (obviously).
> >
> >Is there a way to reset getopt at all on OS/2?
>
> To quote the man page: "To reinitialize getopt(), that is, to restart parsing
> options, set optind to zero."
Well, that's fun. On platforms with optreset, you have to set optind to
1. Sigh.
>
> And I don't think it's just OS/2. My (admittedly rather old) linux machine
> doesn't mention optreset on its man page either. Just
And it is resettable, too?
So, do we go for an os_reset_getopt()? Or some other method?
Cheers,
Ben.
--
http://www.apache-ssl.org/ben.html
"My grandfather once told me that there are two kinds of people: those
who work and those who take the credit. He told me to try to be in the
first group; there was less competition there."
- Indira Gandhi
Re: cvs commit: apache-2.0/mpm/src/main http_config.c http_main.c
Posted by Brian Havard <br...@kheldar.apana.org.au>.
On Sun, 11 Jul 1999 17:29:23 +0100, Ben Laurie wrote:
>Brian Havard wrote:
>>
>> I don't know about anyone else but my getopt doesn't have this optreset. Is
>> it important?
>
>Well, if I'm going to preserve the original behaviour as much as I can,
>yes. The reason being that hooks are defined early on, but I need
>-DSHOW_HOOKS before they are, but there's also a pre-command-line hook
>that has to come _after_ hooks have been hooked (obviously).
>
>Is there a way to reset getopt at all on OS/2?
To quote the man page: "To reinitialize getopt(), that is, to restart parsing
options, set optind to zero."
And I don't think it's just OS/2. My (admittedly rather old) linux machine
doesn't mention optreset on its man page either. Just
GETOPT(3) Linux Programmer's Manual GETOPT(3)
NAME
getopt - Read command line options
SYNOPSIS
#include <unistd.h>
int getopt(int argc, char * const argv[],
const char *optstring);
extern char *optarg;
extern int optind, opterr, optopt;
[...]
CONFORMS TO
getopt() :
POSIX.1
--
______________________________________________________________________________
| Brian Havard | "He is not the messiah! |
| brianh@kheldar.apana.org.au | He's a very naughty boy!" - Life of Brian |
------------------------------------------------------------------------------
Re: cvs commit: apache-2.0/mpm/src/main http_config.c http_main.c
Posted by Ben Laurie <be...@algroup.co.uk>.
Brian Havard wrote:
>
> On 10 Jul 1999 13:32:48 -0000, ben@hyperreal.org wrote:
>
> >ben 99/07/10 06:32:48
> >
> > Modified: mpm/src/include ap_hooks.h
> > mpm/src/main http_config.c http_main.c
> > Log:
> > Rudimentary debugging for hooks.
> >
> > Revision Changes Path
> > 1.3 +4 -0 apache-2.0/mpm/src/include/ap_hooks.h
>
> [...]
>
> > Index: http_main.c
> > ===================================================================
> > RCS file: /export/home/cvs/apache-2.0/mpm/src/main/http_main.c,v
> > retrieving revision 1.3
> > retrieving revision 1.4
> > diff -u -r1.3 -r1.4
> > --- http_main.c 1999/07/05 13:00:45 1.3
> > +++ http_main.c 1999/07/10 13:32:47 1.4
> > @@ -247,6 +247,7 @@
> > pool *ptemp; /* Pool for temporart config stuff */
> > pool *pcommands; /* Pool for -C and -c switches */
> > extern char *optarg;
> > + extern int optind,optreset;
>
> I don't know about anyone else but my getopt doesn't have this optreset. Is
> it important?
Well, if I'm going to preserve the original behaviour as much as I can,
yes. The reason being that hooks are defined early on, but I need
-DSHOW_HOOKS before they are, but there's also a pre-command-line hook
that has to come _after_ hooks have been hooked (obviously).
Is there a way to reset getopt at all on OS/2?
I'm sure we can find another way if not (for example, pull such things
out of the environment instead/as well).
Cheers,
Ben.
--
http://www.apache-ssl.org/ben.html
"My grandfather once told me that there are two kinds of people: those
who work and those who take the credit. He told me to try to be in the
first group; there was less competition there."
- Indira Gandhi
Re: cvs commit: apache-2.0/mpm/src/main http_config.c http_main.c
Posted by Brian Havard <br...@kheldar.apana.org.au>.
On 10 Jul 1999 13:32:48 -0000, ben@hyperreal.org wrote:
>ben 99/07/10 06:32:48
>
> Modified: mpm/src/include ap_hooks.h
> mpm/src/main http_config.c http_main.c
> Log:
> Rudimentary debugging for hooks.
>
> Revision Changes Path
> 1.3 +4 -0 apache-2.0/mpm/src/include/ap_hooks.h
[...]
> Index: http_main.c
> ===================================================================
> RCS file: /export/home/cvs/apache-2.0/mpm/src/main/http_main.c,v
> retrieving revision 1.3
> retrieving revision 1.4
> diff -u -r1.3 -r1.4
> --- http_main.c 1999/07/05 13:00:45 1.3
> +++ http_main.c 1999/07/10 13:32:47 1.4
> @@ -247,6 +247,7 @@
> pool *ptemp; /* Pool for temporart config stuff */
> pool *pcommands; /* Pool for -C and -c switches */
> extern char *optarg;
> + extern int optind,optreset;
I don't know about anyone else but my getopt doesn't have this optreset. Is
it important?
--
______________________________________________________________________________
| Brian Havard | "He is not the messiah! |
| brianh@kheldar.apana.org.au | He's a very naughty boy!" - Life of Brian |
------------------------------------------------------------------------------