Exemplo n.º 1
0
void dnet_server_node_destroy(struct dnet_node *n)
{
	dnet_log(n, DNET_LOG_DSA, "Destroying server node at %s, st: %p.\n",
			dnet_dump_node(n), n->st);

	n->need_exit = 1;

	dnet_srw_cleanup(n);

	dnet_locks_destroy(n);

	dnet_notify_exit(n);

	dnet_node_destroy(n);
}
Exemplo n.º 2
0
void dnet_server_node_destroy(struct dnet_node *n)
{
	dnet_log(n, DNET_LOG_DEBUG, "Destroying server node at %s, st: %p.\n",
			dnet_dump_node(n), n->st);

	dnet_srw_cleanup(n);

	dnet_node_cleanup_common_resources(n);

	if (n->cb && n->cb->backend_cleanup)
		n->cb->backend_cleanup(n->cb->command_private);

	dnet_locks_destroy(n);
	dnet_notify_exit(n);

	free(n);
}
Exemplo n.º 3
0
struct dnet_node *dnet_server_node_create(struct dnet_config *cfg)
{
	struct dnet_node *n;
	struct dnet_raw_id *ids = NULL;
	int id_num = 0;
	int err = -ENOMEM;

	n = dnet_node_create(cfg);
	if (!n) {
		goto err_out_exit;
	}

	if (!n->notify_hash_size) {
		n->notify_hash_size = DNET_DEFAULT_NOTIFY_HASH_SIZE;

	err = dnet_notify_init(n);
	if (err)
		goto err_out_node_destroy;

		dnet_log(n, DNET_LOG_NOTICE, "No notify hash size provided, using default %d.\n",
				n->notify_hash_size);
	}

	err = dnet_cache_init(n);
	if (err)
		goto err_out_notify_exit;

	if (cfg->flags & DNET_CFG_JOIN_NETWORK) {
		int s;

		err = dnet_locks_init(n, cfg->oplock_num);
		if (err)
			goto err_out_cache_cleanup;

		ids = dnet_ids_init(n, cfg->history_env, &id_num, cfg->storage_free);
		if (!ids)
			goto err_out_locks_destroy;

		n->addr.addr_len = sizeof(n->addr.addr);
		err = dnet_socket_create(n, cfg, &n->addr, 1);
		if (err < 0)
			goto err_out_ids_cleanup;

		s = err;
		dnet_setup_id(&n->id, cfg->group_id, ids[0].id);

		n->st = dnet_state_create(n, cfg->group_id, ids, id_num, &n->addr, s, &err, DNET_JOIN, dnet_state_accept_process);
		if (!n->st) {
			close(s);
			goto err_out_state_destroy;
		}

		free(ids);
		ids = NULL;

		err = dnet_srw_init(n, cfg);
		if (err) {
			dnet_log(n, DNET_LOG_ERROR, "srw: initialization failure: %s %d\n", strerror(-err), err);
		}
	}

	dnet_log(n, DNET_LOG_DSA, "New server node has been created at %s, ids: %d.\n",
			dnet_dump_node(n), id_num);

	return n;

err_out_state_destroy:
	dnet_srw_cleanup(n);
	dnet_state_put(n->st);
err_out_ids_cleanup:
	free(ids);
err_out_locks_destroy:
	dnet_locks_destroy(n);
err_out_cache_cleanup:
	dnet_cache_cleanup(n);
err_out_notify_exit:
	dnet_notify_exit(n);
err_out_node_destroy:
	dnet_node_destroy(n);
err_out_exit:
	return NULL;
}