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 Dave Ingram <da...@dmi.me.uk> on 2009/04/02 19:45:53 UTC

APR feature detection

Hi guys,

Is there any way that my module can detect which APR features are
enabled in Apache? It relies on DBD, and if that's not available then my
module just segfaults, which isn't very friendly. I'd prefer to give an
error message to the user, telling them that DBD is required.

Does anyone have any tips, or should I ask the APR list instead?

Thanks,


Dave

Re: APR feature detection

Posted by Dave Ingram <da...@dmi.me.uk>.
Sorin Manolache wrote:
> On Thu, Apr 2, 2009 at 19:45, Dave Ingram <da...@dmi.me.uk> wrote:
>   
>> Hi guys,
>>
>> Is there any way that my module can detect which APR features are
>> enabled in Apache? It relies on DBD, and if that's not available then my
>> module just segfaults, which isn't very friendly. I'd prefer to give an
>> error message to the user, telling them that DBD is required.
>>
>> Does anyone have any tips, or should I ask the APR list instead?
>>     
>
> dbd does this:
>     APR_REGISTER_OPTIONAL_FN(ap_dbd_prepare);
>     APR_REGISTER_OPTIONAL_FN(ap_dbd_open);
>     APR_REGISTER_OPTIONAL_FN(ap_dbd_close);
>     APR_REGISTER_OPTIONAL_FN(ap_dbd_acquire);
>     APR_REGISTER_OPTIONAL_FN(ap_dbd_cacquire);
>
> APR_RETRIEVE_OPTIONAL_FN(one of the functions above) should give you
> NULL if DBD is absent.
>
> The two macros are declared in apr_optional.h.
>   
Thanks Sorin -- just what I was after!


Dave

Re: APR feature detection

Posted by Dave Ingram <da...@dmi.me.uk>.
Sorin Manolache wrote:
> On Thu, Apr 2, 2009 at 19:45, Dave Ingram <da...@dmi.me.uk> wrote:
>   
>> Hi guys,
>>
>> Is there any way that my module can detect which APR features are
>> enabled in Apache? It relies on DBD, and if that's not available then my
>> module just segfaults, which isn't very friendly. I'd prefer to give an
>> error message to the user, telling them that DBD is required.
>>
>> Does anyone have any tips, or should I ask the APR list instead?
>>     
>
> dbd does this:
>     APR_REGISTER_OPTIONAL_FN(ap_dbd_prepare);
>     APR_REGISTER_OPTIONAL_FN(ap_dbd_open);
>     APR_REGISTER_OPTIONAL_FN(ap_dbd_close);
>     APR_REGISTER_OPTIONAL_FN(ap_dbd_acquire);
>     APR_REGISTER_OPTIONAL_FN(ap_dbd_cacquire);
>
> APR_RETRIEVE_OPTIONAL_FN(one of the functions above) should give you
> NULL if DBD is absent.
>
> The two macros are declared in apr_optional.h.
>   

Actually, that's not quite what I was after -- those are defined by
mod_dbd, which I don't rely on (as it's initialised too late for my
module's purposes). I do all of the DBD interaction myself. Is there any
other way to be sure it's enabled? Would:

if (apr_dbd_open != NULL) {
  // error...
}

work?


Dave

Re: APR feature detection

Posted by Sorin Manolache <so...@gmail.com>.
On Thu, Apr 2, 2009 at 19:45, Dave Ingram <da...@dmi.me.uk> wrote:
> Hi guys,
>
> Is there any way that my module can detect which APR features are
> enabled in Apache? It relies on DBD, and if that's not available then my
> module just segfaults, which isn't very friendly. I'd prefer to give an
> error message to the user, telling them that DBD is required.
>
> Does anyone have any tips, or should I ask the APR list instead?

dbd does this:
    APR_REGISTER_OPTIONAL_FN(ap_dbd_prepare);
    APR_REGISTER_OPTIONAL_FN(ap_dbd_open);
    APR_REGISTER_OPTIONAL_FN(ap_dbd_close);
    APR_REGISTER_OPTIONAL_FN(ap_dbd_acquire);
    APR_REGISTER_OPTIONAL_FN(ap_dbd_cacquire);

APR_RETRIEVE_OPTIONAL_FN(one of the functions above) should give you
NULL if DBD is absent.

The two macros are declared in apr_optional.h.

S

-- 
A: Because it reverses the logical flow of conversation.
Q: Why is top-posting frowned upon?
A: Top-posting.
Q: What is the most annoying thing in e-mail?