[Asterisk-code-review] res/res_stasis: Fixed wrong StasisEnd timestamp (...asterisk[master])

sungtae kim asteriskteam at digium.com
Sun Mar 10 17:56:45 CDT 2019


sungtae kim has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/11126


Change subject: res/res_stasis: Fixed wrong StasisEnd timestamp
......................................................................

res/res_stasis: Fixed wrong StasisEnd timestamp

Because StasisEnd's timestamp created it's own timestamp, it makes
wrong timestamp, compare to other channel event(ChannelDestroyed).
Fixed to getting a timestamp from the Channel's timestamp.

ASTERISK-28333

Change-Id: I5eb8380fc472f1100535a6bc4983c64767026116
---
M res/res_stasis.c
1 file changed, 9 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/26/11126/1

diff --git a/res/res_stasis.c b/res/res_stasis.c
index 4b7c3ed..c79ed06 100644
--- a/res/res_stasis.c
+++ b/res/res_stasis.c
@@ -116,16 +116,23 @@
 		const struct stasis_message_sanitizer *sanitize)
 {
 	struct ast_channel_blob *payload = stasis_message_data(message);
+	struct ast_json *msg;
 
 	if (sanitize && sanitize->channel_snapshot &&
 			sanitize->channel_snapshot(payload->snapshot)) {
 		return NULL;
 	}
 
-	return ast_json_pack("{s: s, s: o, s: o}",
+	msg = ast_json_pack("{s: s, s: O, s: o}",
 		"type", "StasisEnd",
-		"timestamp", ast_json_timeval(ast_tvnow(), NULL),
+		"timestamp", ast_json_object_get(payload->blob, "timestamp"),
 		"channel", ast_channel_snapshot_to_json(payload->snapshot, sanitize));
+	if (!msg) {
+		ast_log(LOG_ERROR, "Failed to pack JSON for StasisEnd message\n");
+		return NULL;
+	}
+
+	return msg;
 }
 
 STASIS_MESSAGE_TYPE_DEFN_LOCAL(end_message_type,

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/11126
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: I5eb8380fc472f1100535a6bc4983c64767026116
Gerrit-Change-Number: 11126
Gerrit-PatchSet: 1
Gerrit-Owner: sungtae kim <pchero21 at gmail.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20190310/db733df3/attachment.html>


More information about the asterisk-code-review mailing list