You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-user@axis.apache.org by Ben Wyckoff <be...@mirror-image.com> on 2008/02/19 21:10:23 UTC

[Axis2C] mod_axis2 service shutdown problem

Hello,
    I'm experimenting with mod_axis2 in Apache 2.2.4 on Solaris 10 (I know
Solaris isn't officially supported, but this appears to be a general apache2
issue.) I started with the echo service sample and started modifying it. I
allocate some resources at service init time (in echo_init) that I need to
free/close at service free time (in echo_free.)

If I run this in the simple axis2_http_server, echo_free gets called when I
stop the server. But when I run this in apache2, echo_free does NOT appear
to be called when I stop apache.

I've started to look at the code for mod_axis2, and I see where the call to
AXIS2_SVC_SKELETON_INIT is made, but I see no corresponding call to _FREE.
In apache2, shutdown handling is usually done via a registered pool cleanup
handler, and I don't see one of those either, but I haven't walked through
all of the axis2_worker code yet.

I've searched the bug DB and the email archive, and haven't found any
relevant references.

Has anyone else run into this issue? Is anyone trying to allocate resources
that have to be freed? (In particular, I'm opening a database, and I need to
properly close it - I can't just rely on the OS to free memory or close file
handles.)

Thanks,
-Ben Wyckoff

P.S. I see that 1.3.0 RC2 doesn't contain any changes to mod_axis2.c


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-c-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-c-user-help@ws.apache.org


Re: [Axis2C] mod_axis2 service shutdown problem

Posted by Ben Wyckoff <be...@mirror-image.com>.
Thanks Dumindu. I've opened an issue in Jira, and I've been looking at the
code a bit more, and I think the issue is a bit more complex. I'll move the
discussion to the dev-list.

-Ben


> From: Dumindu Pallewela <pa...@gmail.com>
> Date: Wed, 20 Feb 2008 11:39:58 +0530
> To: <be...@mirror-image.com>
> Cc: Apache AXIS C Developers List <ax...@ws.apache.org>, Apache AXIS C
> User List <ax...@ws.apache.org>
> Subject: Re: [Axis2C] mod_axis2 service shutdown problem
> 
> Hi Ben,
> 
> On Feb 20, 2008 1:40 AM, Ben Wyckoff <be...@mirror-image.com> wrote:
> <snip>
>> Has anyone else run into this issue? Is anyone trying to allocate resources
>> that have to be freed? (In particular, I'm opening a database, and I need to
>> properly close it - I can't just rely on the OS to free memory or close file
>> handles.)
> </snip>
> 
> This seems to be a problem with mod_axis2. Although the memory
> allocated with apr_pools will get free'd eventually without free
> functions being called, in order to free up other resources, we need
> to register relevant free functions to pool cleanup of a pool which
> has resource's lifetime. Please add a jira issue.
> 
> The attached patch should solve this issue when shared memory is not
> used. I'm not sure if it works when shared memory is used. Hope that
> someone familiar with axis2c shared memory implementation will look
> further into it.
> 
> Regards,
> Dumindu.
> 
> -- 
> Dumindu Pallewela
> http://blog.dumindu.com
> GPG ID: 0x9E131672
> 
> WSO2 | "Oxygenating the Web Service Platform" | http://wso2.com


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-c-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-c-user-help@ws.apache.org


Re: [Axis2C] mod_axis2 service shutdown problem

Posted by Samisa Abeysinghe <sa...@wso2.com>.
Ben Wyckoff wrote:
> Thanks for the response Dumindu. I added the issue to Jira, and I'm moving
> the discussion to the dev list because I think the issue is a bit more
> complex.
>
> For the record, I'm an experienced developer, and I've spent a considerable
> amount of time in the past couple of years working on apache modules. I'm
> relatively new to "web services" (but not web servers), but I hope I can
> contribute meaningfully to the axis2c project.
>
> There are a couple of related issues I think.
>
> The axis2_post_config handler runs in the root apache process, but if I
> understand correctly, services aren't loaded and initialized until they are
> first referenced in the context of a child process. If that is the case, the
> svc_skeleton_free operation should also happen in the context of the child
> process, right? I recall seeing something in the archives about a fix to
> prevent services from being loaded multiple times, but I don't know the
> details.
>   

A service is loaded on the first request, and will live there throughout 
the lifetime of the server. In other words, there is only one service 
instance in the description hierarchy.

> Also, when I have worked wth apr_rmm in apache modules in the past, I have
> used the child_init hook to call rmm_attach, and then a child pool cleanup
> handler to call rmm_detach, according to the rmm docs. From what I've seen,
> many modules fail to do that, and I believe it is "safe" because those
> functions are a no-op. Furthermore, mod_axis2 doesn't call rmm_destroy.
>
> In my particular scenario, I want to use a Transactional BerkeleyDB,
> possibly with replication, which means that bdb needs to run in a single
> process. I can control the httpd.conf to only create a single child, but I
> need to make sure that my axis2c service that uses bdb is initialized and
> freed in the same process so I can properly initialize and close my db.
>
> Since the axis2 worker is created in the root process, it makes sense to
> free that in the root process as well. I don't yet understand the inner
> workings of the axis2 worker, but it seems to me that mod_axis2 could use
> the child_init hook to register a child process pool cleanup handler to
> notify the worker that a child is going away, and then the worker could (via
> refcounting perhaps) free the appropriate service skeletons? There is still
> an issue of handling the multiple-child-process general case - how does the
> overall design address that situation?
>   

Is your problems is bout sharing data across services? Or is it about 
how to initialize and un-initialize some data related to a service 
within a service lifetime?

Regards,
Samisa...

> Regards,
> -Ben
>
>   
>> On Feb 20, 2008 1:40 AM, Ben Wyckoff <be...@mirror-image.com> wrote:
>> <snip>
>>     
>>> Has anyone else run into this issue? Is anyone trying to allocate resources
>>> that have to be freed? (In particular, I'm opening a database, and I need to
>>> properly close it - I can't just rely on the OS to free memory or close file
>>> handles.)
>>>       
>> </snip>
>>
>> This seems to be a problem with mod_axis2. Although the memory
>> allocated with apr_pools will get free'd eventually without free
>> functions being called, in order to free up other resources, we need
>> to register relevant free functions to pool cleanup of a pool which
>> has resource's lifetime. Please add a jira issue.
>>
>> The attached patch should solve this issue when shared memory is not
>> used. I'm not sure if it works when shared memory is used. Hope that
>> someone familiar with axis2c shared memory implementation will look
>> further into it.
>>
>> Regards,
>> Dumindu.
>>     
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-c-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-c-dev-help@ws.apache.org
>
>
>
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-c-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-c-dev-help@ws.apache.org


Re: [Axis2C] mod_axis2 service shutdown problem

Posted by Ben Wyckoff <be...@mirror-image.com>.
Thanks for the response Dumindu. I added the issue to Jira, and I'm moving
the discussion to the dev list because I think the issue is a bit more
complex.

For the record, I'm an experienced developer, and I've spent a considerable
amount of time in the past couple of years working on apache modules. I'm
relatively new to "web services" (but not web servers), but I hope I can
contribute meaningfully to the axis2c project.

There are a couple of related issues I think.

The axis2_post_config handler runs in the root apache process, but if I
understand correctly, services aren't loaded and initialized until they are
first referenced in the context of a child process. If that is the case, the
svc_skeleton_free operation should also happen in the context of the child
process, right? I recall seeing something in the archives about a fix to
prevent services from being loaded multiple times, but I don't know the
details.

Also, when I have worked wth apr_rmm in apache modules in the past, I have
used the child_init hook to call rmm_attach, and then a child pool cleanup
handler to call rmm_detach, according to the rmm docs. From what I've seen,
many modules fail to do that, and I believe it is "safe" because those
functions are a no-op. Furthermore, mod_axis2 doesn't call rmm_destroy.

In my particular scenario, I want to use a Transactional BerkeleyDB,
possibly with replication, which means that bdb needs to run in a single
process. I can control the httpd.conf to only create a single child, but I
need to make sure that my axis2c service that uses bdb is initialized and
freed in the same process so I can properly initialize and close my db.

Since the axis2 worker is created in the root process, it makes sense to
free that in the root process as well. I don't yet understand the inner
workings of the axis2 worker, but it seems to me that mod_axis2 could use
the child_init hook to register a child process pool cleanup handler to
notify the worker that a child is going away, and then the worker could (via
refcounting perhaps) free the appropriate service skeletons? There is still
an issue of handling the multiple-child-process general case - how does the
overall design address that situation?

Regards,
-Ben

> 
> On Feb 20, 2008 1:40 AM, Ben Wyckoff <be...@mirror-image.com> wrote:
> <snip>
>> Has anyone else run into this issue? Is anyone trying to allocate resources
>> that have to be freed? (In particular, I'm opening a database, and I need to
>> properly close it - I can't just rely on the OS to free memory or close file
>> handles.)
> </snip>
> 
> This seems to be a problem with mod_axis2. Although the memory
> allocated with apr_pools will get free'd eventually without free
> functions being called, in order to free up other resources, we need
> to register relevant free functions to pool cleanup of a pool which
> has resource's lifetime. Please add a jira issue.
> 
> The attached patch should solve this issue when shared memory is not
> used. I'm not sure if it works when shared memory is used. Hope that
> someone familiar with axis2c shared memory implementation will look
> further into it.
> 
> Regards,
> Dumindu.


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-c-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-c-dev-help@ws.apache.org


Re: [Axis2C] mod_axis2 service shutdown problem

Posted by Dumindu Pallewela <pa...@gmail.com>.
Hi Ben,

On Feb 20, 2008 1:40 AM, Ben Wyckoff <be...@mirror-image.com> wrote:
<snip>
> Has anyone else run into this issue? Is anyone trying to allocate resources
> that have to be freed? (In particular, I'm opening a database, and I need to
> properly close it - I can't just rely on the OS to free memory or close file
> handles.)
</snip>

This seems to be a problem with mod_axis2. Although the memory
allocated with apr_pools will get free'd eventually without free
functions being called, in order to free up other resources, we need
to register relevant free functions to pool cleanup of a pool which
has resource's lifetime. Please add a jira issue.

The attached patch should solve this issue when shared memory is not
used. I'm not sure if it works when shared memory is used. Hope that
someone familiar with axis2c shared memory implementation will look
further into it.

Regards,
Dumindu.

-- 
Dumindu Pallewela
http://blog.dumindu.com
GPG ID: 0x9E131672

WSO2 | "Oxygenating the Web Service Platform" | http://wso2.com

Re: [Axis2C] mod_axis2 service shutdown problem

Posted by Dumindu Pallewela <pa...@gmail.com>.
Hi Ben,

On Feb 20, 2008 1:40 AM, Ben Wyckoff <be...@mirror-image.com> wrote:
<snip>
> Has anyone else run into this issue? Is anyone trying to allocate resources
> that have to be freed? (In particular, I'm opening a database, and I need to
> properly close it - I can't just rely on the OS to free memory or close file
> handles.)
</snip>

This seems to be a problem with mod_axis2. Although the memory
allocated with apr_pools will get free'd eventually without free
functions being called, in order to free up other resources, we need
to register relevant free functions to pool cleanup of a pool which
has resource's lifetime. Please add a jira issue.

The attached patch should solve this issue when shared memory is not
used. I'm not sure if it works when shared memory is used. Hope that
someone familiar with axis2c shared memory implementation will look
further into it.

Regards,
Dumindu.

-- 
Dumindu Pallewela
http://blog.dumindu.com
GPG ID: 0x9E131672

WSO2 | "Oxygenating the Web Service Platform" | http://wso2.com