<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7654.12">
<TITLE>RE: [Kamailio-Users] core:proxy.c problem</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/plain format -->
<P><FONT SIZE=2>Hello,<BR>
Sorry again for top-posting, web client Agrrr....<BR>
<BR>
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.<BR>
<BR>
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)<BR>
<BR>
As I said, I think that the proxy object abstractization should have ownership of all it's members.<BR>
<BR>
<BR>
Greetings<BR>
Marius<BR>
<BR>
-----Original Message-----<BR>
From: Daniel-Constantin Mierla [<A HREF="mailto:miconda@gmail.com">mailto:miconda@gmail.com</A>]<BR>
Sent: Tue 1/26/2010 7:11 PM<BR>
To: Marius Zbihlei<BR>
Cc: sr-dev@lists.sip-router.org; users@lists.kamailio.org<BR>
Subject: Re: [Kamailio-Users] core:proxy.c problem<BR>
<BR>
Hello,<BR>
<BR>
On 1/26/10 5:02 PM, marius zbihlei wrote:<BR>
> Hello,<BR>
><BR>
> There seems to be a design problem in proxy.c mk_proxy(str* name,<BR>
> unsigned short port, unsigned short proto,<BR>
> int is_sips) function. The purpose of this function is to<BR>
> create a proxy and return a pointer to the<BR>
> created structure.<BR>
><BR>
> The issue arises from the fact that the name (type struct str) member<BR>
> of the proxy structure is not deep copied from the given<BR>
> parameters(refer to the str* name ) (the hostent structure is instead<BR>
> deep copied). This isn't a problem for now but I have worked on a<BR>
> small patch that caches proxies (using add_proxy() and find_proxy())<BR>
> and ,because of this shallow copy, things are broken.<BR>
<BR>
how is it going to be? Each structure will have a reference counter to<BR>
ensure is not deleted while still in use? Is the structure in shm?<BR>
<BR>
<BR>
><BR>
> I said that this is a design problem because we can let the shallow<BR>
> copy happen (performance is better), and when needed the caller should<BR>
> provide a buffer that doesn't change (let him do the copy instead).<BR>
> This is not clearly documented but done from<BR>
> /modules(_k)/utils/conf.c. But it this way we may have a memory leak<BR>
> when the proxy is deallocated, because I doubt that the caller keeps<BR>
> track of the allocated buffers(the code in proxy.c doesn't take<BR>
> ownership of the given pointer).<BR>
><BR>
> This affects functions mk_proxy and mk_shm_proxy in both kamailio(1.5<BR>
> to speak of) and sip-router.<BR>
><BR>
> I have created a patch that also does a deep copy of the name, thus<BR>
> removing the need for the caller to bother about the lifetime of the<BR>
> name buffer.<BR>
><BR>
> Any ideas?!<BR>
Seems ok for me, maybe Andrei can comment better in relation with tm and<BR>
other core functions.<BR>
<BR>
Did you (intend to) attach the patch or you just mentioned it.<BR>
<BR>
Cheers,<BR>
Daniel<BR>
<BR>
--<BR>
Daniel-Constantin Mierla<BR>
* <A HREF="http://www.asipto.com/">http://www.asipto.com/</A><BR>
<BR>
<BR>
</FONT>
</P>
</BODY>
</HTML>