File tree 3 files changed +14
-5
lines changed
3 files changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -244,6 +244,7 @@ static void ssl_close_sockets(pj_ssl_sock_t *ssock)
244
244
static pj_bool_t on_handshake_complete (pj_ssl_sock_t * ssock ,
245
245
pj_status_t status )
246
246
{
247
+ ssock -> handshake_status = status ;
247
248
/* Cancel handshake timer */
248
249
if (ssock -> timer .id == TIMER_HANDSHAKE_TIMEOUT ) {
249
250
pj_timer_heap_cancel (ssock -> param .timer_heap , & ssock -> timer );
Original file line number Diff line number Diff line change @@ -112,6 +112,7 @@ struct pj_ssl_sock_t
112
112
pj_ioqueue_op_key_t shutdown_op_key ;
113
113
pj_timer_entry timer ;
114
114
pj_status_t verify_status ;
115
+ pj_status_t handshake_status ;
115
116
116
117
pj_bool_t is_closing ;
117
118
unsigned long last_err ;
Original file line number Diff line number Diff line change @@ -1714,13 +1714,20 @@ static void ssl_reset_sock_state(pj_ssl_sock_t *ssock)
1714
1714
* Avoid calling SSL_shutdown() if handshake wasn't completed.
1715
1715
* OpenSSL 1.0.2f complains if SSL_shutdown() is called during an
1716
1716
* SSL handshake, while previous versions always return 0.
1717
+ * Call SSL_shutdown() when there is a timeout handshake failure or
1718
+ * the last error is not SSL_ERROR_SYSCALL and not SSL_ERROR_SSL.
1717
1719
*/
1718
1720
if (ossock -> ossl_ssl && SSL_in_init (ossock -> ossl_ssl ) == 0 ) {
1719
- int ret = SSL_shutdown (ossock -> ossl_ssl );
1720
- if (ret == 0 ) {
1721
- /* SSL_shutdown will potentially trigger a bunch of
1722
- * data to dump to the socket */
1723
- post_unlock_flush_circ_buf = 1 ;
1721
+ if (ssock -> handshake_status == PJ_ETIMEDOUT ||
1722
+ (ssock -> last_err != SSL_ERROR_SYSCALL &&
1723
+ ssock -> last_err != SSL_ERROR_SSL ))
1724
+ {
1725
+ int ret = SSL_shutdown (ossock -> ossl_ssl );
1726
+ if (ret == 0 ) {
1727
+ /* SSL_shutdown will potentially trigger a bunch of
1728
+ * data to dump to the socket */
1729
+ post_unlock_flush_circ_buf = 1 ;
1730
+ }
1724
1731
}
1725
1732
}
1726
1733
You can’t perform that action at this time.
0 commit comments