[Kamailio-Users] core:proxy.c problem

Marius Zbihlei Marius.Zbihlei at 1and1.ro
Tue Jan 26 20:10:31 CET 2010


Hello,
Sorry again for top-posting, web client Agrrr....

I will push the patch to upstream tomorrow, if nobody has anything against it. Along with the proxy caching functionality that I described in the previous mail today, they are for now in a  single patch, so i need a little time to break it in two, and only commit this atm.

I am for a deep copy of the name. My reason is that also the mk_shm_proxy funtion requires (even if documentation says nothing)  the name parameter to point to something in shared memory(as to be addressable by other processes)

As I said, I think that the proxy object abstractization should have ownership of all it's members.


Greetings
Marius

-----Original Message-----
From: Daniel-Constantin Mierla [mailto:miconda at gmail.com]
Sent: Tue 1/26/2010 7:11 PM
To: Marius Zbihlei
Cc: sr-dev at lists.sip-router.org; users at lists.kamailio.org
Subject: Re: [Kamailio-Users] core:proxy.c problem
 
Hello,

On 1/26/10 5:02 PM, marius zbihlei wrote:
> Hello,
>
> There seems to be a design problem in proxy.c mk_proxy(str* name, 
> unsigned short port, unsigned short proto,
>        int is_sips) function. The purpose of this function is to 
> create a proxy and return a pointer to the
> created structure.
>
> The issue arises from the fact that the name (type struct str) member 
> of the proxy structure is not deep copied from the given 
> parameters(refer to the str* name ) (the hostent structure is instead 
> deep copied). This isn't a problem for now but I have worked on a 
> small patch that caches proxies (using add_proxy() and find_proxy()) 
> and ,because of this shallow copy, things are broken.

how is it going to be? Each structure will have a reference counter to 
ensure is not deleted while still in use? Is the structure in shm?


>
> I said that this is a design problem because we can let the shallow 
> copy happen (performance is better), and when needed the caller should 
> provide a buffer that doesn't change (let him do the copy instead). 
> This is not clearly documented but done from 
> /modules(_k)/utils/conf.c. But it this way we may have a memory leak 
> when the proxy is deallocated, because I doubt that the caller keeps 
> track of the allocated buffers(the code in proxy.c doesn't take 
> ownership of the given pointer).
>
> This affects functions mk_proxy and mk_shm_proxy in both kamailio(1.5 
> to speak of) and sip-router.
>
> I have created a patch that also does a deep copy of the name, thus 
> removing the need for the caller to bother about the lifetime of the 
> name buffer.
>
> Any ideas?!
Seems ok for me, maybe Andrei can comment better in relation with tm and 
other core functions.

Did you (intend to) attach the patch or you just mentioned it.

Cheers,
Daniel

-- 
Daniel-Constantin Mierla
* http://www.asipto.com/


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sip-router.org/pipermail/sr-users/attachments/20100126/3a3ad7a8/attachment.htm>


More information about the sr-users mailing list