]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Revert patch with accidental reversion of a previous patch
authorTerry Wilson <twilson@digium.com>
Wed, 16 Mar 2011 19:45:10 +0000 (19:45 +0000)
committerTerry Wilson <twilson@digium.com>
Wed, 16 Mar 2011 19:45:10 +0000 (19:45 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.6.2@310997 65c4cc65-6c06-0410-ace0-fbb531ad65f3

main/manager.c
main/tcptls.c

index eac123c143c37a0a0d887c382dad8caca980e469..5ab7a37e4c5a72204ce4c1355634c7b0856f6898 100644 (file)
@@ -228,6 +228,7 @@ struct mansession {
        struct mansession_session *session;
        FILE *f;
        int fd;
+       int write_error:1;
 };
 
 static AST_LIST_HEAD_STATIC(sessions, mansession_session);
@@ -964,11 +965,15 @@ struct ast_variable *astman_get_variables(const struct message *m)
  */
 static int send_string(struct mansession *s, char *string)
 {
-       if (s->f) {
-               return ast_careful_fwrite(s->f, s->fd, string, strlen(string), s->session->writetimeout);
-       } else {
-               return ast_careful_fwrite(s->session->f, s->session->fd, string, strlen(string), s->session->writetimeout);
+       int res;
+
+       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))) {
+               s->write_error = 1;
        }
+
+       return res;
 }
 
 /*!
@@ -3277,7 +3282,7 @@ static void *session_do(void *data)
 
        astman_append(&s, "Asterisk Call Manager/%s\r\n", AMI_VERSION); /* welcome prompt */
        for (;;) {
-               if ((res = do_message(&s)) < 0)
+               if ((res = do_message(&s)) < 0 || s.write_error)
                        break;
        }
        /* session is over, explain why and terminate */
index e5a335a1e5002a5f2dcaa2460d5e81a63aeb40b8..6c84762d5d6e4db43dfd5e171d98d9e947066c0f 100644 (file)
@@ -139,12 +139,8 @@ static void *handle_tcptls_connection(void *data)
        * open a FILE * as appropriate.
        */
        if (!tcptls_session->parent->tls_cfg) {
-               if ((tcptls_session->f = fdopen(tcptls_session->fd, "w+"))) {
-                       if(setvbuf(tcptls_session->f, NULL, _IONBF, 0)) {
-                               fclose(tcptls_session->f);
-                               tcptls_session->f = NULL;
-                       }
-               }
+               tcptls_session->f = fdopen(tcptls_session->fd, "w+");
+               setvbuf(tcptls_session->f, NULL, _IONBF, 0);
        }
 #ifdef DO_SSL
        else if ( (tcptls_session->ssl = SSL_new(tcptls_session->parent->tls_cfg->ssl_ctx)) ) {