Skip to content

Commit

Permalink
mxqd: Start jobs without main loop iteration
Browse files Browse the repository at this point in the history
Try to start as many jobs jobs as possible without going through a main
loop iteration (database roundtrip).
  • Loading branch information
donald committed Jul 6, 2017
1 parent 6a15b2b commit 82d7a31
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions mxqd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 82d7a31

Please sign in to comment.