<HTML>
<HEAD>
<TITLE>Problem with AMI action userevent</TITLE>
</HEAD>
<BODY>
<FONT FACE="Verdana, Helvetica, Arial"><SPAN STYLE='font-size:12.0px'>When action_userevent was rewritten to not use local variables there was an omission. The buffer is not initialized each time so things keep getting appended to the buffer.<BR>
<BR>
In addition I would find it useful to have the ping action return the timestamp. That way I do not have to have timestamp event enabled and when I want to check the time sync with the asterisk server I can just to a ping and get a timestamp back.<BR>
<BR>
Here is a patch the current svn version of manager.c from the 1.6.0 branch<BR>
<BR>
<BR>
--- manager.c 2009-02-11 15:16:16.000000000 -0800<BR>
+++ manager.c.mine 2009-02-11 15:10:52.000000000 -0800<BR>
@@ -1089,9 +1089,13 @@<BR>
<BR>
static int action_ping(struct mansession *s, const struct message *m)<BR>
{<BR>
+ struct timeval now;<BR>
+<BR>
+ now = ast_tvnow();<BR>
+<BR>
astman_append(s, "Response: Success\r\n"<BR>
- "Ping: Pong\r\n"<BR>
- "\r\n");<BR>
+ "Ping: Pong Timestamp: %ld.%06lu\r\n"<BR>
+ "\r\n", now.tv_sec, (unsigned long) now.tv_usec);<BR>
return 0;<BR>
}<BR>
<BR>
@@ -2462,6 +2466,8 @@<BR>
const char *event = astman_get_header(m, "UserEvent");<BR>
struct ast_str *body = ast_str_thread_get(&userevent_buf, 16);<BR>
int x;<BR>
+ /* better init stuff so ast_str_append can be called */<BR>
+ body->used = 0;<BR>
for (x = 0; x < m->hdrcount; x++) {<BR>
if (strncasecmp("UserEvent:", m->headers[x], strlen("UserEvent:"))) {<BR>
ast_str_append(&body, 0, "%s\r\n", m->headers[x]);<BR>
<BR>
-- <BR>
Jim Dickenson<BR>
<a href="mailto:dickenson@cfmc.com">mailto:dickenson@cfmc.com</a><BR>
<BR>
CfMC<BR>
<a href="http://www.cfmc.com/">http://www.cfmc.com/</a><BR>
<BR>
</SPAN></FONT>
</BODY>
</HTML>