Welcome! Log In Create A New Profile

Advanced

Re: communication between worker processes

Maxim Dounin
October 19, 2009 06:50PM
Hello!

On Mon, Oct 19, 2009 at 05:18:12PM -0400, Leo P. wrote:

> Maxim Dounin wrote:
> >Hello!
> >
> >On Mon, Oct 19, 2009 at 12:23:00AM -0400, Leo P. wrote:
> >
> >>How might I be able to send a message or (custom) event to some
> >>given worker process? I am storing pointers to requests (and the
> >>workers that processed them) in shared memory for a module (
> >>http://github.com/slact/nginx_http_push_module ), and need to alert
> >>said workers to respond to said requests, from the context of a
> >>location request handler in a module. (maybe using ngx_channel
> >>stuff?)
> >>I'd really appreciate any suggestions.
> >
> >There is no infrastructure for interprocess notifications in nginx
> >right now. Basically it's the reason why there is no such things
> >as busy locks and so on.
> >
> >You may try to emulate it via e.g. message queue in shared memory
> >and periodic timer in each worker process to check it. It's not
> >perfect, but probably will work for you.
> >
> >Maxim Dounin
> >
> >
> What about using ngx_add_channel_event on process initialization?
> Is there anything obviously wrong with doing something like the following:
>
> /*in init process callback*/
> ngx_socket_t my_channel=ngx_channel;
> /* is that the correct socket? what about
> ngx_processes[ngx_process_slot].channel[0] and
> ngx_processes[ngx_process_slot].channel[1] ?
> which could be used?
> */

[...]

Socket pairs in question are used for nginx's own needs (control
commands from master to workers). Any attempt to reuse them will
case nginx malfunction at next control command.

Eventually this will grow into something more generic and modules
will be able to use this for their own commands. But it's not here
yet.

Maxim Dounin

p.s. BTW, just to make sure you know: nginx_http_push_module
relies on shared memory as something unconditionally available for
all processes, but this isn't really true during binary upgrades.
New binary creates their own shared memory zones from scratch. As
a result - module won't survive binary upgrades flawlessly but
will loose messages instead.
Subject Author Posted

communication between worker processes

slact October 19, 2009 12:28AM

Re: communication between worker processes

Maxim Dounin October 19, 2009 01:34AM

Re: communication between worker processes

slact October 19, 2009 05:22PM

Re: communication between worker processes

Maxim Dounin October 19, 2009 06:50PM

Re: communication between worker processes

slact October 22, 2009 05:32PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

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