Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 0 additions & 21 deletions TSRM/TSRM.c
Original file line number Diff line number Diff line change
Expand Up @@ -576,27 +576,6 @@ void ts_free_id(ts_rsrc_id id)
TSRM_ERROR((TSRM_ERROR_LEVEL_CORE, "Successfully freed resource id %d", id));
}/*}}}*/

TSRM_API void ts_apply_for_id(ts_rsrc_id id, void (*cb)(void *))
{
int rsrc_id = TSRM_UNSHUFFLE_RSRC_ID(id);

tsrm_mutex_lock(tsmm_mutex);

if (tsrm_tls_table && resource_types_table) {
for (int i = 0; i < tsrm_tls_table_size; i++) {
tsrm_tls_entry *p = tsrm_tls_table[i];

while (p) {
if (p->count > rsrc_id && p->storage[rsrc_id]) {
cb(p->storage[rsrc_id]);
}
p = p->next;
}
}
}

tsrm_mutex_unlock(tsmm_mutex);
}

/*
* Utility Functions
Expand Down
3 changes: 0 additions & 3 deletions TSRM/TSRM.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,6 @@ TSRM_API void ts_free_thread(void);
/* deallocates all occurrences of a given id */
TSRM_API void ts_free_id(ts_rsrc_id id);

/* Runs a callback on all resources of the given id.
* The caller is responsible for ensuring the underlying resources don't data-race. */
TSRM_API void ts_apply_for_id(ts_rsrc_id id, void (*cb)(void *));

/* Debug support */
#define TSRM_ERROR_LEVEL_ERROR 1
Expand Down
15 changes: 2 additions & 13 deletions Zend/zend.c
Original file line number Diff line number Diff line change
Expand Up @@ -826,19 +826,13 @@ static void executor_globals_ctor(zend_executor_globals *executor_globals) /* {{
}
/* }}} */

static void executor_globals_persistent_list_dtor(void *storage)
static void executor_globals_dtor(zend_executor_globals *executor_globals) /* {{{ */
{
zend_executor_globals *executor_globals = storage;
zend_ini_dtor(executor_globals->ini_directives);

if (&executor_globals->persistent_list != global_persistent_list) {
zend_destroy_rsrc_list(&executor_globals->persistent_list);
}
}

static void executor_globals_dtor(zend_executor_globals *executor_globals) /* {{{ */
{
zend_ini_dtor(executor_globals->ini_directives);

if (executor_globals->zend_constants != GLOBAL_CONSTANTS_TABLE) {
zend_hash_destroy(executor_globals->zend_constants);
free(executor_globals->zend_constants);
Expand Down Expand Up @@ -1128,9 +1122,6 @@ void zend_shutdown(void) /* {{{ */
zend_vm_dtor();

zend_destroy_rsrc_list(&EG(persistent_list));
#ifdef ZTS
ts_apply_for_id(executor_globals_id, executor_globals_persistent_list_dtor);
#endif
zend_destroy_modules();

virtual_cwd_deactivate();
Expand Down Expand Up @@ -1183,8 +1174,6 @@ void zend_shutdown(void) /* {{{ */
#endif
zend_destroy_rsrc_list_dtors();

zend_unload_modules();

zend_optimizer_shutdown();
startup_done = false;
}
Expand Down
1 change: 0 additions & 1 deletion Zend/zend.h
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,6 @@ void zend_shutdown(void);
void zend_register_standard_ini_entries(void);
zend_result zend_post_startup(void);
void zend_set_utility_values(zend_utility_values *utility_values);
void zend_unload_modules(void);

ZEND_API ZEND_COLD ZEND_NORETURN void _zend_bailout(const char *filename, uint32_t lineno);
ZEND_API size_t zend_get_page_size(void);
Expand Down
43 changes: 6 additions & 37 deletions Zend/zend_API.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ ZEND_API HashTable module_registry;
static zend_module_entry **module_request_startup_handlers;
static zend_module_entry **module_request_shutdown_handlers;
static zend_module_entry **module_post_deactivate_handlers;
static zend_module_entry **modules_dl_loaded;

static zend_class_entry **class_cleanup_handlers;

Expand Down Expand Up @@ -2399,7 +2398,6 @@ ZEND_API void zend_collect_module_handlers(void) /* {{{ */
int startup_count = 0;
int shutdown_count = 0;
int post_deactivate_count = 0;
int dl_loaded_count = 0;
zend_class_entry *ce;
int class_count = 0;

Expand All @@ -2414,9 +2412,6 @@ ZEND_API void zend_collect_module_handlers(void) /* {{{ */
if (module->post_deactivate_func) {
post_deactivate_count++;
}
if (module->handle) {
dl_loaded_count++;
}
} ZEND_HASH_FOREACH_END();
module_request_startup_handlers = (zend_module_entry**)realloc(
module_request_startup_handlers,
Expand All @@ -2429,9 +2424,6 @@ ZEND_API void zend_collect_module_handlers(void) /* {{{ */
module_request_shutdown_handlers[shutdown_count] = NULL;
module_post_deactivate_handlers = module_request_shutdown_handlers + shutdown_count + 1;
module_post_deactivate_handlers[post_deactivate_count] = NULL;
/* Cannot reuse module_request_startup_handlers because it is freed in zend_destroy_modules, which happens before zend_unload_modules. */
modules_dl_loaded = realloc(modules_dl_loaded, sizeof(zend_module_entry*) * (dl_loaded_count + 1));
modules_dl_loaded[dl_loaded_count] = NULL;
startup_count = 0;

ZEND_HASH_MAP_FOREACH_PTR(&module_registry, module) {
Expand All @@ -2444,9 +2436,6 @@ ZEND_API void zend_collect_module_handlers(void) /* {{{ */
if (module->post_deactivate_func) {
module_post_deactivate_handlers[--post_deactivate_count] = module;
}
if (module->handle) {
modules_dl_loaded[--dl_loaded_count] = module;
}
} ZEND_HASH_FOREACH_END();

/* Collect internal classes with static members */
Expand Down Expand Up @@ -3250,22 +3239,17 @@ void module_destructor(zend_module_entry *module) /* {{{ */
clean_module_functions(module);
}

#if ZEND_RC_DEBUG
zend_rc_debug = orig_rc_debug;
#endif
}
/* }}} */

void module_registry_unload(const zend_module_entry *module)
{
#if HAVE_LIBDL
if (!getenv("ZEND_DONT_UNLOAD_MODULES")) {
if (module->handle && !getenv("ZEND_DONT_UNLOAD_MODULES")) {
DL_UNLOAD(module->handle);
}
#else
ZEND_IGNORE_VALUE(module);
#endif

#if ZEND_RC_DEBUG
zend_rc_debug = orig_rc_debug;
#endif
}
/* }}} */

ZEND_API void zend_activate_modules(void) /* {{{ */
{
Expand Down Expand Up @@ -3311,18 +3295,6 @@ ZEND_API void zend_deactivate_modules(void) /* {{{ */
}
/* }}} */

void zend_unload_modules(void) /* {{{ */
{
zend_module_entry **modules = modules_dl_loaded;
while (*modules) {
module_registry_unload(*modules);
modules++;
}
free(modules_dl_loaded);
modules_dl_loaded = NULL;
}
/* }}} */

ZEND_API void zend_post_deactivate_modules(void) /* {{{ */
{
if (EG(full_tables_cleanup)) {
Expand All @@ -3341,9 +3313,6 @@ ZEND_API void zend_post_deactivate_modules(void) /* {{{ */
break;
}
module_destructor(module);
if (module->handle) {
module_registry_unload(module);
}
zend_string_release_ex(key, 0);
} ZEND_HASH_MAP_FOREACH_END_DEL();
} else {
Expand Down
2 changes: 1 addition & 1 deletion Zend/zend_modules.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ extern ZEND_API HashTable module_registry;

void module_destructor(zend_module_entry *module);
int module_registry_request_startup(zend_module_entry *module);
void module_registry_unload(const zend_module_entry *module);
int module_registry_unload_temp(const zend_module_entry *module);
END_EXTERN_C()

#endif
8 changes: 7 additions & 1 deletion ext/odbc/php_odbc.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,13 @@ static void _close_odbc_conn(zend_resource *rsrc)
SQLFreeEnv(conn->henv);
}
efree(conn);
ODBCG(num_links)--;
/* See https://github.com/php/php-src/issues/12974 why we need to check the if */
#ifdef ZTS
if (odbc_module_entry.module_started)
#endif
{
ODBCG(num_links)--;
}
}
/* }}} */

Expand Down
10 changes: 8 additions & 2 deletions ext/pgsql/pgsql.c
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,14 @@ static void _close_pgsql_plink(zend_resource *rsrc)
PQclear(res);
}
PQfinish(link);
PGG(num_persistent)--;
PGG(num_links)--;
/* See https://github.com/php/php-src/issues/12974 why we need to check the if */
#ifdef ZTS
if (pgsql_module_entry.module_started)
#endif
{
PGG(num_persistent)--;
PGG(num_links)--;
}
rsrc->ptr = NULL;
}

Expand Down