summaryrefslogtreecommitdiff
path: root/main/manager.c
diff options
context:
space:
mode:
authorKevin Harwell <kharwell@digium.com>2017-08-15 13:12:10 -0500
committerKevin Harwell <kharwell@digium.com>2017-08-16 09:41:42 -0500
commitf919adac8d65ed2b54776259128b1252ffd461e6 (patch)
tree94c283a4c2d5d249f1a5486f8ff67e25adac4c5e /main/manager.c
parent0442fcb5869df3ba9e37fac5428897d2374f7e77 (diff)
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
Diffstat (limited to 'main/manager.c')
-rw-r--r--main/manager.c7
1 files changed, 4 insertions, 3 deletions
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");