cellog          Tue Jun 10 19:20:33 2008 UTC

  Added files:                 (Branch: PHP_5_3)
    /php-src/ext/phar/tests     bug45218_SLOWTEST.phpt 

  Modified files:              
    /php-src/ext/phar   phar.phar phar_object.c 
  Log:
  fix PHP Bug #45218: PHAR archive built from directory limited by max open 
file handles
  
http://cvs.php.net/viewvc.cgi/php-src/ext/phar/phar.phar?r1=1.7.2.9&r2=1.7.2.10&diff_format=u
Index: php-src/ext/phar/phar.phar
http://cvs.php.net/viewvc.cgi/php-src/ext/phar/phar_object.c?r1=1.266.2.16&r2=1.266.2.17&diff_format=u
Index: php-src/ext/phar/phar_object.c
diff -u php-src/ext/phar/phar_object.c:1.266.2.16 
php-src/ext/phar/phar_object.c:1.266.2.17
--- php-src/ext/phar/phar_object.c:1.266.2.16   Mon Jun  2 15:49:03 2008
+++ php-src/ext/phar/phar_object.c      Tue Jun 10 19:20:33 2008
@@ -17,7 +17,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: phar_object.c,v 1.266.2.16 2008/06/02 15:49:03 helly Exp $ */
+/* $Id: phar_object.c,v 1.266.2.17 2008/06/10 19:20:33 cellog Exp $ */
 
 #include "phar_internal.h"
 #include "func_interceptors.h"
@@ -1347,12 +1347,13 @@
                char *b;
                uint l;
                zval *ret;
+               int count;
        } *p_obj = (struct _t*) puser;
        uint str_key_len, base_len = p_obj->l, fname_len;
        phar_entry_data *data;
        php_stream *fp;
        long contents_len;
-       char *fname, *error, *base = p_obj->b, *opened, *save = NULL, *temp = 
NULL;
+       char *fname, *error = NULL, *base = p_obj->b, *opened, *save = NULL, 
*temp = NULL;
        phar_zstr key;
        char *str_key;
        zend_class_entry *ce = p_obj->c;
@@ -1591,6 +1592,15 @@
 
        data->internal_file->compressed_filesize = 
data->internal_file->uncompressed_filesize = contents_len;
        phar_entry_delref(data TSRMLS_CC);
+       if (++p_obj->count && p_obj->count % 900) {
+               /* every 900 files, flush so we remove open temp file handles, 
fixes Bug #45218 */
+               phar_flush(p_obj->p->arc.archive, 0, 0, 0, &error TSRMLS_CC);
+               if (error) {
+                       zend_throw_exception_ex(phar_ce_PharException, 0 
TSRMLS_CC, error);
+                       efree(error);
+                       return ZEND_HASH_APPLY_STOP;
+               }
+       }
        return ZEND_HASH_APPLY_KEEP;
 }
 /* }}} */
@@ -1613,6 +1623,7 @@
                char *b;
                uint l;
                zval *ret;
+               int count;
        } pass;
 
        PHAR_ARCHIVE_OBJECT();
@@ -1688,6 +1699,7 @@
        pass.p = phar_obj;
        pass.b = dir;
        pass.l = dir_len;
+       pass.count = 0;
        pass.ret = return_value;
 
        if (SUCCESS == spl_iterator_apply((apply_reg ? regexiter : iteriter), 
(spl_iterator_apply_func_t) phar_build, (void *) &pass TSRMLS_CC)) {
@@ -1725,6 +1737,7 @@
                char *b;
                uint l;
                zval *ret;
+               int count;
        } pass;
        PHAR_ARCHIVE_OBJECT();
 
@@ -1745,6 +1758,7 @@
        pass.b = base;
        pass.l = base_len;
        pass.ret = return_value;
+       pass.count = 0;
 
        if (SUCCESS == spl_iterator_apply(obj, (spl_iterator_apply_func_t) 
phar_build, (void *) &pass TSRMLS_CC)) {
                phar_flush(phar_obj->arc.archive, 0, 0, 0, &error TSRMLS_CC);

http://cvs.php.net/viewvc.cgi/php-src/ext/phar/tests/bug45218_SLOWTEST.phpt?view=markup&rev=1.1
Index: php-src/ext/phar/tests/bug45218_SLOWTEST.phpt
+++ php-src/ext/phar/tests/bug45218_SLOWTEST.phpt



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

Reply via email to