Ticket #198: xcache-trunk-stream-patch

File xcache-trunk-stream-patch, 2.1 KB (added by hlang, 2 years ago)

patch cache php modul streams in xcache version 3.0.0

Line 
1diff -u -r -N xcache-trunk/mod_cacher/xc_cacher.c xcache-trunk-stream/mod_cacher/xc_cacher.c
2--- xcache-trunk/mod_cacher/xc_cacher.c 2012-08-07 09:20:56.000000000 +0200
3+++ xcache-trunk-stream/mod_cacher/xc_cacher.c  2012-08-08 17:05:39.000000000 +0200
4@@ -1021,6 +1021,24 @@
5        : FAILURE;
6 }
7 /* }}} */
8+#else
9+static int xc_resolve_stream_path_stat(const char *filepath, struct stat *statbuf TSRMLS_DC) /* {{{ */
10+{
11+   php_stream_statbuf ssb;
12+   php_stream_wrapper *wrapper = NULL;
13+   char *path_for_open = NULL;
14+
15+   wrapper = php_stream_locate_url_wrapper(filepath, &path_for_open, 0 TSRMLS_CC);
16+   if ((wrapper) && (wrapper->wops) && (wrapper->wops->url_stat) &&
17+       (wrapper != &php_plain_files_wrapper) && 
18+       (SUCCESS == wrapper->wops->url_stat(wrapper, path_for_open, PHP_STREAM_URL_STAT_QUIET, &ssb, NULL TSRMLS_CC))) {
19+       *statbuf = ssb.sb;
20+       return SUCCESS;
21+   }
22+
23+   return FAILURE;
24+}
25+/* }}} */
26 #endif
27 typedef struct xc_compiler_t { /* {{{ */
28    /* XCache cached compile state */
29@@ -1113,6 +1131,18 @@
30        return SUCCESS;
31    }
32 
33+#ifdef ZEND_ENGINE_2_3
34+   if (strstr(compiler->filename, "://") != NULL)
35+   {
36+       if (SUCCESS != xc_resolve_stream_path_stat(compiler->filename, statbuf)) {
37+           return FAILURE;
38+       }
39+
40+       compiler->opened_path = xc_expand_url(compiler->filename, compiler->opened_path_buffer TSRMLS_CC);
41+       return SUCCESS;
42+   }
43+#endif
44+
45    return FAILURE;
46 }
47 /* }}} */
48@@ -1152,6 +1182,14 @@
49        time_t delta;
50 
51        if (compiler->opened_path) {
52+#ifdef ZEND_ENGINE_2_3
53+           if (strstr(compiler->opened_path, "://") != NULL) {
54+               if (SUCCESS != xc_resolve_stream_path_stat(compiler->opened_path, &buf TSRMLS_CC)) {
55+                   return FAILURE;
56+               }
57+           } else
58+#endif
59+
60            if (VCWD_STAT(compiler->opened_path, &buf) != 0) {
61                return FAILURE;
62            }
63@@ -2161,11 +2199,11 @@
64    if (!XG(cacher)
65     || !h->filename
66     || !SG(request_info).path_translated
67-    || strstr(h->filename, "://") != NULL
68 #ifdef ZEND_ENGINE_2_3
69     /* supported by php_resolve_path */
70     || (!XG(stat) && strstr(PG(include_path), "://") != NULL)
71 #else
72+    || strstr(h->filename, "://") != NULL
73     || strstr(PG(include_path), "://") != NULL
74 #endif
75     ) {