Re: Bug#212988: ITP: turck-mmcache -- Precompiler and cache to improve performance of PHP scripts
* Jonathan Oxer
| Turck MMCache is a PHP Accelerator, Optimizer, Encoder and Dynamic
| Content Cache. It increases performance of PHP scripts by caching
| them in a compiled state, so that the overhead of compiling is almost
| completely eliminated. It also uses some optimizations for speedup
| of PHP script execution. Turck MMCache typically reduces server
| load and increases the speed of PHP code by 1-10 times.
You probably want a patch similar to this to enable it to mkdir the
cache dir (unless you enable the cache_dir to be a directory which is
shipped in the package). Also sending this upstream might be a good
idea, I haven't gotten around to it.
diff -ru turck-mmcache-2.4.0/mmcache.c turck-mmcache-2.4.0.tfheen/mmcache.c
--- turck-mmcache-2.4.0/mmcache.c 2003-09-22 09:51:51.000000000 +0200
+++ turck-mmcache-2.4.0.tfheen/mmcache.c 2003-09-25 11:23:10.000000000 +0200
@@ -812,9 +814,33 @@
(v & 0x0000ff));
}
+static void mmcache_make_cache_dir_if_missing() {
+ int ret;
+ struct stat statbuf;
+ /* Ensure cache_dir exists */
+
+ ret = stat(MMCG(cache_dir), &statbuf);
+ if (ret == 0) {
+ /* It exists, check that it is a directory */
+ if (!S_ISDIR(statbuf.st_mode)) {
+ zend_error(E_ERROR, "cache_dir is not a directory");
+ } /* else, all is well */
+ } else {
+ if (errno == ENOENT) {
+ if (mkdir(MMCG(cache_dir), 0700) != 0) {
+ zend_error(E_ERROR, "something weird happened mkdir-ing cache_dir: %s", strerror(errno));
+ }
+ } else {
+ zend_error(E_ERROR, "something weird happened stat-ing cache_dir: %s", strerror(errno));
+
+ }
+ }
+}
+
#ifdef MMCACHE_USE_INODE
static int mmcache_inode_key(char* s, dev_t dev, ino_t ino TSRMLS_DC) {
int n;
+ mmcache_make_cache_dir_if_missing();
strncpy(s, MMCG(cache_dir), MAXPATHLEN-1);
strlcat(s, "/mmcache-", MAXPATHLEN-1);
n = strlen(s);
@@ -849,6 +876,8 @@
if (call_user_function(CG(function_table), (zval**)NULL, &md5, &retval, 1, params TSRMLS_CC) == SUCCESS &&
retval.type == IS_STRING &&
retval.value.str.len == 32) {
+
+ mmcache_make_cache_dir_if_missing();
strncpy(s, MMCG(cache_dir), MAXPATHLEN-1);
strlcat(s, prefix, MAXPATHLEN);
strlcat(s, retval.value.str.val, MAXPATHLEN);
--
Tollef Fog Heen ,''`.
UNIX is user friendly, it's just picky about who its friends are : :' :
`. `'
`-
Reply to: