]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Fixes issue with ast_tcptls_server_start failing on second attempt to bind.
authorDavid Vossel <dvossel@digium.com>
Fri, 20 May 2011 21:24:48 +0000 (21:24 +0000)
committerDavid Vossel <dvossel@digium.com>
Fri, 20 May 2011 21:24:48 +0000 (21:24 +0000)
(closes issue #19289)
Reported by: wdoekes
Patches:
      issue19289_delay_old_address_setting_tcptls.patch uploaded by wdoekes (license 717)

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

main/tcptls.c

index e5a335a1e5002a5f2dcaa2460d5e81a63aeb40b8..2b51b49c160c390e51df616ab25d5a7be6a704c4 100644 (file)
@@ -389,7 +389,8 @@ struct ast_tcptls_session_instance *ast_tcptls_client_create(struct ast_tcptls_s
                return NULL;
        }
 
-       desc->old_address = desc->remote_address;
+       /* If we return early, there is no connection */
+       desc->old_address.sin_family = 0;
 
        if (desc->accept_fd != -1)
                close(desc->accept_fd);
@@ -424,6 +425,8 @@ struct ast_tcptls_session_instance *ast_tcptls_client_create(struct ast_tcptls_s
        tcptls_session->parent->worker_fn = NULL;
        memcpy(&tcptls_session->remote_address, &desc->remote_address, sizeof(tcptls_session->remote_address));
 
+       /* Set current info */
+       desc->old_address = desc->remote_address;
        return tcptls_session;
 
 error:
@@ -445,7 +448,8 @@ void ast_tcptls_server_start(struct ast_tcptls_session_args *desc)
                return;
        }
        
-       desc->old_address = desc->local_address;
+       /* If we return early, there is no one listening */
+       desc->old_address.sin_family = 0;
        
        /* Shutdown a running server if there is one */
        if (desc->master != AST_PTHREADT_NULL) {
@@ -490,6 +494,9 @@ void ast_tcptls_server_start(struct ast_tcptls_session_args *desc)
                        strerror(errno));
                goto error;
        }
+
+       /* Set current info */
+       desc->old_address = desc->local_address;
        return;
 
 error: