Re: Accessing server config during parent startup

2001-07-10 Thread Robin Berjon

On Tuesday 10 July 2001 05:42, Doug MacEachern wrote:
 On Mon, 9 Jul 2001, Robin Berjon wrote:
  cfg = (axkit_dir_config *)
  ap_get_module_config(s-module_config, XS_AxKit);

 try s-lookup_defaults instead of s-module_config

 see also: modperl-2.0/src/modules/perl/modperl_pcw.c
 where you can see howto access all of the config apache has
 parsed.  the same logic should work with 1.x, just need to
 s/apr_pool_t/pool/g and the like.

Thanks Doug, the first option works like a charm :) And I'm far too scared 
already what with all this finding out about XS and all to apply the second 
one immediately, but I definitely will once I get a better grasp of these 
things.

Thanks a lot !

-- 
___
Robin Berjon [EMAIL PROTECTED] -- CTO
k n o w s c a p e : // venture knowledge agency www.knowscape.com
---
Let us think the unthinkable, let us do the undoable. Let us prepare 
to grapple with the ineffable itself, and see if we may not eff it 
after all. 
-- Dirk Gently (Douglas Adams)




Accessing server config during parent startup

2001-07-09 Thread Robin Berjon

Hi,

I'm having trouble trying to access server config directives during parent 
startup. Basically, I've got a module which needs to access a configuration 
directive in order to compile some non-Perl files to Perl while the server 
starts and before children are created so that the code they generate will 
stay shared. The directive I need access to is defined by AxKit, so I can 
play with the source code that defines it to make it available to Perl at 
that time.

In order to access the configuration, I'm using (in a nutshell):

cfg = (axkit_dir_config *)
ap_get_module_config(s-module_config, XS_AxKit);

where s is an Apache::Server object mapped to T_PTROBJ in the typemap. The 
code is working and now returns a cfg that exists but hasn't been 
initialised, ie it is as if no directives had been read at all (or so it 
seems). However, it is clear that the code is called after the directives 
have been read.

This may all be due to a problem in my code, but before I go on and go 
insane, I wondered if using the server object thus has any chance of working, 
and if there is a description of the right way to do this somewhere.

Thanks !

-- 
___
Robin Berjon [EMAIL PROTECTED] -- CTO
k n o w s c a p e : // venture knowledge agency www.knowscape.com
---
Oops. My Brain just hit a bad sector. 




RE: Accessing server config during parent startup

2001-07-09 Thread Geoffrey Young



 -Original Message-
 From: Robin Berjon [mailto:[EMAIL PROTECTED]]
 Sent: Monday, July 09, 2001 11:58 AM
 To: [EMAIL PROTECTED]
 Subject: Accessing server config during parent startup
 
 
 Hi,
 
 I'm having trouble trying to access server config directives 
 during parent 
 startup. Basically, I've got a module which needs to access a 
 configuration 
 directive in order to compile some non-Perl files to Perl 
 while the server 
 starts and before children are created so that the code they 
 generate will 
 stay shared. The directive I need access to is defined by 
 AxKit, so I can 
 play with the source code that defines it to make it 
 available to Perl at 
 that time.
 
 In order to access the configuration, I'm using (in a nutshell):
 
 cfg = (axkit_dir_config *)
 ap_get_module_config(s-module_config, XS_AxKit);

I only just skimmed the sources, but I don't think it is possible.  AxKit
populates the per-dir config, not the per-server config, and you need a
request record to dig out the per-dir config.

interesting to see what Matt says, though...

--Geoff



Re: Accessing server config during parent startup

2001-07-09 Thread Robin Berjon

On Monday 09 July 2001 18:09, Geoffrey Young wrote:
  From: Robin Berjon [mailto:[EMAIL PROTECTED]]
  In order to access the configuration, I'm using (in a nutshell):
 
  cfg = (axkit_dir_config *)
  ap_get_module_config(s-module_config, XS_AxKit);

 I only just skimmed the sources, but I don't think it is possible.  AxKit
 populates the per-dir config, not the per-server config, and you need a
 request record to dig out the per-dir config.

Yes, that much I know (there's a lot more to it, but I tried to boil it down 
to a simple description in order to make it palatable). Having a request 
object at server startup is not possible, or would be a hack which I'd rather 
avoid.

I added a server config creator which is an exact copy of the per-directory 
config creator to the module struct, except that it takes a server_rec as its 
second arg instead of a string. Perhaps I need to do something with that 
server_rec (eg set the module config on it instead of simply returning it), 
but I wasn't able to find anything helpful in the Apache docs (I might have 
missed though, pointers welcome).

 interesting to see what Matt says, though...

Matt probably won't be back for a while, which is why I'm posting here 
instead of pestering him directly on #axkit ;-)

-- 
___
Robin Berjon [EMAIL PROTECTED] -- CTO
k n o w s c a p e : // venture knowledge agency www.knowscape.com
---
The only sensible way to estimate the stability of a Windows server 
is to power it down and try it out as a step ladder. 
-- Robert Crawford, in the Monastery




Re: Accessing server config during parent startup

2001-07-09 Thread Robin Berjon

On Monday 09 July 2001 19:38, Robin Berjon wrote:
 On Monday 09 July 2001 18:09, Geoffrey Young wrote:
   From: Robin Berjon [mailto:[EMAIL PROTECTED]]
   In order to access the configuration, I'm using (in a nutshell):
  
   cfg = (axkit_dir_config *)
   ap_get_module_config(s-module_config, XS_AxKit);
 
 I added a server config creator which is an exact copy of the per-directory
 config creator to the module struct, except that it takes a server_rec as
 its second arg instead of a string. Perhaps I need to do something with
 that server_rec (eg set the module config on it instead of simply returning
 it), but I wasn't able to find anything helpful in the Apache docs (I might
 have missed though, pointers welcome).

It would seem (if I understand correctly) that my cfg is only finally 
initialized after the server merge and dir merge have been called, but that 
unfortunately Perl sections are called before that... Can anyone confirm 
this ? And if it is the case, is there a way I can work around that problem, 
eg by defining some handler code to be called after merging but before 
children are created ?

Thanks !

-- 
___
Robin Berjon [EMAIL PROTECTED] -- CTO
k n o w s c a p e : // venture knowledge agency www.knowscape.com
---
Always remember you're unique just like everyone else. 




Re: Accessing server config during parent startup

2001-07-09 Thread Doug MacEachern

On Mon, 9 Jul 2001, Robin Berjon wrote:
 
 cfg = (axkit_dir_config *)
 ap_get_module_config(s-module_config, XS_AxKit);

try s-lookup_defaults instead of s-module_config

see also: modperl-2.0/src/modules/perl/modperl_pcw.c
where you can see howto access all of the config apache has
parsed.  the same logic should work with 1.x, just need to 
s/apr_pool_t/pool/g and the like.