Welcome! Log In Create A New Profile

Advanced

Re: [PATCH] Option to disable buffering in uwsgi module

Maxim Dounin
September 30, 2011 06:18AM
Hello!

On Fri, Sep 30, 2011 at 01:00:12PM +0300, Peter Smit wrote:

> Attached and inlined is a patch which makes it possible to disable
> buffering for the fastcgi,scgi and uwsgi modules in the following
> ways:
>
> - By using a {module}_buffering on|off configuration value
> - By using the X-Accel-Buffering header
>
> This is essential for any apps that want to do comet / websocket style
> communications.
>
>
>
> Index: ngx_http_fastcgi_module.c
> ===================================================================
> --- ngx_http_fastcgi_module.c (revision 4157)
> +++ ngx_http_fastcgi_module.c (working copy)
> @@ -228,6 +228,13 @@
> offsetof(ngx_http_fastcgi_loc_conf_t, upstream.store_access),
> NULL },
>
> + { ngx_string("fastcgi_buffering"),
> + NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
> + ngx_conf_set_flag_slot,
> + NGX_HTTP_LOC_CONF_OFFSET,
> + offsetof(ngx_http_fastcgi_loc_conf_t, upstream.buffering),
> + NULL },
> +
> { ngx_string("fastcgi_ignore_client_abort"),
> NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
> ngx_conf_set_flag_slot,
> @@ -602,7 +609,7 @@
> u->abort_request = ngx_http_fastcgi_abort_request;
> u->finalize_request = ngx_http_fastcgi_finalize_request;
>
> - u->buffering = 1;
> + u->buffering = flcf->upstream.buffering;
>
> u->pipe = ngx_pcalloc(r->pool, sizeof(ngx_event_pipe_t));
> if (u->pipe == NULL) {
> @@ -2072,6 +2079,8 @@
> conf->catch_stderr = NGX_CONF_UNSET_PTR;
>
> conf->keep_conn = NGX_CONF_UNSET;
> +
> + conf->upstream.change_buffering = 1;
>
> ngx_str_set(&conf->upstream.module, "fastcgi");
>

The fastcgi part is just wrong.

You can't enable non-buffered mode for fastcgi without providing
appropriate input filter, this will result in fastcgi response
(i.e. with all fastcgi framing and so on) to be sent to client
(or, rather, part of it).

> Index: ngx_http_scgi_module.c
> ===================================================================
> --- ngx_http_scgi_module.c (revision 4157)
> +++ ngx_http_scgi_module.c (working copy)
> @@ -96,6 +96,13 @@
> offsetof(ngx_http_scgi_loc_conf_t, upstream.store_access),
> NULL },
>
> + { ngx_string("scgi_buffering"),
> + NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
> + ngx_conf_set_flag_slot,
> + NGX_HTTP_LOC_CONF_OFFSET,
> + offsetof(ngx_http_scgi_loc_conf_t, upstream.buffering),
> + NULL },
> +
> { ngx_string("scgi_ignore_client_abort"),
> NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
> ngx_conf_set_flag_slot,
> @@ -412,7 +419,7 @@
> u->abort_request = ngx_http_scgi_abort_request;
> u->finalize_request = ngx_http_scgi_finalize_request;
>
> - u->buffering = 1;
> + u->buffering = scf->upstream.buffering;
>
> u->pipe = ngx_pcalloc(r->pool, sizeof(ngx_event_pipe_t));
> if (u->pipe == NULL) {
> @@ -1038,6 +1045,8 @@
> /* "scgi_cyclic_temp_file" is disabled */
> conf->upstream.cyclic_temp_file = 0;
>
> + conf->upstream.change_buffering = 1;
> +
> ngx_str_set(&conf->upstream.module, "scgi");
>
> return conf;
> Index: ngx_http_uwsgi_module.c
> ===================================================================
> --- ngx_http_uwsgi_module.c (revision 4157)
> +++ ngx_http_uwsgi_module.c (working copy)
> @@ -123,6 +123,13 @@
> offsetof(ngx_http_uwsgi_loc_conf_t, upstream.store_access),
> NULL },
>
> + { ngx_string("uwsgi_buffering"),
> + NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
> + ngx_conf_set_flag_slot,
> + NGX_HTTP_LOC_CONF_OFFSET,
> + offsetof(ngx_http_uwsgi_loc_conf_t, upstream.buffering),
> + NULL },
> +
> { ngx_string("uwsgi_ignore_client_abort"),
> NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
> ngx_conf_set_flag_slot,
> @@ -445,7 +452,7 @@
> u->abort_request = ngx_http_uwsgi_abort_request;
> u->finalize_request = ngx_http_uwsgi_finalize_request;
>
> - u->buffering = 1;
> + u->buffering = uwcf->upstream.buffering;
>
> u->pipe = ngx_pcalloc(r->pool, sizeof(ngx_event_pipe_t));
> if (u->pipe == NULL) {
> @@ -1091,6 +1098,8 @@
> /* "uwsgi_cyclic_temp_file" is disabled */
> conf->upstream.cyclic_temp_file = 0;
>
> + conf->upstream.change_buffering = 1;
> +
> ngx_str_set(&conf->upstream.module, "uwsgi");
>
> return conf;

The scgi/uwsgi part looks ok. I'll commit as soon as Igor approves.

Maxim Dounin

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

Option to disable buffering in uwsgi module Attachments

Peter Smit 3960 August 04, 2011 06:40AM

Re: Option to disable buffering in uwsgi module

Igor Sysoev 1481 August 04, 2011 06:46AM

Re: Option to disable buffering in uwsgi module Attachments

Peter Smit 1004 September 23, 2011 02:26AM

Re: Option to disable buffering in uwsgi module

Maxim Dounin 1020 September 23, 2011 06:32AM

Re: Option to disable buffering in uwsgi module

Peter Smit 1111 September 23, 2011 06:52AM

Re: Option to disable buffering in uwsgi module

Maxim Dounin 1031 September 23, 2011 07:08AM

Re: Option to disable buffering in uwsgi module

Peter Smit 951 September 30, 2011 04:08AM

[PATCH] Option to disable buffering in uwsgi module

Peter Smit 1137 September 30, 2011 06:02AM

Re: [PATCH] Option to disable buffering in uwsgi module

Maxim Dounin 977 September 30, 2011 06:18AM

Re: [PATCH] Option to disable buffering in uwsgi module

Peter Smit 1129 September 30, 2011 06:22AM

Re: [PATCH] Option to disable buffering in uwsgi module

Maxim Dounin 1208 September 30, 2011 08:04AM

Re: Option to disable buffering in uwsgi module

Maxim Dounin 1151 September 30, 2011 06:06AM



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

Online Users

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