Providing access to nginx state machine

agentzh agentzh at gmail.com
Fri May 7 05:46:08 MSD 2010


On Thu, May 6, 2010 at 10:53 PM, Marko Kevac <marko at kevac.org> wrote:
> Hello.
>
> As far as I can see nginx provides access to it's state machine only
> via 'upstream modules'. Am I right?
>

Surely not :)

> I want to speak to another network service from nginx handler without
> blocking it.
>
> Lighttpd web server, for example, provides simple way to do this. You
> can connect(), send() something, for example, give lighttpd descriptor
> and return something like WAITING_FOR_FD. When descriptor becomes
> ready, lighttpd will return to same module and module will be
> available to receive().
>
> Is there similar API in nginx?
>

There's no such simple elegant API in the nginx core. See the
implementation of ngx_http_upstream.c for details :)

Our ngx_drizzle and ngx_postgres are also examples to let third party
libraries (like libdrizzle and libpq) manage the sockets for us in a
content handler. My ngx_echo module is also an example falling into
the same category (more or less).

BTW, upstream modules are just special cases of content handler modules ;)

Cheers,
-agentzh



More information about the nginx-devel mailing list