Welcome! Log In Create A New Profile

Advanced

launching a user thread from a module

April 13, 2021 10:13AM
Hello,

I'd like to spawn a single custom thread as a part of my nginx module. The idea is that it can be used to perform some periodic tasks, asynchronously and independently from HTTP requests. (In other words, I use nginx/module as a framework.) And here I faced with a problem: when I launch my thread in different module hooks, it got killed as soon as parent process exits. So naturally I should be doing this from the master process context, i.e. in init_master hook - which is not implemented, according to the documentation. Is there another place which I can use to launch a user thread?

Thanks
Andrew

P.S. I also tried to offload my thread function as a task to a nginx-managed thread_pool, but this also did not work, as it seems in the stages where I try to use thread_pool (init_module, postconfig), it is not yet fully initialized and a call to ngx_thread_task_post crashes when accessing some queue structure which is zero at that moment.
Subject Author Posted

launching a user thread from a module

xdrew April 13, 2021 10:13AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 278
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