File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -3798,11 +3798,12 @@ PHP_MINIT_FUNCTION(mongodb)
3798
3798
3799
3799
REGISTER_INI_ENTRIES ();
3800
3800
3801
- /* Initialize libmongoc */
3802
- mongoc_init ();
3803
-
3804
- /* Initialize libbson */
3801
+ /* Assign our custom vtable to libbson, so all memory allocation in libbson
3802
+ * (and libmongoc) will use PHP's persistent memory API. After doing so,
3803
+ * initialize libmongoc. Later, we will shutdown libmongoc and restore
3804
+ * libbson's vtable in the final GSHUTDOWN. */
3805
3805
bson_mem_set_vtable (& bson_mem_vtable );
3806
+ mongoc_init ();
3806
3807
3807
3808
/* Prep default object handlers to be used when we register the classes */
3808
3809
memcpy (& phongo_std_object_handlers , zend_get_std_object_handlers (), sizeof (zend_object_handlers ));
@@ -3982,8 +3983,8 @@ PHP_GSHUTDOWN_FUNCTION(mongodb)
3982
3983
* all threads have been destroyed, and it is now safe to shutdown libmongoc
3983
3984
* and restore libbson's original vtable. */
3984
3985
if (bson_atomic_int_add (& phongo_num_threads , -1 ) == 0 ) {
3985
- bson_mem_restore_vtable ();
3986
3986
mongoc_cleanup ();
3987
+ bson_mem_restore_vtable ();
3987
3988
}
3988
3989
}
3989
3990
/* }}} */
You can’t perform that action at this time.
0 commit comments