Welcome! Log In Create A New Profile

Advanced

Nginx thread pool question

Posted by NginxNewbee 
Nginx thread pool question
April 29, 2019 01:36PM
Hello everyone ! Nginx newbie here. I am actually writing a module that will handle the my http request. For this, I added a location content handler (or location directive handler) in my module. My content handler interfaces with a library which is not asynchronous. So within handler, I queue up a task to nginx thread pool. I also added a thread completion handler. The problem I am running into is that Nginx doesn't wait for my thread to finish. With in my location content handler, I queue up task and return NGX_DONE and Nginx finalizes my request while thread is running. I also tried hooking up this handler code in HTTP_CONTENT_PHASE handler instead of location content handler, but no luck so far yet.

So long story short - How can I make Nginx wait for my thread to finish before finalizing the request in HTTP_CONTENT_PHASE ? Second question - Why is it so hard to do it in Nginx :-) ?

Thanks
Newbie
Re: Nginx thread pool question
May 18, 2019 07:04PM
I think i was finally able to figure this out and wrote my solution here. Hope this helps.

https://stackoverflow.com/questions/55908530/how-to-make-nginx-wait-for-a-thread-pool-task-in-http-content-phase
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 87
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready