Author: rhuijben Date: Wed Feb 18 14:53:56 2015 New Revision: 1660641 URL: http://svn.apache.org/r1660641 Log: Following up on r1660610, add another pool cleanup handler to handle the case where the root pool is cleaned up before the state pool.
This should fix the problems in the swig bindings. * subversion/libsvn_subr/sqlite.c (function_wrapper_baton_t): Hold state pool reference. (clear_sqlite_function_scratch): Add forward definition. (clear_sqlite_function): Rename to... (clear_sqlite_function_state): ... this. Reset registration. (clear_sqlite_function_scratch): New function. (svn_sqlite__create_scalar_function): Add second registration. Modified: subversion/trunk/subversion/libsvn_subr/sqlite.c Modified: subversion/trunk/subversion/libsvn_subr/sqlite.c URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/sqlite.c?rev=1660641&r1=1660640&r2=1660641&view=diff ============================================================================== --- subversion/trunk/subversion/libsvn_subr/sqlite.c (original) +++ subversion/trunk/subversion/libsvn_subr/sqlite.c Wed Feb 18 14:53:56 2015 @@ -1479,6 +1479,7 @@ struct function_wrapper_baton_t void *baton; apr_pool_t *scratch_pool; + apr_pool_t *state_pool; }; static void @@ -1515,13 +1516,32 @@ wrapped_func(sqlite3_context *context, } } -/* pool cleanup function for function context */ +/* Forward definition */ +static apr_status_t clear_sqlite_function_scratch(void *baton); + +/* pool cleanup function for function context on state pool */ static apr_status_t -clear_sqlite_function(void *baton) +clear_sqlite_function_state(void *baton) { struct function_wrapper_baton_t *fwb = baton; svn_pool_destroy(fwb->scratch_pool); + + apr_pool_cleanup_kill(fwb->scratch_pool, baton, + clear_sqlite_function_scratch); + + return APR_SUCCESS; +} + +/* pool cleanup function for global cleanup on internal pool */ +static apr_status_t +clear_sqlite_function_scratch(void *baton) +{ + struct function_wrapper_baton_t *fwb = baton; + + apr_pool_cleanup_kill(fwb->state_pool, baton, + clear_sqlite_function_state); + return APR_SUCCESS; } @@ -1544,6 +1564,7 @@ svn_sqlite__create_scalar_function(svn_s We create a subpool in the global pool and only destroy it when we want it to be destroyed */ + fwb->state_pool = db->state_pool; fwb->scratch_pool = svn_pool_create(NULL); fwb->func = func; fwb->baton = baton; @@ -1556,7 +1577,11 @@ svn_sqlite__create_scalar_function(svn_s fwb, wrapped_func, NULL, NULL), db); - apr_pool_cleanup_register(db->state_pool, fwb, clear_sqlite_function, + apr_pool_cleanup_register(fwb->state_pool, fwb, + clear_sqlite_function_state, + apr_pool_cleanup_null); + apr_pool_cleanup_register(fwb->scratch_pool, fwb, + clear_sqlite_function_scratch, apr_pool_cleanup_null); return SVN_NO_ERROR;