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


Ignore:
Timestamp:
2019-08-03T09:28:50Z (5 years ago)
Author:
Matthieu Riolo <matthieu.riolo@…>
Children:
c0e4fc50
Parents:
2dda1d4
git-author:
Michal Koutný <xm.koutny+hos@…> (2015-05-07 11:49:47)
git-committer:
Matthieu Riolo <matthieu.riolo@…> (2019-08-03 09:28:50)
Message:

sysman: Naive autostart instrumentation of locsrv

  • Add IPC_FLAG_AUTOSTART flag.
  • libsysman: sysman's broker and control API.
  • Simple implementation of service unit, exposee verification is missing.
  • Simple mapping of exposee to unit name in locsrv.
  • Temporary debug prints in locsrv.

Conflicts:

boot/Makefile.common
boot/arch/amd64/Makefile.inc
uspace/lib/c/include/ipc/services.h
uspace/srv/locsrv/locsrv.c

File:
1 edited

Legend:

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

    r2dda1d4 r5559712  
    3535#include "log.h"
    3636#include "sysman.h"
     37#include "unit.h"
    3738
    3839
     
    150151
    151152                /* Process event */
    152                 sysman_log(LVL_DEBUG2, "process(%p, %p)", event->handler, event->data);
     153                sysman_log(LVL_DEBUG2, "process_event(%p, %p)",
     154                    event->handler, event->data);
    153155                event->handler(event->data);
    154156                free(event);
    155157        }
     158}
     159
     160/** Create and queue job for unit
     161 *
     162 * @param[in]  callback  callback must explicitly delete reference to job
     163 */
     164int sysman_queue_job(unit_t *unit, unit_state_t target_state,
     165    callback_handler_t callback, void *callback_arg)
     166{
     167        job_t *job = job_create(unit, target_state);
     168        if (job == NULL) {
     169                return ENOMEM;
     170        }
     171
     172        job_add_ref(job);
     173        sysman_object_observer(job, callback, callback_arg);
     174
     175        job_add_ref(job);
     176        sysman_raise_event(&sysman_event_job_process, job);
     177
     178        job_del_ref(&job);
     179        return EOK;
    156180}
    157181
     
    226250
    227251// NOTE must run in main event loop fibril
    228 void sysman_event_job_process(void *arg)
    229 {
    230         job_t *job = arg;
     252void sysman_event_job_process(void *data)
     253{
     254        job_t *job = data;
    231255        dyn_array_t job_closure;
    232256        dyn_array_initialize(&job_closure, job_ptr_t, 0);
     
    250274        job_del_ref(&job);
    251275
    252         // TODO explain why calling asynchronously
    253         sysman_raise_event(&sysman_event_job_queue_run, NULL);
     276        job_queue_process();
    254277        return;
    255278
     
    265288}
    266289
    267 
    268 void sysman_event_job_queue_run(void *unused)
    269 {
    270         job_t *job;
    271         while ((job = job_queue_pop_runnable())) {
    272                 job_run(job);
    273                 job_del_ref(&job);
    274         }
    275 }
    276 
    277 void sysman_event_job_changed(void *object)
    278 {
    279         notify_observers(object);
     290void sysman_event_job_finished(void *data)
     291{
     292        notify_observers(data);
    280293        /* Unreference the event data */
    281         job_t *job = object;
     294        job_t *job = data;
    282295        job_del_ref(&job);
    283 }
     296
     297        /* The finished job, might have been blocking */
     298        job_queue_process();
     299}
     300
     301void sysman_event_unit_exposee_created(void *data)
     302{
     303        unit_t *unit = data;
     304        unit_exposee_created(unit);
     305}
     306
     307void sysman_event_unit_failed(void *data)
     308{
     309        unit_t *unit = data;
     310        unit_fail(unit);
     311}
     312
     313void sysman_event_unit_state_changed(void *data)
     314{
     315        notify_observers(data);
     316}
Note: See TracChangeset for help on using the changeset viewer.