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 nik600 <ni...@gmail.com> on 2014/12/04 16:04:36 UTC

problem with shared memory and directives for httpd

Dear all

i'm experiencing a problem with shared memory and i'm not able to figure it
out.

i've got a segment of shared memory in my module config and seen that if
set some settings for the module in my configuration this memory isn't
available in the request process.

i've also attached an example (very simplified and without any mutex, just
to show the case).

i've noticed that if i have in my server configuration:

 <IfModule mod_kcache.c>
      KcacheEnabled On
</IfModule>

The memory segment is not availabe:

>>[Thu Dec 04 15:26:15 2014] [crit] [client 127.0.0.1] kcache_return_result
invalid  config->s

But if i comment this directive:

 <IfModule mod_kcache.c>
#      KcacheEnabled On
</IfModule>

The memory segment is available and gets updated:

>>[Thu Dec 04 15:24:47 2014] [debug] src/mod_kcache.c(96): [client
127.0.0.1] config->s->counter=68
>>[Thu Dec 04 15:24:48 2014] [debug] src/mod_kcache.c(96): [client
127.0.0.1] config->s->counter=69
>>[Thu Dec 04 15:24:48 2014] [debug] src/mod_kcache.c(96): [client
127.0.0.1] config->s->counter=70
...

i've attached the full example (100 lines of code)

I'll appreciate any help, thank all in advance

-- 
/*************/
nik600
http://www.kumbe.it

Re: problem with shared memory and directives for httpd

Posted by nik600 <ni...@gmail.com>.
yes, now it works, thanks again!

2014-12-04 23:49 GMT+01:00 nik600 <ni...@gmail.com>:

> Thanks a lot!
>
> i've understand the logic... i'll try and let you know!
>
> 2014-12-04 23:43 GMT+01:00 Yann Ylavic <yl...@gmail.com>:
>
>> On Thu, Dec 4, 2014 at 10:52 PM, Yann Ylavic <yl...@gmail.com>
>> wrote:
>> > Please see attached modifications (where only a server_config is used).
>>
>> Note that I did not even test compile the chages, just a POC...
>>
>
>
>
> --
> /*************/
> nik600
> http://www.kumbe.it
>



-- 
/*************/
nik600
http://www.kumbe.it

Re: problem with shared memory and directives for httpd

Posted by nik600 <ni...@gmail.com>.
Thanks a lot!

i've understand the logic... i'll try and let you know!

2014-12-04 23:43 GMT+01:00 Yann Ylavic <yl...@gmail.com>:

> On Thu, Dec 4, 2014 at 10:52 PM, Yann Ylavic <yl...@gmail.com> wrote:
> > Please see attached modifications (where only a server_config is used).
>
> Note that I did not even test compile the chages, just a POC...
>



-- 
/*************/
nik600
http://www.kumbe.it

Re: problem with shared memory and directives for httpd

Posted by Yann Ylavic <yl...@gmail.com>.
On Thu, Dec 4, 2014 at 10:52 PM, Yann Ylavic <yl...@gmail.com> wrote:
> Please see attached modifications (where only a server_config is used).

Note that I did not even test compile the chages, just a POC...

Re: problem with shared memory and directives for httpd

Posted by Yann Ylavic <yl...@gmail.com>.
Hi,

to not depend on where you declare :

 <IfModule mod_kcache.c>
      KcacheEnabled On
 </IfModule>

you need to iterate over the server_rec list in post_config and
child_init hooks.

Please see attached modifications (where only a server_config is used).

Regards,
Yann.


On Thu, Dec 4, 2014 at 5:46 PM, nik600 <ni...@gmail.com> wrote:
> because i've tried with both or with only one.
>
> IE, if i use:
>
> module AP_MODULE_DECLARE_DATA kcache_module = {
> STANDARD20_MODULE_STUFF,NULL , NULL, create_server_conf, merge_conf,
> kcache_directives, register_hooks };
>
> i have the same behaviour
>
>
> 2014-12-04 17:32 GMT+01:00 Eric Johanson <er...@valmarc.com>:
>
>> Okay but why are you managing the kcache_config structure with both the
>> per-directory AND the server-level functions?  You should decide if your
>> kcache_config is server-wide or if it is per-directory, and use only the
>> appropriate functions.
>> -Eric
>>
>>
>> From: nik600 [mailto:nik600@gmail.com]
>> Sent: Thursday, December 04, 2014 11:15 AM
>> To: modules-dev@httpd.apache.org
>> Subject: Re: problem with shared memory and directives for httpd
>>
>> Hi
>>
>> thanks for your reply.
>>
>> i've tried also with a merging function but i have the same behaviour.
>>
>> Attached the same example with also merge function.
>>
>> Maybe i'm doing something wrong in my merge function?
>>
>>
>> 2014-12-04 16:33 GMT+01:00 Eric Johanson <ericj@valmarc.com<mailto:
>> ericj@valmarc.com>>:
>> You have no merge function defined for your server-level config structure
>> (kcache_config).  I would definitely try implementing that function.
>> Otherwise, when apache goes to combine two levels of the config hierarchy
>> together, the resulting combination is likely to just be an empty version
>> of kcache_config, which sounds like it could be causing your problem.
>>
>> -Eric
>>
>>
>> From: nik600 [mailto:nik600@gmail.com<ma...@gmail.com>]
>> Sent: Thursday, December 04, 2014 10:05 AM
>> To: modules-dev@httpd.apache.org<ma...@httpd.apache.org>
>> Subject: problem with shared memory and directives for httpd
>>
>> Dear all
>>
>> i'm experiencing a problem with shared memory and i'm not able to figure
>> it out.
>>
>> i've got a segment of shared memory in my module config and seen that if
>> set some settings for the module in my configuration this memory isn't
>> available in the request process.
>>
>> i've also attached an example (very simplified and without any mutex, just
>> to show the case).
>>
>> i've noticed that if i have in my server configuration:
>>
>>  <IfModule mod_kcache.c>
>>       KcacheEnabled On
>> </IfModule>
>>
>> The memory segment is not availabe:
>>
>> >>[Thu Dec 04 15:26:15 2014] [crit] [client 127.0.0.1]
>> kcache_return_result invalid  config->s
>>
>> But if i comment this directive:
>>
>>  <IfModule mod_kcache.c>
>> #      KcacheEnabled On
>> </IfModule>
>>
>> The memory segment is available and gets updated:
>>
>> >>[Thu Dec 04 15:24:47 2014] [debug] src/mod_kcache.c(96): [client
>> 127.0.0.1] config->s->counter=68
>> >>[Thu Dec 04 15:24:48 2014] [debug] src/mod_kcache.c(96): [client
>> 127.0.0.1] config->s->counter=69
>> >>[Thu Dec 04 15:24:48 2014] [debug] src/mod_kcache.c(96): [client
>> 127.0.0.1] config->s->counter=70
>> ...
>>
>> i've attached the full example (100 lines of code)
>>
>> I'll appreciate any help, thank all in advance
>>
>> --
>> /*************/
>> nik600
>> http://www.kumbe.it
>>
>>
>>
>> --
>> /*************/
>> nik600
>> http://www.kumbe.it
>>
>
>
>
> --
> /*************/
> nik600
> http://www.kumbe.it

Re: problem with shared memory and directives for httpd

Posted by nik600 <ni...@gmail.com>.
because i've tried with both or with only one.

IE, if i use:

module AP_MODULE_DECLARE_DATA kcache_module = {
STANDARD20_MODULE_STUFF,NULL , NULL, create_server_conf, merge_conf,
kcache_directives, register_hooks };

i have the same behaviour


2014-12-04 17:32 GMT+01:00 Eric Johanson <er...@valmarc.com>:

> Okay but why are you managing the kcache_config structure with both the
> per-directory AND the server-level functions?  You should decide if your
> kcache_config is server-wide or if it is per-directory, and use only the
> appropriate functions.
> -Eric
>
>
> From: nik600 [mailto:nik600@gmail.com]
> Sent: Thursday, December 04, 2014 11:15 AM
> To: modules-dev@httpd.apache.org
> Subject: Re: problem with shared memory and directives for httpd
>
> Hi
>
> thanks for your reply.
>
> i've tried also with a merging function but i have the same behaviour.
>
> Attached the same example with also merge function.
>
> Maybe i'm doing something wrong in my merge function?
>
>
> 2014-12-04 16:33 GMT+01:00 Eric Johanson <ericj@valmarc.com<mailto:
> ericj@valmarc.com>>:
> You have no merge function defined for your server-level config structure
> (kcache_config).  I would definitely try implementing that function.
> Otherwise, when apache goes to combine two levels of the config hierarchy
> together, the resulting combination is likely to just be an empty version
> of kcache_config, which sounds like it could be causing your problem.
>
> -Eric
>
>
> From: nik600 [mailto:nik600@gmail.com<ma...@gmail.com>]
> Sent: Thursday, December 04, 2014 10:05 AM
> To: modules-dev@httpd.apache.org<ma...@httpd.apache.org>
> Subject: problem with shared memory and directives for httpd
>
> Dear all
>
> i'm experiencing a problem with shared memory and i'm not able to figure
> it out.
>
> i've got a segment of shared memory in my module config and seen that if
> set some settings for the module in my configuration this memory isn't
> available in the request process.
>
> i've also attached an example (very simplified and without any mutex, just
> to show the case).
>
> i've noticed that if i have in my server configuration:
>
>  <IfModule mod_kcache.c>
>       KcacheEnabled On
> </IfModule>
>
> The memory segment is not availabe:
>
> >>[Thu Dec 04 15:26:15 2014] [crit] [client 127.0.0.1]
> kcache_return_result invalid  config->s
>
> But if i comment this directive:
>
>  <IfModule mod_kcache.c>
> #      KcacheEnabled On
> </IfModule>
>
> The memory segment is available and gets updated:
>
> >>[Thu Dec 04 15:24:47 2014] [debug] src/mod_kcache.c(96): [client
> 127.0.0.1] config->s->counter=68
> >>[Thu Dec 04 15:24:48 2014] [debug] src/mod_kcache.c(96): [client
> 127.0.0.1] config->s->counter=69
> >>[Thu Dec 04 15:24:48 2014] [debug] src/mod_kcache.c(96): [client
> 127.0.0.1] config->s->counter=70
> ...
>
> i've attached the full example (100 lines of code)
>
> I'll appreciate any help, thank all in advance
>
> --
> /*************/
> nik600
> http://www.kumbe.it
>
>
>
> --
> /*************/
> nik600
> http://www.kumbe.it
>



-- 
/*************/
nik600
http://www.kumbe.it

RE: problem with shared memory and directives for httpd

Posted by Eric Johanson <er...@valmarc.com>.
Okay but why are you managing the kcache_config structure with both the per-directory AND the server-level functions?  You should decide if your kcache_config is server-wide or if it is per-directory, and use only the appropriate functions.
-Eric


From: nik600 [mailto:nik600@gmail.com]
Sent: Thursday, December 04, 2014 11:15 AM
To: modules-dev@httpd.apache.org
Subject: Re: problem with shared memory and directives for httpd

Hi

thanks for your reply.

i've tried also with a merging function but i have the same behaviour.

Attached the same example with also merge function.

Maybe i'm doing something wrong in my merge function?


2014-12-04 16:33 GMT+01:00 Eric Johanson <er...@valmarc.com>>:
You have no merge function defined for your server-level config structure (kcache_config).  I would definitely try implementing that function.  Otherwise, when apache goes to combine two levels of the config hierarchy together, the resulting combination is likely to just be an empty version of kcache_config, which sounds like it could be causing your problem.

-Eric


From: nik600 [mailto:nik600@gmail.com<ma...@gmail.com>]
Sent: Thursday, December 04, 2014 10:05 AM
To: modules-dev@httpd.apache.org<ma...@httpd.apache.org>
Subject: problem with shared memory and directives for httpd

Dear all

i'm experiencing a problem with shared memory and i'm not able to figure it out.

i've got a segment of shared memory in my module config and seen that if set some settings for the module in my configuration this memory isn't available in the request process.

i've also attached an example (very simplified and without any mutex, just to show the case).

i've noticed that if i have in my server configuration:

 <IfModule mod_kcache.c>
      KcacheEnabled On
</IfModule>

The memory segment is not availabe:

>>[Thu Dec 04 15:26:15 2014] [crit] [client 127.0.0.1] kcache_return_result invalid  config->s

But if i comment this directive:

 <IfModule mod_kcache.c>
#      KcacheEnabled On
</IfModule>

The memory segment is available and gets updated:

>>[Thu Dec 04 15:24:47 2014] [debug] src/mod_kcache.c(96): [client 127.0.0.1] config->s->counter=68
>>[Thu Dec 04 15:24:48 2014] [debug] src/mod_kcache.c(96): [client 127.0.0.1] config->s->counter=69
>>[Thu Dec 04 15:24:48 2014] [debug] src/mod_kcache.c(96): [client 127.0.0.1] config->s->counter=70
...

i've attached the full example (100 lines of code)

I'll appreciate any help, thank all in advance

--
/*************/
nik600
http://www.kumbe.it



--
/*************/
nik600
http://www.kumbe.it

Re: problem with shared memory and directives for httpd

Posted by nik600 <ni...@gmail.com>.
Hi

thanks for your reply.

i've tried also with a merging function but i have the same behaviour.

Attached the same example with also merge function.

Maybe i'm doing something wrong in my merge function?


2014-12-04 16:33 GMT+01:00 Eric Johanson <er...@valmarc.com>:

> You have no merge function defined for your server-level config structure
> (kcache_config).  I would definitely try implementing that function.
> Otherwise, when apache goes to combine two levels of the config hierarchy
> together, the resulting combination is likely to just be an empty version
> of kcache_config, which sounds like it could be causing your problem.
>
> -Eric
>
>
> From: nik600 [mailto:nik600@gmail.com]
> Sent: Thursday, December 04, 2014 10:05 AM
> To: modules-dev@httpd.apache.org
> Subject: problem with shared memory and directives for httpd
>
> Dear all
>
> i'm experiencing a problem with shared memory and i'm not able to figure
> it out.
>
> i've got a segment of shared memory in my module config and seen that if
> set some settings for the module in my configuration this memory isn't
> available in the request process.
>
> i've also attached an example (very simplified and without any mutex, just
> to show the case).
>
> i've noticed that if i have in my server configuration:
>
>  <IfModule mod_kcache.c>
>       KcacheEnabled On
> </IfModule>
>
> The memory segment is not availabe:
>
> >>[Thu Dec 04 15:26:15 2014] [crit] [client 127.0.0.1]
> kcache_return_result invalid  config->s
>
> But if i comment this directive:
>
>  <IfModule mod_kcache.c>
> #      KcacheEnabled On
> </IfModule>
>
> The memory segment is available and gets updated:
>
> >>[Thu Dec 04 15:24:47 2014] [debug] src/mod_kcache.c(96): [client
> 127.0.0.1] config->s->counter=68
> >>[Thu Dec 04 15:24:48 2014] [debug] src/mod_kcache.c(96): [client
> 127.0.0.1] config->s->counter=69
> >>[Thu Dec 04 15:24:48 2014] [debug] src/mod_kcache.c(96): [client
> 127.0.0.1] config->s->counter=70
> ...
>
> i've attached the full example (100 lines of code)
>
> I'll appreciate any help, thank all in advance
>
> --
> /*************/
> nik600
> http://www.kumbe.it
>



-- 
/*************/
nik600
http://www.kumbe.it

RE: problem with shared memory and directives for httpd

Posted by Eric Johanson <er...@valmarc.com>.
You have no merge function defined for your server-level config structure (kcache_config).  I would definitely try implementing that function.  Otherwise, when apache goes to combine two levels of the config hierarchy together, the resulting combination is likely to just be an empty version of kcache_config, which sounds like it could be causing your problem.

-Eric


From: nik600 [mailto:nik600@gmail.com]
Sent: Thursday, December 04, 2014 10:05 AM
To: modules-dev@httpd.apache.org
Subject: problem with shared memory and directives for httpd

Dear all

i'm experiencing a problem with shared memory and i'm not able to figure it out.

i've got a segment of shared memory in my module config and seen that if set some settings for the module in my configuration this memory isn't available in the request process.

i've also attached an example (very simplified and without any mutex, just to show the case).

i've noticed that if i have in my server configuration:

 <IfModule mod_kcache.c>
      KcacheEnabled On
</IfModule>

The memory segment is not availabe:

>>[Thu Dec 04 15:26:15 2014] [crit] [client 127.0.0.1] kcache_return_result invalid  config->s

But if i comment this directive:

 <IfModule mod_kcache.c>
#      KcacheEnabled On
</IfModule>

The memory segment is available and gets updated:

>>[Thu Dec 04 15:24:47 2014] [debug] src/mod_kcache.c(96): [client 127.0.0.1] config->s->counter=68
>>[Thu Dec 04 15:24:48 2014] [debug] src/mod_kcache.c(96): [client 127.0.0.1] config->s->counter=69
>>[Thu Dec 04 15:24:48 2014] [debug] src/mod_kcache.c(96): [client 127.0.0.1] config->s->counter=70
...

i've attached the full example (100 lines of code)

I'll appreciate any help, thank all in advance

--
/*************/
nik600
http://www.kumbe.it