Updated to fix async reads/writes.

This commit is contained in:
Brad Broerman 2013-01-21 11:35:58 -05:00
parent 277efaffab
commit fae955a1ae

View file

@ -240,7 +240,7 @@ static size_t php_openssl_sockop_write(php_stream *stream, const char *buf, size
if( errno == EAGAIN && ( err == SSL_ERROR_WANT_READ || SSL_ERROR_WANT_WRITE ) ) retry = 1; if( errno == EAGAIN && ( err == SSL_ERROR_WANT_READ || SSL_ERROR_WANT_WRITE ) ) retry = 1;
if( retry ) { if( retry && blocked ) {
php_pollfd_for(sslsock->s.socket, (err == SSL_ERROR_WANT_READ) ? php_pollfd_for(sslsock->s.socket, (err == SSL_ERROR_WANT_READ) ?
(POLLIN|POLLPRI) : (POLLOUT|POLLPRI), has_timeout ? &left_time : NULL); (POLLIN|POLLPRI) : (POLLOUT|POLLPRI), has_timeout ? &left_time : NULL);
} }
@ -249,9 +249,10 @@ static size_t php_openssl_sockop_write(php_stream *stream, const char *buf, size
if( err == SSL_ERROR_NONE ) if( err == SSL_ERROR_NONE )
break; break;
if( blocked ) {
php_pollfd_for(sslsock->s.socket, (err == SSL_ERROR_WANT_READ) ? php_pollfd_for(sslsock->s.socket, (err == SSL_ERROR_WANT_READ) ?
(POLLIN|POLLPRI) : (POLLOUT|POLLPRI), has_timeout ? &left_time : NULL); (POLLIN|POLLPRI) : (POLLOUT|POLLPRI), has_timeout ? &left_time : NULL);
}
} }
} while(retry); } while(retry);
@ -347,7 +348,7 @@ static size_t php_openssl_sockop_read(php_stream *stream, char *buf, size_t coun
stream->eof = (retry == 0 && errno != EAGAIN && !SSL_pending(sslsock->ssl_handle)); stream->eof = (retry == 0 && errno != EAGAIN && !SSL_pending(sslsock->ssl_handle));
if( retry ) { if( retry && blocked ) {
php_pollfd_for(sslsock->s.socket, (err == SSL_ERROR_WANT_WRITE) ? php_pollfd_for(sslsock->s.socket, (err == SSL_ERROR_WANT_WRITE) ?
(POLLOUT|POLLPRI) : (POLLIN|POLLPRI), has_timeout ? &left_time : NULL); (POLLOUT|POLLPRI) : (POLLIN|POLLPRI), has_timeout ? &left_time : NULL);
} }
@ -358,9 +359,10 @@ static size_t php_openssl_sockop_read(php_stream *stream, char *buf, size_t coun
if( err == SSL_ERROR_NONE ) if( err == SSL_ERROR_NONE )
break; break;
if( blocked ) {
php_pollfd_for(sslsock->s.socket, (err == SSL_ERROR_WANT_WRITE) ? php_pollfd_for(sslsock->s.socket, (err == SSL_ERROR_WANT_WRITE) ?
(POLLOUT|POLLPRI) : (POLLIN|POLLPRI), has_timeout ? &left_time : NULL); (POLLOUT|POLLPRI) : (POLLIN|POLLPRI), has_timeout ? &left_time : NULL);
}
} }
} while (retry); } while (retry);
@ -373,9 +375,7 @@ static size_t php_openssl_sockop_read(php_stream *stream, char *buf, size_t coun
php_set_sock_blocking(sslsock->s.socket, 1 TSRMLS_CC); php_set_sock_blocking(sslsock->s.socket, 1 TSRMLS_CC);
sslsock->s.is_blocked = 1; sslsock->s.is_blocked = 1;
} }
} } else {
else
{
nr_bytes = php_stream_socket_ops.read(stream, buf, count TSRMLS_CC); nr_bytes = php_stream_socket_ops.read(stream, buf, count TSRMLS_CC);
} }
@ -1104,3 +1104,4 @@ php_stream *php_openssl_ssl_socket_factory(const char *proto, long protolen,
* vim<600: noet sw=4 ts=4 * vim<600: noet sw=4 ts=4
*/ */