File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ --TEST--
2+ OPcache static cache uses the Win32 shared memory and lock backend
3+ --EXTENSIONS--
4+ opcache
5+ --SKIPIF--
6+ <?php
7+ if (PHP_OS_FAMILY !== 'Windows ' ) {
8+ die ('skip Windows only ' );
9+ }
10+ ?>
11+ --INI--
12+ opcache.enable=1
13+ opcache.enable_cli=1
14+ opcache.static_cache.volatile_size_mb=32
15+ opcache.static_cache.persistent_size_mb=32
16+ --FILE--
17+ <?php
18+
19+ $ volatileInfo = OPcache \volatile_cache_info ();
20+ $ persistentInfo = OPcache \persistent_cache_info ();
21+
22+ var_dump ($ volatileInfo ['available ' ]);
23+ var_dump ($ persistentInfo ['available ' ]);
24+ var_dump ($ volatileInfo ['shared_model ' ]);
25+ var_dump ($ persistentInfo ['shared_model ' ]);
26+ var_dump ($ volatileInfo ['shared_memory ' ]);
27+ var_dump ($ persistentInfo ['shared_memory ' ]);
28+
29+ OPcache \volatile_clear ();
30+ OPcache \persistent_clear ();
31+
32+ $ key = 'windows-backend ' ;
33+
34+ var_dump (OPcache \volatile_lock ($ key ));
35+ var_dump (OPcache \volatile_store ($ key , ['backend ' => 'volatile ' ]));
36+ var_dump (OPcache \persistent_lock ($ key ));
37+ OPcache \persistent_store ($ key , ['backend ' => 'persistent ' ]);
38+
39+ var_dump (OPcache \volatile_fetch ($ key ));
40+ var_dump (OPcache \persistent_fetch ($ key ));
41+
42+ ?>
43+ --EXPECT--
44+ bool(true)
45+ bool(true)
46+ string(5) "win32"
47+ string(5) "win32"
48+ int(33554432)
49+ int(33554432)
50+ bool(true)
51+ bool(true)
52+ bool(true)
53+ array(1) {
54+ ["backend"]=>
55+ string(8) "volatile"
56+ }
57+ array(1) {
58+ ["backend"]=>
59+ string(10) "persistent"
60+ }
Original file line number Diff line number Diff line change @@ -71,7 +71,7 @@ const char *zend_opcache_static_cache_subsystem_failure_reason = NULL;
7171static HashTable zend_opcache_static_cache_safe_direct_handler_table ;
7272static bool zend_opcache_static_cache_safe_direct_handlers_initialized = false;
7373
74- #if defined( ZTS ) && !defined( ZEND_WIN32 )
74+ #ifdef ZTS
7575ZEND_EXT_TLS bool zend_opcache_static_cache_zts_lock_is_write = false;
7676#endif
7777ZEND_EXT_TLS HashTable zend_opcache_static_cache_attribute_classes ;
Original file line number Diff line number Diff line change @@ -137,15 +137,13 @@ typedef struct _zend_opcache_static_cache_storage {
137137 bool initialized ;
138138 bool initialized_before_request ;
139139 bool lock_initialized ;
140- #ifndef ZEND_WIN32
141140 int lock_file ;
142141 char lockfile_name [MAXPATHLEN ];
143142#ifdef ZTS
144143 zend_thread_rwlock_t zts_lock ;
145144 MUTEX_T entry_locks [ZEND_OPCACHE_STATIC_CACHE_ENTRY_LOCK_STRIPES ];
146145 bool entry_locks_initialized ;
147146#endif
148- #endif
149147} zend_opcache_static_cache_storage ;
150148
151149typedef struct _zend_opcache_static_cache_context {
@@ -374,7 +372,7 @@ extern ZEND_EXT_TLS HashTable zend_opcache_static_cache_class_blob_handles;
374372extern ZEND_EXT_TLS bool zend_opcache_static_cache_class_blob_handles_initialized ;
375373extern bool zend_opcache_static_cache_safe_direct_classes_marked ;
376374extern ZEND_EXT_TLS zend_opcache_static_cache_context * zend_opcache_static_cache_active_context_ptr ;
377- #if defined( ZTS ) && !defined( ZEND_WIN32 )
375+ #ifdef ZTS
378376extern ZEND_EXT_TLS bool zend_opcache_static_cache_zts_lock_is_write ;
379377#endif
380378extern ZEND_EXT_TLS HashTable * zend_opcache_static_cache_tracked_roots ;
You can’t perform that action at this time.
0 commit comments