From c68a82ac7df73fa17ee89cb06e79bb82c919dec8 Mon Sep 17 00:00:00 2001 From: Steph Fox Date: Sun, 22 Jun 2008 16:35:26 +0000 Subject: [PATCH] - Revert the two blocks of code that implement the phar_build optimization, causes segfaults under *nix - Leave the new structure in place to make re-implementation trivial --- ext/phar/phar_object.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c index 25ff33702a..0078ab6959 100755 --- a/ext/phar/phar_object.c +++ b/ext/phar/phar_object.c @@ -1614,13 +1614,7 @@ after_open_fp: if (error) { efree(error); } - /* convert to PHAR_UFP */ - php_stream_close(data->internal_file->fp); - data->internal_file->fp_type = PHAR_UFP; - data->internal_file->offset_abs = data->internal_file->offset = php_stream_tell(p_obj->fp); - contents_len = php_stream_copy_to_stream(fp, p_obj->fp, PHP_STREAM_COPY_ALL); - data->internal_file->uncompressed_filesize = data->internal_file->compressed_filesize = - php_stream_tell(p_obj->fp) - data->internal_file->offset; + contents_len = php_stream_copy_to_stream(fp, data->fp, PHP_STREAM_COPY_ALL); } if (close_fp) { php_stream_close(fp); @@ -1637,6 +1631,16 @@ after_open_fp: 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; } /* }}} */ -- 2.50.1