_zend_hash_del_el_ex(ht, idx, p, prev);
}
+ZEND_API void ZEND_FASTCALL zend_hash_del_bucket(HashTable *ht, Bucket *p)
+{
+ IS_CONSISTENT(ht);
+ HT_ASSERT(GC_REFCOUNT(ht) == 1);
+ _zend_hash_del_el(ht, HT_IDX_TO_HASH(p - ht->arData), p);
+}
+
ZEND_API int ZEND_FASTCALL zend_hash_del(HashTable *ht, zend_string *key)
{
zend_ulong h;
ZEND_API int ZEND_FASTCALL zend_hash_str_del(HashTable *ht, const char *key, size_t len);
ZEND_API int ZEND_FASTCALL zend_hash_str_del_ind(HashTable *ht, const char *key, size_t len);
ZEND_API int ZEND_FASTCALL zend_hash_index_del(HashTable *ht, zend_ulong h);
+ZEND_API void ZEND_FASTCALL zend_hash_del_bucket(HashTable *ht, Bucket *p);
/* Data retreival */
ZEND_API zval* ZEND_FASTCALL zend_hash_find(const HashTable *ht, zend_string *key);
#include "zend_virtual_cwd.h"
#include "zend_accelerator_util_funcs.h"
#include "zend_accelerator_hash.h"
+#include "ext/pcre/php_pcre.h"
#ifndef ZEND_WIN32
#include <netdb.h>
ZCSG(force_restart_time) = 0;
}
+#ifndef ZTS
+static void accel_reset_pcre_cache(void)
+{
+ Bucket *p;
+
+ ZEND_HASH_FOREACH_BUCKET(&PCRE_G(pcre_cache), p) {
+ /* Remove PCRE cache entries with inconsistent keys */
+ if (IS_ACCEL_INTERNED(p->key)) {
+ p->key = NULL;
+ zend_hash_del_bucket(&PCRE_G(pcre_cache), p);
+ }
+ } ZEND_HASH_FOREACH_END();
+}
+#endif
+
static void accel_activate(void)
{
+#ifndef ZTS
+ zend_bool reset_pcre = 0;
+#endif
if (!ZCG(enabled) || !accel_startup_ok) {
return;
zend_shared_alloc_restore_state();
ZCSG(accelerator_enabled) = ZCSG(cache_status_before_restart);
- ZCSG(last_restart_time) = ZCG(request_time);
+ if (ZCSG(last_restart_time) < ZCG(request_time)) {
+ ZCSG(last_restart_time) = ZCG(request_time);
+ } else {
+ ZCSG(last_restart_time)++;
+ }
accel_restart_leave();
}
+#ifndef ZTS
+ } else {
+ reset_pcre = 1;
+#endif
}
zend_shared_alloc_unlock();
}
ZCG(cwd_check) = 1;
SHM_PROTECT();
+
+ if (ZCSG(last_restart_time) != ZCG(last_restart_time)) {
+ /* SHM was reinitialized. */
+ ZCG(last_restart_time) = ZCSG(last_restart_time);
+
+ /* Reset in-process realpath cache */
+ realpath_cache_clean();
+
+#ifndef ZTS
+ accel_reset_pcre_cache();
+ } else if (reset_pcre) {
+ accel_reset_pcre_cache();
+#endif
+ }
}
#if !ZEND_DEBUG
break;
}
+ /* remeber the last restart time in the process memory */
+ ZCG(last_restart_time) = ZCSG(last_restart_time);
+
/* from this point further, shared memory is supposed to be OK */
/* Init auto-global strings */
zend_hash_clean(CG(function_table));
zend_hash_clean(CG(class_table));
zend_hash_clean(EG(zend_constants));
+
+ accel_reset_pcre_cache();
#endif
}
};
-ZEND_DECLARE_MODULE_GLOBALS(pcre)
+PHPAPI ZEND_DECLARE_MODULE_GLOBALS(pcre)
static void pcre_handle_exec_error(int pcre_code) /* {{{ */
* as hash keys especually for this table.
* See bug #63180
*/
- pce = zend_hash_str_update_mem(&PCRE_G(pcre_cache), regex->val, regex->len, &new_entry, sizeof(pcre_cache_entry));
+ if (!IS_INTERNED(regex) || !(GC_FLAGS(regex) & IS_STR_PERMANENT)) {
+ zend_string *str = zend_string_init(regex->val, regex->len, 1);
+ GC_REFCOUNT(str) = 0; /* will be incremented by zend_hash_update_mem() */
+ str->h = regex->h;
+ regex = str;
+ }
+
+ pce = zend_hash_update_mem(&PCRE_G(pcre_cache), regex, &new_entry, sizeof(pcre_cache_entry));
return pce;
}