Changeset ed5367b in mainline for uspace/srv/sysman/units


Ignore:
Timestamp:
2019-08-07T10:01:13Z (7 years ago)
Author:
Matthieu Riolo <matthieu.riolo@…>
Children:
a097c50
Parents:
68ae40a
git-author:
Michal Koutný <xm.koutny+hos@…> (2015-11-05 01:52:07)
git-committer:
Matthieu Riolo <matthieu.riolo@…> (2019-08-07 10:01:13)
Message:

sysman: Implement stopping units

Currently fails service monitoring because of taskman flawed event flags.
However, job closure works well.

Location:
uspace/srv/sysman/units
Files:
4 edited

Legend:

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

    r68ae40a red5367b  
    240240}
    241241
     242static int unit_cfg_stop(unit_t *unit)
     243{
     244        unit_cfg_t *u_cfg = CAST_CFG(unit);
     245        assert(u_cfg);
     246
     247        /*
     248         * It makes no sense to stop configuration (i.e. unload it), however,
     249         * lets virtually stop it not to make obstructions for potential
     250         * restart = reload of configuration.
     251         */
     252        unit->state = STATE_STOPPED;
     253        return EOK;
     254}
     255
    242256static void unit_cfg_exposee_created(unit_t *unit)
    243257{
  • uspace/srv/sysman/units/unit_mnt.c

    r68ae40a red5367b  
    229229}
    230230
     231static int unit_mnt_stop(unit_t *unit)
     232{
     233        unit_mnt_t *u_mnt = CAST_MNT(unit);
     234        assert(u_mnt);
     235        /* autostart implies blocking */
     236        assert(!u_mnt->autostart || u_mnt->blocking);
     237
     238       
     239        // TODO think about unit's lifecycle (is STOPPED only acceptable?)
     240        // note: we should never hit STATE_STARTING, since it'd mean there are
     241        //       two jobs running at once (unless job cancellation is implemented)
     242        assert(unit->state == STATE_STARTED);
     243
     244        /*
     245         * We don't expect unmount to be blocking, since if some files are
     246         * being used, it'd return EBUSY immediately. That's why we call
     247         * unmount synchronously in the event loop fibril.
     248         */
     249        int rc = unmount(u_mnt->mountpoint);
     250
     251        if (rc == EOK) {
     252                unit->state = STATE_STOPPED;
     253                return EOK;
     254        } else if (rc == EBUSY) {
     255                assert(unit->state == STATE_STARTED);
     256                return EBUSY;
     257        } else {
     258                /*
     259                 * Mount may be still usable, but be conservative and mark unit
     260                 * as failed.
     261                 */
     262                unit->state = STATE_FAILED;
     263                return rc;
     264        }
     265}
     266
    231267static void unit_mnt_exposee_created(unit_t *unit)
    232268{
  • uspace/srv/sysman/units/unit_svc.c

    r68ae40a red5367b  
    112112}
    113113
     114static int unit_svc_stop(unit_t *unit)
     115{
     116        unit_svc_t *u_svc = CAST_SVC(unit);
     117        assert(u_svc);
     118
     119       
     120        // TODO think about unit's lifecycle (is STOPPED only acceptable?)
     121        // note: May change when job cancellation is possible.
     122        assert(unit->state == STATE_STARTED);
     123
     124        int rc = task_kill(u_svc->main_task_id);
     125
     126        if (rc != EOK) {
     127                /* Task may still be running, but be conservative about unit's
     128                 * state. */
     129                unit->state = STATE_FAILED;
     130                return rc;
     131        }
     132
     133        unit->state = STATE_STOPPING;
     134
     135        return EOK;
     136}
     137
     138
    114139static void unit_svc_exposee_created(unit_t *unit)
    115140{
  • uspace/srv/sysman/units/unit_tgt.c

    r68ae40a red5367b  
    6363}
    6464
     65static int unit_tgt_stop(unit_t *unit)
     66{
     67        unit_tgt_t *u_tgt = CAST_TGT(unit);
     68        assert(u_tgt);
     69
     70        unit->state = STATE_STOPPED;
     71        return EOK;
     72}
     73
    6574static void unit_tgt_exposee_created(unit_t *unit)
    6675{
Note: See TracChangeset for help on using the changeset viewer.