ZCG(mem) = zend_arena_alloc(&CG(arena), memory_used);
#endif
- /* Copy into shared memory */
- new_persistent_script = zend_accel_script_persist(new_persistent_script, NULL, 0);
+ /* Copy into memory block */
+ new_persistent_script = zend_accel_script_persist(new_persistent_script, NULL, 0, 0);
zend_shared_alloc_destroy_xlat_table();
}
/* Copy into shared memory */
- new_persistent_script = zend_accel_script_persist(new_persistent_script, &key, key_length);
+ new_persistent_script = zend_accel_script_persist(new_persistent_script, &key, key_length, 1);
zend_shared_alloc_destroy_xlat_table();
static int zend_accel_init_shm(void)
{
+ int i;
+
zend_shared_alloc_lock();
accel_shared_globals = zend_shared_alloc(sizeof(zend_accel_shared_globals));
ZCSG(last_restart_time) = 0;
ZCSG(restart_in_progress) = 0;
+
+ for (i = 0; i < -HT_MIN_MASK; i++) {
+ ZCSG(uninitialized_bucket)[i] = HT_INVALID_IDX;
+ }
+
zend_shared_alloc_unlock();
return SUCCESS;
ht->pDestructor = NULL;
if (!(ht->u.flags & HASH_FLAG_INITIALIZED)) {
- HT_SET_DATA_ADDR(ht, &uninitialized_bucket);
+ if (EXPECTED(!ZCG(current_persistent_script)->corrupted)) {
+ HT_SET_DATA_ADDR(ht, &ZCSG(uninitialized_bucket));
+ } else {
+ HT_SET_DATA_ADDR(ht, &uninitialized_bucket);
+ }
return;
}
if (ht->nNumUsed == 0) {
efree(HT_GET_DATA_ADDR(ht));
ht->nTableMask = HT_MIN_MASK;
- HT_SET_DATA_ADDR(ht, &uninitialized_bucket);
+ if (EXPECTED(!ZCG(current_persistent_script)->corrupted)) {
+ HT_SET_DATA_ADDR(ht, &ZCSG(uninitialized_bucket));
+ } else {
+ HT_SET_DATA_ADDR(ht, &uninitialized_bucket);
+ }
ht->u.flags &= ~HASH_FLAG_INITIALIZED;
return;
}
ht->pDestructor = NULL;
if (!(ht->u.flags & HASH_FLAG_INITIALIZED)) {
- HT_SET_DATA_ADDR(ht, &uninitialized_bucket);
+ if (EXPECTED(!ZCG(current_persistent_script)->corrupted)) {
+ HT_SET_DATA_ADDR(ht, &ZCSG(uninitialized_bucket));
+ } else {
+ HT_SET_DATA_ADDR(ht, &uninitialized_bucket);
+ }
return;
}
if (ht->nNumUsed == 0) {
efree(HT_GET_DATA_ADDR(ht));
ht->nTableMask = HT_MIN_MASK;
- HT_SET_DATA_ADDR(ht, &uninitialized_bucket);
+ if (EXPECTED(!ZCG(current_persistent_script)->corrupted)) {
+ HT_SET_DATA_ADDR(ht, &ZCSG(uninitialized_bucket));
+ } else {
+ HT_SET_DATA_ADDR(ht, &uninitialized_bucket);
+ }
ht->u.flags &= ~HASH_FLAG_INITIALIZED;
return;
}
zend_hash_apply(class_table, (apply_func_t) zend_update_parent_ce);
}
-zend_persistent_script *zend_accel_script_persist(zend_persistent_script *script, char **key, unsigned int key_length)
+zend_persistent_script *zend_accel_script_persist(zend_persistent_script *script, char **key, unsigned int key_length, int for_shm)
{
script->mem = ZCG(mem);
+ script->corrupted = 0;
+ ZCG(current_persistent_script) = script;
+
+ if (!for_shm) {
+ /* script is not going to be saved in SHM */
+ script->corrupted = 1;
+ }
ZEND_ASSERT(((zend_uintptr_t)ZCG(mem) & 0x7) == 0); /* should be 8 byte aligned */
zend_shared_alloc_clear_xlat_table();
zend_hash_persist(&script->script.function_table, zend_persist_op_array);
zend_persist_op_array_ex(&script->script.main_op_array, script);
+ script->corrupted = 0;
+ ZCG(current_persistent_script) = NULL;
+
return script;
}
int zend_accel_script_persistable(zend_persistent_script *script);
uint zend_accel_script_persist_calc(zend_persistent_script *script, char *key, unsigned int key_length, int for_shm);
-zend_persistent_script *zend_accel_script_persist(zend_persistent_script *script, char **key, unsigned int key_length);
+zend_persistent_script *zend_accel_script_persist(zend_persistent_script *script, char **key, unsigned int key_length, int for_shm);
#endif /* ZEND_PERSIST_H */