Changeset ff20afc in mainline for uspace/srv/sysman/repo.c
- Timestamp:
- 2019-08-17T13:12:47Z (6 years ago)
- Children:
- 5a88d87
- Parents:
- d5cca04
- git-author:
- Michal Koutný <xm.koutny+hos@…> (2015-12-04 13:56:42)
- git-committer:
- Matthieu Riolo <matthieu.riolo@…> (2019-08-17 13:12:47)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/sysman/repo.c
rd5cca04 rff20afc 42 42 static hash_table_t units_by_name; 43 43 static hash_table_t units_by_handle; 44 /** Lock to protect units_by_name and units_by_handle, so that 45 * repo_find_unit_by_* can be called also from non-event loop fibrils. 46 */ 47 static FIBRIL_RWLOCK_INITIALIZE(repo_lock); 44 48 45 49 /* Hash table functions */ … … 137 141 sysman_log(LVL_DEBUG2, "%s('%s')", __func__, unit_name(unit)); 138 142 143 fibril_rwlock_write_lock(&repo_lock); 139 144 if (hash_table_insert_unique(&units_by_name, &unit->units_by_name)) { 140 145 /* Pointers are same size as unit_handle_t both on 32b and 64b */ … … 143 148 hash_table_insert(&units_by_handle, &unit->units_by_handle); 144 149 list_append(&unit->units, &units); 150 fibril_rwlock_write_unlock(&repo_lock); 145 151 return EOK; 146 152 } else { 153 fibril_rwlock_write_unlock(&repo_lock); 147 154 return EEXISTS; 148 155 } … … 268 275 unit_t *repo_find_unit_by_name(const char *name) 269 276 { 277 fibril_rwlock_read_lock(&repo_lock); 270 278 ht_link_t *ht_link = hash_table_find(&units_by_name, (void *)name); 279 fibril_rwlock_read_unlock(&repo_lock); 280 271 281 if (ht_link != NULL) { 272 282 return hash_table_get_inst(ht_link, unit_t, units_by_name); … … 278 288 unit_t *repo_find_unit_by_handle(unit_handle_t handle) 279 289 { 290 fibril_rwlock_read_lock(&repo_lock); 280 291 ht_link_t *ht_link = hash_table_find(&units_by_handle, &handle); 292 fibril_rwlock_read_unlock(&repo_lock); 293 281 294 if (ht_link != NULL) { 282 295 return hash_table_get_inst(ht_link, unit_t, units_by_handle); … … 286 299 } 287 300 301 void repo_rlock(void) 302 { 303 fibril_rwlock_read_lock(&repo_lock); 304 } 305 306 void repo_runlock(void) 307 { 308 fibril_rwlock_read_unlock(&repo_lock); 309 }
Note:
See TracChangeset
for help on using the changeset viewer.