/* fat_file_close -- * Close fat-file. If count of links to fat-file * descriptor is greater than 1 (i.e. somebody esle holds pointer * to this descriptor) just decrement it. Otherwise * do the following. If this descriptor corresponded to removed fat-file * then free clusters contained fat-file data, delete descriptor from * "rhash" table and free memory allocated by descriptor. If descriptor * correspondes to non-removed fat-file and 'ino' field has value from * unique inode numbers pool then set count of links to descriptor to zero * and leave it in hash, otherwise delete descriptor from "vhash" and free * memory allocated by the descriptor * * PARAMETERS: * mt_entry - mount table entry * fat_fd - fat-file descriptor * * RETURNS: * RC_OK, or -1 if error occured (errno set appropriately) */ int fat_file_close( rtems_filesystem_mount_table_entry_t *mt_entry, fat_file_fd_t *fat_fd ) { int rc = RC_OK; fat_fs_info_t *fs_info = mt_entry->fs_info; uint32_t key = 0; /* * if links_num field of fat-file descriptor is greater than 1 * decrement the count of links and return */ if (fat_fd->links_num > 1) { fat_fd->links_num--; return rc; } key = fat_construct_key(mt_entry, &fat_fd->dir_pos.sname); if (fat_fd->flags & FAT_FILE_REMOVED) { rc = fat_file_truncate(mt_entry, fat_fd, 0); if ( rc != RC_OK ) return rc; _hash_delete(fs_info->rhash, key, fat_fd->ino, fat_fd); if ( fat_ino_is_unique(mt_entry, fat_fd->ino) ) fat_free_unique_ino(mt_entry, fat_fd->ino); free(fat_fd); } else { if (fat_ino_is_unique(mt_entry, fat_fd->ino)) { fat_fd->links_num = 0; } else { _hash_delete(fs_info->vhash, key, fat_fd->ino, fat_fd); free(fat_fd); } } /* * flush any modified "cached" buffer back to disk */ rc = fat_buf_release(fs_info); return rc; }
void harbor_release(struct harbor *h) { if (h->master_fd >= 0) { close(h->master_fd); } free(h->master_addr); int i; for (i=0;i<REMOTE_MAX;i++) { if (h->remote_fd[i] >= 0) { close(h->remote_fd[i]); free(h->remote_addr[i]); } } _hash_delete(h->map); free(h); }
HARBOR_API void harbor_release(struct harbor *h) { struct skynet_context *ctx = h->ctx; if (h->master_fd >= 0) { skynet_socket_close(ctx, h->master_fd); } skynet_free(h->master_addr); skynet_free(h->local_addr); int i; for (i=0;i<REMOTE_MAX;i++) { if (h->remote_fd[i] >= 0) { skynet_socket_close(ctx, h->remote_fd[i]); skynet_free(h->remote_addr[i]); } } _hash_delete(h->map); skynet_free(h); }
void dummy_release(struct dummy *d) { _hash_delete(d->map); skynet_free(d); }