Nginx mutli-threaded plugin

Fasih faskiri.devel at
Tue Jan 1 18:27:30 UTC 2013

Hi guys

I need to write a plugin which does some CPU intensive work. I want to be
able to create a thread which does some work and once done post an event
into nginx thread via ngx_add_timer. I tried compiling my plugin with
NGX_THREADS=pthread but that doesnt configure saying that the threading
support is broken.  I can obviously switch to a single threaded mode but
that would be significantly difficult for me and would prefer to use only
as the very last resort.

Can you please advice how to go about doing this? I am considering pulling
out the usage of 'ngx_event_timer_mutex' outside #if NGX_THREADS. Frankly I
am surprised how no other plugin had this kind of requirement, the "broken
support" commit has been there since quite some time now.

One final question, if I do the CPU intensive work in the nginx thread and
I have <cpu-cores> number of workers, how would the system behave? Will
accept_mutex on/off change the behavior?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the nginx-devel mailing list