You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modules-dev@httpd.apache.org by Nick Kew <ni...@apache.org> on 2009/08/16 02:09:32 UTC

[Fwd: Re: Hello World Module in UTF-8]

Michael Franklin wrote:
> So my questions are:  
> 
> 1)  In an Apache module, how do you output a std::wstring or wchar_t* to the client as UTF-8?  

You would have to ensure it is utf-8, then output it.  Or else
use it with an output filter that converts to utf-8.  But if
you're using 16-bit chars internally, why not output as utf-16?

> 2)  Does APR have an API designed specifically for this purpose?

apr_xlate should do the job, provided it finds the required to and from
encodings on your platform's iconv (or whatever windows has as an
alternative).

Do any of the charset filter modules - e.g. mod_charset_lite - help?
That should be the easy way.

If it doesn't, I'd start looking at the platform.  Maybe install iconv,
then install apr-* and httpd on top of it.  Apache can't do that for
you because of licensing issues - you have to do it yourself (it's
not an issue for most of us, as iconv is included as standard on
modern OSs).

Either that, or cast a critical eye on whether your wchar stream is
(bytewise) what you think it is.

Re: post-config phase question

Posted by Michael Durket <du...@highwire.stanford.edu>.
Actually, I think it had to do with my trace function. Instead of using an ap_log_error call
I was using fprintf for a very quick-and-dirty solution. Once I stopped doing that the 
multiple copies of the messages went away. I thought I could get away with 
using fprintf this time, but obviously not.

On Nov 11, 2009, at 7:26 AM, Eric Covener wrote:

> On Wed, Nov 11, 2009 at 10:06 AM, Michael Durket
> <du...@highwire.stanford.edu> wrote:
>> Weird, because I'm tracing the entry to post-config in my code and the second
>> phase seems to be called 8 times which on my system is the value listed in the StartServers
>> directive.
> 
> Sounds like you're either hooked into child_init or calling some code
> from both post_config and child_init -- can you post the smallest
> working module that demonstrates it?
> 
> (also on Windows, 4 times is normal -- 2 in the parent and 2 in the child)
> 
> -- 
> Eric Covener
> covener@gmail.com


Re: post-config phase question

Posted by Eric Covener <co...@gmail.com>.
On Wed, Nov 11, 2009 at 10:06 AM, Michael Durket
<du...@highwire.stanford.edu> wrote:
> Weird, because I'm tracing the entry to post-config in my code and the second
> phase seems to be called 8 times which on my system is the value listed in the StartServers
> directive.

Sounds like you're either hooked into child_init or calling some code
from both post_config and child_init -- can you post the smallest
working module that demonstrates it?

(also on Windows, 4 times is normal -- 2 in the parent and 2 in the child)

-- 
Eric Covener
covener@gmail.com

Re: post-config phase question

Posted by Michael Durket <du...@highwire.stanford.edu>.
Weird, because I'm tracing the entry to post-config in my code and the second 
phase seems to be called 8 times which on my system is the value listed in the StartServers 
directive.

On Nov 10, 2009, at 2:45 PM, Sorin Manolache wrote:

> On Tue, Nov 10, 2009 at 23:40, Michael Durket
> <du...@highwire.stanford.edu> wrote:
>> Based on the few books that describe Apache module writing and a presentation
>> that I've found on the web from an Apache conference, the advice to module
>> writers is to remember that Apache calls the post-config phase twice - once
>> while it's checking its configuration files, and then when it's ready to start up
>> it discards all that and calls post-config again to really set things up.
>> 
>> But it appears to me (via tracing I've done in my own module) that post-config
>> is actually called once at configuration file checking time, and then once per
>> server process start (we're using MPM here) during the second (actual Apache
>> startup phase).
>> 
>> Is this correct?
> 
> No. It's done twice, before forking the children. The post_configs run
> as the user who launched apache (typically root), before the sever
> switches to the user/group specified in the corresponding
> configuration directives.
> 
> Have a look in server/main.c in the sources of apache.
> 
> Sorin


Re: post-config phase question

Posted by Sorin Manolache <so...@gmail.com>.
On Tue, Nov 10, 2009 at 23:40, Michael Durket
<du...@highwire.stanford.edu> wrote:
> Based on the few books that describe Apache module writing and a presentation
> that I've found on the web from an Apache conference, the advice to module
> writers is to remember that Apache calls the post-config phase twice - once
> while it's checking its configuration files, and then when it's ready to start up
> it discards all that and calls post-config again to really set things up.
>
> But it appears to me (via tracing I've done in my own module) that post-config
> is actually called once at configuration file checking time, and then once per
> server process start (we're using MPM here) during the second (actual Apache
> startup phase).
>
> Is this correct?

No. It's done twice, before forking the children. The post_configs run
as the user who launched apache (typically root), before the sever
switches to the user/group specified in the corresponding
configuration directives.

Have a look in server/main.c in the sources of apache.

Sorin

post-config phase question

Posted by Michael Durket <du...@highwire.stanford.edu>.
Based on the few books that describe Apache module writing and a presentation
that I've found on the web from an Apache conference, the advice to module 
writers is to remember that Apache calls the post-config phase twice - once 
while it's checking its configuration files, and then when it's ready to start up
it discards all that and calls post-config again to really set things up.

But it appears to me (via tracing I've done in my own module) that post-config
is actually called once at configuration file checking time, and then once per 
server process start (we're using MPM here) during the second (actual Apache
startup phase).

Is this correct?