From 1c6d391e29236bdfb7a5759728a90af2e56f2cbb Mon Sep 17 00:00:00 2001
From: Morris Jette <jette@schedmd.com>
Date: Tue, 3 Jan 2017 19:20:58 -0700
Subject: [PATCH] Improve clarity of code

This modifies the logic in commit e089b63a for better clarity
---
 src/plugins/select/cons_res/select_cons_res.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/plugins/select/cons_res/select_cons_res.c b/src/plugins/select/cons_res/select_cons_res.c
index 370c97df4ce..ab4723540ab 100644
--- a/src/plugins/select/cons_res/select_cons_res.c
+++ b/src/plugins/select/cons_res/select_cons_res.c
@@ -1908,14 +1908,20 @@ static int _will_run_test(struct job_record *job_ptr, bitstr_t *bitmap,
 				last_job_ptr = tmp_job_ptr;
 				_rm_job_from_res(future_part, future_usage,
 						 tmp_job_ptr, 0);
-				if ((rm_job_cnt++ > 200) && !timed_out)
+				if (timed_out) {
+					/* After timeout, remove ALL remaining
+					 * jobs and test if the pending job can
+					 * start, rather than executing the slow
+					 * cr_job_test() operation after
+					 * removing every 200 jobs */
+					continue;
+				}
+				if (rm_job_cnt++ > 200)
 					break;
 				next_job_ptr = list_peek_next(job_iterator);
 				if (!next_job_ptr) {
 					more_jobs = false;
 					break;
-				} else if (timed_out) {
-					continue;
 				} else if (next_job_ptr->end_time >
 				 	   (first_job_ptr->end_time +
 					    time_window)) {
-- 
GitLab