Index: apc.c =================================================================== RCS file: /repository/pecl/apc/apc.c,v retrieving revision 3.16 diff -u -r3.16 apc.c --- apc.c 28 Oct 2006 02:28:26 -0000 3.16 +++ apc.c 16 Mar 2007 06:39:51 -0000 @@ -292,9 +292,8 @@ } #endif -int apc_stat_paths(const char* filename, const char* path, struct stat* buf) +int apc_search_paths(const char* filename, const char* path, apc_fileinfo_t* fileinfo) { - char filepath[MAXPATHLEN]; char** paths; char *exec_fname; int exec_fname_length; @@ -302,9 +301,10 @@ int i; TSRMLS_FETCH(); - assert(filename && buf); + assert(filename && fileinfo); - if (IS_ABSOLUTE_PATH(filename, strlen(filename)) && apc_stat(filename, buf) == 0) { + if (IS_ABSOLUTE_PATH(filename, strlen(filename)) && apc_stat(filename, &fileinfo->st_buf) == 0) { + strncpy(fileinfo->fullpath, filename, MAXPATHLEN); return 0; } @@ -314,8 +314,8 @@ /* for each directory in paths, look for filename inside */ for (i = 0; paths[i]; i++) { - snprintf(filepath, sizeof(filepath), "%s%c%s", paths[i], DEFAULT_SLASH, filename); - if (apc_stat(filepath, buf) == 0) { + snprintf(fileinfo->fullpath, sizeof(fileinfo->fullpath), "%s%c%s", paths[i], DEFAULT_SLASH, filename); + if (apc_stat(fileinfo->fullpath, &fileinfo->st_buf) == 0) { found = 1; break; } @@ -329,11 +329,11 @@ while((--exec_fname_length >= 0) && !IS_SLASH(exec_fname[exec_fname_length])); if((exec_fname && exec_fname[0] != '[') && exec_fname_length > 0) { /* not: [no active file] or no path */ - memcpy(filepath, exec_fname, exec_fname_length); - filepath[exec_fname_length] = DEFAULT_SLASH; - strcpy(filepath +exec_fname_length +1, filename); - /* apc_wprint("filename: %s, exec_fname: %s, filepath: %s", filename, exec_fname, filepath); */ - if (apc_stat(filepath, buf) == 0) { + memcpy(fileinfo->fullpath, exec_fname, exec_fname_length); + fileinfo->fullpath[exec_fname_length] = DEFAULT_SLASH; + strcpy(fileinfo->fullpath +exec_fname_length +1, filename); + /* apc_wprint("filename: %s, exec_fname: %s, fileinfo->fullpath: %s", filename, exec_fname, fileinfo->fullpath); */ + if (apc_stat(fileinfo->fullpath, &fileinfo->st_buf) == 0) { found = 1; } } Index: apc.h =================================================================== RCS file: /repository/pecl/apc/apc.h,v retrieving revision 3.12 diff -u -r3.12 apc.h --- apc.h 12 Mar 2006 00:31:45 -0000 3.12 +++ apc.h 16 Mar 2007 06:39:51 -0000 @@ -87,13 +87,20 @@ extern char** apc_tokenize(const char* s, char delim); /* filesystem functions */ + +typedef struct apc_fileinfo_t +{ + char fullpath[MAXPATHLEN+1]; + struct stat st_buf; +} apc_fileinfo_t; + #ifndef PHP_WIN32 #define apc_stat(f, b) stat(f, b) #else #define apc_stat(f, b) apc_win32_stat(f, b TSRMLS_CC) extern int apc_win32_stat(const char *path, struct stat *buf TSRMLS_DC); #endif -extern int apc_stat_paths(const char* filename, const char* path, struct stat*); +extern int apc_search_paths(const char* filename, const char* path, apc_fileinfo_t* fileinfo); /* regular expression wrapper functions */ extern void* apc_regex_compile_array(char* patterns[]); Index: apc_cache.c =================================================================== RCS file: /repository/pecl/apc/apc_cache.c,v retrieving revision 3.135 diff -u -r3.135 apc_cache.c --- apc_cache.c 8 Mar 2007 22:17:09 -0000 3.135 +++ apc_cache.c 16 Mar 2007 06:39:52 -0000 @@ -710,7 +710,8 @@ TSRMLS_DC) { static char canon_path[MAXPATHLEN]; - struct stat buf, *tmp_buf=NULL; + struct stat *tmp_buf=NULL; + struct apc_fileinfo_t fileinfo = {0,}; int len; assert(key != NULL); @@ -746,9 +747,9 @@ tmp_buf = sapi_get_stat(TSRMLS_C); /* Apache has already done this stat() for us */ } if(tmp_buf) { - buf = *tmp_buf; + fileinfo.st_buf = *tmp_buf; } else { - if (apc_stat_paths(filename, include_path, &buf) != 0) { + if (apc_search_paths(filename, include_path, &fileinfo) != 0) { #ifdef __DEBUG_APC__ fprintf(stderr,"Stat failed %s - bailing (%s) (%d)\n",filename,SG(request_info).path_translated); #endif @@ -756,9 +757,9 @@ } } - if(APCG(max_file_size) < buf.st_size) { + if(APCG(max_file_size) < fileinfo.st_buf.st_size) { #ifdef __DEBUG_APC__ - fprintf(stderr,"File is too big %s (%d - %ld) - bailing\n",filename,t,buf.st_size); + fprintf(stderr,"File is too big %s (%d - %ld) - bailing\n",filename,t,fileinfo.st_buf.st_size); #endif return 0; } @@ -775,15 +776,15 @@ * tiny safety is easier than educating the world. This is now * configurable, but the default is still 2 seconds. */ - if(APCG(file_update_protection) && (t - buf.st_mtime < APCG(file_update_protection))) { + if(APCG(file_update_protection) && (t - fileinfo.st_buf.st_mtime < APCG(file_update_protection))) { #ifdef __DEBUG_APC__ - fprintf(stderr,"File is too new %s (%d - %d) - bailing\n",filename,t,buf.st_mtime); + fprintf(stderr,"File is too new %s (%d - %d) - bailing\n",filename,t,fileinfo.st_buf.st_mtime); #endif return 0; } - key->data.file.device = buf.st_dev; - key->data.file.inode = buf.st_ino; + key->data.file.device = fileinfo.st_buf.st_dev; + key->data.file.inode = fileinfo.st_buf.st_ino; /* * If working with content management systems that like to munge the mtime, * it might be appropriate to key off of the ctime to be immune to systems @@ -796,9 +797,9 @@ * set the apc.stat_ctime=true to enable this check. */ if(APCG(stat_ctime)) { - key->mtime = (buf.st_ctime > buf.st_mtime) ? buf.st_ctime : buf.st_mtime; + key->mtime = (fileinfo.st_buf.st_ctime > fileinfo.st_buf.st_mtime) ? fileinfo.st_buf.st_ctime : fileinfo.st_buf.st_mtime; } else { - key->mtime = buf.st_mtime; + key->mtime = fileinfo.st_buf.st_mtime; } key->type = APC_CACHE_KEY_FILE; return 1; Index: apc_compile.c =================================================================== RCS file: /repository/pecl/apc/apc_compile.c,v retrieving revision 3.81 diff -u -r3.81 apc_compile.c --- apc_compile.c 15 Mar 2007 22:11:55 -0000 3.81 +++ apc_compile.c 16 Mar 2007 06:39:52 -0000 @@ -1092,6 +1092,7 @@ { int i; int local_dst_alloc = 0; + apc_fileinfo_t fileinfo; #ifdef ZEND_ENGINE_2 apc_opflags_t * flags = NULL; #endif @@ -1257,6 +1258,24 @@ } goto cleanup; } + +#ifdef ZEND_ENGINE_2 + if(APCG(fpstat)==0) { + if((zo->opcode == ZEND_INCLUDE_OR_EVAL) && + (zo->op1.op_type == IS_CONST && zo->op1.u.constant.type == IS_STRING)) { + /* constant includes */ + if(!IS_ABSOLUTE_PATH(Z_STRVAL_P(&zo->op1.u.constant),len)) { + if (apc_search_paths(Z_STRVAL_P(&zo->op1.u.constant), PG(include_path), &fileinfo) == 0) { + zend_op *dzo = &(dst->opcodes[i]); + deallocate(dzo->op1.u.constant.value.str.val); + dzo->op1.u.constant.value.str.len = strlen(fileinfo.fullpath); + dzo->op1.u.constant.value.str.val = apc_xstrdup(fileinfo.fullpath, + allocate); + } + } + } + } +#endif } #ifdef ZEND_ENGINE_2