<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
The problem is that buf is allocated on the stack, on a zone
reserved for pv_get_timenows2() function, which is destroyed as soon
as the function execution ends.<br>
<br>
You either define buf as static, or you allocate it dynamically in
the function and free it later.<br>
<br>
Cheers,<br>
Daniel<br>
<br>
<div class="moz-cite-prefix">On 2/7/13 7:25 PM, Mino Haluz wrote:<br>
</div>
<blockquote
cite="mid:CAFA7yDQdAFYg7SZwQtZNrhfO64FEY9qGn5JNyKjxufkDSsWCLg@mail.gmail.com"
type="cite">
<div dir="ltr">I added new pseudovariale $TMS which gives time in
miliseconds. If I print $TMS value it is ok, but when I assign
it to avp, it gives strange values.
<div><br>
</div>
<div style="">pv_time.c</div>
<div><br>
</div>
<div>
<div>int pv_get_timenows2(struct sip_msg *msg, pv_param_t
*param,</div>
<div> pv_value_t *res)</div>
<div>{</div>
<div> struct timeval tv;<br>
</div>
<div> char buf[30];</div>
<div> str _s;</div>
<div> gettimeofday(&tv, NULL);</div>
<div> unsigned long long msEpoch =</div>
<div> (unsigned long long)(tv.tv_sec) * 1000 +</div>
<div> (unsigned long long)(tv.tv_usec) / 1000;</div>
<div> _s.len = sprintf(buf, "%lld", msEpoch);</div>
<div> _s.s = buf; //<------- I think problem is
here<br>
</div>
<div> return pv_get_strval(msg, param, res, &_s);</div>
<div>}</div>
</div>
<div><br>
</div>
<div style="">So how should I properly copy buf to _s ? </div>
<div style=""><br>
</div>
<div style="">Thanks,</div>
<div style="">Mino</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
</div>
<div class="gmail_extra"><br>
<br>
<div class="gmail_quote">On Thu, Feb 7, 2013 at 11:00 AM, Mino
Haluz <span dir="ltr"><<a moz-do-not-send="true"
href="mailto:mino.haluz@gmail.com" target="_blank">mino.haluz@gmail.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">Hi,
<div><br>
</div>
<div>I assume there is no avp or function which could give
me duration of ended dialog in miliseconds (I have to
send it in RADIUS message). I can run some bash script
which could return me this value but seems to me bit
awkward.</div>
<div><br>
</div>
<div>How you would do it? To adjust dialog module so that
it could return it to some avp value within dialog-end
event route and thus save it to radius?</div>
<span class="HOEnZb"><font color="#888888">
<div>
<br>
</div>
<div>Mino</div>
</font></span></div>
</blockquote>
</div>
<br>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
sr-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:sr-dev@lists.sip-router.org">sr-dev@lists.sip-router.org</a>
<a class="moz-txt-link-freetext" href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev</a>
</pre>
</blockquote>
<br>
<pre class="moz-signature" cols="72">--
Daniel-Constantin Mierla - <a class="moz-txt-link-freetext" href="http://www.asipto.com">http://www.asipto.com</a>
<a class="moz-txt-link-freetext" href="http://twitter.com/#!/miconda">http://twitter.com/#!/miconda</a> - <a class="moz-txt-link-freetext" href="http://www.linkedin.com/in/miconda">http://www.linkedin.com/in/miconda</a>
Kamailio World Conference, April 16-17, 2013, Berlin
- <a class="moz-txt-link-freetext" href="http://conference.kamailio.com">http://conference.kamailio.com</a> -</pre>
</body>
</html>