Changeset 8ae8262 in mainline for uspace/srv/sysman/repo.c
- Timestamp:
- 2019-08-07T11:08:17Z (6 years ago)
- 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)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/sysman/repo.c
r5353f50 r8ae8262 74 74 .equal = &units_by_handle_ht_equal, 75 75 .key_equal = &units_by_handle_ht_key_equal, 76 .remove_callback = NULL // TODO realy unneeded?76 .remove_callback = NULL 77 77 }; 78 78 … … 108 108 .equal = &units_by_name_ht_equal, 109 109 .key_equal = &units_by_name_ht_key_equal, 110 .remove_callback = NULL // TODO realy unneeded?110 .remove_callback = NULL 111 111 }; 112 112 113 113 /* Repository functions */ 114 115 static 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 } 114 124 115 125 void repo_init(void) … … 122 132 { 123 133 assert(unit); 124 assert(unit-> state == STATE_EMBRYO);134 assert(unit->repo_state == REPO_EMBRYO); 125 135 assert(unit->handle == 0); 126 136 assert(unit->name != NULL); … … 139 149 } 140 150 151 int 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 141 157 void repo_begin_update(void) { 142 158 sysman_log(LVL_DEBUG2, "%s", __func__); … … 146 162 { 147 163 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; 150 171 } 151 172 … … 162 183 163 184 /* 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? 166 189 */ 167 190 hash_table_apply(&units_by_name, &repo_commit_unit, NULL); … … 180 203 } 181 204 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; 186 209 } 187 210
Note:
See TracChangeset
for help on using the changeset viewer.