Ticket #198: xcache-2.0.1-stream-patch

File xcache-2.0.1-stream-patch, 2.1 KB (added by hlang, 21 months ago)

patch cache php modul streams in xcache version 2.0.x

Line 
1diff -u -r -N xcache-2.0.1/xcache.c xcache-2.0.1-stream/xcache.c
2--- xcache-2.0.1/xcache.c   2012-07-14 03:29:58.000000000 +0200
3+++ xcache-2.0.1-stream/xcache.c    2012-08-07 13:56:57.000000000 +0200
4@@ -1006,6 +1006,25 @@
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+
16+   wrapper = php_stream_locate_url_wrapper(filepath, &path_for_open, 0 TSRMLS_CC);
17+   if ((wrapper) && (wrapper->wops) && (wrapper->wops->url_stat) &&
18+       (wrapper != &php_plain_files_wrapper) && 
19+       (SUCCESS == wrapper->wops->url_stat(wrapper, path_for_open, PHP_STREAM_URL_STAT_QUIET, &ssb, NULL TSRMLS_CC))) {
20+       *statbuf = ssb.sb;
21+       return SUCCESS;
22+   }
23+
24+   return FAILURE;
25+}
26+/* }}} */
27 #endif
28 typedef struct xc_compiler_t { /* {{{ */
29    /* XCache cached compile state */
30@@ -1097,6 +1116,18 @@
31        compiler->opened_path = xc_expand_url(compiler->filename, compiler->opened_path_buffer TSRMLS_CC);
32        return SUCCESS;
33    }
34+   
35+#ifdef ZEND_ENGINE_2_3
36+   if (strstr(compiler->filename, "://") != NULL)
37+   {
38+       if (SUCCESS != xc_resolve_stream_path_stat(compiler->filename, statbuf)) {
39+           return FAILURE;
40+       }
41+
42+       compiler->opened_path = xc_expand_url(compiler->filename, compiler->opened_path_buffer TSRMLS_CC);
43+       return SUCCESS;
44+   }
45+#endif
46 
47    return FAILURE;
48 }
49@@ -1137,6 +1168,13 @@
50        time_t delta;
51 
52        if (compiler->opened_path) {
53+#ifdef ZEND_ENGINE_2_3
54+           if (strstr(compiler->opened_path, "://") != NULL) {
55+               if (SUCCESS != xc_resolve_stream_path_stat(compiler->opened_path, &buf TSRMLS_CC)) {
56+                   return FAILURE;
57+               }
58+           } else
59+#endif
60            if (VCWD_STAT(compiler->opened_path, &buf) != 0) {
61                return FAILURE;
62            }
63@@ -2147,11 +2185,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     ) {