From c14c6db3ac6ddffda36ccda3e7702121eeda145f Mon Sep 17 00:00:00 2001 From: Moe Jette <jette1@llnl.gov> Date: Mon, 30 Aug 2010 18:51:49 +0000 Subject: [PATCH] fix two recently introduced memory leaks --- src/plugins/sched/builtin/builtin_wrapper.c | 5 +++-- src/slurmctld/job_scheduler.c | 10 ++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/plugins/sched/builtin/builtin_wrapper.c b/src/plugins/sched/builtin/builtin_wrapper.c index b7f769ec3e3..e6ee3c93550 100644 --- a/src/plugins/sched/builtin/builtin_wrapper.c +++ b/src/plugins/sched/builtin/builtin_wrapper.c @@ -148,9 +148,10 @@ void slurm_sched_plugin_job_is_pending( void ) while ((job_queue_rec = (job_queue_rec_t *) list_pop_bottom(job_queue, sort_job_queue2))) { job_ptr = job_queue_rec->job_ptr; - if (job_queue_rec->part_ptr != job_ptr->part_ptr) + part_ptr = job_queue_rec->part_ptr; + xfree(job_queue_rec); + if (part_ptr != job_ptr->part_ptr) continue; /* Only test one partition */ - part_ptr = job_ptr->part_ptr; /* Determine minimum and maximum node counts */ min_nodes = MAX(job_ptr->details->min_nodes, diff --git a/src/slurmctld/job_scheduler.c b/src/slurmctld/job_scheduler.c index 97e2000e42f..636cbf4be1b 100644 --- a/src/slurmctld/job_scheduler.c +++ b/src/slurmctld/job_scheduler.c @@ -314,7 +314,7 @@ extern int schedule(uint32_t job_limit) uint32_t job_depth = 0; job_queue_rec_t *job_queue_rec; struct job_record *job_ptr; - struct part_record **failed_parts = NULL; + struct part_record *part_ptr, **failed_parts = NULL; bitstr_t *save_avail_node_bitmap; /* Locks: Read config, write job, write node, read partition */ slurmctld_lock_t job_write_lock = @@ -386,6 +386,9 @@ extern int schedule(uint32_t job_limit) job_queue = build_job_queue(); while ((job_queue_rec = (job_queue_rec_t *) list_pop_bottom(job_queue, sort_job_queue2))) { + job_ptr = job_queue_rec->job_ptr; + part_ptr = job_queue_rec->part_ptr; + xfree(job_queue_rec); if ((time(NULL) - sched_start) >= sched_timeout) { debug("sched: loop taking too long, breaking out"); break; @@ -395,7 +398,6 @@ extern int schedule(uint32_t job_limit) job_depth); break; } - job_ptr = job_queue_rec->job_ptr; if (!IS_JOB_PENDING(job_ptr)) continue; /* started in other partition */ if (job_ptr->priority == 0) { /* held */ @@ -407,9 +409,9 @@ extern int schedule(uint32_t job_limit) job_ptr->priority); continue; } - if (job_ptr->part_ptr != job_queue_rec->part_ptr) { + if (job_ptr->part_ptr != part_ptr) { /* Cycle through partitions usable for this job */ - job_ptr->part_ptr = job_queue_rec->part_ptr; + job_ptr->part_ptr = part_ptr; } if ((job_ptr->resv_name == NULL) && _failed_partition(job_ptr->part_ptr, failed_parts, -- GitLab