Last change
on this file since 694253c was 694253c, checked in by Matthieu Riolo <matthieu.riolo@…>, 6 years ago |
Skeleton for sysman (unit) jobs control
|
-
Property mode
set to
100644
|
File size:
981 bytes
|
Line | |
---|
1 | #include <adt/list.h>
|
---|
2 | #include <errno.h>
|
---|
3 |
|
---|
4 | #include "dep.h"
|
---|
5 | #include "job.h"
|
---|
6 | #include "sysman.h"
|
---|
7 |
|
---|
8 | static int sysman_create_closure_jobs(unit_t *unit, job_t **entry_job_ptr,
|
---|
9 | list_t *accumulator, job_type_t type)
|
---|
10 | {
|
---|
11 | int rc = EOK;
|
---|
12 | job_t *job = job_create(type);
|
---|
13 | if (job == NULL) {
|
---|
14 | rc = ENOMEM;
|
---|
15 | goto fail;
|
---|
16 | }
|
---|
17 |
|
---|
18 | job->unit = unit;
|
---|
19 | // TODO set blocking jobs
|
---|
20 |
|
---|
21 | list_foreach(unit->dependencies, dependencies, unit_dependency_t, edge) {
|
---|
22 | rc = sysman_create_closure_jobs(edge->dependency, NULL,
|
---|
23 | accumulator, type);
|
---|
24 | if (rc != EOK) {
|
---|
25 | goto fail;
|
---|
26 | }
|
---|
27 | }
|
---|
28 |
|
---|
29 | list_append(&job->link, accumulator);
|
---|
30 |
|
---|
31 | if (entry_job_ptr != NULL) {
|
---|
32 | *entry_job_ptr = job;
|
---|
33 | }
|
---|
34 | return EOK;
|
---|
35 |
|
---|
36 | fail:
|
---|
37 | job_destroy(&job);
|
---|
38 | return rc;
|
---|
39 | }
|
---|
40 |
|
---|
41 | int sysman_unit_start(unit_t *unit)
|
---|
42 | {
|
---|
43 | list_t new_jobs;
|
---|
44 | list_initialize(&new_jobs);
|
---|
45 |
|
---|
46 | job_t *job = NULL;
|
---|
47 | int rc = sysman_create_closure_jobs(unit, &job, &new_jobs, JOB_START);
|
---|
48 | if (rc != EOK) {
|
---|
49 | return rc;
|
---|
50 | }
|
---|
51 |
|
---|
52 | job_queue_jobs(&new_jobs);
|
---|
53 |
|
---|
54 | return job_wait(job);
|
---|
55 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.