Welcome! Log In Create A New Profile

Advanced

Re: Nginx thread pool is not working in 1.14 in custom module

May 23, 2018 09:08AM
Thanks for the response.
The main issue is that now request is closed before actual task is done in thread pool.
How can I avoid that?
It worked fine before the upgrade.
What is correct thread pool usage in custom module in 1.14?

Here is my request handler for reference:
static ngx_int_t ngx_http_thread_handler(ngx_http_request_t* r)
{
//...

// Add handler (blocking handler)
task->handler = ngx_http_cgpi_task_handler;
// Init event
task->event.data = taskCtx;
task->event.handler = ngx_http_cgpi_task_done_cb;

// Try to get the pool to put task
ngx_thread_pool_t* tp = clcf->thread_pool;

if (tp == NULL)
{
// Create pool if not exists
if (ngx_http_complex_value(r, clcf->thread_pool_value, &name) != NGX_OK)
{
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "ngx_http_complex_value \"%V\" failed", &name);
return NGX_ERROR;
}
tp = ngx_thread_pool_get((ngx_cycle_t* ) ngx_cycle, &name);
if (tp == NULL)
{
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "thread pool \"%V\" not found", &name);
return NGX_ERROR;
}
}

// Put the task into thread pool
if (ngx_thread_task_post(tp, task) != NGX_OK)
{
return NGX_ERROR;
}
// Make the request blocked
r->main->blocked++;
r->aio = 1;

return NGX_AGAIN;
}
Subject Author Posted

Nginx thread pool is not working in 1.14 in custom module

isolomka May 23, 2018 05:33AM

Re: Nginx thread pool is not working in 1.14 in custom module

Maxim Dounin May 23, 2018 08:34AM

Re: Nginx thread pool is not working in 1.14 in custom module

isolomka May 23, 2018 09:08AM

Re: Nginx thread pool is not working in 1.14 in custom module

Maxim Dounin May 23, 2018 10:30AM

Re: Nginx thread pool is not working in 1.14 in custom module

isolomka May 23, 2018 10:48AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 301
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready