Last change
on this file since c0c388d2 was c0c388d2, checked in by Matthieu Riolo <matthieu.riolo@…>, 6 years ago |
Sysman jobs memory management (refcnt)
|
-
Property mode
set to
100644
|
File size:
1.1 KB
|
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 | /* Job is passed to the accumulator, i.e. no add_ref. */
|
---|
30 | list_append(&job->link, accumulator);
|
---|
31 |
|
---|
32 | if (entry_job_ptr != NULL) {
|
---|
33 | *entry_job_ptr = job;
|
---|
34 | }
|
---|
35 | return EOK;
|
---|
36 |
|
---|
37 | fail:
|
---|
38 | job_del_ref(&job);
|
---|
39 | return rc;
|
---|
40 | }
|
---|
41 |
|
---|
42 | int sysman_unit_start(unit_t *unit)
|
---|
43 | {
|
---|
44 | list_t new_jobs;
|
---|
45 | list_initialize(&new_jobs);
|
---|
46 |
|
---|
47 | job_t *job = NULL;
|
---|
48 | int rc = sysman_create_closure_jobs(unit, &job, &new_jobs, JOB_START);
|
---|
49 | if (rc != EOK) {
|
---|
50 | return rc;
|
---|
51 | }
|
---|
52 |
|
---|
53 | // TODO handle errors when adding job accumulator
|
---|
54 | job_queue_jobs(&new_jobs);
|
---|
55 |
|
---|
56 | return job_wait(job);
|
---|
57 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.