mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-28 18:51:30 +00:00
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
This commit is contained in:
@@ -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");
|
||||
|
Reference in New Issue
Block a user