tcptls.c: Don't close TCP client file descriptors more than once
ASTERISK-28430 #close Change-Id: Ib556b0a0c95cca939e956886214ec8d828d89606
This commit is contained in:
parent
61116d5dbc
commit
fa023cbfa0
|
@ -608,13 +608,8 @@ struct ast_tcptls_session_instance *ast_tcptls_client_start(struct ast_tcptls_se
|
||||||
return handle_tcptls_connection(tcptls_session);
|
return handle_tcptls_connection(tcptls_session);
|
||||||
|
|
||||||
client_start_error:
|
client_start_error:
|
||||||
if (desc) {
|
|
||||||
close(desc->accept_fd);
|
|
||||||
desc->accept_fd = -1;
|
|
||||||
}
|
|
||||||
ao2_ref(tcptls_session, -1);
|
ao2_ref(tcptls_session, -1);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ast_tcptls_session_instance *ast_tcptls_client_create(struct ast_tcptls_session_args *desc)
|
struct ast_tcptls_session_instance *ast_tcptls_client_create(struct ast_tcptls_session_args *desc)
|
||||||
|
@ -631,10 +626,6 @@ struct ast_tcptls_session_instance *ast_tcptls_client_create(struct ast_tcptls_s
|
||||||
/* If we return early, there is no connection */
|
/* If we return early, there is no connection */
|
||||||
ast_sockaddr_setnull(&desc->old_address);
|
ast_sockaddr_setnull(&desc->old_address);
|
||||||
|
|
||||||
if (desc->accept_fd != -1) {
|
|
||||||
close(desc->accept_fd);
|
|
||||||
}
|
|
||||||
|
|
||||||
fd = desc->accept_fd = socket(ast_sockaddr_is_ipv6(&desc->remote_address) ?
|
fd = desc->accept_fd = socket(ast_sockaddr_is_ipv6(&desc->remote_address) ?
|
||||||
AF_INET6 : AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
AF_INET6 : AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||||
if (desc->accept_fd < 0) {
|
if (desc->accept_fd < 0) {
|
||||||
|
@ -672,6 +663,9 @@ struct ast_tcptls_session_instance *ast_tcptls_client_create(struct ast_tcptls_s
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* From here on out, the iostream owns the accept_fd and it will take
|
||||||
|
* care of closing it when the iostream is closed */
|
||||||
|
|
||||||
tcptls_session->parent = desc;
|
tcptls_session->parent = desc;
|
||||||
tcptls_session->parent->worker_fn = NULL;
|
tcptls_session->parent->worker_fn = NULL;
|
||||||
ast_sockaddr_copy(&tcptls_session->remote_address,
|
ast_sockaddr_copy(&tcptls_session->remote_address,
|
||||||
|
|
Loading…
Reference in New Issue