<!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&nbsp; 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)&nbsp; 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>
&gt; Hello,<BR>
&gt;<BR>
&gt; There seems to be a design problem in proxy.c mk_proxy(str* name,<BR>
&gt; unsigned short port, unsigned short proto,<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int is_sips) function. The purpose of this function is to<BR>
&gt; create a proxy and return a pointer to the<BR>
&gt; created structure.<BR>
&gt;<BR>
&gt; The issue arises from the fact that the name (type struct str) member<BR>
&gt; of the proxy structure is not deep copied from the given<BR>
&gt; parameters(refer to the str* name ) (the hostent structure is instead<BR>
&gt; deep copied). This isn't a problem for now but I have worked on a<BR>
&gt; small patch that caches proxies (using add_proxy() and find_proxy())<BR>
&gt; 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>
&gt;<BR>
&gt; I said that this is a design problem because we can let the shallow<BR>
&gt; copy happen (performance is better), and when needed the caller should<BR>
&gt; provide a buffer that doesn't change (let him do the copy instead).<BR>
&gt; This is not clearly documented but done from<BR>
&gt; /modules(_k)/utils/conf.c. But it this way we may have a memory leak<BR>
&gt; when the proxy is deallocated, because I doubt that the caller keeps<BR>
&gt; track of the allocated buffers(the code in proxy.c doesn't take<BR>
&gt; ownership of the given pointer).<BR>
&gt;<BR>
&gt; This affects functions mk_proxy and mk_shm_proxy in both kamailio(1.5<BR>
&gt; to speak of) and sip-router.<BR>
&gt;<BR>
&gt; I have created a patch that also does a deep copy of the name, thus<BR>
&gt; removing the need for the caller to bother about the lifetime of the<BR>
&gt; name buffer.<BR>
&gt;<BR>
&gt; 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>