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