Skip to content
Snippets Groups Projects
Commit cb197d76 authored by hajekd's avatar hajekd Committed by Sean Bright
Browse files

chan_sip.c: chan_sip unstable with TLS after asterisk start or reloads

Fixes random asterisk crash on start or reload with TLS phones.

ASTERISK-28034 #close
Reported-by: David Hajek

Change-Id: I2a859f97dc80c348e2fa56e918214ee29521c4ac
parent 5ae6c7bc
Branches
Tags
No related merge requests found
...@@ -2575,7 +2575,8 @@ static int sip_tcptls_write(struct ast_tcptls_session_instance *tcptls_session, ...@@ -2575,7 +2575,8 @@ static int sip_tcptls_write(struct ast_tcptls_session_instance *tcptls_session,
   
ao2_lock(tcptls_session); ao2_lock(tcptls_session);
   
if (!(th = ao2_t_find(threadt, &tmp, OBJ_POINTER, "ao2_find, getting sip_threadinfo in tcp helper thread")) || if (!tcptls_session->stream ||
!(th = ao2_t_find(threadt, &tmp, OBJ_POINTER, "ao2_find, getting sip_threadinfo in tcp helper thread")) ||
!(packet = ao2_alloc(sizeof(*packet), tcptls_packet_destructor)) || !(packet = ao2_alloc(sizeof(*packet), tcptls_packet_destructor)) ||
!(packet->data = ast_str_create(len))) { !(packet->data = ast_str_create(len))) {
goto tcptls_write_setup_error; goto tcptls_write_setup_error;
...@@ -3097,7 +3098,7 @@ static void *_sip_tcp_helper_thread(struct ast_tcptls_session_instance *tcptls_s ...@@ -3097,7 +3098,7 @@ static void *_sip_tcp_helper_thread(struct ast_tcptls_session_instance *tcptls_s
   
if (read(me->alert_pipe[0], &alert, sizeof(alert)) == -1) { if (read(me->alert_pipe[0], &alert, sizeof(alert)) == -1) {
ast_log(LOG_ERROR, "read() failed: %s\n", strerror(errno)); ast_log(LOG_ERROR, "read() failed: %s\n", strerror(errno));
continue; goto cleanup;
} }
   
switch (alert) { switch (alert) {
...@@ -3115,10 +3116,13 @@ static void *_sip_tcp_helper_thread(struct ast_tcptls_session_instance *tcptls_s ...@@ -3115,10 +3116,13 @@ static void *_sip_tcp_helper_thread(struct ast_tcptls_session_instance *tcptls_s
ast_log(LOG_WARNING, "Failure to write to tcp/tls socket\n"); ast_log(LOG_WARNING, "Failure to write to tcp/tls socket\n");
} }
ao2_t_ref(packet, -1, "tcptls packet sent, this is no longer needed"); ao2_t_ref(packet, -1, "tcptls packet sent, this is no longer needed");
} else {
goto cleanup;
} }
break; break;
default: default:
ast_log(LOG_ERROR, "Unknown tcptls thread alert '%u'\n", alert); ast_log(LOG_ERROR, "Unknown tcptls thread alert '%u'\n", alert);
goto cleanup;
} }
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment