Merged revisions 320338 via svnmerge from
authorDavid Vossel <dvossel@digium.com>
Fri, 20 May 2011 21:40:19 +0000 (21:40 +0000)
committerDavid Vossel <dvossel@digium.com>
Fri, 20 May 2011 21:40:19 +0000 (21:40 +0000)
https://origsvn.digium.com/svn/asterisk/branches/1.8

................
  r320338 | dvossel | 2011-05-20 16:39:36 -0500 (Fri, 20 May 2011) | 14 lines

  Merged revisions 320271 via svnmerge from
  https://origsvn.digium.com/svn/asterisk/branches/1.6.2

  ........
    r320271 | dvossel | 2011-05-20 16:24:48 -0500 (Fri, 20 May 2011) | 8 lines

    Fixes issue with ast_tcptls_server_start failing on second attempt to bind.

    (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/trunk@320340 65c4cc65-6c06-0410-ace0-fbb531ad65f3

main/tcptls.c

index 135f638..8159a49 100644 (file)
@@ -417,7 +417,8 @@ struct ast_tcptls_session_instance *ast_tcptls_client_create(struct ast_tcptls_s
                return NULL;
        }
 
-       ast_sockaddr_copy(&desc->old_address, &desc->remote_address);
+       /* If we return early, there is no connection */
+       ast_sockaddr_setnull(&desc->old_address);
 
        if (desc->accept_fd != -1)
                close(desc->accept_fd);
@@ -454,6 +455,8 @@ struct ast_tcptls_session_instance *ast_tcptls_client_create(struct ast_tcptls_s
        ast_sockaddr_copy(&tcptls_session->remote_address,
                          &desc->remote_address);
 
+       /* Set current info */
+       ast_sockaddr_copy(&desc->old_address, &desc->remote_address);
        return tcptls_session;
 
 error:
@@ -475,7 +478,8 @@ void ast_tcptls_server_start(struct ast_tcptls_session_args *desc)
                return;
        }
 
-       ast_sockaddr_copy(&desc->old_address, &desc->local_address);
+       /* If we return early, there is no one listening */
+       ast_sockaddr_setnull(&desc->old_address);
 
        /* Shutdown a running server if there is one */
        if (desc->master != AST_PTHREADT_NULL) {
@@ -521,6 +525,10 @@ void ast_tcptls_server_start(struct ast_tcptls_session_args *desc)
                        strerror(errno));
                goto error;
        }
+
+       /* Set current info */
+       ast_sockaddr_copy(&desc->old_address, &desc->local_address);
+
        return;
 
 error: