diff options
author | Kevin P. Fleming <kpfleming@digium.com> | 2005-10-01 15:41:27 +0000 |
---|---|---|
committer | Kevin P. Fleming <kpfleming@digium.com> | 2005-10-01 15:41:27 +0000 |
commit | 9835bc4330133fbc283b40cb86e9c8d5c2392c59 (patch) | |
tree | 72102d76a9b39e80750a94d47b4cf7d6061d7841 /manager.c | |
parent | 270b98d2f4386422cb9a31f9b9570c1ee0638127 (diff) |
add ast_build_string_va(), which accepts a varargs list directly
ensure the _entire_ manager_event() output is either queued or sent via ast_carefulwrite()
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6708 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'manager.c')
-rwxr-xr-x | manager.c | 13 |
1 files changed, 7 insertions, 6 deletions
@@ -1473,13 +1473,16 @@ static int append_event(struct mansession *s, const char *str) int manager_event(int category, char *event, char *fmt, ...) { struct mansession *s; + char auth[80]; char tmp[4096]; - char auth[256]; + char *tmp_next = tmp; + size_t tmp_left = sizeof(tmp) - 2; va_list ap; - authority_to_str(category, auth, sizeof(auth)); + ast_build_string(&tmp_next, &tmp_left, "Event: %s\r\nPrivilege: %s\r\n", + event, authority_to_str(category, auth, sizeof(auth))); va_start(ap, fmt); - vsnprintf(tmp, sizeof(tmp) - 3, fmt, ap); + ast_build_string_va(&tmp_next, &tmp_left, fmt, ap); va_end(ap); strcat(tmp, "\r\n"); @@ -1492,11 +1495,9 @@ int manager_event(int category, char *event, char *fmt, ...) continue; ast_mutex_lock(&s->__lock); - ast_cli(s->fd, "Event: %s\r\n", event); - ast_cli(s->fd, "Privilege: %s\r\n", auth); if (s->busy) { append_event(s, tmp); - } else if (ast_carefulwrite(s->fd, tmp, strlen(tmp), 100) < 0) { + } else if (ast_carefulwrite(s->fd, tmp, sizeof(tmp) - tmp_left + 1, 100) < 0) { ast_log(LOG_WARNING, "Disconnecting slow (or gone) manager session!\n"); s->dead = 1; pthread_kill(s->t, SIGURG); |