- if ( pool->ltp_numqs > 1 )
- i = ldap_int_poolq_hash( pool, arg );
- else
+ if ( pool->ltp_numqs > 1 ) {
+ int min = pool->ltp_wqs[0]->ltp_max_pending + pool->ltp_wqs[0]->ltp_max_count;
+ int min_x = 0, cnt;
+ for ( i = 0; i < pool->ltp_numqs; i++ ) {
+ /* take first queue that has nothing active */
+ if ( !pool->ltp_wqs[i]->ltp_active_count ) {
+ min_x = i;
+ break;
+ }
+ cnt = pool->ltp_wqs[i]->ltp_active_count + pool->ltp_wqs[i]->ltp_pending_count;
+ if ( cnt < min ) {
+ min = cnt;
+ min_x = i;
+ }
+ }
+ i = min_x;
+ } else