diff --git a/mxqd.c b/mxqd.c index 14867cc0..ce78837d 100644 --- a/mxqd.c +++ b/mxqd.c @@ -2444,15 +2444,20 @@ int main(int argc, char *argv[]) continue; } - slots_started = start_user_with_least_running_global_slot_count(server); - if (slots_started == -1) { - mxq_daemon_set_status(server->mysql, daemon, MXQ_DAEMON_STATUS_WAITING); - mx_log_info("no slots_started => we have users waiting for free slots"); - slots_started = 0; - poll_interval.tv_sec=3; - continue; - } else if (slots_started) { - mx_log_info("slots_started=%lu :: Main Loop started %lu slots.", slots_started, slots_started); + slots_started=0; + do { + res = start_user_with_least_running_global_slot_count(server); + if (res>0) { + slots_started+=res; + } + } while (res>0); + if (slots_started) + mx_log_info("Main loop started %lu slots.", slots_started); + if (res<0) { + mx_log_info("No more slots started because we have users waiting for free slots"); + mxq_daemon_set_status(server->mysql, daemon, MXQ_DAEMON_STATUS_WAITING); + poll_interval.tv_sec=3; + continue; } if (!slots_started && !slots_returned && !global_sigint_cnt && !global_sigterm_cnt) {