block_cache::~block_cache() { hash_uninit(transaction_hash); hash_uninit(hash); fssh_mutex_destroy(&lock); }
static void uninit() { unregister_generic_syscall(LAUNCH_SPEEDUP_SYSCALLS, 1); recursive_lock_lock(&sLock); // free all sessions from the hashes uint32 cookie = 0; Session *session; while ((session = (Session *)hash_remove_first(sTeamHash, &cookie)) != NULL) { delete session; } cookie = 0; while ((session = (Session *)hash_remove_first(sPrefetchHash, &cookie)) != NULL) { delete session; } // free all sessions from the main prefetch list for (session = sMainPrefetchSessions; session != NULL; ) { sMainPrefetchSessions = session->Next(); delete session; session = sMainPrefetchSessions; } hash_uninit(sTeamHash); hash_uninit(sPrefetchHash); recursive_lock_destroy(&sLock); }
Session::~Session() { mutex_destroy(&fLock); // free all nodes if (fNodeHash) { // ... from the hash uint32 cookie = 0; struct node *node; while ((node = (struct node *)hash_remove_first(fNodeHash, &cookie)) != NULL) { //TRACE((" node %ld:%Ld\n", node->ref.device, node->ref.node)); free(node); } hash_uninit(fNodeHash); } else { // ... from the list struct node *node = fNodes, *next = NULL; for (; node != NULL; node = next) { next = node->next; free(node); } } StopWatchingTeam(); }
static status_t init() { sTeamHash = hash_init(64, Session::NextOffset(), &team_compare, &team_hash); if (sTeamHash == NULL) return B_NO_MEMORY; status_t status; sPrefetchHash = hash_init(64, Session::NextOffset(), &prefetch_compare, &prefetch_hash); if (sPrefetchHash == NULL) { status = B_NO_MEMORY; goto err1; } recursive_lock_init(&sLock, "launch speedup"); // register kernel syscalls if (register_generic_syscall(LAUNCH_SPEEDUP_SYSCALLS, launch_speedup_control, 1, 0) != B_OK) { status = B_ERROR; goto err3; } // read in prefetch knowledge base mkdir("/etc/launch_cache", 0755); load_prefetch_data(); // start boot session sMainSession = start_session(-1, -1, -1, "system boot"); sMainSession->Unlock(); dprintf("START BOOT %Ld\n", system_time()); return B_OK; err3: recursive_lock_destroy(&sLock); hash_uninit(sPrefetchHash); err1: hash_uninit(sTeamHash); return status; }
status_t uninit_stack() { TRACE(("Unloading network stack\n")); put_module(NET_SOCKET_MODULE_NAME); uninit_timers(); uninit_device_interfaces(); uninit_interfaces(); uninit_domains(); uninit_notifications(); mutex_destroy(&sChainLock); mutex_destroy(&sInitializeChainLock); // remove chains and families chain::DeleteChains(sProtocolChains); chain::DeleteChains(sDatalinkProtocolChains); chain::DeleteChains(sReceivingProtocolChains); uint32 cookie = 0; while (true) { struct family* family = (struct family*)hash_remove_first(sFamilies, &cookie); if (family == NULL) break; delete family; } hash_uninit(sProtocolChains); hash_uninit(sDatalinkProtocolChains); hash_uninit(sReceivingProtocolChains); hash_uninit(sFamilies); return B_OK; }
static errno_t cache_do_destroy( cache_t *c ) { hal_mutex_lock( &c->lock ); while(!queue_empty(&c->lru)) { cache_el_t * el; //queue_remove_last( &c->lru, el, cache_el_t *, lru ); queue_remove_first( &c->lru, el, cache_el_t *, lru ); cache_do_destroy_el(el); } hal_mutex_unlock( &c->lock ); hash_uninit(c->hash); hal_mutex_destroy( &c->lock ); return 0; }
int nfs_unmount(fs_cookie fs) { nfs_fs *nfs = (nfs_fs *)fs; TRACE("nfs_unmount: fsid 0x%x\n", nfs->id); // put_vnode on the root to release the ref to it vfs_put_vnode(nfs->id, VNODETOVNID(nfs->root_vnode)); nfs_unmount_fs(nfs); hash_uninit(nfs->handle_hash); rpc_destroy_state(&nfs->rpc); mutex_destroy(&nfs->lock); kfree(nfs); return 0; }
static int pipefs_unmount(fs_cookie _fs) { struct pipefs *fs = _fs; struct pipefs_vnode *v; struct hash_iterator i; TRACE(("pipefs_unmount: entry fs = 0x%x\n", fs)); // delete all of the vnodes hash_open(fs->vnode_list_hash, &i); while((v = (struct pipefs_vnode *)hash_next(fs->vnode_list_hash, &i)) != NULL) { pipefs_delete_vnode(fs, v, true); } hash_close(fs->vnode_list_hash, &i, false); hash_uninit(fs->vnode_list_hash); mutex_destroy(&fs->hash_lock); kfree(fs); return 0; }
static int pipefs_mount(fs_cookie *_fs, fs_id id, const char *pipefs, void *args, vnode_id *root_vnid) { struct pipefs *fs; struct pipefs_vnode *v; struct pipefs_vnode *anon_v; int err; TRACE(("pipefs_mount: entry\n")); if(thepipefs) { dprintf("double mount of pipefs attempted\n"); err = ERR_GENERAL; goto err; } fs = kmalloc(sizeof(struct pipefs)); if(fs == NULL) { err = ERR_NO_MEMORY; goto err; } fs->id = id; fs->next_vnode_id = 0; err = mutex_init(&fs->hash_lock, "pipefs_mutex"); if(err < 0) { goto err1; } fs->vnode_list_hash = hash_init(PIPEFS_HASH_SIZE, offsetof(struct pipefs_vnode, all_next), &pipefs_vnode_compare_func, &pipefs_vnode_hash_func); if(fs->vnode_list_hash == NULL) { err = ERR_NO_MEMORY; goto err2; } // create a vnode v = pipefs_create_vnode(fs, "", STREAM_TYPE_DIR); if(v == NULL) { err = ERR_NO_MEMORY; goto err3; } // set it up v->parent = v; fs->root_vnode = v; hash_insert(fs->vnode_list_hash, v); *root_vnid = v->id; *_fs = fs; // create the anonymous pipe anon_v = pipefs_create_vnode(fs, "anon", STREAM_TYPE_PIPE); if(anon_v == NULL) { err = ERR_NO_MEMORY; goto err4; } // set it up anon_v->parent = v; fs->anon_vnode = anon_v; hash_insert(fs->vnode_list_hash, anon_v); mutex_lock(&v->stream.u.dir.dir_lock); pipefs_insert_in_dir(v, anon_v); mutex_unlock(&v->stream.u.dir.dir_lock); thepipefs = fs; return 0; err4: pipefs_delete_vnode(fs, v, true); err3: hash_uninit(fs->vnode_list_hash); err2: mutex_destroy(&fs->hash_lock); err1: kfree(fs); err: return err; }
status_t init_stack() { status_t status = init_domains(); if (status != B_OK) return status; status = init_interfaces(); if (status != B_OK) goto err1; status = init_device_interfaces(); if (status != B_OK) goto err2; status = init_timers(); if (status != B_OK) goto err3; status = init_notifications(); if (status < B_OK) { // If this fails, it just means there won't be any notifications, // it's not a fatal error. dprintf("networking stack notifications could not be initialized: %s\n", strerror(status)); } module_info* dummy; status = get_module(NET_SOCKET_MODULE_NAME, &dummy); if (status != B_OK) goto err4; mutex_init(&sChainLock, "net chains"); mutex_init(&sInitializeChainLock, "net intialize chains"); sFamilies = hash_init(10, offsetof(struct family, next), &family::Compare, &family::Hash); if (sFamilies == NULL) { status = B_NO_MEMORY; goto err5; } sProtocolChains = hash_init(10, offsetof(struct chain, next), &chain::Compare, &chain::Hash); if (sProtocolChains == NULL) { status = B_NO_MEMORY; goto err6; } sDatalinkProtocolChains = hash_init(10, offsetof(struct chain, next), &chain::Compare, &chain::Hash); if (sDatalinkProtocolChains == NULL) { status = B_NO_MEMORY; goto err7; } sReceivingProtocolChains = hash_init(10, offsetof(struct chain, next), &chain::Compare, &chain::Hash); if (sReceivingProtocolChains == NULL) { status = B_NO_MEMORY; goto err8; } sInitialized = true; link_init(); scan_modules("network/protocols"); scan_modules("network/datalink_protocols"); // TODO: for now! register_domain_datalink_protocols(AF_INET, IFT_LOOP, "network/datalink_protocols/loopback_frame/v1", NULL); register_domain_datalink_protocols(AF_INET6, IFT_LOOP, "network/datalink_protocols/loopback_frame/v1", NULL); register_domain_datalink_protocols(AF_INET, IFT_ETHER, "network/datalink_protocols/arp/v1", "network/datalink_protocols/ethernet_frame/v1", NULL); register_domain_datalink_protocols(AF_INET6, IFT_ETHER, "network/datalink_protocols/ipv6_datagram/v1", "network/datalink_protocols/ethernet_frame/v1", NULL); return B_OK; err8: hash_uninit(sDatalinkProtocolChains); err7: hash_uninit(sProtocolChains); err6: hash_uninit(sFamilies); err5: mutex_destroy(&sInitializeChainLock); mutex_destroy(&sChainLock); err4: uninit_timers(); err3: uninit_device_interfaces(); err2: uninit_interfaces(); err1: uninit_domains(); return status; }