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 Paulo Vicentini <vi...@gmail.com> on 2008/05/05 19:38:28 UTC

service life-cycle / resources

Hi,

What is the approach in order to keep in memory data information between
service requests?

Be my service: myservice.so deployed in axis2/c.

What about its life-cycle after deploying it?

If I allocate resources (pointers, files descriptors, mapped files,etc)
during my service invocation and I don't free explicitly  those resources ,
will they remain available between requests?
Do all requests over my service remain to the same process address space?

Thanks
Paulo

Re: service life-cycle / resources

Posted by Paulo Vicentini <vi...@gmail.com>.
Okay,
I'll study all those examples and I will try to implement them with my needs

Thank you very much
Paulo
On Tue, May 6, 2008 at 12:49 AM, Uthaiyashankar <sh...@wso2.com> wrote:

> Paulo Vicentini wrote:
>
> >
> > For instance:
> >
> > My service needs to mmap a file but I wouldn't like to call mmap for
> > every request…
> >
> > So I would like to keep the address returned by mmap functional between
> > requests.
> >
>
> As Samisa suggested, you can keep this information in service context. You
> can see an example implementation in [1], which is calling a method
> "sct_provider_get_sct_hash" in line 180. (The method is implemented in [2]
> line 158). "sct_provider_get_sct_hash" method is creating an axutil_hash_t
> and store it in conf_ctx. You can easily change it to store it in service
> context.
>
> In apache prefork MPM(this is default in apache in linux), multiple httpd
> processes will be created. So you will have multiple process address space.
> In that case, even if you create it in service context, it will be in a
> single process address space. So, if a request hits another httpd process,
> information stored in first httpd address space cannot be accessed from
> second httpd process. To overcome this, you have to enable shared global
> pool by giving a positive value for "Axis2GlobalPoolSize" option in
> httpd.conf. Please refer [3]. Then before creating/accessing a persistence
> object, you have to switch to global pool. Once finished accessing it, you
> have to switch back to local pool (you can see this in [1] line 128 and 190)
>
> Regards,
> Shankar
>
> [1]
> http://svn.apache.org/repos/asf/webservices/rampart/trunk/c/samples/server/secconv_echo/echo.c
> [2]
> http://svn.apache.org/repos/asf/webservices/rampart/trunk/c/src/secconv/sct_provider.c
> [3] http://ws.apache.org/axis2/c/docs/axis2c_manual.html#mod_axis2
>
>  Tks
> > Paulo
> >
> >
> > On Mon, May 5, 2008 at 4:23 PM, Samisa Abeysinghe <samisa@wso2.com<mailto:
> > samisa@wso2.com>> wrote:
> >
> >    Paulo Vicentini wrote:
> >
> >
> >        Hi,
> >
> >        What is the approach in order to keep in memory data
> >        information between service requests?
> >
> >    You can use service context. Please gave a look into the sg_math
> >    sample. There are other ways of doing this as well, like the use
> >    of shared memory. Shankar, can you comment please?
> >
> >
> >        Be my service: myservice.so deployed in axis2/c.
> >
> >        What about its life-cycle after deploying it?
> >
> >
> >    It lives, till you shutdown the server.
> >
> >
> >        If I allocate resources (pointers, files descriptors, mapped
> >        files,etc) during my service invocation and I don't free
> >        explicitly  those resources , will they remain available
> >        between requests?
> >
> >
> >    They will not be available. And if you are using simple axis
> >    server, this would lead to memory leaks.
> >
> >        Do all requests over my service remain to the same process
> >        address space?
> >
> >
> >    If you are using simple axis server, yes. But if you are using
> >    httpd, may be yea, may be not, based on the MPM in use.
> >
> >    Samisa...
> >
> >         Thanks
> >        Paulo
> >
> >  ------------------------------------------------------------------------
> >
> >        No virus found in this incoming message.
> >        Checked by AVG. Version: 7.5.524 / Virus Database:
> >        269.23.8/1413 - Release Date: 5/3/2008 11:22 AM
> >
> >
> >
> >    --    Samisa Abeysinghe Director, Engineering; WSO2 Inc.
> >
> >    http://www.wso2.com/ - "The Open Source SOA Company"
> >
> >
> >    ---------------------------------------------------------------------
> >    To unsubscribe, e-mail: axis-c-user-unsubscribe@ws.apache.org
> >    <ma...@ws.apache.org>
> >    For additional commands, e-mail: axis-c-user-help@ws.apache.org
> >    <ma...@ws.apache.org>
> >
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-c-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-c-user-help@ws.apache.org
>
>

Re: service life-cycle / resources

Posted by Uthaiyashankar <sh...@wso2.com>.
Paulo Vicentini wrote:
>
> For instance:
>
> My service needs to mmap a file but I wouldn't like to call mmap for 
> every request…
>
> So I would like to keep the address returned by mmap functional 
> between requests.

As Samisa suggested, you can keep this information in service context. 
You can see an example implementation in [1], which is calling a method 
"sct_provider_get_sct_hash" in line 180. (The method is implemented in 
[2] line 158). "sct_provider_get_sct_hash" method is creating an 
axutil_hash_t and store it in conf_ctx. You can easily change it to 
store it in service context.

In apache prefork MPM(this is default in apache in linux), multiple 
httpd processes will be created. So you will have multiple process 
address space. In that case, even if you create it in service context, 
it will be in a single process address space. So, if a request hits 
another httpd process, information stored in first httpd address space 
cannot be accessed from second httpd process. To overcome this, you have 
to enable shared global pool by giving a positive value for 
"Axis2GlobalPoolSize" option in httpd.conf. Please refer [3]. Then 
before creating/accessing a persistence object, you have to switch to 
global pool. Once finished accessing it, you have to switch back to 
local pool (you can see this in [1] line 128 and 190)

Regards,
Shankar

[1] 
http://svn.apache.org/repos/asf/webservices/rampart/trunk/c/samples/server/secconv_echo/echo.c
[2] 
http://svn.apache.org/repos/asf/webservices/rampart/trunk/c/src/secconv/sct_provider.c
[3] http://ws.apache.org/axis2/c/docs/axis2c_manual.html#mod_axis2

>  
> Tks
> Paulo
>
> On Mon, May 5, 2008 at 4:23 PM, Samisa Abeysinghe <samisa@wso2.com 
> <ma...@wso2.com>> wrote:
>
>     Paulo Vicentini wrote:
>
>
>         Hi,
>
>         What is the approach in order to keep in memory data
>         information between service requests?
>
>     You can use service context. Please gave a look into the sg_math
>     sample. There are other ways of doing this as well, like the use
>     of shared memory. Shankar, can you comment please?
>
>
>         Be my service: myservice.so deployed in axis2/c.
>
>         What about its life-cycle after deploying it?
>
>
>     It lives, till you shutdown the server.
>
>
>         If I allocate resources (pointers, files descriptors, mapped
>         files,etc) during my service invocation and I don't free
>         explicitly  those resources , will they remain available
>         between requests?
>
>
>     They will not be available. And if you are using simple axis
>     server, this would lead to memory leaks.
>
>         Do all requests over my service remain to the same process
>         address space?
>
>
>     If you are using simple axis server, yes. But if you are using
>     httpd, may be yea, may be not, based on the MPM in use.
>
>     Samisa...
>
>          Thanks
>         Paulo
>         ------------------------------------------------------------------------
>
>         No virus found in this incoming message.
>         Checked by AVG. Version: 7.5.524 / Virus Database:
>         269.23.8/1413 - Release Date: 5/3/2008 11:22 AM
>          
>
>
>
>     -- 
>     Samisa Abeysinghe Director, Engineering; WSO2 Inc.
>
>     http://www.wso2.com/ - "The Open Source SOA Company"
>
>
>     ---------------------------------------------------------------------
>     To unsubscribe, e-mail: axis-c-user-unsubscribe@ws.apache.org
>     <ma...@ws.apache.org>
>     For additional commands, e-mail: axis-c-user-help@ws.apache.org
>     <ma...@ws.apache.org>
>
>


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


Re: service life-cycle / resources

Posted by Paulo Vicentini <vi...@gmail.com>.
For instance:

My service needs to mmap a file but I wouldn't like to call mmap for every
request…
So I would like to keep the address returned by mmap functional between
requests.

Tks
Paulo

On Mon, May 5, 2008 at 4:23 PM, Samisa Abeysinghe <sa...@wso2.com> wrote:

> Paulo Vicentini wrote:
>
> >
> > Hi,
> >
> > What is the approach in order to keep in memory data information between
> > service requests?
> >
> > You can use service context. Please gave a look into the sg_math sample.
> There are other ways of doing this as well, like the use of shared memory.
> Shankar, can you comment please?
>
> >
> > Be my service: myservice.so deployed in axis2/c.
> >
> > What about its life-cycle after deploying it?
> >
> >
> It lives, till you shutdown the server.
>
> If I allocate resources (pointers, files descriptors, mapped files,etc)
> > during my service invocation and I don't free explicitly  those resources ,
> > will they remain available between requests?
> >
> >
> They will not be available. And if you are using simple axis server, this
> would lead to memory leaks.
>
> > Do all requests over my service remain to the same process address
> > space?
> >
>
> If you are using simple axis server, yes. But if you are using httpd, may
> be yea, may be not, based on the MPM in use.
>
> Samisa...
>
>  Thanks
> > Paulo
> > ------------------------------------------------------------------------
> >
> > No virus found in this incoming message.
> > Checked by AVG. Version: 7.5.524 / Virus Database: 269.23.8/1413 -
> > Release Date: 5/3/2008 11:22 AM
> >
> >
>
>
> --
> Samisa Abeysinghe Director, Engineering; WSO2 Inc.
>
> http://www.wso2.com/ - "The Open Source SOA Company"
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-c-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-c-user-help@ws.apache.org
>
>

Re: service life-cycle / resources

Posted by Samisa Abeysinghe <sa...@wso2.com>.
Paulo Vicentini wrote:
>
> Hi,
>
> What is the approach in order to keep in memory data information 
> between service requests?
>
You can use service context. Please gave a look into the sg_math sample. 
There are other ways of doing this as well, like the use of shared 
memory. Shankar, can you comment please?
>
> Be my service: myservice.so deployed in axis2/c.
>
> What about its life-cycle after deploying it?
>

It lives, till you shutdown the server.

> If I allocate resources (pointers, files descriptors, mapped 
> files,etc) during my service invocation and I don't free explicitly 
>  those resources , will they remain available between requests?
>

They will not be available. And if you are using simple axis server, 
this would lead to memory leaks.
> Do all requests over my service remain to the same process address space?

If you are using simple axis server, yes. But if you are using httpd, 
may be yea, may be not, based on the MPM in use.

Samisa...

>  
> Thanks
> Paulo
> ------------------------------------------------------------------------
>
> No virus found in this incoming message.
> Checked by AVG. 
> Version: 7.5.524 / Virus Database: 269.23.8/1413 - Release Date: 5/3/2008 11:22 AM
>   


-- 
Samisa Abeysinghe 
Director, Engineering; WSO2 Inc.

http://www.wso2.com/ - "The Open Source SOA Company"


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