iliaa Tue Dec 5 01:39:08 2006 UTC
Modified files: (Branch: PHP_5_2)
/php-src/ext/openssl xp_ssl.c
/php-src NEWS
Log:
Fixed bug #39571 (timeout ssl:// connections).
http://cvs.php.net/viewvc.cgi/php-src/ext/openssl/xp_ssl.c?r1=1.22.2.3.2.2&r2=1.22.2.3.2.3&diff_format=u
Index: php-src/ext/openssl/xp_ssl.c
diff -u php-src/ext/openssl/xp_ssl.c:1.22.2.3.2.2
php-src/ext/openssl/xp_ssl.c:1.22.2.3.2.3
--- php-src/ext/openssl/xp_ssl.c:1.22.2.3.2.2 Thu Oct 5 00:38:00 2006
+++ php-src/ext/openssl/xp_ssl.c Tue Dec 5 01:39:07 2006
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: xp_ssl.c,v 1.22.2.3.2.2 2006/10/05 00:38:00 iliaa Exp $ */
+/* $Id: xp_ssl.c,v 1.22.2.3.2.3 2006/12/05 01:39:07 iliaa Exp $ */
#include "php.h"
#include "ext/standard/file.h"
@@ -99,7 +99,7 @@
/* re-negotiation, or perhaps the SSL layer needs more
* packets: retry in next iteration */
errno = EAGAIN;
- retry = sslsock->s.is_blocked;
+ retry = 1;
break;
case SSL_ERROR_SYSCALL:
if (ERR_peek_error() == 0) {
@@ -386,6 +386,9 @@
int n, retry = 1;
if (cparam->inputs.activate && !sslsock->ssl_active) {
+ float timeout = sslsock->s.timeout.tv_sec +
sslsock->s.timeout.tv_usec / 1000000;
+ int blocked = sslsock->s.is_blocked;
+
if (!sslsock->state_set) {
if (sslsock->is_client) {
SSL_set_connect_state(sslsock->ssl_handle);
@@ -395,9 +398,23 @@
sslsock->state_set = 1;
}
+ if (sslsock->is_client && SUCCESS ==
php_set_sock_blocking(sslsock->s.socket, 0 TSRMLS_CC)) {
+ sslsock->s.is_blocked = 0;
+ }
do {
if (sslsock->is_client) {
+ struct timeval tvs, tve;
+ struct timezone tz;
+
+ gettimeofday(&tvs, &tz);
n = SSL_connect(sslsock->ssl_handle);
+ gettimeofday(&tve, &tz);
+
+ timeout -= (tve.tv_sec + tve.tv_usec / 1000000)
- (tvs.tv_sec + tvs.tv_usec / 1000000);
+ if (timeout < 0) {
+ php_error_docref(NULL TSRMLS_CC,
E_WARNING, "SSL: connection timeout");
+ return -1;
+ }
} else {
n = SSL_accept(sslsock->ssl_handle);
}
@@ -409,6 +426,10 @@
}
} while (retry);
+ if (sslsock->is_client && sslsock->s.is_blocked != blocked &&
SUCCESS == php_set_sock_blocking(sslsock->s.socket, blocked TSRMLS_CC)) {
+ sslsock->s.is_blocked = blocked;
+ }
+
if (n == 1) {
X509 *peer_cert;
@@ -741,8 +762,8 @@
memset(sslsock, 0, sizeof(*sslsock));
sslsock->s.is_blocked = 1;
- sslsock->s.timeout.tv_sec = FG(default_socket_timeout);
- sslsock->s.timeout.tv_usec = 0;
+ sslsock->s.timeout.tv_sec = timeout->tv_sec;
+ sslsock->s.timeout.tv_usec = timeout->tv_usec;
/* we don't know the socket until we have determined if we are binding
or
* connecting */
http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.400&r2=1.2027.2.547.2.401&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.547.2.400 php-src/NEWS:1.2027.2.547.2.401
--- php-src/NEWS:1.2027.2.547.2.400 Tue Dec 5 01:25:29 2006
+++ php-src/NEWS Tue Dec 5 01:39:07 2006
@@ -73,6 +73,7 @@
- Fixed bug #39602 (Invalid session.save_handler crashes PHP). (Dmitry)
- Fixed bug #39583 (ftp_put() does not change transfer mode to ASCII). (Tony)
- Fixed bug #39576 (array_walk() doesn't separate userdata zval). (Tony)
+- Fixed bug #39571 (timeout ssl:// connections). (Ilia)
- Fixed bug #39564 (PDO::errorInfo() returns inconsistent information when
sqlite3_step() fails). (Tony)
- Fixed bug #39548 (ZMSG_LOG_SCRIPT_NAME not routed to OutputDebugString()
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php