From f919adac8d65ed2b54776259128b1252ffd461e6 Mon Sep 17 00:00:00 2001 From: Kevin Harwell Date: Tue, 15 Aug 2017 13:12:10 -0500 Subject: manager: hook event is not being raised When the iostream code went in it introduced a conditional that made it so the hook event was not being raised even if a hook is present. This patch adds a check to see if a hook is present in astman_append. If so then call into the send_string function, which in turn raises the even for specified hook. Also updated the ami hooks unit test, so the test could be automated. ASTERISK-27200 #close Change-Id: Iff37f02f9708195d8f23e68f959d6eab720e1e36 --- main/manager.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'main/manager.c') diff --git a/main/manager.c b/main/manager.c index d16a69278..e67efe3f3 100644 --- a/main/manager.c +++ b/main/manager.c @@ -2905,14 +2905,13 @@ int ast_hook_send_action(struct manager_custom_hook *hook, const char *msg) return ret; } - /*! * helper function to send a string to the socket. * Return -1 on error (e.g. buffer full). */ static int send_string(struct mansession *s, char *string) { - struct ast_iostream *stream = s->stream ? s->stream : s->session->stream; + struct ast_iostream *stream; int len, res; /* It's a result from one of the hook's action invocation */ @@ -2925,6 +2924,8 @@ static int send_string(struct mansession *s, char *string) return 0; } + stream = s->stream ? s->stream : s->session->stream; + len = strlen(string); ast_iostream_set_timeout_inactivity(stream, s->session->writetimeout); res = ast_iostream_write(stream, string, len); @@ -2971,7 +2972,7 @@ void astman_append(struct mansession *s, const char *fmt, ...) return; } - if (s->tcptls_session != NULL && s->tcptls_session->stream != NULL) { + if (s->hook || (s->tcptls_session != NULL && s->tcptls_session->stream != NULL)) { send_string(s, ast_str_buffer(buf)); } else { ast_verbose("No connection stream in astman_append, should not happen\n"); -- cgit v1.2.3