mirror of
https://github.com/php/php-src.git
synced 2025-08-16 22:18:50 +02:00
Support VirtualProtect for opcache.protect_memory
Don't enable this on AppVeyor yet, as there is still an open issue in phar.
This commit is contained in:
parent
db7aba538d
commit
eb8c07fe2f
2 changed files with 23 additions and 0 deletions
|
@ -305,7 +305,9 @@ static inline int accel_restart_is_active(void)
|
||||||
static inline int accel_activate_add(void)
|
static inline int accel_activate_add(void)
|
||||||
{
|
{
|
||||||
#ifdef ZEND_WIN32
|
#ifdef ZEND_WIN32
|
||||||
|
SHM_UNPROTECT();
|
||||||
INCREMENT(mem_usage);
|
INCREMENT(mem_usage);
|
||||||
|
SHM_PROTECT();
|
||||||
#else
|
#else
|
||||||
struct flock mem_usage_lock;
|
struct flock mem_usage_lock;
|
||||||
|
|
||||||
|
@ -327,8 +329,10 @@ static inline void accel_deactivate_sub(void)
|
||||||
{
|
{
|
||||||
#ifdef ZEND_WIN32
|
#ifdef ZEND_WIN32
|
||||||
if (ZCG(counted)) {
|
if (ZCG(counted)) {
|
||||||
|
SHM_UNPROTECT();
|
||||||
DECREMENT(mem_usage);
|
DECREMENT(mem_usage);
|
||||||
ZCG(counted) = 0;
|
ZCG(counted) = 0;
|
||||||
|
SHM_PROTECT();
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
struct flock mem_usage_unlock;
|
struct flock mem_usage_unlock;
|
||||||
|
|
|
@ -594,6 +594,25 @@ void zend_accel_shared_protect(int mode)
|
||||||
for (i = 0; i < ZSMMG(shared_segments_count); i++) {
|
for (i = 0; i < ZSMMG(shared_segments_count); i++) {
|
||||||
mprotect(ZSMMG(shared_segments)[i]->p, ZSMMG(shared_segments)[i]->size, mode);
|
mprotect(ZSMMG(shared_segments)[i]->p, ZSMMG(shared_segments)[i]->size, mode);
|
||||||
}
|
}
|
||||||
|
#elif defined(ZEND_WIN32)
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (!smm_shared_globals) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mode) {
|
||||||
|
mode = PAGE_READONLY;
|
||||||
|
} else {
|
||||||
|
mode = PAGE_READWRITE;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < ZSMMG(shared_segments_count); i++) {
|
||||||
|
DWORD oldProtect;
|
||||||
|
if (!VirtualProtect(ZSMMG(shared_segments)[i]->p, ZSMMG(shared_segments)[i]->size, mode, &oldProtect)) {
|
||||||
|
zend_accel_error(ACCEL_LOG_ERROR, "Failed to protect memory");
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue