Exemplo n.º 1
0
static char *
ngx_http_vod_thread_pool_command(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
	ngx_thread_pool_t **tp = (ngx_thread_pool_t **)((u_char*)conf + cmd->offset);
	ngx_str_t  *value;

	if (*tp != NGX_CONF_UNSET_PTR) {
		return "is duplicate";
	}

	value = cf->args->elts;

	if (cf->args->nelts > 1)
	{
		*tp = ngx_thread_pool_add(cf, &value[1]);
	}
	else
	{
		*tp = ngx_thread_pool_add(cf, NULL);
	}

	if (*tp == NULL)
	{
		return NGX_CONF_ERROR;
	}

	return NGX_CONF_OK;
}
Exemplo n.º 2
0
static char *
ngx_thread_pool(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
    ngx_str_t          *value;
    ngx_uint_t          i;
    ngx_thread_pool_t  *tp;
    value = cf->args->elts;
    tp = ngx_thread_pool_add(cf, &value[1]);
    if (tp == NULL)
    {
        return NGX_CONF_ERROR;
    }
    if (tp->threads)
    {
        ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
                           "duplicate thread pool \"%V\"", &tp->name);
        return NGX_CONF_ERROR;
    }
    tp->max_queue = 65536;
    for (i = 2; i < cf->args->nelts; i++)
    {
        if (ngx_strncmp(value[i].data, "threads=", 8) == 0)
        {
            tp->threads = ngx_atoi(value[i].data + 8, value[i].len - 8);
            if (tp->threads == (ngx_uint_t) NGX_ERROR || tp->threads == 0)
            {
                ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
                                   "invalid threads value \"%V\"", &value[i]);
                return NGX_CONF_ERROR;
            }
            continue;
        }
        if (ngx_strncmp(value[i].data, "max_queue=", 10) == 0)
        {
            tp->max_queue = ngx_atoi(value[i].data + 10, value[i].len - 10);
            if (tp->max_queue == NGX_ERROR)
            {
                ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
                                   "invalid max_queue value \"%V\"", &value[i]);
                return NGX_CONF_ERROR;
            }
            continue;
        }
    }
    if (tp->threads == 0)
    {
        ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
                           "\"%V\" must have \"threads\" parameter",
                           &cmd->name);
        return NGX_CONF_ERROR;
    }
    return NGX_CONF_OK;
}