Esempio n. 1
0
void data_dispatcher_register(data_dispatcher_t *dispatcher, data_dispatcher_type_t type, fixed_queue_t *queue) {
  assert(dispatcher != NULL);

  hash_map_erase(dispatcher->dispatch_table, (void *)type);
  if (queue)
    hash_map_set(dispatcher->dispatch_table, (void *)type, queue);
}
Esempio n. 2
0
void btu_free_quick_timer(TIMER_LIST_ENT *p_tle)
{
    assert(p_tle != NULL);

    p_tle->in_use = FALSE;

    // Get the alarm for the timer list entry.
    osi_alarm_t *alarm = hash_map_get(btu_l2cap_alarm_hash_map, p_tle);
    if (alarm == NULL) {
        LOG_DEBUG("%s Unable to find expected alarm in hashmap", __func__);
        return;
    }
    osi_alarm_cancel(alarm);
    hash_map_erase(btu_l2cap_alarm_hash_map, p_tle);
}
Esempio n. 3
0
static void wb_pop_block(struct cache_info * info, uint32_t number, uint32_t index)
{
	assert(info->blocks[index].block);
	assert(info->blocks[index].block->cache_number == number);
	
	bdesc_release(&info->blocks[index].block);
	
	/* this will set blocks[0].lru/mru as necessary */
	info->blocks[index].prev->next = info->blocks[index].next;
	info->blocks[index].next->prev = info->blocks[index].prev;
	
	/* now it's a free slot */
	info->blocks[index].next_index = info->blocks[0].free_index;
	info->blocks[index].next = &info->blocks[info->blocks[0].free_index];
	info->blocks[0].free_index = index;
	
	hash_map_erase(info->block_map, (void *) number);
}
static void exit_handler(struct task_struct * process)
{
	patchgroup_scope_t * scope;
	
	assert(current == process);
	spin_lock(&scope_lock);
	
	scope = hash_map_find_val(scope_map, process);
	if(scope)
	{
		/* See fork_handler() for an explanation of these 3 lines. */
		spin_unlock(&scope_lock);
		fstitchd_enter();
		spin_lock(&scope_lock);
		
		hash_map_erase(scope_map, process);
		patchgroup_scope_destroy(scope);
		
		fstitchd_leave(0);
	}
	spin_unlock(&scope_lock);
}
Esempio n. 5
0
static void reassemble_and_dispatch(BT_HDR *packet)
{
    LOG_DEBUG("reassemble_and_dispatch\n");

    if ((packet->event & MSG_EVT_MASK) == MSG_HC_TO_STACK_HCI_ACL) {
        uint8_t *stream = packet->data + packet->offset;
        uint16_t handle;
        uint16_t l2cap_length;
        uint16_t acl_length;

        STREAM_TO_UINT16(handle, stream);
        STREAM_TO_UINT16(acl_length, stream);
        STREAM_TO_UINT16(l2cap_length, stream);

        assert(acl_length == packet->len - HCI_ACL_PREAMBLE_SIZE);

        uint8_t boundary_flag = GET_BOUNDARY_FLAG(handle);
        handle = handle & HANDLE_MASK;

        BT_HDR *partial_packet = (BT_HDR *)hash_map_get(partial_packets, (void *)(uintptr_t)handle);

        if (boundary_flag == START_PACKET_BOUNDARY) {
            if (partial_packet) {
                LOG_WARN("%s found unfinished packet for handle with start packet. Dropping old.\n", __func__);
                hash_map_erase(partial_packets, (void *)(uintptr_t)handle);
                buffer_allocator->free(partial_packet);
            }

            uint16_t full_length = l2cap_length + L2CAP_HEADER_SIZE + HCI_ACL_PREAMBLE_SIZE;
            if (full_length <= packet->len) {
                if (full_length < packet->len) {
                    LOG_WARN("%s found l2cap full length %d less than the hci length %d.\n", __func__, l2cap_length, packet->len);
                }

                callbacks->reassembled(packet);
                return;
            }

            partial_packet = (BT_HDR *)buffer_allocator->alloc(full_length + sizeof(BT_HDR));
            partial_packet->event = packet->event;
            partial_packet->len = full_length;
            partial_packet->offset = packet->len;

            memcpy(partial_packet->data, packet->data + packet->offset, packet->len);

            // Update the ACL data size to indicate the full expected length
            stream = partial_packet->data;
            STREAM_SKIP_UINT16(stream); // skip the handle
            UINT16_TO_STREAM(stream, full_length - HCI_ACL_PREAMBLE_SIZE);

            hash_map_set(partial_packets, (void *)(uintptr_t)handle, partial_packet);
            // Free the old packet buffer, since we don't need it anymore
            buffer_allocator->free(packet);
        } else {
            if (!partial_packet) {
                LOG_ERROR("%s got continuation for unknown packet. Dropping it.\n", __func__);
                buffer_allocator->free(packet);
                return;
            }

            packet->offset += HCI_ACL_PREAMBLE_SIZE; // skip ACL preamble
            packet->len -= HCI_ACL_PREAMBLE_SIZE;
            uint16_t projected_offset = partial_packet->offset + packet->len;
            if (projected_offset > partial_packet->len) { // len stores the expected length
                LOG_ERROR("%s got packet which would exceed expected length of %d. Truncating.\n", __func__, partial_packet->len);
                packet->len = partial_packet->len - partial_packet->offset;
                projected_offset = partial_packet->len;
            }

            memcpy(
                partial_packet->data + partial_packet->offset,
                packet->data + packet->offset,
                packet->len
            );

            // Free the old packet buffer, since we don't need it anymore
            buffer_allocator->free(packet);
            partial_packet->offset = projected_offset;

            if (partial_packet->offset == partial_packet->len) {
                hash_map_erase(partial_packets, (void *)(uintptr_t)handle);
                partial_packet->offset = 0;
                callbacks->reassembled(partial_packet);
            }
        }
    } else {
        callbacks->reassembled(packet);
    }
}
Esempio n. 6
0
static void background_connection_remove(bt_bdaddr_t *address) {
  if (address && background_connections)
    hash_map_erase(background_connections, address);
}
Esempio n. 7
0
static void serve_forget(fuse_req_t req, fuse_ino_t ino, unsigned long nlookup)
{
	Dprintf("%s(ino = %lu, nlookup = %lu)\n", __FUNCTION__, ino, nlookup);
	(void) hash_map_erase(reqmount(req)->parents, (void *) ino);
	fuse_reply_none(req);
}