Exemplo n.º 1
0
static int udp_bind_finalize(uv_handle_t *handle)
{
	check_bufsize((uv_handle_t *)handle);
	/* Handle is already created, just create context. */
	handle->data = session_new();
	assert(handle->data);
	return io_start_read((uv_handle_t *)handle);
}
Exemplo n.º 2
0
int udp_bind(uv_udp_t *handle, struct sockaddr *addr)
{
	unsigned flags = UV_UDP_REUSEADDR;
	if (addr->sa_family == AF_INET6) {
		flags |= UV_UDP_IPV6ONLY;
	}
	int ret = uv_udp_bind(handle, addr, flags);
	if (ret != 0) {
		return ret;
	}
	handle->data = NULL;
	check_bufsize((uv_handle_t *)handle);
	return io_start_read((uv_handle_t *)handle);
}
Exemplo n.º 3
0
/*
 * verify that the stager config is valid.
 */
int
verify_stager_cfg(const stager_cfg_t *cfg)	/* cfg to verify */
{

	node_t *node;

	Trace(TR_OPRMSG, "verify stager cfg entry");
	if (ISNULL(cfg)) {
		Trace(TR_OPRMSG, "verify stager cfg failed: %s", samerrmsg);
		return (-1);
	}

	/* check basics */
	if (cfg->max_retries != int_reset &&
	    cfg->change_flag & ST_max_retries &&
	    check_maxretries(cfg) != 0) {

		Trace(TR_OPRMSG, "verify stager cfg failed: %s", samerrmsg);
		return (-1);
	}

	if (cfg->max_active != int_reset &&
	    cfg->change_flag & ST_max_active &&
	    check_maxactive(cfg) != 0) {

		Trace(TR_OPRMSG, "verify stager cfg failed: %s", samerrmsg);
		return (-1);
	}
	if (*cfg->stage_log != char_array_reset &&
	    cfg->change_flag & ST_stage_log &&
	    check_logfile(cfg->stage_log) != 0) {

		Trace(TR_OPRMSG, "verify stager cfg failed: %s", samerrmsg);
		return (-1);
	}

	/* check drives */
	if (cfg->stage_drive_list != NULL) {
		sqm_lst_t *libs;

		if (get_all_libraries(NULL, &libs) == -1) {
			Trace(TR_OPRMSG, "verify stager cfg failed: %s",
			    samerrmsg);
			return (-1);
		}

		for (node = cfg->stage_drive_list->head;
		    node != NULL; node = node->next) {
			if (check_stage_drives((drive_directive_t *)node->data,
			    libs) != 0) {

				free_list_of_libraries(libs);
				Trace(TR_OPRMSG,
				    "verify stager cfg failed: %s",
				    samerrmsg);
				return (-1);
			}
		}
		free_list_of_libraries(libs);
	}

	/* check buffers */
	if (cfg->stage_buf_list != NULL) {
		for (node = cfg->stage_buf_list->head;
		    node != NULL; node = node->next) {
			if (check_bufsize(
			    (buffer_directive_t *)node->data) != 0) {
				Trace(TR_OPRMSG,
				    "verify stager cfg failed: %s",
				    samerrmsg);
				return (-1);
			}
		}
	}

	/* check the dk stager stream */
	if (check_stager_stream(cfg->dk_stream) != 0) {
		Trace(TR_OPRMSG, "verify stager cfg failed: %s", samerrmsg);
		return (-1);
	}

	Trace(TR_OPRMSG, "stager cfg is valid");
	return (0);
}