|
cvs: pecl /apc INSTALL apc_cache.c apc_globals.h php_apc.c: msg#00264php.pecl.cvs
rasmus Fri Jul 29 16:54:12 2005 EDT Modified files: /pecl/apc INSTALL apc_cache.c apc_globals.h php_apc.c Log: Add file_update_protection configuration directive. See the INSTALL file for a full description. http://cvs.php.net/diff.php/pecl/apc/INSTALL?r1=3.43&r2=3.44&ty=u Index: pecl/apc/INSTALL diff -u pecl/apc/INSTALL:3.43 pecl/apc/INSTALL:3.44 --- pecl/apc/INSTALL:3.43 Thu Jul 21 04:11:13 2005 +++ pecl/apc/INSTALL Fri Jul 29 16:54:10 2005 @@ -285,3 +285,25 @@ against cache slams. Setting this to 0 disables this feature. (Default: 0) + + apc.file_update_protection + When you modify a file on a live web server you really + should do so in an atomic manner. That is, write to a + temporary file and rename (mv) the file into its permanent + position when it is ready. Many text editors, cp, tar and + other such programs don't do this. This means that there + is a chance that a file is accessed (and cached) while it + is still being written to. This file_update_protection + setting puts a delay on caching brand new files. The + default is 2 seconds which means that if the modification + timestamp (mtime) on a file shows that it is less than 2 + seconds old when it is accessed, it will not be cached. + The unfortunate person who accessed this half-written file + will still see weirdness, but at least it won't persist. + If you are certain you always atomically update your files + by using something like rsync which does this correctly, you + can turn this protection off by setting it to 0. If you + have a system that is flooded with io causing some update + procedure to take longer than 2 seconds, you may want to + increase this a bit. + (Default: 2) http://cvs.php.net/diff.php/pecl/apc/apc_cache.c?r1=3.89&r2=3.90&ty=u Index: pecl/apc/apc_cache.c diff -u pecl/apc/apc_cache.c:3.89 pecl/apc/apc_cache.c:3.90 --- pecl/apc/apc_cache.c:3.89 Fri Jul 29 04:19:30 2005 +++ pecl/apc/apc_cache.c Fri Jul 29 16:54:11 2005 @@ -28,7 +28,7 @@ */ -/* $Id: apc_cache.c,v 3.89 2005/07/29 08:19:30 rasmus Exp $ */ +/* $Id: apc_cache.c,v 3.90 2005/07/29 20:54:11 rasmus Exp $ */ #include "apc_cache.h" #include "apc_lock.h" @@ -571,7 +571,8 @@ TSRMLS_DC) { struct stat buf, *tmp_buf=NULL; - + + TSRMLS_FETCH(); assert(key != NULL); if (!filename || !SG(request_info).path_translated) { @@ -605,27 +606,16 @@ * request time and we want to avoid caching files that have not been * completely written. Of course, people should be using atomic * mechanisms to push files onto live web servers, but adding this - * tiny safety is easier than educating the world. + * tiny safety is easier than educating the world. This is now + * configurable, but the default is still 2 seconds. */ - if(t - buf.st_mtime < 2) { + if(APCG(file_update_protection) && (t - 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); #endif return 0; } - /* - * This is an even bigger hack than the above. - * - * Basically this will cause a file only to be cached on a percentage - * of the attempts. This is to avoid cache slams when starting up a - * very busy server or when modifying files on a very busy live server. - * There is no point having many processes all trying to cache the same - * file at the same time. By introducing a chance of being cached - * we theoretically cut the cache slam problem by the given percentage. - * For example if apc.slam_defense is set to 66 then 2/3 of the attempts - * to cache an uncached file will be ignored. - */ key->data.file.device = buf.st_dev; key->data.file.inode = buf.st_ino; /* @@ -636,7 +626,9 @@ * "older" template. At some point the Smarty templating system did this. * I generally disagree with using the ctime here because you lose the * ability to warm up new content by saving it to a temporary file, hitting - * it once to cache it and then renaming it into its permanent location. + * it once to cache it and then renaming it into its permanent location so + * I am leaving this commented out by default. If you need this, uncomment + * it. */ /* key->mtime = (buf.st_ctime > buf.st_mtime) ? buf.st_ctime : buf.st_mtime; */ key->mtime = buf.st_mtime; http://cvs.php.net/diff.php/pecl/apc/apc_globals.h?r1=3.16&r2=3.17&ty=u Index: pecl/apc/apc_globals.h diff -u pecl/apc/apc_globals.h:3.16 pecl/apc/apc_globals.h:3.17 --- pecl/apc/apc_globals.h:3.16 Fri Jul 29 04:19:31 2005 +++ pecl/apc/apc_globals.h Fri Jul 29 16:54:11 2005 @@ -29,7 +29,7 @@ */ -/* $Id: apc_globals.h,v 3.16 2005/07/29 08:19:31 rasmus Exp $ */ +/* $Id: apc_globals.h,v 3.17 2005/07/29 20:54:11 rasmus Exp $ */ #ifndef APC_GLOBALS_H #define APC_GLOBALS_H @@ -67,6 +67,7 @@ /* false if files should only be cached if filtered in */ int slam_defense; /* Probability of a process not caching an uncached file */ size_t* mem_size_ptr; /* size of blocks allocated to file being cached (NULL outside my_compile_file) */ + int file_update_protection; /* Age in seconds before a file is eligible to be cached - 0 to disable */ ZEND_END_MODULE_GLOBALS(apc) /* (the following declaration is defined in php_apc.c) */ http://cvs.php.net/diff.php/pecl/apc/php_apc.c?r1=3.57&r2=3.58&ty=u Index: pecl/apc/php_apc.c diff -u pecl/apc/php_apc.c:3.57 pecl/apc/php_apc.c:3.58 --- pecl/apc/php_apc.c:3.57 Fri Jul 29 04:19:32 2005 +++ pecl/apc/php_apc.c Fri Jul 29 16:54:11 2005 @@ -26,7 +26,7 @@ */ -/* $Id: php_apc.c,v 3.57 2005/07/29 08:19:32 rasmus Exp $ */ +/* $Id: php_apc.c,v 3.58 2005/07/29 20:54:11 rasmus Exp $ */ #include "php_apc.h" #include "apc_cache.h" @@ -116,7 +116,8 @@ #endif PHP_INI_ENTRY("apc.filters", "", PHP_INI_SYSTEM, OnUpdate_filters) STD_PHP_INI_BOOLEAN("apc.cache_by_default", "1", PHP_INI_SYSTEM, OnUpdateInt, cache_by_default, zend_apc_globals, apc_globals) -STD_PHP_INI_BOOLEAN("apc.slam_defense", "0", PHP_INI_SYSTEM, OnUpdateInt, slam_defense, zend_apc_globals, apc_globals) +STD_PHP_INI_BOOLEAN("apc.slam_defense", "0", PHP_INI_SYSTEM, OnUpdateInt, slam_defense, zend_apc_globals, apc_globals) +STD_PHP_INI_BOOLEAN("apc.file_update_protection", "2", PHP_INI_SYSTEM, OnUpdateInt,file_update_protection, zend_apc_globals, apc_globals) PHP_INI_END() /* }}} */ @@ -133,7 +134,7 @@ #else php_info_print_table_row(2, "MMAP Support", "Disabled"); #endif - php_info_print_table_row(2, "Revision", "$Revision: 3.57 $"); + php_info_print_table_row(2, "Revision", "$Revision: 3.58 $"); php_info_print_table_row(2, "Build Date", __DATE__ " " __TIME__); php_info_print_table_end(); DISPLAY_INI_ENTRIES(); |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | cvs: pecl /apc apc_fcntl_win32.c: 00264, Frank M. Kromann |
|---|---|
| Next by Date: | cvs: pecl /http php_http_std_defs.h /http/tests HttpRequest_002.phpt: 00264, Michael Wallner |
| Previous by Thread: | cvs: pecl /http php_http_request_api.hi: 00264, Michael Wallner |
| Next by Thread: | cvs: pecl /http php_http_std_defs.h /http/tests HttpRequest_002.phpt: 00264, Michael Wallner |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |