<!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: [sr-dev] How to parse msg stored in the tm correctly?</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/plain format -->

<P><FONT SIZE=2>HI Andrei<BR>
<BR>
&nbsp;&nbsp;&nbsp; thanks a lot!<BR>
<BR>
&gt;&gt; Hi Ser Gurus:<BR>
&gt;&gt;<BR>
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; How to parse msg stored in the tm correctly?<BR>
&gt;&gt;<BR>
&gt;&gt; e.g in the reply msg, we can get the corresponding request from tm:<BR>
&gt;&gt;<BR>
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; msg&nbsp; = t-&gt;uas.request;<BR>
&gt;&gt;<BR>
&gt;&gt; The sip_msg_cloner seems copy only via/from/to/cseq/auth headers and<BR>
&gt;&gt; parsed headers to the shm, right?<BR>
&gt;&gt;<BR>
&gt;&gt; what if we want to parse the other headers,<BR>
&gt;&gt;<BR>
&gt;&gt; e.g:&nbsp; parse_headers(msg, HDR_ROUTE_F, 0)&lt;0)<BR>
&gt;<BR>
&gt;By default all headers are parsed before creating the transaction, so<BR>
&gt;you'll have all the headers in the shm copy.<BR>
&gt;What you don't always have parsed is the content of a header (but that<BR>
&gt;depends on the header type).<BR>
&nbsp;&nbsp;<BR>
&nbsp;&nbsp;&nbsp; Oh I see,&nbsp; what we need is a parsed content of route header.<BR>
<BR>
&gt;&gt;<BR>
&gt;&gt; The parse_headers uses pkg_alloc, thus the parsed result is<BR>
&gt;&gt; pkg_alloced and stored the tm structure,&nbsp; then it never get freed until<BR>
&gt;&gt; tm is destoried ( but even in this case tm may call shm_free instead of<BR>
&gt;&gt; pkg_free???? )<BR>
&gt;<BR>
&gt;In general one calls parse_headers only on a copy of the message stored<BR>
&gt;in tm (see fake_req()).<BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp; I see.<BR>
<BR>
&gt;&gt;<BR>
&gt;&gt; So how can we parsed the tm-stored msg and how to do it correctly?<BR>
&gt;<BR>
&gt;If you could be more specific (what headers do you need and from where,<BR>
&gt;e.g. failure route or a tm hook) it would help.<BR>
<BR>
&nbsp;&nbsp;&nbsp; Here is the detailed case:<BR>
<BR>
&nbsp;&nbsp;&nbsp; U1 --&gt; p-cscf --&gt; U2<BR>
<BR>
&nbsp;&nbsp;&nbsp; U1 call U2, U2 reply with 183 and 200 OK.<BR>
&nbsp;&nbsp;&nbsp;<BR>
&nbsp;&nbsp;&nbsp; The p-cscf&nbsp; handles the 183/200 reply in two different processes,<BR>
we need to get original request's route header and its parsed content.<BR>
<BR>
the&nbsp; old psudocode is like which cause memory leak/crash the sytem:<BR>
<BR>
&nbsp;&nbsp;&nbsp; msg&nbsp; = t-&gt;uas.request;<BR>
&nbsp;&nbsp;&nbsp; parse_headers(msg, HDR_ROUTE_F, 0)<BR>
&nbsp;&nbsp;&nbsp; parse_rr(h);<BR>
<BR>
&nbsp;&nbsp;<BR>
according to your email, it seems should be something like :<BR>
<BR>
&nbsp;&nbsp;&nbsp; msg&nbsp; = fake_req(t-&gt;uas.request);<BR>
&nbsp;&nbsp;&nbsp; parse_headers(msg, HDR_ROUTE_F, 0)<BR>
&nbsp;&nbsp;&nbsp; parse_rr(h);<BR>
&nbsp;&nbsp;&nbsp; free_faked_req(msg);<BR>
<BR>
&nbsp;&nbsp;&nbsp;<BR>
&nbsp;&nbsp;&nbsp; since 183/200 are in different process and need the same parsed route header<BR>
&nbsp;content, is there a way to copied the parsed content to shm to avoid duplicate parsing?<BR>
Or is there a way to copy the parsed-header's content to shm before creating the transaction?<BR>
<BR>
<BR>
<BR>
<BR>
Kind regards<BR>
<BR>
Min Wang</FONT>
</P>

</BODY>
</HTML>