- /* Is it a continuation of a VLV search? */
- if ( !vc || so->so_vlv <= SLAP_CONTROL_IGNORED ||
- vc->vc_context != so->so_vcontext ) {
- /* Is it a continuation of a paged search? */
- if ( !ps || so->so_paged <= SLAP_CONTROL_IGNORED ||
- op->o_conn->c_pagedresults_state.ps_cookie != ps->ps_cookie ) {
- ok = 0;
- } else if ( !ps->ps_size ) {
- /* Abandoning current request */
- ok = 0;
- so->so_nentries = 0;
- rs->sr_err = LDAP_SUCCESS;
- }
- }
- if (( vc && so->so_paged > SLAP_CONTROL_IGNORED ) ||
- ( ps && so->so_vlv > SLAP_CONTROL_IGNORED )) {
- /* changed from paged to vlv or vice versa, abandon */
- ok = 0;
- so->so_nentries = 0;
- rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
+
+ if( so->so_running > 0 ){
+ /* another thread is handling, response busy to client */
+ so = NULL;
+ ok = 0;
+ } else {
+
+ /* Is it a continuation of a VLV search? */
+ if ( !vc || so->so_vlv <= SLAP_CONTROL_IGNORED ||
+ vc->vc_context != so->so_vcontext ) {
+ /* Is it a continuation of a paged search? */
+ if ( !ps || so->so_paged <= SLAP_CONTROL_IGNORED ||
+ op->o_conn->c_pagedresults_state.ps_cookie != ps->ps_cookie ) {
+ ok = 0;
+ } else if ( !ps->ps_size ) {
+ /* Abandoning current request */
+ ok = 0;
+ so->so_nentries = 0;
+ rs->sr_err = LDAP_SUCCESS;
+ }
+ }
+ if (( vc && so->so_paged > SLAP_CONTROL_IGNORED ) ||
+ ( ps && so->so_vlv > SLAP_CONTROL_IGNORED )) {
+ /* changed from paged to vlv or vice versa, abandon */
+ ok = 0;
+ so->so_nentries = 0;
+ rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
+ }
+
+ if ( ok ) {
+ /* occupy before mutex unlock */
+ so->so_running = 1;
+ }
+