Changeset ab49a0d in mainline for uspace/srv
- Timestamp:
- 2010-12-23T16:11:01Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 467bf40, 77cea41
- Parents:
- 8dd039a (diff), 8240dc5a (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - Location:
- uspace/srv
- Files:
-
- 5 edited
-
devman/devman.c (modified) (8 diffs)
-
devmap/devmap.c (modified) (10 diffs)
-
fs/devfs/devfs_ops.c (modified) (7 diffs)
-
net/tl/tcp/tcp.c (modified) (1 diff)
-
vfs/vfs_lookup.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/devman/devman.c
r8dd039a rab49a0d 392 392 printf(NAME ": create_root_node\n"); 393 393 394 fibril_rwlock_write_lock(&tree->rwlock); 394 395 node = create_dev_node(); 395 396 if (node != NULL) { … … 401 402 tree->root_node = node; 402 403 } 404 fibril_rwlock_write_unlock(&tree->rwlock); 403 405 404 406 return node != NULL; … … 463 465 /** Start a driver 464 466 * 465 * The driver's mutex is assumed to be locked.466 *467 467 * @param drv The driver's structure. 468 468 * @return True if the driver's task is successfully spawned, false … … 473 473 int rc; 474 474 475 assert(fibril_mutex_is_locked(&drv->driver_mutex)); 476 475 477 printf(NAME ": start_driver '%s'\n", drv->name); 476 478 … … 867 869 /** Find the device node structure of the device witch has the specified handle. 868 870 * 869 * Device tree's rwlock should be held at least for reading.870 *871 871 * @param tree The device tree where we look for the device node. 872 872 * @param handle The handle of the device. … … 876 876 { 877 877 unsigned long key = handle; 878 link_t *link = hash_table_find(&tree->devman_devices, &key); 878 link_t *link; 879 880 assert(fibril_rwlock_is_locked(&tree->rwlock)); 881 882 link = hash_table_find(&tree->devman_devices, &key); 879 883 return hash_table_get_instance(link, node_t, devman_link); 880 884 } … … 932 936 /** Insert new device into device tree. 933 937 * 934 * The device tree's rwlock should be already held exclusively when calling this935 * function.936 *937 938 * @param tree The device tree. 938 939 * @param node The newly added device node. … … 949 950 assert(tree != NULL); 950 951 assert(dev_name != NULL); 952 assert(fibril_rwlock_is_write_locked(&tree->rwlock)); 951 953 952 954 node->name = dev_name; -
uspace/srv/devmap/devmap.c
r8dd039a rab49a0d 46 46 #include <str.h> 47 47 #include <ipc/devmap.h> 48 #include <assert.h> 48 49 49 50 #define NAME "devmap" … … 208 209 } 209 210 210 /** Find namespace with given name. 211 * 212 * The devices_list_mutex should be already held when 213 * calling this function. 214 * 215 */ 211 /** Find namespace with given name. */ 216 212 static devmap_namespace_t *devmap_namespace_find_name(const char *name) 217 213 { 218 214 link_t *item; 215 216 assert(fibril_mutex_is_locked(&devices_list_mutex)); 217 219 218 for (item = namespaces_list.next; item != &namespaces_list; item = item->next) { 220 219 devmap_namespace_t *namespace = … … 229 228 /** Find namespace with given handle. 230 229 * 231 * The devices_list_mutex should be already held when232 * calling this function.233 *234 230 * @todo: use hash table 235 231 * … … 238 234 { 239 235 link_t *item; 236 237 assert(fibril_mutex_is_locked(&devices_list_mutex)); 238 240 239 for (item = namespaces_list.next; item != &namespaces_list; item = item->next) { 241 240 devmap_namespace_t *namespace = … … 248 247 } 249 248 250 /** Find device with given name. 251 * 252 * The devices_list_mutex should be already held when 253 * calling this function. 254 * 255 */ 249 /** Find device with given name. */ 256 250 static devmap_device_t *devmap_device_find_name(const char *ns_name, 257 251 const char *name) 258 252 { 259 253 link_t *item; 254 255 assert(fibril_mutex_is_locked(&devices_list_mutex)); 256 260 257 for (item = devices_list.next; item != &devices_list; item = item->next) { 261 258 devmap_device_t *device = … … 271 268 /** Find device with given handle. 272 269 * 273 * The devices_list_mutex should be already held when274 * calling this function.275 *276 270 * @todo: use hash table 277 271 * … … 280 274 { 281 275 link_t *item; 276 277 assert(fibril_mutex_is_locked(&devices_list_mutex)); 278 282 279 for (item = devices_list.next; item != &devices_list; item = item->next) { 283 280 devmap_device_t *device = … … 290 287 } 291 288 292 /** Create a namespace (if not already present) 293 * 294 * The devices_list_mutex should be already held when 295 * calling this function. 296 * 297 */ 289 /** Create a namespace (if not already present). */ 298 290 static devmap_namespace_t *devmap_namespace_create(const char *ns_name) 299 291 { 300 devmap_namespace_t *namespace = devmap_namespace_find_name(ns_name); 292 devmap_namespace_t *namespace; 293 294 assert(fibril_mutex_is_locked(&devices_list_mutex)); 295 296 namespace = devmap_namespace_find_name(ns_name); 301 297 if (namespace != NULL) 302 298 return namespace; … … 323 319 } 324 320 325 /** Destroy a namespace (if it is no longer needed) 326 * 327 * The devices_list_mutex should be already held when 328 * calling this function. 329 * 330 */ 321 /** Destroy a namespace (if it is no longer needed). */ 331 322 static void devmap_namespace_destroy(devmap_namespace_t *namespace) 332 323 { 324 assert(fibril_mutex_is_locked(&devices_list_mutex)); 325 333 326 if (namespace->refcnt == 0) { 334 327 list_remove(&(namespace->namespaces)); … … 339 332 } 340 333 341 /** Increase namespace reference count by including device 342 * 343 * The devices_list_mutex should be already held when 344 * calling this function. 345 * 346 */ 334 /** Increase namespace reference count by including device. */ 347 335 static void devmap_namespace_addref(devmap_namespace_t *namespace, 348 336 devmap_device_t *device) 349 337 { 338 assert(fibril_mutex_is_locked(&devices_list_mutex)); 339 350 340 device->namespace = namespace; 351 341 namespace->refcnt++; 352 342 } 353 343 354 /** Decrease namespace reference count 355 * 356 * The devices_list_mutex should be already held when 357 * calling this function. 358 * 359 */ 344 /** Decrease namespace reference count. */ 360 345 static void devmap_namespace_delref(devmap_namespace_t *namespace) 361 346 { 347 assert(fibril_mutex_is_locked(&devices_list_mutex)); 348 362 349 namespace->refcnt--; 363 350 devmap_namespace_destroy(namespace); 364 351 } 365 352 366 /** Unregister device and free it 367 * 368 * The devices_list_mutex should be already held when 369 * calling this function. 370 * 371 */ 353 /** Unregister device and free it. */ 372 354 static void devmap_device_unregister_core(devmap_device_t *device) 373 355 { 356 assert(fibril_mutex_is_locked(&devices_list_mutex)); 357 374 358 devmap_namespace_delref(device->namespace); 375 359 list_remove(&(device->devices)); -
uspace/srv/fs/devfs/devfs_ops.c
r8dd039a rab49a0d 60 60 typedef struct { 61 61 devmap_handle_t handle; 62 int phone; 62 int phone; /**< When < 0, the structure is incomplete. */ 63 63 size_t refcount; 64 64 link_t link; 65 fibril_condvar_t cv; /**< Broadcast when completed. */ 65 66 } device_t; 66 67 … … 227 228 [DEVICES_KEY_HANDLE] = (unsigned long) node->handle 228 229 }; 229 230 link_t *lnk; 231 230 232 fibril_mutex_lock(&devices_mutex); 231 link_t *lnk = hash_table_find(&devices, key); 233 restart: 234 lnk = hash_table_find(&devices, key); 232 235 if (lnk == NULL) { 233 236 device_t *dev = (device_t *) malloc(sizeof(device_t)); … … 237 240 } 238 241 242 dev->handle = node->handle; 243 dev->phone = -1; /* mark as incomplete */ 244 dev->refcount = 1; 245 fibril_condvar_initialize(&dev->cv); 246 247 /* 248 * Insert the incomplete device structure so that other 249 * fibrils will not race with us when we drop the mutex 250 * below. 251 */ 252 hash_table_insert(&devices, key, &dev->link); 253 254 /* 255 * Drop the mutex to allow recursive devfs requests. 256 */ 257 fibril_mutex_unlock(&devices_mutex); 258 239 259 int phone = devmap_device_connect(node->handle, 0); 260 261 fibril_mutex_lock(&devices_mutex); 262 263 /* 264 * Notify possible waiters about this device structure 265 * being completed (or destroyed). 266 */ 267 fibril_condvar_broadcast(&dev->cv); 268 240 269 if (phone < 0) { 270 /* 271 * Connecting failed, need to remove the 272 * entry and free the device structure. 273 */ 274 hash_table_remove(&devices, key, DEVICES_KEYS); 241 275 fibril_mutex_unlock(&devices_mutex); 276 242 277 free(dev); 243 278 return ENOENT; 244 279 } 245 280 246 dev->handle = node->handle;281 /* Set the correct phone. */ 247 282 dev->phone = phone; 248 dev->refcount = 1;249 250 hash_table_insert(&devices, key, &dev->link);251 283 } else { 252 284 device_t *dev = hash_table_get_instance(lnk, device_t, link); 285 286 if (dev->phone < 0) { 287 /* 288 * Wait until the device structure is completed 289 * and start from the beginning as the device 290 * structure might have entirely disappeared 291 * while we were not holding the mutex in 292 * fibril_condvar_wait(). 293 */ 294 fibril_condvar_wait(&dev->cv, &devices_mutex); 295 goto restart; 296 } 297 253 298 dev->refcount++; 254 299 } … … 564 609 565 610 device_t *dev = hash_table_get_instance(lnk, device_t, link); 611 assert(dev->phone >= 0); 566 612 567 613 ipc_callid_t callid; … … 627 673 628 674 device_t *dev = hash_table_get_instance(lnk, device_t, link); 675 assert(dev->phone >= 0); 629 676 630 677 ipc_callid_t callid; … … 696 743 697 744 device_t *dev = hash_table_get_instance(lnk, device_t, link); 745 assert(dev->phone >= 0); 698 746 dev->refcount--; 699 747 … … 743 791 744 792 device_t *dev = hash_table_get_instance(lnk, device_t, link); 793 assert(dev->phone >= 0); 745 794 746 795 /* Make a request at the driver */ -
uspace/srv/net/tl/tcp/tcp.c
r8dd039a rab49a0d 2085 2085 if (!fibril) { 2086 2086 free(operation_timeout); 2087 return EPARTY; /* FIXME: use another EC */ 2088 } 2087 return ENOMEM; 2088 } 2089 2089 2090 // fibril_mutex_lock(&socket_data->operation.mutex); 2090 2091 /* Start the timeout fibril */ -
uspace/srv/vfs/vfs_lookup.c
r8dd039a rab49a0d 179 179 fibril_mutex_unlock(&plb_mutex); 180 180 181 if (( (int) rc < EOK) || (!result))181 if ((int) rc < EOK) 182 182 return (int) rc; 183 184 if (!result) 185 return EOK; 183 186 184 187 result->triplet.fs_handle = (fs_handle_t) rc;
Note:
See TracChangeset
for help on using the changeset viewer.
