cvs: ZendEngine2(PHP_5_2) / zend_execute.c zend_vm_def.h zend_vm_execute.h

From: Date: Mon, 15 May 2006 15:31:28 +0000
Subject: cvs: ZendEngine2(PHP_5_2) / zend_execute.c zend_vm_def.h zend_vm_execute.h
Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-4883@lists.php.net to get a copy of this message
dmitry Mon May 15 15:31:28 2006 UTC Modified files: (Branch: PHP_5_2) /ZendEngine2 zend_execute.c zend_vm_def.h zend_vm_execute.h Log: Optimized require_once/include_once (eliminated fopen() on second usage)

http://cvs.php.net/viewcvs.cgi/ZendEngine2/zend_execute.c?r1=1.716.2.12.2.3&r2=1.716.2.12.2.4&diff_format=u Index: ZendEngine2/zend_execute.c diff -u ZendEngine2/zend_execute.c:1.716.2.12.2.3 ZendEngine2/zend_execute.c:1.716.2.12.2.4 --- ZendEngine2/zend_execute.c:1.716.2.12.2.3 Thu May 11 21:07:39 2006 +++ ZendEngine2/zend_execute.c Mon May 15 15:31:27 2006 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_execute.c,v 1.716.2.12.2.3 2006/05/11 21:07:39 helly Exp $ */ +/* $Id: zend_execute.c,v 1.716.2.12.2.4 2006/05/15 15:31:27 dmitry Exp $ */ #define ZEND_INTENSIVE_DEBUGGING 0 @@ -37,6 +37,9 @@ #include "zend_interfaces.h" #include "zend_vm.h" +/* Virtual current working directory support */ +#include "tsrm_virtual_cwd.h" + #define _CONST_CODE 0 #define _TMP_CODE 1 #define _VAR_CODE 2 http://cvs.php.net/viewcvs.cgi/ZendEngine2/zend_vm_def.h?r1=1.59.2.29.2.2&r2=1.59.2.29.2.3&diff_format=u Index: ZendEngine2/zend_vm_def.h diff -u ZendEngine2/zend_vm_def.h:1.59.2.29.2.2 ZendEngine2/zend_vm_def.h:1.59.2.29.2.3 --- ZendEngine2/zend_vm_def.h:1.59.2.29.2.2 Thu May 11 21:07:39 2006 +++ ZendEngine2/zend_vm_def.h Mon May 15 15:31:27 2006 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_vm_def.h,v 1.59.2.29.2.2 2006/05/11 21:07:39 helly Exp $ */ +/* $Id: zend_vm_def.h,v 1.59.2.29.2.3 2006/05/15 15:31:27 dmitry Exp $ */ /* If you change this file, please regenerate the zend_vm_execute.h and * zend_vm_opcodes.h files by running: @@ -2692,16 +2692,29 @@ switch (Z_LVAL(opline->op2.u.constant)) { case ZEND_INCLUDE_ONCE: case ZEND_REQUIRE_ONCE: { - int dummy = 1; zend_file_handle file_handle; + char cwd[MAXPATHLEN]; + cwd_state state; - if (SUCCESS == zend_stream_open(Z_STRVAL_P(inc_filename), &file_handle TSRMLS_CC)) { + if (IS_ABSOLUTE_PATH(Z_STRVAL_P(inc_filename), Z_STRLEN_P(inc_filename))) { + cwd[0] = '\0'; + } else if (!VCWD_GETCWD(cwd, MAXPATHLEN)) { + cwd[0] = '\0'; + } + + state.cwd_length = strlen(cwd); + state.cwd = zend_strndup(cwd, state.cwd_length); + + if (!virtual_file_ex(&state, Z_STRVAL_P(inc_filename), NULL, 1) && + zend_hash_exists(&EG(included_files), state.cwd, state.cwd_length+1)) { + failure_retval=1; + } else if (SUCCESS == zend_stream_open(Z_STRVAL_P(inc_filename), &file_handle TSRMLS_CC)) { if (!file_handle.opened_path) { - file_handle.opened_path = estrndup(inc_filename->value.str.val, inc_filename->value.str.len); + file_handle.opened_path = estrndup(Z_STRVAL_P(inc_filename), Z_STRLEN_P(inc_filename)); } - if (zend_hash_add(&EG(included_files), file_handle.opened_path, strlen(file_handle.opened_path)+1, (void *)&dummy, sizeof(int), NULL)==SUCCESS) { + if (zend_hash_add_empty_element(&EG(included_files), file_handle.opened_path, strlen(file_handle.opened_path)+1)==SUCCESS) { new_op_array = zend_compile_file(&file_handle, (Z_LVAL(opline->op2.u.constant)==ZEND_INCLUDE_ONCE?ZEND_INCLUDE:ZEND_REQUIRE) TSRMLS_CC); zend_destroy_file_handle(&file_handle TSRMLS_CC); } else { @@ -2715,7 +2728,7 @@ zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, Z_STRVAL_P(inc_filename)); } } - break; + free(state.cwd); } break; case ZEND_INCLUDE: http://cvs.php.net/viewcvs.cgi/ZendEngine2/zend_vm_execute.h?r1=1.62.2.30.2.2&r2=1.62.2.30.2.3&diff_format=u Index: ZendEngine2/zend_vm_execute.h diff -u ZendEngine2/zend_vm_execute.h:1.62.2.30.2.2 ZendEngine2/zend_vm_execute.h:1.62.2.30.2.3 --- ZendEngine2/zend_vm_execute.h:1.62.2.30.2.2 Thu May 11 21:07:39 2006 +++ ZendEngine2/zend_vm_execute.h Mon May 15 15:31:27 2006 @@ -1897,16 +1897,29 @@ switch (Z_LVAL(opline->op2.u.constant)) { case ZEND_INCLUDE_ONCE: case ZEND_REQUIRE_ONCE: { - int dummy = 1; zend_file_handle file_handle; + char cwd[MAXPATHLEN]; + cwd_state state; - if (SUCCESS == zend_stream_open(Z_STRVAL_P(inc_filename), &file_handle TSRMLS_CC)) { + if (IS_ABSOLUTE_PATH(Z_STRVAL_P(inc_filename), Z_STRLEN_P(inc_filename))) { + cwd[0] = '\0'; + } else if (!VCWD_GETCWD(cwd, MAXPATHLEN)) { + cwd[0] = '\0'; + } + + state.cwd_length = strlen(cwd); + state.cwd = zend_strndup(cwd, state.cwd_length); + + if (!virtual_file_ex(&state, Z_STRVAL_P(inc_filename), NULL, 1) && + zend_hash_exists(&EG(included_files), state.cwd, state.cwd_length+1)) { + failure_retval=1; + } else if (SUCCESS == zend_stream_open(Z_STRVAL_P(inc_filename), &file_handle TSRMLS_CC)) { if (!file_handle.opened_path) { - file_handle.opened_path = estrndup(inc_filename->value.str.val, inc_filename->value.str.len); + file_handle.opened_path = estrndup(Z_STRVAL_P(inc_filename), Z_STRLEN_P(inc_filename)); } - if (zend_hash_add(&EG(included_files), file_handle.opened_path, strlen(file_handle.opened_path)+1, (void *)&dummy, sizeof(int), NULL)==SUCCESS) { + if (zend_hash_add_empty_element(&EG(included_files), file_handle.opened_path, strlen(file_handle.opened_path)+1)==SUCCESS) { new_op_array = zend_compile_file(&file_handle, (Z_LVAL(opline->op2.u.constant)==ZEND_INCLUDE_ONCE?ZEND_INCLUDE:ZEND_REQUIRE) TSRMLS_CC); zend_destroy_file_handle(&file_handle TSRMLS_CC); } else { @@ -1920,7 +1933,7 @@ zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, Z_STRVAL_P(inc_filename)); } } - break; + free(state.cwd); } break; case ZEND_INCLUDE: @@ -4318,16 +4331,29 @@ switch (Z_LVAL(opline->op2.u.constant)) { case ZEND_INCLUDE_ONCE: case ZEND_REQUIRE_ONCE: { - int dummy = 1; zend_file_handle file_handle; + char cwd[MAXPATHLEN]; + cwd_state state; - if (SUCCESS == zend_stream_open(Z_STRVAL_P(inc_filename), &file_handle TSRMLS_CC)) { + if (IS_ABSOLUTE_PATH(Z_STRVAL_P(inc_filename), Z_STRLEN_P(inc_filename))) { + cwd[0] = '\0'; + } else if (!VCWD_GETCWD(cwd, MAXPATHLEN)) { + cwd[0] = '\0'; + } + + state.cwd_length = strlen(cwd); + state.cwd = zend_strndup(cwd, state.cwd_length); + + if (!virtual_file_ex(&state, Z_STRVAL_P(inc_filename), NULL, 1) && + zend_hash_exists(&EG(included_files), state.cwd, state.cwd_length+1)) { + failure_retval=1; + } else if (SUCCESS == zend_stream_open(Z_STRVAL_P(inc_filename), &file_handle TSRMLS_CC)) { if (!file_handle.opened_path) { - file_handle.opened_path = estrndup(inc_filename->value.str.val, inc_filename->value.str.len); + file_handle.opened_path = estrndup(Z_STRVAL_P(inc_filename), Z_STRLEN_P(inc_filename)); } - if (zend_hash_add(&EG(included_files), file_handle.opened_path, strlen(file_handle.opened_path)+1, (void *)&dummy, sizeof(int), NULL)==SUCCESS) { + if (zend_hash_add_empty_element(&EG(included_files), file_handle.opened_path, strlen(file_handle.opened_path)+1)==SUCCESS) { new_op_array = zend_compile_file(&file_handle, (Z_LVAL(opline->op2.u.constant)==ZEND_INCLUDE_ONCE?ZEND_INCLUDE:ZEND_REQUIRE) TSRMLS_CC); zend_destroy_file_handle(&file_handle TSRMLS_CC); } else { @@ -4341,7 +4367,7 @@ zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, Z_STRVAL_P(inc_filename)); } } - break; + free(state.cwd); } break; case ZEND_INCLUDE: @@ -7321,16 +7347,29 @@ switch (Z_LVAL(opline->op2.u.constant)) { case ZEND_INCLUDE_ONCE: case ZEND_REQUIRE_ONCE: { - int dummy = 1; zend_file_handle file_handle; + char cwd[MAXPATHLEN]; + cwd_state state; - if (SUCCESS == zend_stream_open(Z_STRVAL_P(inc_filename), &file_handle TSRMLS_CC)) { + if (IS_ABSOLUTE_PATH(Z_STRVAL_P(inc_filename), Z_STRLEN_P(inc_filename))) { + cwd[0] = '\0'; + } else if (!VCWD_GETCWD(cwd, MAXPATHLEN)) { + cwd[0] = '\0'; + } + + state.cwd_length = strlen(cwd); + state.cwd = zend_strndup(cwd, state.cwd_length); + + if (!virtual_file_ex(&state, Z_STRVAL_P(inc_filename), NULL, 1) && + zend_hash_exists(&EG(included_files), state.cwd, state.cwd_length+1)) { + failure_retval=1; + } else if (SUCCESS == zend_stream_open(Z_STRVAL_P(inc_filename), &file_handle TSRMLS_CC)) { if (!file_handle.opened_path) { - file_handle.opened_path = estrndup(inc_filename->value.str.val, inc_filename->value.str.len); + file_handle.opened_path = estrndup(Z_STRVAL_P(inc_filename), Z_STRLEN_P(inc_filename)); } - if (zend_hash_add(&EG(included_files), file_handle.opened_path, strlen(file_handle.opened_path)+1, (void *)&dummy, sizeof(int), NULL)==SUCCESS) { + if (zend_hash_add_empty_element(&EG(included_files), file_handle.opened_path, strlen(file_handle.opened_path)+1)==SUCCESS) { new_op_array = zend_compile_file(&file_handle, (Z_LVAL(opline->op2.u.constant)==ZEND_INCLUDE_ONCE?ZEND_INCLUDE:ZEND_REQUIRE) TSRMLS_CC); zend_destroy_file_handle(&file_handle TSRMLS_CC); } else { @@ -7344,7 +7383,7 @@ zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, Z_STRVAL_P(inc_filename)); } } - break; + free(state.cwd); } break; case ZEND_INCLUDE: @@ -19416,16 +19455,29 @@ switch (Z_LVAL(opline->op2.u.constant)) { case ZEND_INCLUDE_ONCE: case ZEND_REQUIRE_ONCE: { - int dummy = 1; zend_file_handle file_handle; + char cwd[MAXPATHLEN]; + cwd_state state; - if (SUCCESS == zend_stream_open(Z_STRVAL_P(inc_filename), &file_handle TSRMLS_CC)) { + if (IS_ABSOLUTE_PATH(Z_STRVAL_P(inc_filename), Z_STRLEN_P(inc_filename))) { + cwd[0] = '\0'; + } else if (!VCWD_GETCWD(cwd, MAXPATHLEN)) { + cwd[0] = '\0'; + } + + state.cwd_length = strlen(cwd); + state.cwd = zend_strndup(cwd, state.cwd_length); + + if (!virtual_file_ex(&state, Z_STRVAL_P(inc_filename), NULL, 1) && + zend_hash_exists(&EG(included_files), state.cwd, state.cwd_length+1)) { + failure_retval=1; + } else if (SUCCESS == zend_stream_open(Z_STRVAL_P(inc_filename), &file_handle TSRMLS_CC)) { if (!file_handle.opened_path) { - file_handle.opened_path = estrndup(inc_filename->value.str.val, inc_filename->value.str.len); + file_handle.opened_path = estrndup(Z_STRVAL_P(inc_filename), Z_STRLEN_P(inc_filename)); } - if (zend_hash_add(&EG(included_files), file_handle.opened_path, strlen(file_handle.opened_path)+1, (void *)&dummy, sizeof(int), NULL)==SUCCESS) { + if (zend_hash_add_empty_element(&EG(included_files), file_handle.opened_path, strlen(file_handle.opened_path)+1)==SUCCESS) { new_op_array = zend_compile_file(&file_handle, (Z_LVAL(opline->op2.u.constant)==ZEND_INCLUDE_ONCE?ZEND_INCLUDE:ZEND_REQUIRE) TSRMLS_CC); zend_destroy_file_handle(&file_handle TSRMLS_CC); } else { @@ -19439,7 +19491,7 @@ zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, Z_STRVAL_P(inc_filename)); } } - break; + free(state.cwd); } break; case ZEND_INCLUDE:
« previous php.zend-engine.cvs (#4883) next »