Hi Nikita, On Sat, 11 Aug 2018 at 11:03, Nikita Popov <nikita....@gmail.com> wrote:
> On Wed, Aug 8, 2018 at 11:09 PM, Nicolai Scheer <nicolai.sch...@gmail.com> > wrote: > >> [resource destructor does not get called until shutdown] > > > My guess would be some kind of refcounting issue. For example > zend_update_property will already increment the refcount of the assigned > value itself. So if you create a value with refcount 1 and then assign it > to an object property, you likely need to do an explicit delref. If you > don't, then the value is leaked and your resource destructor will not run > until shutdown. > > Yes, you're absolutely right. I switched from: zval *rsrc = NULL; rsrc = zend_list_insert( conn_data, le_wmqe_connection_rc ); zend_update_property( php_wmqe_connection_entry, getThis(), "connection", sizeof( "connection" ) - 1, rsrc ); to: zend_resource *rsrc = NULL; rsrc = zend_register_resource( conn_data, le_wmqe_connection_rc ); add_property_resource( getThis(), "connection", rsrc ); Now the refcounting seems to be appropriate and the resource dtor gets called on object destruction. I guess it would be better to leave resources all alone and switch to custom object storage for that matter... Thanks! Greetings Nico