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/