#46685 [NEW]: SSL code should use select.
| From: | scott dot php at scottrix dot co dot uk | Date: | Wed, 26 Nov 2008 10:48:17 +0000 |
| Subject: | #46685 [NEW]: SSL code should use select. | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-131349@lists.php.net to get a copy of this message | ||
From: scott dot php at scottrix dot co dot uk
Operating system: Linux
PHP version: 5.2.6
PHP Bug Type: Performance problem
Bug description: SSL code should use select.
Description:
------------
We have had some problems with CPU usage using PHP test scripts on some
systems at work. Looking into the strace logs it appeared to be in a tight
loop doing lots of reads mostly getting an EAGAIN error. Looking into the
problem further it seems there are two locations in the file
ext/openssl/xp_ssl.c that were causing these "loops".
at line 223 (approx):
int retry = 1;
do {
nr_bytes = SSL_read(sslsock->ssl_handle, buf, count);
if (nr_bytes <= 0) {
retry = handle_ssl_error(stream, nr_bytes, 0 TSRMLS_CC);
stream->eof = (retry == 0 && errno != EAGAIN &&
SSL_pending(sslsock->ssl_handle));
} else {
/* we got the data */
break;
}
} while (retry);
and the loop around the lines (429):
if (n <= 0) {
retry = handle_ssl_error(stream, n, 1 TSRMLS_CC);
} else {
break;
}
They both involve SSL connections and I understand that one needs to be
very careful using select in this area since the socket is a layer away
from the SSL reading etc. However, the openssl code does come with some
examples on how to do this and I have created a patch that seemed to help a
lot in our case that I thought someone who knows more about php internals
would like to look at and maybe incorporate to some extent into future
releases. I will hopefully be able to attach the patch once I have
submitted the bug.
--
Edit bug report at http://bugs.php.net/?id=46685&edit=1
--
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=46685&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=46685&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=46685&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=46685&r=fixedcvs
Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=46685&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=46685&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=46685&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=46685&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=46685&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=46685&r=support
Expected behavior: http://bugs.php.net/fix.php?id=46685&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=46685&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=46685&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=46685&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=46685&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=46685&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=46685&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=46685&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=46685&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=46685&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=46685&r=mysqlcfg