diff options
author | 2017-03-28 10:18:06 +0200 | |
---|---|---|
committer | 2017-03-28 10:21:06 +0200 | |
commit | 48827b7b9862ab5961f938f38a8667e15421a50c (patch) | |
tree | b3f2100155ae7adc2125ab93f162a8566f39d8af /src/jobs.c | |
parent | f9fc4077cc0eb167f3e65f54cc27717c79beee92 (diff) |
Fix bug in recycling jobs
The bug was creating an infinite loop starving
the system (or other possible horrific stuff).
Also updated the test.
Change-Id: Id71dd112d2ed4651ac8aa56d2c57b088d69b8655
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'src/jobs.c')
-rw-r--r-- | src/jobs.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -146,7 +146,9 @@ static struct job *job_create( /* allocates the job */ job = free_jobs; - if (!job) { + if (job) + free_jobs = job->next; + else { pthread_mutex_unlock(&mutex); job = malloc(sizeof *job); pthread_mutex_lock(&mutex); @@ -369,7 +371,7 @@ int jobs_init(int allowed_count, int start_count, int waiter_count) } /* terminate all the threads and all pending requests */ -void jobs_terminate() +void jobs_terminate(int wait) { struct job *job; pthread_t me, other; |