# HG changeset patch # User LordOfWar # Date 2009-09-12 18:45:51 # Node ID bbc92828afdd52d4a43905843575f428171dad60 # Parent ecb6efb70fb107fe597c02e48c96624061954063 created function \"change_job_priority\" and \"remove_job\" (this remove_job function recieves a job number and returns structure distrenjob, it was made to assist the change_job_priority function) I also fixed an error where add_job_to_queue wasn't updating its prev_job pointer, which would of resulted in the loss of jobs between head and where the new job is inserted. diff --git a/src/server/distrend.c b/src/server/distrend.c --- a/src/server/distrend.c +++ b/src/server/distrend.c @@ -322,9 +322,37 @@ void add_job_to_queue(struct distrenjob job->next = current_job; break; } + + prev_job = current_job; } // end of for statement } +void change_job_priority(int jobnum, int new_priority){ + struct distrenjob *job = &remove_job(jobnum); + job->priority = new_priority; + add_job_to_queue(job); +} + +distrenjob remove_job(int jobnum_t){ + struct distrenjob *job; + struct distrenjob *prev_job = head; + + for(job = head; job != NULL; job = job->next){ + if(job == NULL){ + return NULL; + } + if(job->jobnum = jobnum_t){ + prev_job = job->next; + return job; + } + + prev_job = job; + } + + // job was not found if this point is reached + return NULL; +} + /**