X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fjobs.c;h=aa014f3a4b94bd2b525aca8ef4eedb9cf215c4f8;hb=b612db216c2793c34e264254794db3308d20d796;hp=a9773aa54b9bac32bd89bf6c3910155a0dc4557c;hpb=0ea0734fa3f304af325b4a0429bb0cfaabeeed96;p=src%2Fapp-framework-binder.git diff --git a/src/jobs.c b/src/jobs.c index a9773aa5..aa014f3a 100644 --- a/src/jobs.c +++ b/src/jobs.c @@ -510,7 +510,7 @@ static int queue_job( enum start_mode start_mode) { struct job *job; - int rc; + int rc, busy; pthread_mutex_lock(&mutex); @@ -527,8 +527,9 @@ static int queue_job( goto error; /* start a thread if needed */ + busy = busy_thread_count == started_thread_count; if (start_mode != Start_Lazy - && busy_thread_count == started_thread_count + && busy && (start_mode == Start_Urgent || remaining_job_count + started_thread_count < allowed_job_count) && started_thread_count < allowed_thread_count) { /* all threads are busy and a new can be started */ @@ -537,11 +538,16 @@ static int queue_job( ERROR("can't start initial thread: %m"); goto error2; } + busy = 0; } /* queues the job */ job_add(job); + /* wakeup an evloop if needed */ + if (busy) + evloop_wakeup(); + /* signal an existing job */ pthread_cond_signal(&cond); pthread_mutex_unlock(&mutex); @@ -909,6 +915,7 @@ void jobs_exit(void (*handler)()) } /* wake up the threads */ + evloop_wakeup(); pthread_cond_broadcast(&cond); /* leave */