Re: [PHP-CVS] svn: /php/php-src/trunk/ Zend/zend.c Zend/zend_compile.c Zend/zend_globals.h Zend/zend_language_scanner.c Zend/zend_language_scanner.h Zend/zend_language_scanner.l Zend/zend_language_sca

2010-12-22 Thread Moriyoshi Koizumi
Okay, I'm gonna take a look into it.  Thanks.

Moriyoshi

On Tue, Dec 21, 2010 at 10:39 PM, Antony Dovgal t...@daylessday.org wrote:
 To reproduce, use the following configure line:
 ./configure --enable-exif

 On 12/21/2010 12:34 PM, Antony Dovgal wrote:
 ext/exif doesn't compile after this patch because of this:

 ext/exif/exif.o: In function `OnUpdateEncode':
 /local/qa/HEAD_non-ZTS/ext/exif/exif.c:169: undefined reference to 
 `zend_multibyte_check_encoding_list'
 ext/exif/exif.o: In function `OnUpdateDecode':
 /local/qa/HEAD_non-ZTS/ext/exif/exif.c:178: undefined reference to 
 `zend_multibyte_check_encoding_list'

 And if I change the code to use zend_multibyte_fetch_encoding(), the error 
 messages are back:
 ./sapi/cli/php -v
 PHP Warning:  PHP Startup: Illegal encoding ignored: 'ISO-8859-15' in 
 Unknown on line 0
 PHP Warning:  PHP Startup: Illegal encoding ignored: 'UCS-2BE' in Unknown on 
 line 0
 PHP Warning:  PHP Startup: Illegal encoding ignored: 'UCS-2LE' in Unknown on 
 line 0
 PHP Warning:  PHP Startup: Illegal encoding ignored: 'JIS' in Unknown on 
 line 0
 PHP Warning:  PHP Startup: Illegal encoding ignored: 'JIS' in Unknown on 
 line 0
 PHP 5.3.99-dev (cli) (built: Dec 21 2010 00:21:28) (DEBUG)
 Copyright (c) 1997-2010 The PHP Group
 Zend Engine v2.4.0, Copyright (c) 1998-2010 Zend Technologies

 --
 Wbr,
 Antony Dovgal
 ---
 http://pinba.org - realtime statistics for PHP


--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] svn: /php/php-src/trunk/ext/exif/ exif.c

2010-12-22 Thread Moriyoshi Koizumi
moriyoshiWed, 22 Dec 2010 10:25:33 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=306572

Log:
- Fix build.

Changed paths:
U   php/php-src/trunk/ext/exif/exif.c

Modified: php/php-src/trunk/ext/exif/exif.c
===
--- php/php-src/trunk/ext/exif/exif.c   2010-12-22 06:50:39 UTC (rev 306571)
+++ php/php-src/trunk/ext/exif/exif.c   2010-12-22 10:25:33 UTC (rev 306572)
@@ -166,18 +166,30 @@

 ZEND_INI_MH(OnUpdateEncode)
 {
-   if (new_value  strlen(new_value)  
!zend_multibyte_check_encoding_list(new_value TSRMLS_CC)) {
-   php_error_docref(NULL TSRMLS_CC, E_WARNING, Illegal encoding 
ignored: '%s', new_value);
-   return FAILURE;
+   if (new_value  new_value_length) {
+   const zend_encoding **return_list;
+   size_t return_size;
+   if (FAILURE == zend_multibyte_parse_encoding_list(new_value, 
new_value_length,
+   return_list, return_size, 0 TSRMLS_CC)) {
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, Illegal 
encoding ignored: '%s', new_value);
+   return FAILURE;
+   }
+   efree(return_list);
}
return OnUpdateString(entry, new_value, new_value_length, mh_arg1, 
mh_arg2, mh_arg3, stage TSRMLS_CC);
 }

 ZEND_INI_MH(OnUpdateDecode)
 {
-   if (!zend_multibyte_check_encoding_list(new_value TSRMLS_CC)) {
-   php_error_docref(NULL TSRMLS_CC, E_WARNING, Illegal encoding 
ignored: '%s', new_value);
-   return FAILURE;
+   if (new_value) {
+   const zend_encoding **return_list;
+   size_t return_size;
+   if (FAILURE == zend_multibyte_parse_encoding_list(new_value, 
new_value_length,
+   return_list, return_size, 0 TSRMLS_CC)) {
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, Illegal 
encoding ignored: '%s', new_value);
+   return FAILURE;
+   }
+   efree(return_list);
}
return OnUpdateString(entry, new_value, new_value_length, mh_arg1, 
mh_arg2, mh_arg3, stage TSRMLS_CC);
 }

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-CVS] svn: /php/php-src/trunk/ext/exif/ exif.c

2010-12-22 Thread Antony Dovgal
On 12/22/2010 01:25 PM, Moriyoshi Koizumi wrote:
 moriyoshiWed, 22 Dec 2010 10:25:33 +
 
 Revision: http://svn.php.net/viewvc?view=revisionrevision=306572
 
 Log:
 - Fix build.

That does indeed fix the build, but the error messages are still there:
./sapi/cli/php -v
PHP Warning:  PHP Startup: Illegal encoding ignored: 'ISO-8859-15' in Unknown 
on line 0
PHP Warning:  PHP Startup: Illegal encoding ignored: 'UCS-2BE' in Unknown on 
line 0
PHP Warning:  PHP Startup: Illegal encoding ignored: 'UCS-2LE' in Unknown on 
line 0
PHP Warning:  PHP Startup: Illegal encoding ignored: 'JIS' in Unknown on line 0
PHP Warning:  PHP Startup: Illegal encoding ignored: 'JIS' in Unknown on line 0
PHP 5.3.99-dev (cli) (built: Dec 22 2010 00:21:29) (DEBUG)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2010 Zend Technologies

-- 
Wbr,
Antony Dovgal
---
http://pinba.org - realtime statistics for PHP

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] svn: /php/win-installer/trunk/ PHPInstallerBase52.wxs PHPInstallerBase52NTS.wxs PHPInstallerBase53.wxs PHPInstallerBase53NTS.wxs PHPInstallerBase60.wxs PHPInstallerBase60NTS.wxs

2010-12-22 Thread John Mertic
jmertic  Wed, 22 Dec 2010 15:53:33 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=306573

Log:
Bug 12595 - Fix problem where only the first argument to the php script is 
passed; now support up to 9 arguments.

Bug: http://bugs.php.net/12595 (Open) $argv passing
  
Changed paths:
U   php/win-installer/trunk/PHPInstallerBase52.wxs
U   php/win-installer/trunk/PHPInstallerBase52NTS.wxs
U   php/win-installer/trunk/PHPInstallerBase53.wxs
U   php/win-installer/trunk/PHPInstallerBase53NTS.wxs
U   php/win-installer/trunk/PHPInstallerBase60.wxs
U   php/win-installer/trunk/PHPInstallerBase60NTS.wxs

Modified: php/win-installer/trunk/PHPInstallerBase52.wxs
===
--- php/win-installer/trunk/PHPInstallerBase52.wxs  2010-12-22 10:25:33 UTC 
(rev 306572)
+++ php/win-installer/trunk/PHPInstallerBase52.wxs  2010-12-22 15:53:33 UTC 
(rev 306573)
@@ -197,7 +197,7 @@
   Sequence=10
   Command=Run
   Target=[!file13]
-  Argument=quot;%1quot;/
+  Argument=quot;%1quot; quot;%2quot; quot;%3quot; 
quot;%4quot; quot;%5quot; quot;%6quot; quot;%7quot; quot;%8quot; 
quot;%9quot;/
   /Extension
 /ProgId
   /Component

Modified: php/win-installer/trunk/PHPInstallerBase52NTS.wxs
===
--- php/win-installer/trunk/PHPInstallerBase52NTS.wxs   2010-12-22 10:25:33 UTC 
(rev 306572)
+++ php/win-installer/trunk/PHPInstallerBase52NTS.wxs   2010-12-22 15:53:33 UTC 
(rev 306573)
@@ -175,7 +175,7 @@
   Sequence=10
   Command=Run
   Target=[!file13]
-  Argument=quot;%1quot;/
+  Argument=quot;%1quot; quot;%2quot; quot;%3quot; 
quot;%4quot; quot;%5quot; quot;%6quot; quot;%7quot; quot;%8quot; 
quot;%9quot;/
   /Extension
 /ProgId
   /Component

Modified: php/win-installer/trunk/PHPInstallerBase53.wxs
===
--- php/win-installer/trunk/PHPInstallerBase53.wxs  2010-12-22 10:25:33 UTC 
(rev 306572)
+++ php/win-installer/trunk/PHPInstallerBase53.wxs  2010-12-22 15:53:33 UTC 
(rev 306573)
@@ -196,8 +196,8 @@
 Verb Id=open
   Sequence=10
   Command=Run
-  Target=[!file13]
-  Argument=quot;%1quot;/
+  Target=[!file13]
+  Argument=quot;%1quot; quot;%2quot; quot;%3quot; 
quot;%4quot; quot;%5quot; quot;%6quot; quot;%7quot; quot;%8quot; 
quot;%9quot;/
   /Extension
 /ProgId
   /Component

Modified: php/win-installer/trunk/PHPInstallerBase53NTS.wxs
===
--- php/win-installer/trunk/PHPInstallerBase53NTS.wxs   2010-12-22 10:25:33 UTC 
(rev 306572)
+++ php/win-installer/trunk/PHPInstallerBase53NTS.wxs   2010-12-22 15:53:33 UTC 
(rev 306573)
@@ -175,7 +175,7 @@
   Sequence=10
   Command=Run
   Target=[!file13]
-  Argument=quot;%1quot;/
+  Argument=quot;%1quot; quot;%2quot; quot;%3quot; 
quot;%4quot; quot;%5quot; quot;%6quot; quot;%7quot; quot;%8quot; 
quot;%9quot;/
   /Extension
 /ProgId
   /Component

Modified: php/win-installer/trunk/PHPInstallerBase60.wxs
===
--- php/win-installer/trunk/PHPInstallerBase60.wxs  2010-12-22 10:25:33 UTC 
(rev 306572)
+++ php/win-installer/trunk/PHPInstallerBase60.wxs  2010-12-22 15:53:33 UTC 
(rev 306573)
@@ -197,7 +197,7 @@
   Sequence=10
   Command=Run
   Target=[!file13]
-  Argument=quot;%1quot;/
+  Argument=quot;%1quot; quot;%2quot; quot;%3quot; 
quot;%4quot; quot;%5quot; quot;%6quot; quot;%7quot; quot;%8quot; 
quot;%9quot;/
   /Extension
 /ProgId
   /Component

Modified: php/win-installer/trunk/PHPInstallerBase60NTS.wxs
===
--- php/win-installer/trunk/PHPInstallerBase60NTS.wxs   2010-12-22 10:25:33 UTC 
(rev 306572)
+++ php/win-installer/trunk/PHPInstallerBase60NTS.wxs   2010-12-22 15:53:33 UTC 
(rev 306573)
@@ -175,7 +175,7 @@
   Sequence=10
   Command=Run
   Target=[!file13]
-  Argument=quot;%1quot;/
+  Argument=quot;%1quot; quot;%2quot; quot;%3quot; 
quot;%4quot; quot;%5quot; quot;%6quot; quot;%7quot; quot;%8quot; 
quot;%9quot;/
   /Extension
 /ProgId
   /Component

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[PHP-CVS] svn: /php/win-installer/trunk/ PHPInstallerScripts52.vbs PHPInstallerScripts53.vbs PHPInstallerScripts60.vbs

2010-12-22 Thread John Mertic
jmertic  Wed, 22 Dec 2010 16:03:43 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=306574

Log:
Bug 52753 - Comment out changing '\' to '/' in the path to the PHP dll/exe 
since it causes an invalid http.conf file

Bug: http://bugs.php.net/52753 (Assigned) With proposed fix: use of '/' in 
httpd.conf causes apache crash 
  
Changed paths:
U   php/win-installer/trunk/PHPInstallerScripts52.vbs
U   php/win-installer/trunk/PHPInstallerScripts53.vbs
U   php/win-installer/trunk/PHPInstallerScripts60.vbs

Modified: php/win-installer/trunk/PHPInstallerScripts52.vbs
===
--- php/win-installer/trunk/PHPInstallerScripts52.vbs   2010-12-22 15:53:33 UTC 
(rev 306573)
+++ php/win-installer/trunk/PHPInstallerScripts52.vbs   2010-12-22 16:03:43 UTC 
(rev 306574)
@@ -14,7 +14,8 @@
 If ( right(strApacheDir,1)  \ ) then
 strApacheDir = strApacheDir  \
 End If
-strPHPPath = Replace(strInstallDir,\,/)
+' Bug 52753 - Comment out since it causes an invalid http.conf file
+' strPHPPath = Replace(strInstallDir,\,/)

 strDirective = vbCrLf  vbCrLf  #BEGIN PHP INSTALLER EDITS - REMOVE ONLY 
ON UNINSTALL  vbCrLf
 If ( strWebServerType = apacheCGI ) Then

Modified: php/win-installer/trunk/PHPInstallerScripts53.vbs
===
--- php/win-installer/trunk/PHPInstallerScripts53.vbs   2010-12-22 15:53:33 UTC 
(rev 306573)
+++ php/win-installer/trunk/PHPInstallerScripts53.vbs   2010-12-22 16:03:43 UTC 
(rev 306574)
@@ -14,7 +14,8 @@
 If ( right(strApacheDir,1)  \ ) then
 strApacheDir = strApacheDir  \
 End If
-strPHPPath = Replace(strInstallDir,\,/)
+' Bug 52753 - Comment out since it causes an invalid http.conf file
+' strPHPPath = Replace(strInstallDir,\,/)

 strDirective = vbCrLf  vbCrLf  #BEGIN PHP INSTALLER EDITS - REMOVE ONLY 
ON UNINSTALL  vbCrLf
 If ( strWebServerType = apacheCGI ) Then

Modified: php/win-installer/trunk/PHPInstallerScripts60.vbs
===
--- php/win-installer/trunk/PHPInstallerScripts60.vbs   2010-12-22 15:53:33 UTC 
(rev 306573)
+++ php/win-installer/trunk/PHPInstallerScripts60.vbs   2010-12-22 16:03:43 UTC 
(rev 306574)
@@ -14,7 +14,8 @@
 If ( right(strApacheDir,1)  \ ) then
 strApacheDir = strApacheDir  \
 End If
-strPHPPath = Replace(strInstallDir,\,/)
+' Bug 52753 - Comment out since it causes an invalid http.conf file
+' strPHPPath = Replace(strInstallDir,\,/)

 strDirective = vbCrLf  vbCrLf  #BEGIN PHP INSTALLER EDITS - REMOVE ONLY 
ON UNINSTALL  vbCrLf
 If ( strWebServerType = apacheCGI ) Then

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[PHP-CVS] svn: /php/php-src/ branches/PHP_5_3/NEWS branches/PHP_5_3/ext/filter/filter.c branches/PHP_5_3/ext/filter/tests/bug52209.phpt trunk/ext/filter/filter.c trunk/ext/filter/tests/bug52209.phpt

2010-12-22 Thread Ilia Alshanetsky
iliaaWed, 22 Dec 2010 16:18:59 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=306575

Log:
Fixed bug #52209 (INPUT_ENV returns NULL for set variables (CLI)).

Bug: http://bugs.php.net/52209 (Open) INPUT_ENV returns NULL for set variables 
(CLI)
  
Changed paths:
U   php/php-src/branches/PHP_5_3/NEWS
U   php/php-src/branches/PHP_5_3/ext/filter/filter.c
A   php/php-src/branches/PHP_5_3/ext/filter/tests/bug52209.phpt
U   php/php-src/trunk/ext/filter/filter.c
A   php/php-src/trunk/ext/filter/tests/bug52209.phpt

Modified: php/php-src/branches/PHP_5_3/NEWS
===
--- php/php-src/branches/PHP_5_3/NEWS   2010-12-22 16:03:43 UTC (rev 306574)
+++ php/php-src/branches/PHP_5_3/NEWS   2010-12-22 16:18:59 UTC (rev 306575)
@@ -24,6 +24,7 @@
 - Filter extension:
   . Fixed bug #53150 (FILTER_FLAG_NO_RES_RANGE is missing some IP ranges).
 (Ilia)
+  . Fixed bug #52209 (INPUT_ENV returns NULL for set variables (CLI)). (Ilia)
   . Fixed bug #47435 (FILTER_FLAG_NO_RES_RANGE don't work with ipv6).
 (Ilia, valli at icsurselva dot ch)


Modified: php/php-src/branches/PHP_5_3/ext/filter/filter.c
===
--- php/php-src/branches/PHP_5_3/ext/filter/filter.c2010-12-22 16:03:43 UTC 
(rev 306574)
+++ php/php-src/branches/PHP_5_3/ext/filter/filter.c2010-12-22 16:18:59 UTC 
(rev 306575)
@@ -559,7 +559,7 @@
if (jit_initialization) {
zend_is_auto_global(_ENV, sizeof(_ENV)-1 
TSRMLS_CC);
}
-   array_ptr = IF_G(env_array);
+   array_ptr = IF_G(env_array) ? IF_G(env_array) : 
PG(http_globals)[TRACK_VARS_ENV];
break;
case PARSE_SESSION:
/* FIXME: Implement session source */

Added: php/php-src/branches/PHP_5_3/ext/filter/tests/bug52209.phpt
===
--- php/php-src/branches/PHP_5_3/ext/filter/tests/bug52209.phpt 
(rev 0)
+++ php/php-src/branches/PHP_5_3/ext/filter/tests/bug52209.phpt 2010-12-22 
16:18:59 UTC (rev 306575)
@@ -0,0 +1,10 @@
+--TEST--
+Bug #52209 (INPUT_ENV returns NULL for set variables (CLI))
+--SKIPIF--
+?php if (!extension_loaded(filter) || !empty($_ENV['PWD'])) die(skip); ?
+--FILE--
+?php
+   var_dump(filter_input(INPUT_ENV, 'PWD'));
+?
+--EXPECTF--
+string(%d) %s

Modified: php/php-src/trunk/ext/filter/filter.c
===
--- php/php-src/trunk/ext/filter/filter.c   2010-12-22 16:03:43 UTC (rev 
306574)
+++ php/php-src/trunk/ext/filter/filter.c   2010-12-22 16:18:59 UTC (rev 
306575)
@@ -546,7 +546,7 @@
if (PG(auto_globals_jit)) {
zend_is_auto_global(_ENV, sizeof(_ENV)-1 
TSRMLS_CC);
}
-   array_ptr = IF_G(env_array);
+   array_ptr = IF_G(env_array) ? IF_G(env_array) : 
PG(http_globals)[TRACK_VARS_ENV];
break;
case PARSE_SESSION:
/* FIXME: Implement session source */

Added: php/php-src/trunk/ext/filter/tests/bug52209.phpt
===
--- php/php-src/trunk/ext/filter/tests/bug52209.phpt
(rev 0)
+++ php/php-src/trunk/ext/filter/tests/bug52209.phpt2010-12-22 16:18:59 UTC 
(rev 306575)
@@ -0,0 +1,10 @@
+--TEST--
+Bug #52209 (INPUT_ENV returns NULL for set variables (CLI))
+--SKIPIF--
+?php if (!extension_loaded(filter) || !empty($_ENV['PWD'])) die(skip); ?
+--FILE--
+?php
+   var_dump(filter_input(INPUT_ENV, 'PWD'));
+?
+--EXPECTF--
+string(%d) %s

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[PHP-CVS] svn: /php/win-installer/trunk/ PHPInstallerBase53.wxs PHPInstallerBase53NTS.wxs PHPInstallerBase60.wxs PHPInstallerBase60NTS.wxs

2010-12-22 Thread John Mertic
jmertic  Wed, 22 Dec 2010 19:15:03 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=306577

Log:
Newer versions of Windows allow the use of %*, so let's go with that instead.

Changed paths:
U   php/win-installer/trunk/PHPInstallerBase53.wxs
U   php/win-installer/trunk/PHPInstallerBase53NTS.wxs
U   php/win-installer/trunk/PHPInstallerBase60.wxs
U   php/win-installer/trunk/PHPInstallerBase60NTS.wxs

Modified: php/win-installer/trunk/PHPInstallerBase53.wxs
===
--- php/win-installer/trunk/PHPInstallerBase53.wxs  2010-12-22 18:42:46 UTC 
(rev 306576)
+++ php/win-installer/trunk/PHPInstallerBase53.wxs  2010-12-22 19:15:03 UTC 
(rev 306577)
@@ -197,7 +197,7 @@
   Sequence=10
   Command=Run
   Target=[!file13]
-  Argument=quot;%1quot; quot;%2quot; quot;%3quot; 
quot;%4quot; quot;%5quot; quot;%6quot; quot;%7quot; quot;%8quot; 
quot;%9quot;/
+  Argument=quot;%*quot;/
   /Extension
 /ProgId
   /Component

Modified: php/win-installer/trunk/PHPInstallerBase53NTS.wxs
===
--- php/win-installer/trunk/PHPInstallerBase53NTS.wxs   2010-12-22 18:42:46 UTC 
(rev 306576)
+++ php/win-installer/trunk/PHPInstallerBase53NTS.wxs   2010-12-22 19:15:03 UTC 
(rev 306577)
@@ -175,7 +175,7 @@
   Sequence=10
   Command=Run
   Target=[!file13]
-  Argument=quot;%1quot; quot;%2quot; quot;%3quot; 
quot;%4quot; quot;%5quot; quot;%6quot; quot;%7quot; quot;%8quot; 
quot;%9quot;/
+  Argument=quot;%*quot;/
   /Extension
 /ProgId
   /Component

Modified: php/win-installer/trunk/PHPInstallerBase60.wxs
===
--- php/win-installer/trunk/PHPInstallerBase60.wxs  2010-12-22 18:42:46 UTC 
(rev 306576)
+++ php/win-installer/trunk/PHPInstallerBase60.wxs  2010-12-22 19:15:03 UTC 
(rev 306577)
@@ -197,7 +197,7 @@
   Sequence=10
   Command=Run
   Target=[!file13]
-  Argument=quot;%1quot; quot;%2quot; quot;%3quot; 
quot;%4quot; quot;%5quot; quot;%6quot; quot;%7quot; quot;%8quot; 
quot;%9quot;/
+  Argument=quot;%*quot;/
   /Extension
 /ProgId
   /Component

Modified: php/win-installer/trunk/PHPInstallerBase60NTS.wxs
===
--- php/win-installer/trunk/PHPInstallerBase60NTS.wxs   2010-12-22 18:42:46 UTC 
(rev 306576)
+++ php/win-installer/trunk/PHPInstallerBase60NTS.wxs   2010-12-22 19:15:03 UTC 
(rev 306577)
@@ -175,7 +175,7 @@
   Sequence=10
   Command=Run
   Target=[!file13]
-  Argument=quot;%1quot; quot;%2quot; quot;%3quot; 
quot;%4quot; quot;%5quot; quot;%6quot; quot;%7quot; quot;%8quot; 
quot;%9quot;/
+  Argument=quot;%*quot;/
   /Extension
 /ProgId
   /Component

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[PHP-CVS] svn: /php/php-src/ branches/PHP_5_3/NEWS branches/PHP_5_3/ext/openssl/xp_ssl.c trunk/ext/openssl/xp_ssl.c

2010-12-22 Thread Gustavo André dos Santos Lopes
cataphract   Thu, 23 Dec 2010 01:44:54 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=306581

Log:
- Fixed bug #53592 (stream_socket_enable_crypto() busy-waits in client mode).
- Fixed stream_socket_enable_crypto() not honoring the socket timeout in
  server mode.

Bug: http://bugs.php.net/53592 (Assigned) stream_socket_enable_crypto() uses 
NONBLOCK
  
Changed paths:
U   php/php-src/branches/PHP_5_3/NEWS
U   php/php-src/branches/PHP_5_3/ext/openssl/xp_ssl.c
U   php/php-src/trunk/ext/openssl/xp_ssl.c

Modified: php/php-src/branches/PHP_5_3/NEWS
===
--- php/php-src/branches/PHP_5_3/NEWS	2010-12-23 00:17:51 UTC (rev 306580)
+++ php/php-src/branches/PHP_5_3/NEWS	2010-12-23 01:44:54 UTC (rev 306581)
@@ -49,6 +49,10 @@
   . Implemented FR #53447 (Cannot disable SessionTicket extension for servers
 that do not support it) by adding a no_ticket SSL context option. (Adam,
 Tony)
+  . Fixed bug #53592 (stream_socket_enable_crypto() busy-waits in client mode).
+(Gustavo)
+  . Fixed stream_socket_enable_crypto() not honoring the socket timeout in
+server mode. (Gustavo)

 - PDO Oracle driver:
   . Fixed bug #39199 (Cannot load Lob data with more than 4000 bytes on

Modified: php/php-src/branches/PHP_5_3/ext/openssl/xp_ssl.c
===
--- php/php-src/branches/PHP_5_3/ext/openssl/xp_ssl.c	2010-12-23 00:17:51 UTC (rev 306580)
+++ php/php-src/branches/PHP_5_3/ext/openssl/xp_ssl.c	2010-12-23 01:44:54 UTC (rev 306581)
@@ -411,8 +411,10 @@
 	int n, retry = 1;

 	if (cparam-inputs.activate  !sslsock-ssl_active) {
-		float timeout = sslsock-connect_timeout.tv_sec + sslsock-connect_timeout.tv_usec / 100;
-		int blocked = sslsock-s.is_blocked;
+		struct timeval	start_time,
+		*timeout;
+		intblocked		= sslsock-s.is_blocked,
+		has_timeout = 0;

 #if OPENSSL_VERSION_NUMBER = 0x0090806fL  !defined(OPENSSL_NO_TLSEXT)
 		if (sslsock-is_client  sslsock-sni) {
@@ -429,36 +431,70 @@
 			sslsock-state_set = 1;
 		}

-		if (sslsock-is_client  SUCCESS == php_set_sock_blocking(sslsock-s.socket, 0 TSRMLS_CC)) {
-	sslsock-s.is_blocked = 0;
+		if (SUCCESS == php_set_sock_blocking(sslsock-s.socket, 0 TSRMLS_CC)) {
+			sslsock-s.is_blocked = 0;
 		}
+
+		timeout = sslsock-is_client ? sslsock-connect_timeout : sslsock-s.timeout;
+		has_timeout = !sslsock-s.is_blocked  (timeout-tv_sec || timeout-tv_usec);
+		/* gettimeofday is not monotonic; using it here is not strictly correct */
+		if (has_timeout) {
+			gettimeofday(start_time, NULL);
+		}
+
 		do {
+			struct timeval	cur_time,
+			elapsed_time;
+
 			if (sslsock-is_client) {
-struct timeval tvs, tve;
-struct timezone tz;
-
-gettimeofday(tvs, tz);
 n = SSL_connect(sslsock-ssl_handle);
-gettimeofday(tve, tz);
+			} else {
+n = SSL_accept(sslsock-ssl_handle);
+			}

-timeout -= (tve.tv_sec + (float) tve.tv_usec / 100) - (tvs.tv_sec + (float) tvs.tv_usec / 100);
-if (timeout  0) {
-	php_error_docref(NULL TSRMLS_CC, E_WARNING, SSL: connection timeout);
+			if (has_timeout) {
+gettimeofday(cur_time, NULL);
+elapsed_time.tv_sec  = cur_time.tv_sec  - start_time.tv_sec;
+elapsed_time.tv_usec = cur_time.tv_usec - start_time.tv_usec;
+if (cur_time.tv_usec  start_time.tv_usec) {
+	elapsed_time.tv_sec  -= 1L;
+	elapsed_time.tv_usec += 100L;
+}
+
+if (elapsed_time.tv_sec  timeout-tv_sec ||
+		(elapsed_time.tv_sec == timeout-tv_sec 
+		elapsed_time.tv_usec  timeout-tv_usec)) {
+	php_error_docref(NULL TSRMLS_CC, E_WARNING, SSL: crypto enabling timeout);
 	return -1;
 }
-			} else {
-n = SSL_accept(sslsock-ssl_handle);
 			}

 			if (n = 0) {
-retry = handle_ssl_error(stream, n, sslsock-is_client || sslsock-s.is_blocked TSRMLS_CC);
-
+/* in case of SSL_ERROR_WANT_READ/WRITE, do not retry in non-blocking mode */
+retry = handle_ssl_error(stream, n, blocked TSRMLS_CC);
+if (retry) {
+	/* wait until something interesting happens in the socket. It may be a
+	 * timeout. Also consider the unlikely of possibility of a write block  */
+	int err = SSL_get_error(sslsock-ssl_handle, n);
+	struct timeval left_time;
+
+	if (has_timeout) {
+		left_time.tv_sec  = timeout-tv_sec  - elapsed_time.tv_sec;
+		left_time.tv_usec =	timeout-tv_usec - elapsed_time.tv_usec;
+		if (timeout-tv_usec  elapsed_time.tv_usec) {
+			left_time.tv_sec  -= 1L;
+			left_time.tv_usec += 100L;
+		}
+	}
+	php_pollfd_for(sslsock-s.socket, (err == SSL_ERROR_WANT_READ) ?
+		(POLLIN|POLLPRI) : POLLOUT, has_timeout ? left_time : NULL);
+}
 			} else {
-break;
+retry = 0;
 			}
 		} while (retry);

-		if (sslsock-is_client  sslsock-s.is_blocked != blocked  SUCCESS == php_set_sock_blocking(sslsock-s.socket, blocked TSRMLS_CC)) {
+