Changeset ff20afc in mainline
- Timestamp:
- 2019-08-17T13:12:47Z (5 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)
- Location:
- uspace/srv/sysman
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/sysman/connection_ctl.c
rd5cca04 rff20afc 76 76 } 77 77 78 // TODO this is connection fibril, UNSYNCHRONIZED access to units!79 78 unit_t *unit = repo_find_unit_by_name(unit_name); 80 79 if (unit == NULL) { … … 107 106 sysman_log(LVL_DEBUG2, "%s(%s, %x)", __func__, unit_name, flags); 108 107 109 // TODO this is connection fibril, UNSYNCHRONIZED access to units!110 108 unit_t *unit = repo_find_unit_by_name(unit_name); 111 109 if (unit == NULL) { … … 148 146 sysman_log(LVL_DEBUG2, "%s(%i, %x)", __func__, handle, flags); 149 147 150 // TODO this is connection fibril, UNSYNCHRONIZED access to units!151 148 unit_t *unit = repo_find_unit_by_handle(handle); 152 149 if (unit == NULL) { … … 188 185 size_t to_fill = size / sizeof(unit_handle_t); 189 186 size_t total = 0; 187 repo_rlock(); 190 188 list_foreach(units, units, unit_t, u) { 191 189 if (filled < to_fill) { … … 194 192 ++total; 195 193 } 194 repo_runlock(); 196 195 *act_size = total * sizeof(unit_handle_t); 197 196 return EOK; … … 220 219 221 220 222 // TODO UNSYNCHRONIZED access to units!223 221 rc = fill_handles_buffer(handles, size, &act_size); 224 222 if (rc != EOK) { … … 246 244 } 247 245 248 // TODO UNSYNCHRONIZED access to units!249 246 unit_t *u = repo_find_unit_by_handle(IPC_GET_ARG1(*icall)); 250 247 if (u == NULL) { … … 262 259 static void sysman_unit_get_state(ipc_callid_t iid, ipc_call_t *icall) 263 260 { 264 // TODO UNSYNCHRONIZED access to units!265 261 unit_t *u = repo_find_unit_by_handle(IPC_GET_ARG1(*icall)); 266 262 if (u == NULL) { -
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 } -
uspace/srv/sysman/repo.h
rd5cca04 rff20afc 38 38 #define ANONYMOUS_SERVICE_MASK "service_%" PRIu64 39 39 40 /* 41 * If you access units out of the main event-loop fibril call repo_rlock(), 42 * repo_runlock(). 43 */ 40 44 extern list_t units; 41 45 … … 56 60 extern unit_t *repo_find_unit_by_handle(unit_handle_t); 57 61 62 extern void repo_rlock(void); 63 extern void repo_runlock(void); 58 64 59 65 #endif -
uspace/srv/sysman/sysman.c
rd5cca04 rff20afc 359 359 /* 360 360 * Event handlers 361 */ 362 363 // NOTE must run in main event loop fibril 361 * 362 * NOTE must run in main event loop fibril 363 */ 364 364 365 void sysman_event_job_process(void *data) 365 366 {
Note:
See TracChangeset
for help on using the changeset viewer.