Skip to content
Snippets Groups Projects
Commit 7c26dfdc authored by Howard Chu's avatar Howard Chu Committed by Quanah Gibson-Mount
Browse files

ITS#7235 prevent sop from being freed during init

parent c4b877b0
No related branches found
No related tags found
No related merge requests found
......@@ -2475,7 +2475,10 @@ syncprov_op_search( Operation *op, SlapReply *rs )
ldap_pvt_thread_mutex_init( &sop->s_mutex );
sop->s_rid = srs->sr_state.rid;
sop->s_sid = srs->sr_state.sid;
sop->s_inuse = 1;
/* set refcount=2 to prevent being freed out from under us
* by abandons that occur while we're running here
*/
sop->s_inuse = 2;
ldap_pvt_thread_mutex_lock( &si->si_ops_mutex );
while ( si->si_active ) {
......@@ -2707,7 +2710,10 @@ shortcut:
* for persistent search evaluation
*/
if ( sop ) {
sop->s_filterstr= op->ors_filterstr;
ldap_pvt_thread_mutex_lock( &sop->s_mutex );
sop->s_filterstr = op->ors_filterstr;
/* correct the refcount that was set to 2 before */
sop->s_inuse--;
}
/* If something changed, find the changes */
......@@ -2727,15 +2733,15 @@ shortcut:
#endif
ber_dupbv_x( &fava->f_ava->aa_value, &mincsn, op->o_tmpmemctx );
fava->f_next = op->ors_filter;
if ( sop )
ldap_pvt_thread_mutex_lock( &sop->s_mutex );
op->ors_filter = fand;
filter2bv_x( op, op->ors_filter, &op->ors_filterstr );
if ( sop ) {
sop->s_flags |= PS_FIX_FILTER;
ldap_pvt_thread_mutex_unlock( &sop->s_mutex );
}
}
if ( sop ) {
ldap_pvt_thread_mutex_unlock( &sop->s_mutex );
}
/* Let our callback add needed info to returned entries */
cb = op->o_tmpcalloc(1, sizeof(slap_callback)+sizeof(searchstate), op->o_tmpmemctx);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment