Index: channels/chan_sip.c =================================================================== --- channels/chan_sip.c (revision 401662) +++ channels/chan_sip.c (working copy) @@ -3221,7 +3221,7 @@ goto cleanup; } } else { - timeout = -1; + timeout = 10000; } if (ast_str_strlen(tcptls_session->overflow_buf) == 0) { @@ -3231,6 +3231,10 @@ goto cleanup; } else if (res == 0) { /* timeout */ + if (ao2_ref(tcptls_session, 0) > 2) { + /* someone is using this tcptls_session, keep polling */ + continue; + } ast_debug(2, "SIP %s server timed out\n", tcptls_session->ssl ? "TLS": "TCP"); goto cleanup; }