# module startup problem in 5.1

- Thread: https://externals.io/message/17313
- Original archive: https://news-web.php.net/php.internals/17313
- Started by Stanislav Malyshev on 2005-07-18T13:15:43+00:00
- Messages: 2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #17313 — Stanislav Malyshev — 2005-07-18T13:15:43+00:00

URL: https://externals.io/message/17313#17313

I see very serious problem un current module registration/startup 
functions in 5.1.
In 5.0, there was a function zend_startup_module which did two things:
1. Register PHP module with the system
2. Run startup function of the module

Now, in 5.1 those functions got spearated. However, the problem is that it 
now looks like this:

ZEND_API int zend_startup_module(zend_module_entry *module)
{
     TSRMLS_FETCH();

     if (zend_register_internal_module(module TSRMLS_CC) == SUCCESS &&
         zend_startup_module_ex(module TSRMLS_CC) == SUCCESS) {
         return SUCCESS;
     }
     return FAILURE;
}

The trouble here is that zend_register_internal_module stores module in 
internal hash as value, so when zend_startup_module_ex is run, it runs not 
on the value in the hash but on original value. This leads to 
module_started being never set in the hash value on module which was added 
in runtime - meaning its destructor is never called on shutdown.

Since zend_register_internal_module never returns the hash value, I see no 
easy way to fix this, but I think it must be fixed ASAP.

-- 
Stanislav Malyshev, Zend Products Engineer
stas@zend.com  http://www.zend.com/ +972-3-6139665 ext.115

---

## #17319 — Dmitry Stogov — 2005-07-18T14:57:32+00:00

URL: https://externals.io/message/17313#17319 · In reply to: #17313

Hi Stas,

We can reimplement zend_register_internal_module() to return
zend_module_entry* instead of bool.

(The same behavior is in `dl()` function).

Thanks. Dmitry.

> -----Original Message-----
> From: Stanislav Malyshev [mailto:stas@zend.com] 
> Sent: Monday, July 18, 2005 5:16 PM
> To: PHP Development
> Subject: [PHP-DEV] module startup problem in 5.1
> 
> 
> I see very serious problem un current module registration/startup 
> functions in 5.1.
> In 5.0, there was a function zend_startup_module which did 
> two things: 1. Register PHP module with the system 2. Run 
> startup function of the module
> 
> Now, in 5.1 those functions got spearated. However, the 
> problem is that it 
> now looks like this:
> 
> ZEND_API int zend_startup_module(zend_module_entry *module)
> {
>      TSRMLS_FETCH();
> 
>      if (zend_register_internal_module(module TSRMLS_CC) == SUCCESS &&
>          zend_startup_module_ex(module TSRMLS_CC) == SUCCESS) {
>          return SUCCESS;
>      }
>      return FAILURE;
> }
> 
> The trouble here is that zend_register_internal_module stores 
> module in 
> internal hash as value, so when zend_startup_module_ex is 
> run, it runs not 
> on the value in the hash but on original value. This leads to 
> module_started being never set in the hash value on module 
> which was added 
> in runtime - meaning its destructor is never called on shutdown.
> 
> Since zend_register_internal_module never returns the hash 
> value, I see no 
> easy way to fix this, but I think it must be fixed ASAP.
> 
> -- 
> Stanislav Malyshev, Zend Products Engineer
> stas@zend.com  http://www.zend.com/ +972-3-6139665 ext.115
