val = (zend_bool) atoi(ZSTR_VAL(new_value));
}
- gc_set_enabled(val);
+ gc_enable(val);
return SUCCESS;
}
zend_output_debug_string(1, "%s(%d) : Bailed out without a bailout address!", filename, lineno);
exit(-1);
}
+ gc_protect(1);
CG(unclean_shutdown) = 1;
CG(active_class_entry) = NULL;
CG(in_compilation) = 0;
#endif
}
-ZEND_API void gc_globals_ctor(void)
+void gc_globals_ctor(void)
{
#ifdef ZTS
ts_allocate_id(&gc_globals_id, sizeof(zend_gc_globals), (ts_allocate_ctor) gc_globals_ctor_ex, (ts_allocate_dtor) root_buffer_dtor);
#endif
}
-ZEND_API void gc_globals_dtor(void)
+void gc_globals_dtor(void)
{
#ifndef ZTS
root_buffer_dtor(&gc_globals);
#endif
}
-ZEND_API void gc_reset(void)
+void gc_reset(void)
{
if (GC_G(buf)) {
GC_G(gc_active) = 0;
}
}
-ZEND_API zend_bool gc_set_enabled(zend_bool enable)
+ZEND_API zend_bool gc_enable(zend_bool enable)
{
zend_bool old_enabled = GC_G(gc_enabled);
GC_G(gc_enabled) = enable;
return GC_G(gc_enabled);
}
+ZEND_API zend_bool gc_protect(zend_bool protect)
+{
+ zend_bool old_protected = GC_G(gc_protected);
+ GC_G(gc_protected) = protect;
+ return old_protected;
+}
+
+ZEND_API zend_bool gc_protected(void)
+{
+ return GC_G(gc_protected);
+}
+
static void gc_grow_root_buffer(void)
{
size_t new_size;
if (GC_G(buf_size) >= GC_MAX_BUF_SIZE) {
if (!GC_G(gc_full)) {
zend_error(E_WARNING, "GC buffer overflow (GC disabled)\n");
- //???GC_G(gc_enabled) = 0;
GC_G(gc_active) = 1;
GC_G(gc_protected) = 1;
GC_G(gc_full) = 1;
- CG(unclean_shutdown) = 1;
return;
}
}
uint32_t addr;
gc_root_buffer *newRoot;
- if (UNEXPECTED(GC_G(gc_protected)) || UNEXPECTED(CG(unclean_shutdown))) {
+ if (UNEXPECTED(GC_G(gc_protected))) {
return;
}
}
pefree(refcounts, 1);
+
+ if (GC_G(gc_protected)) {
+ /* something went wrong */
+ return 0;
+ }
}
/* Destroy zvals */
ZEND_API void ZEND_FASTCALL gc_possible_root(zend_refcounted *ref);
ZEND_API void ZEND_FASTCALL gc_remove_from_buffer(zend_refcounted *ref);
-ZEND_API void gc_globals_ctor(void);
-ZEND_API void gc_globals_dtor(void);
-ZEND_API void gc_reset(void);
-ZEND_API zend_bool gc_set_enabled(zend_bool enable);
+
+/* enable/disable automatic start of GC collection */
+ZEND_API zend_bool gc_enable(zend_bool enable);
ZEND_API zend_bool gc_enabled(void);
+/* enable/disable possible root additions */
+ZEND_API zend_bool gc_protect(zend_bool protect);
+ZEND_API zend_bool gc_protected(void);
+
/* The default implementation of the gc_collect_cycles callback. */
ZEND_API int zend_gc_collect_cycles(void);
+
+void gc_globals_ctor(void);
+void gc_globals_dtor(void);
+void gc_reset(void);
+
END_EXTERN_C()
#define GC_REMOVE_FROM_BUFFER(p) do { \