Message ID | 20211029163914.4044794-9-eesposit@redhat.com |
---|---|
State | New |
Headers | show |
Series | job: replace AioContext lock with job_mutex | expand |
29.10.2021 19:39, Emanuele Giuseppe Esposito wrote: > job_event_* functions can be all static, as they are not used > outside job.c > > Add also missing notifier initialization for the on_idle > list in job_create(). > > Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com> > --- > job.c | 13 +++++++++++-- > 1 file changed, 11 insertions(+), 2 deletions(-) > > diff --git a/job.c b/job.c > index db7ad79745..88d911f2d7 100644 > --- a/job.c > +++ b/job.c > @@ -464,6 +464,7 @@ void *job_create(const char *job_id, const JobDriver *driver, JobTxn *txn, > notifier_list_init(&job->on_finalize_completed); > notifier_list_init(&job->on_pending); > notifier_list_init(&job->on_ready); > + notifier_list_init(&job->on_idle); Is that a bug fix? I think it worth small separate patch. > > job_state_transition(job, JOB_STATUS_CREATED); > aio_timer_init(qemu_get_aio_context(), &job->sleep_timer, > @@ -527,12 +528,20 @@ void job_progress_increase_remaining(Job *job, uint64_t delta) > progress_increase_remaining(&job->progress, delta); > } > > -void job_event_cancelled(Job *job) > +/** > + * To be called when a cancelled job is finalised. > + * Called with job_mutex held. > + */ > +static void job_event_cancelled(Job *job) > { > notifier_list_notify(&job->on_finalize_cancelled, job); > } > > -void job_event_completed(Job *job) > +/** > + * To be called when a successfully completed job is finalised. > + * Called with job_mutex held. > + */ > +static void job_event_completed(Job *job) > { > notifier_list_notify(&job->on_finalize_completed, job); > } >
diff --git a/job.c b/job.c index db7ad79745..88d911f2d7 100644 --- a/job.c +++ b/job.c @@ -464,6 +464,7 @@ void *job_create(const char *job_id, const JobDriver *driver, JobTxn *txn, notifier_list_init(&job->on_finalize_completed); notifier_list_init(&job->on_pending); notifier_list_init(&job->on_ready); + notifier_list_init(&job->on_idle); job_state_transition(job, JOB_STATUS_CREATED); aio_timer_init(qemu_get_aio_context(), &job->sleep_timer, @@ -527,12 +528,20 @@ void job_progress_increase_remaining(Job *job, uint64_t delta) progress_increase_remaining(&job->progress, delta); } -void job_event_cancelled(Job *job) +/** + * To be called when a cancelled job is finalised. + * Called with job_mutex held. + */ +static void job_event_cancelled(Job *job) { notifier_list_notify(&job->on_finalize_cancelled, job); } -void job_event_completed(Job *job) +/** + * To be called when a successfully completed job is finalised. + * Called with job_mutex held. + */ +static void job_event_completed(Job *job) { notifier_list_notify(&job->on_finalize_completed, job); }
job_event_* functions can be all static, as they are not used outside job.c Add also missing notifier initialization for the on_idle list in job_create(). Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com> --- job.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)