]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Merged revisions 311140 via svnmerge from
authorMatthew Nicholson <mnicholson@digium.com>
Thu, 17 Mar 2011 15:00:33 +0000 (15:00 +0000)
committerMatthew Nicholson <mnicholson@digium.com>
Thu, 17 Mar 2011 15:00:33 +0000 (15:00 +0000)
https://origsvn.digium.com/svn/asterisk/branches/1.6.2

........
  r311140 | mnicholson | 2011-03-17 09:58:52 -0500 (Thu, 17 Mar 2011) | 4 lines

  Don't write items to the manager socket twice.

  AST-2011-003

  (closes issue 0018987)
  Reported by: ks-steven
........

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@311141 65c4cc65-6c06-0410-ace0-fbb531ad65f3

main/manager.c

index edda8f5f36a1e689c9a9ba66243f9ba675819468..9734d0ea73a9f5e0e65bd410fdd6aaa46e2622cd 100644 (file)
@@ -1846,6 +1846,9 @@ int ast_hook_send_action(struct manager_custom_hook *hook, const char *msg)
 static int send_string(struct mansession *s, char *string)
 {
        int res;
+       FILE *f = s->f ? s->f : s->session->f;
+       int fd = s->f ? s->fd : s->session->fd;
+
        /* It's a result from one of the hook's action invocation */
        if (s->hook) {
                /*
@@ -1854,9 +1857,9 @@ static int send_string(struct mansession *s, char *string)
                 */
                s->hook->helper(EVENT_FLAG_HOOKRESPONSE, "HookResponse", string);
                return 0;
-       }       else if (s->f && (res = ast_careful_fwrite(s->f, s->fd, string, strlen(string), s->session->writetimeout))) {
-               s->write_error = 1;
-       } else if ((res = ast_careful_fwrite(s->session->f, s->session->fd, string, strlen(string), s->session->writetimeout))) {
+       }
+       
+       if ((res = ast_careful_fwrite(f, fd, string, strlen(string), s->session->writetimeout))) {
                s->write_error = 1;
        }