You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@axis.apache.org by Damitha Kumarage <da...@gmail.com> on 2006/11/22 09:06:14 UTC

[Axis2]Add clone method to axis2_property

Hi,
We copy properties from one ctx to another ctx often(in sandesha2 also)
This lead to problems in Sandesha2.
To avoid this would like to add a clone function ot axis2_property like 
we have done in
aixs2_qname.

Damitha

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


Re: [Axis2]Add clone method to axis2_property

Posted by Damitha Kumarage <da...@gmail.com>.
Samisa Abeysinghe wrote:

> Damitha Kumarage wrote:
>
>> Samisa Abeysinghe wrote:
>>
>>> Dinesh Premalal wrote:
>>>
>>>> Hi,
>>>>
>>>> Damitha Kumarage <da...@gmail.com> writes:
>>>>
>>>>  
>>>>
>>>>> Hi,
>>>>> We copy properties from one ctx to another ctx often(in sandesha2 
>>>>> also)
>>>>> This lead to problems in Sandesha2.
>>>>> To avoid this would like to add a clone function ot axis2_property
>>>>> like we have done in
>>>>> aixs2_qname.
>>>>>     
>>>>
>>>>
>>>> If we can maintain a reference counter, we could be able to get rid of
>>>> double freeing etc. Every time you referencing to that property
>>>> reference counter increases. Reference counter decrements when
>>>> freeing. Actual Freeing occurred when reference counter reaches to 0.
>>>> I think this method will be less expensive than cloning.   
>>>
>>>
>>> Ref count solved the problem but increases coupling. It becomes hard 
>>> to use it with all the places needing a reference having to deal 
>>> with ref count.
>>
>>
>> But it seems we have to keep a reference count.  Otherwise it is 
>> impossible to create a new context using exising context.
>> So it seems that we need to add an add_ref function to 
>> aixs2_property. As Dinesh said when axis2_property_free is called
>> this ref count is decreased by 1 and when it is 0 actual freeding 
>> should happen
>
> When are we going to increase the ref count? In which methods? I think 
> we have to be clear on this, before implementing ref count. Unlike in 
> the case of namespaces, where the use is limited, properties are more 
> widely used - so IMHO, maintaining the ref count itself would be a 
> headache.
> P.S. Even with namespace ref count, I am facing problems where there 
> is a leak in client failure cases - but I still cannot figure out 
> where the leak is happening. It sure help in some situations, but not 
> at all times.
>
> The other solution is to  use the scope concept of the property.  For 
> the  properties that  we copy  across,  we can set the scope to  be  
> application, in which case they are not freed by message context.

Currently I use this and it works fine. Actually when I look into the 
whole code I can see that no structs except strings are set to 
properties from client api's level. In all other places where structs 
are set as property values I see that the scope is application level. 
When scope is application level usually the value is not freed by the 
property but by some other owner of the struct. So what I'm going to 
suggest is not to free property values at property level at all. AFAIK 
this will not affect
the current code. In fututre also we can avoid that. This will save us 
from lot of headache.
Also even if we free property values the scope in the property has no 
meaning. It should be a boolean to indicate whether
to free the value or not(May be I was the one who indroduced it to the 
property :)). Because scope of the property can
be understood by to which struct it belongs to(ex. a conf property is 
application scope above is more natural.

> We can also set them at a higher level of the context hierarchy other 
> than message context, however, that is not possible if the properties 
> message level properties (that is each massage has a unique property 
> value), but the requirement suggests otherwise. Please see if that 
> Would be a viable solution. Else we may have to live with ref-count.
>
> Samisa...
>
>
> ---------------------------------------------------------------------
> 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: [Axis2]Add clone method to axis2_property

Posted by Samisa Abeysinghe <sa...@gmail.com>.
Damitha Kumarage wrote:
> Samisa Abeysinghe wrote:
>
>> Dinesh Premalal wrote:
>>
>>> Hi,
>>>
>>> Damitha Kumarage <da...@gmail.com> writes:
>>>
>>>  
>>>
>>>> Hi,
>>>> We copy properties from one ctx to another ctx often(in sandesha2 
>>>> also)
>>>> This lead to problems in Sandesha2.
>>>> To avoid this would like to add a clone function ot axis2_property
>>>> like we have done in
>>>> aixs2_qname.
>>>>     
>>>
>>> If we can maintain a reference counter, we could be able to get rid of
>>> double freeing etc. Every time you referencing to that property
>>> reference counter increases. Reference counter decrements when
>>> freeing. Actual Freeing occurred when reference counter reaches to 0.
>>> I think this method will be less expensive than cloning.   
>>
>> Ref count solved the problem but increases coupling. It becomes hard 
>> to use it with all the places needing a reference having to deal with 
>> ref count.
>
> But it seems we have to keep a reference count.  Otherwise it is 
> impossible to create a new context using exising context.
> So it seems that we need to add an add_ref function to aixs2_property. 
> As Dinesh said when axis2_property_free is called
> this ref count is decreased by 1 and when it is 0 actual freeding 
> should happen
When are we going to increase the ref count? In which methods? I think 
we have to be clear on this, before implementing ref count. Unlike in 
the case of namespaces, where the use is limited, properties are more 
widely used - so IMHO, maintaining the ref count itself would be a 
headache.
P.S. Even with namespace ref count, I am facing problems where there is 
a leak in client failure cases - but I still cannot figure out where the 
leak is happening. It sure help in some situations, but not at all times.

The other solution is to  use the scope concept of the property.  For 
the  properties that  we copy  across,  we can set the scope to  be  
application, in which case they are not freed by message context. We can 
also set them at a higher level of the context hierarchy other than 
message context, however, that is not possible if the properties message 
level properties (that is each massage has a unique property value), but 
the requirement suggests otherwise. Please see if that Would be a viable 
solution. Else we may have to live with ref-count.

Samisa...


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


Re: [Axis2]Add clone method to axis2_property

Posted by Damitha Kumarage <da...@gmail.com>.
Samisa Abeysinghe wrote:

> Dinesh Premalal wrote:
>
>> Hi,
>>
>> Damitha Kumarage <da...@gmail.com> writes:
>>
>>  
>>
>>> Hi,
>>> We copy properties from one ctx to another ctx often(in sandesha2 also)
>>> This lead to problems in Sandesha2.
>>> To avoid this would like to add a clone function ot axis2_property
>>> like we have done in
>>> aixs2_qname.
>>>     
>>
>> If we can maintain a reference counter, we could be able to get rid of
>> double freeing etc. Every time you referencing to that property
>> reference counter increases. Reference counter decrements when
>> freeing. Actual Freeing occurred when reference counter reaches to 0.
>> I think this method will be less expensive than cloning.   
>
> Ref count solved the problem but increases coupling. It becomes hard 
> to use it with all the places needing a reference having to deal with 
> ref count.

But it seems we have to keep a reference count.  Otherwise it is 
impossible to create a new context using exising context.
So it seems that we need to add an add_ref function to aixs2_property. 
As Dinesh said when axis2_property_free is called
this ref count is decreased by 1 and when it is 0 actual freeding should 
happen
Damitha

>
> Samisa...
>
>
> ---------------------------------------------------------------------
> 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: [Axis2]Add clone method to axis2_property

Posted by Samisa Abeysinghe <sa...@wso2.com>.
Dinesh Premalal wrote:
> Hi,
>
> Damitha Kumarage <da...@gmail.com> writes:
>
>   
>> Hi,
>> We copy properties from one ctx to another ctx often(in sandesha2 also)
>> This lead to problems in Sandesha2.
>> To avoid this would like to add a clone function ot axis2_property
>> like we have done in
>> aixs2_qname.
>>     
> If we can maintain a reference counter, we could be able to get rid of
> double freeing etc. Every time you referencing to that property
> reference counter increases. Reference counter decrements when
> freeing. Actual Freeing occurred when reference counter reaches to 0.
> I think this method will be less expensive than cloning. 
>   
Ref count solved the problem but increases coupling. It becomes hard to 
use it with all the places needing a reference having to deal with ref 
count.

Samisa...


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


Re: [Axis2]Add clone method to axis2_property

Posted by Damitha Kumarage <da...@gmail.com>.
Nandika Jayawardana wrote:

> hi,
>
> In addtion to a clone method, if we can change the property create 
> function to
> accept other arguments as well, it would be lot more convenient to use 
> properties,
>
> Instead of
>
> AXIS2_EXTERN axis2_property_t * AXIS2_CALL
> axis2_property_create(const axis2_env_t *env);
>
> have
>
> AXIS2_EXTERN axis2_property_t* AXIS2_CALL
> axis2_property_create(const axis2_env_t *env,
>                                  void *value,
>                                  AXIS2_FREE_VOID_ARG free_func,
>                                  axis2_scope_t *scope);

Since we have used axis2_property_create(env) and then set values in so 
many places changing the
method will involve lot of work. So I suggest

AXIS2_EXTERN axis2_property_t* AXIS2_CALL
axis2_property_create_with_args(
     const axis2_env_t *env,
     void *value,
     AXIS2_FREE_VOID_ARG free_func,
     axis2_scope_t *scope);
Then we can slowly shift using the new creator
Damitha

>
> Regards
> Nandika
>
> On 11/22/06, *Dinesh Premalal* <xydinesh@gmail.com 
> <ma...@gmail.com>> wrote:
>
>     Hi,
>
>     Damitha Kumarage < damitha23@gmail.com
>     <ma...@gmail.com>> writes:
>
>     > Hi,
>     > We copy properties from one ctx to another ctx often(in
>     sandesha2 also)
>     > This lead to problems in Sandesha2.
>     > To avoid this would like to add a clone function ot axis2_property
>     > like we have done in
>     > aixs2_qname.
>     If we can maintain a reference counter, we could be able to get rid of
>     double freeing etc. Every time you referencing to that property
>     reference counter increases. Reference counter decrements when
>     freeing. Actual Freeing occurred when reference counter reaches to 0.
>     I think this method will be less expensive than cloning.
>
>     comments please ...
>
>     BTW , I'm +1 to some kind of mechanism to handle this scenario.
>
>     thanks,
>     Dinesh
>
>     ---------------------------------------------------------------------
>     To unsubscribe, e-mail: axis-c-dev-unsubscribe@ws.apache.org
>     <ma...@ws.apache.org>
>     For additional commands, e-mail: axis-c-dev-help@ws.apache.org
>     <ma...@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: [Axis2]Add clone method to axis2_property

Posted by Nandika Jayawardana <ja...@gmail.com>.
hi,

In addtion to a clone method, if we can change the property create function
to
accept other arguments as well, it would be lot more convenient to use
properties,

Instead of

AXIS2_EXTERN axis2_property_t * AXIS2_CALL
axis2_property_create(const axis2_env_t *env);

have

AXIS2_EXTERN axis2_property_t* AXIS2_CALL
axis2_property_create(const axis2_env_t *env,
                                 void *value,
                                 AXIS2_FREE_VOID_ARG free_func,
                                 axis2_scope_t *scope);

Regards
Nandika

On 11/22/06, Dinesh Premalal <xy...@gmail.com> wrote:
>
> Hi,
>
> Damitha Kumarage <da...@gmail.com> writes:
>
> > Hi,
> > We copy properties from one ctx to another ctx often(in sandesha2 also)
> > This lead to problems in Sandesha2.
> > To avoid this would like to add a clone function ot axis2_property
> > like we have done in
> > aixs2_qname.
> If we can maintain a reference counter, we could be able to get rid of
> double freeing etc. Every time you referencing to that property
> reference counter increases. Reference counter decrements when
> freeing. Actual Freeing occurred when reference counter reaches to 0.
> I think this method will be less expensive than cloning.
>
> comments please ...
>
> BTW , I'm +1 to some kind of mechanism to handle this scenario.
>
> thanks,
> Dinesh
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-c-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-c-dev-help@ws.apache.org
>
>

Re: [Axis2]Add clone method to axis2_property

Posted by Dinesh Premalal <xy...@gmail.com>.
Hi,

Damitha Kumarage <da...@gmail.com> writes:

> Hi,
> We copy properties from one ctx to another ctx often(in sandesha2 also)
> This lead to problems in Sandesha2.
> To avoid this would like to add a clone function ot axis2_property
> like we have done in
> aixs2_qname.
If we can maintain a reference counter, we could be able to get rid of
double freeing etc. Every time you referencing to that property
reference counter increases. Reference counter decrements when
freeing. Actual Freeing occurred when reference counter reaches to 0.
I think this method will be less expensive than cloning. 

comments please ...

BTW , I'm +1 to some kind of mechanism to handle this scenario.

thanks,
Dinesh

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


Re: [Axis2]Add clone method to axis2_property

Posted by Samisa Abeysinghe <sa...@wso2.com>.
Damitha Kumarage wrote:
> Hi,
> We copy properties from one ctx to another ctx often(in sandesha2 also)
> This lead to problems in Sandesha2.
> To avoid this would like to add a clone function ot axis2_property 
> like we have done in
> aixs2_qname.
The problem is how to clone the value, which is a void pointer.

Samisa...


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


Re: [Axis2]Add clone method to axis2_property

Posted by Damitha Kumarage <da...@gmail.com>.
Samisa Abeysinghe wrote:

> Damitha Kumarage wrote:
>
>> Hi,
>> We copy properties from one ctx to another ctx often(in sandesha2 also)
>
> Would the old context be using the property after it being copied to 
> the new context? If so please provide an example.

For example application msg context is used to create a new related msg 
context for ackknowledgement. After that
application message context is continued in use.

> If not, you can re-set the property in the old context to NULL, after 
> copying the reference to the new context and and you can save memory 
> as well. 

I thought of cloning after the problems I faced in sandeshaya2 after 
memory leak fixes in axis2.  However I got rid
of those problems without using cloning. The problem was when I reset an 
property with the same key the orignal property was not freed earlier. 
After the fix, in which the original property is freed I got context 
errors. I avoided these
by not resetting the proprety but first checking whether an property is 
already is set for that key and if so replace the
value for that property with new value. If no property is already 
assigned for that key then only create a new property and set to message 
context
Damitha

>
> Samisa...
>
>
> ---------------------------------------------------------------------
> 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: [Axis2]Add clone method to axis2_property

Posted by Samisa Abeysinghe <sa...@wso2.com>.
Damitha Kumarage wrote:
> Hi,
> We copy properties from one ctx to another ctx often(in sandesha2 also)
Would the old context be using the property after it being copied to the 
new context? If so please provide an example. If not, you can re-set the 
property in the old context to NULL, after copying the reference to the 
new context and and you can save memory as well.

Samisa...


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