예제 #1
0
파일: distmem.c 프로젝트: mesham/distmem
void *distmem_get_specific_entry(struct distmem *dist_kind, void *ptr) {
  struct distmem_memory_information_generic *head = dist_kind->internal_state[get_hashkey(ptr)];
  while (head != NULL) {
    if (head->ptr == ptr) return head->specific_information;
    head = head->next;
  }
  return NULL;
}
예제 #2
0
파일: distmem.c 프로젝트: mesham/distmem
void distmem_put_specific_entry_into_state(struct distmem *dist_kind, void *specific_info, void *ptr,
                                           void (*deallocate_specific_information)(void *)) {
  int hashkey = get_hashkey(ptr);
  struct distmem_memory_information_generic *generic_info =
      (struct distmem_memory_information_generic *)memkind_malloc(MEMKIND_DEFAULT, sizeof(struct distmem_memory_information_generic));
  generic_info->ptr = ptr;
  generic_info->specific_information = specific_info;
  generic_info->deallocate_specific_information = deallocate_specific_information;
  generic_info->next = dist_kind->internal_state[hashkey];
  dist_kind->internal_state[hashkey] = generic_info;
}
예제 #3
0
// thread entrypoint
void dtls_dispatch::operator ()()
{
	// nameserv thread wants to know about this node's hashkey/addr
	nameserv_thread->set_local_addr(get_hashkey(), vn->get_tun_ipaddr());
	update_dht_local_ipaddrs();
	
	while(run_state != SHUTDOWN || pinit->peer_count() > 0 || vn->peer_count() > 0)
	{
		int next_timer = timers.exec();
		if(cleanup_peers())
			continue; // in case cleanup causes loop condition to be satisfied, or sets a timer
		dout() << "Iterating dispatch event loop, next timer " << next_timer << " ms, sockets " << sockets.size() << " handshake " << pinit->peer_count() << " vnet " << vn->peer_count();
		sockets.event_exec_wait(next_timer);
	}
	dout() << "dtls dispatch thread exiting";
}
예제 #4
0
파일: distmem.c 프로젝트: mesham/distmem
static void remove_info_entry_from_state(struct distmem *dist_kind, void *ptr) {
  int hash_key = get_hashkey(ptr);
  struct distmem_memory_information_generic *specific_state = dist_kind->internal_state[hash_key], *last_entry = NULL;
  while (specific_state != NULL) {
    if (specific_state->ptr == ptr) {
      if (last_entry == NULL) {
        dist_kind->internal_state[hash_key] = specific_state->next;
      } else {
        last_entry->next = specific_state->next;
      }
      if (specific_state->deallocate_specific_information != NULL) {
        specific_state->deallocate_specific_information(specific_state->specific_information);
      } else {
        if (specific_state->specific_information != NULL) {
          memkind_free(MEMKIND_DEFAULT, specific_state->specific_information);
        }
      }
      memkind_free(MEMKIND_DEFAULT, specific_state);
      break;
    }
    last_entry = specific_state;
    specific_state = specific_state->next;
  }
}