summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlia Alshanetsky <iliaa@php.net>2007-05-27 17:05:51 +0000
committerIlia Alshanetsky <iliaa@php.net>2007-05-27 17:05:51 +0000
commitd2ec6b60da260fa0061340645aa80ec77b6234e4 (patch)
tree771656d011d0ee9ae6d9b9f19c26a5c069598ca6
parentfaae3e9ecf55bbdb2d0f217016e8b59114b58f4c (diff)
downloadphp-git-d2ec6b60da260fa0061340645aa80ec77b6234e4.tar.gz
Fixed bug #41236 (Regression in timeout handling of non-blocking SSL
connections during reads and writes).
-rw-r--r--NEWS2
-rw-r--r--ext/openssl/xp_ssl.c12
2 files changed, 8 insertions, 6 deletions
diff --git a/NEWS b/NEWS
index 123c773a3f..7fddee2aad 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,8 @@ PHP NEWS
- Fixed bug #41511 (Compile failure under IRIX 6.5.30 building md5.c). (Jani)
- Fixed bug #41504 (json_decode() incorrectly decodes JSON arrays with empty
string keys). (Ilia)
+- Fixed bug #41236 (Regression in timeout handling of non-blocking SSL
+ connections during reads and writes). (Ilia)
24 May 2007, PHP 5.2.3RC1
- Changed CGI install target to php-cgi and 'make install' to install CLI
diff --git a/ext/openssl/xp_ssl.c b/ext/openssl/xp_ssl.c
index f0bad65546..674764ce07 100644
--- a/ext/openssl/xp_ssl.c
+++ b/ext/openssl/xp_ssl.c
@@ -84,7 +84,7 @@ static int is_http_stream_talking_to_iis(php_stream *stream TSRMLS_DC)
return 0;
}
-static int handle_ssl_error(php_stream *stream, int nr_bytes TSRMLS_DC)
+static int handle_ssl_error(php_stream *stream, int nr_bytes, zend_bool is_init TSRMLS_DC)
{
php_openssl_netstream_data_t *sslsock = (php_openssl_netstream_data_t*)stream->abstract;
int err = SSL_get_error(sslsock->ssl_handle, nr_bytes);
@@ -104,7 +104,7 @@ static int handle_ssl_error(php_stream *stream, int nr_bytes TSRMLS_DC)
/* re-negotiation, or perhaps the SSL layer needs more
* packets: retry in next iteration */
errno = EAGAIN;
- retry = 1;
+ retry = is_init ? 1 : sslsock->s.is_blocked;
break;
case SSL_ERROR_SYSCALL:
if (ERR_peek_error() == 0) {
@@ -193,7 +193,7 @@ static size_t php_openssl_sockop_write(php_stream *stream, const char *buf, size
didwrite = SSL_write(sslsock->ssl_handle, buf, count);
if (didwrite <= 0) {
- retry = handle_ssl_error(stream, didwrite TSRMLS_CC);
+ retry = handle_ssl_error(stream, didwrite, 0 TSRMLS_CC);
} else {
break;
}
@@ -226,7 +226,7 @@ static size_t php_openssl_sockop_read(php_stream *stream, char *buf, size_t coun
nr_bytes = SSL_read(sslsock->ssl_handle, buf, count);
if (nr_bytes <= 0) {
- retry = handle_ssl_error(stream, nr_bytes TSRMLS_CC);
+ retry = handle_ssl_error(stream, nr_bytes, 0 TSRMLS_CC);
stream->eof = (retry == 0 && errno != EAGAIN && !SSL_pending(sslsock->ssl_handle));
} else {
@@ -373,7 +373,7 @@ static inline int php_openssl_setup_crypto(php_stream *stream,
}
if (!SSL_set_fd(sslsock->ssl_handle, sslsock->s.socket)) {
- handle_ssl_error(stream, 0 TSRMLS_CC);
+ handle_ssl_error(stream, 0, 1 TSRMLS_CC);
}
if (cparam->inputs.session) {
@@ -428,7 +428,7 @@ static inline int php_openssl_enable_crypto(php_stream *stream,
}
if (n <= 0) {
- retry = handle_ssl_error(stream, n TSRMLS_CC);
+ retry = handle_ssl_error(stream, n, 1 TSRMLS_CC);
} else {
break;
}