Skip to content

Commit abde405

Browse files
committed
- #45808, stream_socket_enable_crypto() blocks and eats CPU
1 parent bd8d427 commit abde405

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

ext/openssl/xp_ssl.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -312,8 +312,12 @@ static inline int php_openssl_setup_crypto(php_stream *stream,
312312
SSL_METHOD *method;
313313

314314
if (sslsock->ssl_handle) {
315-
php_error_docref(NULL TSRMLS_CC, E_WARNING, "SSL/TLS already set-up for this stream");
316-
return -1;
315+
if (sslsock->s.is_blocked) {
316+
php_error_docref(NULL TSRMLS_CC, E_WARNING, "SSL/TLS already set-up for this stream");
317+
return -1;
318+
} else {
319+
return 0;
320+
}
317321
}
318322

319323
/* need to do slightly different things, based on client/server method,
@@ -435,7 +439,8 @@ static inline int php_openssl_enable_crypto(php_stream *stream,
435439
}
436440

437441
if (n <= 0) {
438-
retry = handle_ssl_error(stream, n, 1 TSRMLS_CC);
442+
retry = handle_ssl_error(stream, n, sslsock->is_client || sslsock->s.is_blocked TSRMLS_CC);
443+
439444
} else {
440445
break;
441446
}

0 commit comments

Comments
 (0)