Asynchronous Handler & Callbacks

Daniel Eggert danieleggert at
Tue Nov 21 20:51:35 UTC 2017

I'm writing my own Module and Handler for nginx, but I can't figure out how to do asynchronous work.

From my handler, I'm calling an existing library, that'll run a callback on a thread of its own when it is done.

I can't figure out how to switch back to the nginx event loop thread.

It seems like it's ok for me to run

  return NGX_AGAIN;

inside my callback handler the first time it's called, but once the "external" callback runs, it'd need to tell nginx to run my handler again. I'm assuming that I'd do that my posting an event to the request's event loop and then call


on the request. But I'm a bit lost as to whether that's the right approach.

Thanks in advance.


More information about the nginx-devel mailing list