Changeset 8ae8262 in mainline for uspace/srv/sysman/repo.c


Ignore:
Timestamp:
2019-08-07T11:08:17Z (5 years ago)
Author:
Matthieu Riolo <matthieu.riolo@…>
Children:
130ba46
Parents:
5353f50
git-author:
Michal Koutný <xm.koutny+hos@…> (2015-11-12 02:56:35)
git-committer:
Matthieu Riolo <matthieu.riolo@…> (2019-08-07 11:08:17)
Message:

sysman: Support for anonymous services

  • Daemons that only call task_retval and don't exit are recorded as anonymous services.
  • Split unit run-state and repository state.
  • Partial support for removal of units from repository (needs refcounting yet).
File:
1 edited

Legend:

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

    r5353f50 r8ae8262  
    7474        .equal           = &units_by_handle_ht_equal,
    7575        .key_equal       = &units_by_handle_ht_key_equal,
    76         .remove_callback = NULL // TODO realy unneeded?
     76        .remove_callback = NULL
    7777};
    7878
     
    108108        .equal           = &units_by_name_ht_equal,
    109109        .key_equal       = &units_by_name_ht_key_equal,
    110         .remove_callback = NULL // TODO realy unneeded?
     110        .remove_callback = NULL
    111111};
    112112
    113113/* Repository functions */
     114
     115static void repo_remove_unit_internal(unit_t *u)
     116{
     117        hash_table_remove_item(&units_by_name, &u->units_by_name);
     118        hash_table_remove_item(&units_by_handle, &u->units_by_handle);
     119        list_remove(&u->units);
     120
     121        // TODO decrease refcount of unit
     122        // unit may be referenced e.g. from running job, thus we cannot simply destroy it
     123}
    114124
    115125void repo_init(void)
     
    122132{
    123133        assert(unit);
    124         assert(unit->state == STATE_EMBRYO);
     134        assert(unit->repo_state == REPO_EMBRYO);
    125135        assert(unit->handle == 0);
    126136        assert(unit->name != NULL);
     
    139149}
    140150
     151int repo_remove_unit(unit_t *unit)
     152{
     153        unit->repo_state = REPO_ZOMBIE;
     154        return EOK; /* We could check that unit is present in repo etc... */
     155}
     156
    141157void repo_begin_update(void) {
    142158        sysman_log(LVL_DEBUG2, "%s", __func__);
     
    146162{
    147163        unit_t *unit = hash_table_get_inst(ht_link, unit_t, units_by_name);
    148         if (unit->state == STATE_EMBRYO) {
    149                 unit->state = STATE_STOPPED;
     164        if (unit->repo_state == REPO_ZOMBIE) {
     165                repo_remove_unit_internal(unit);
     166                return true;
     167        }
     168
     169        if (unit->repo_state == REPO_EMBRYO) {
     170                unit->repo_state = REPO_LIVING;
    150171        }
    151172
     
    162183
    163184        /*
    164          * Apply commit to all units_by_name, each commited unit commits its outgoing
    165          * deps, thus eventually commiting all embryo deps as well.
     185         * Apply commit to all units_by_name, each commited unit commits its
     186         * outgoing deps, thus eventually commiting all embryo deps as well.
     187         *
     188         * TODO why not iterate over units list?
    166189         */
    167190        hash_table_apply(&units_by_name, &repo_commit_unit, NULL);
     
    180203        }
    181204
    182         if (unit->state == STATE_EMBRYO) {
    183                 hash_table_remove_item(&units_by_name, ht_link);
    184                 list_remove(&unit->units);
    185                 unit_destroy(&unit);
     205        if (unit->repo_state == REPO_EMBRYO) {
     206                repo_remove_unit_internal(unit);
     207        } else if (unit->repo_state == REPO_ZOMBIE) {
     208                unit->repo_state = REPO_LIVING;
    186209        }
    187210
Note: See TracChangeset for help on using the changeset viewer.