Changeset 694253c in mainline for uspace/srv/sysman/sysman.c


Ignore:
Timestamp:
2019-08-03T07:35:41Z (5 years ago)
Author:
Matthieu Riolo <matthieu.riolo@…>
Children:
c0c388d2
Parents:
f42ee6f
git-author:
Michal Koutný <xm.koutny+hos@…> (2015-03-13 02:06:30)
git-committer:
Matthieu Riolo <matthieu.riolo@…> (2019-08-03 07:35:41)
Message:

Skeleton for sysman (unit) jobs control

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/sysman/sysman.c

    rf42ee6f r694253c  
     1#include <adt/list.h>
    12#include <errno.h>
    23
     4#include "dep.h"
     5#include "job.h"
    36#include "sysman.h"
     7
     8static 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
     36fail:
     37        job_destroy(&job);
     38        return rc;
     39}
    440
    541int sysman_unit_start(unit_t *unit)
    642{
    7         // satisfy dependencies
    8         // start unit (via restarter)
    9         return EOK;
     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);
    1055}
Note: See TracChangeset for help on using the changeset viewer.