Welcome! Log In Create A New Profile

Advanced

proxying from pipes

Jeff Kaufman
October 23, 2012 11:16AM
My module wants to sit in the filter chain passing buffers to an
asynchronous optimization thread and then send them out to the user
when they finish. When a request comes in I have my module roughly
doing:

body filter:
- if first set of buffers
- create pipe, pass pipe_write_fd to optimization thread
- pass all input data to optimization thread
- don't call ngx_http_next_body_filter

Is there a way I can ask nginx to watch this pipe and treat any data
appearing on the pipe as if it is output from my body filter? Passing
it through ngx_http_next_body_filter, etc? And finalizing the request
if there's a problem with the pipe?

What I'm doing now is:
- when creating the pipe
c = ngx_get_connection(pipe_read_fd, r->connection->log);
c.read->handler = my_read_handler;
ngx_add_event(c->read, NGX_READ_EVENT, 0);
- when my_read_handler is called
read() from pipe_read_fd
create buffer, chain link
call ngx_http_next_body_filter

Is this the right way to go about this? It seems very low level and I
would expect proxying from a pipe would be something nginx already
supported.

Another option would be to simply use the pipe for notification and
load the data from the optimization thread through shared memory.

Jeff

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

proxying from pipes

Jeff Kaufman 1131 October 23, 2012 11:16AM

Re: proxying from pipes

Maxim Dounin 545 October 24, 2012 01:18PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

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