<div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><span class="Apple-style-span" style="font-family: Arial; background-color: rgb(255, 255, 255); font-size: medium; ">On Thu, Aug 04, 2011 at 01:32:14PM +0300, Peter Smit wrote:<br style="clear: both; ">
> (This is my first message to this list, please let me know if I'm<br style="clear: both; ">> doing something wrong!)<br style="clear: both; ">><br style="clear: both; ">> In developing a comet style application in a uwsgi/nginx setup I<br style="clear: both; ">
> noticed that nginx always buffers the response when uwsgi_pass is<br style="clear: both; ">> used.<br style="clear: both; ">><br style="clear: both; ">> I'm not sure or there is any particular reason why this is done,<br style="clear: both; ">
> except for the fact that the uwsgi code is originally based on the<br style="clear: both; ">> fastcgi module where indeed buffering is unavoidable. I think however<br style="clear: both; ">> that it makes sense to give the option of disabling buffering with<br style="clear: both; ">
> uwsgi.<br style="clear: both; ">><br style="clear: both; ">> I actually already went ahead and wrote a patch that does exactly<br style="clear: both; ">> this. It introduces a uwsgi_buffering flag and now adheres to the<br style="clear: both; ">
> "X-Accel-Buffering" header. I have only limited capabilities to test<br style="clear: both; ">> this patch, but for me it does exactly that, disabling the buffer.<br style="clear: both; ">><br style="clear: both; ">
> Could some of you review this patch and if it is ok, could it be<br style="clear: both; ">> introduced in nginx?<br style="clear: both; ">><br style="clear: both; ">> I made the patch on the 1.1.0 source. I attached it and included it<br style="clear: both; ">
> inline below this message. Let me know if I should give it in a<br style="clear: both; ">> different format.<br style="clear: both; "><br style="clear: both; ">Thank you for idea, it seems unbuffered proxying should work for uwsgi<br style="clear: both; ">
as well as for scgi, since they both use simple protocol, that is, no<br style="clear: both; ">protocol at all :) for body.<br style="clear: both; "><br style="clear: both; "><br style="clear: both; "></span></blockquote>
<div><br></div><div>How does the process go further? I noticed that the patch is not included yet. Are you waiting for someone to step up to make a patch also for scgi, or are there other reasons for not applying the patch yet? </div>
<div><br></div><div>Regards,</div><div><br></div><div>Peter Smit</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><span class="Apple-style-span" style="font-family: Arial; background-color: rgb(255, 255, 255); font-size: medium; ">--<br style="clear: both; ">
Igor Sysoev<br style="clear: both; "><br style="clear: both; ">_______________________________________________<br style="clear: both; ">nginx-devel mailing list<br style="clear: both; "><a href="mailto:nginx-devel@nginx.org">nginx-devel@nginx.org</a><br style="clear: both; ">
</span><span class="Apple-style-span" style="font-family: Arial; background-color: rgb(255, 255, 255); font-size: medium; "><a href="http://mailman.nginx.org/mailman/listinfo/nginx-devel">http://mailman.nginx.org/mailman/listinfo/nginx-devel</a></span></blockquote>
<div><font class="Apple-style-span" face="Arial" size="3"><br></font>
<br>
--- nginx-1.1.0/src/http/modules/ngx_http_uwsgi_module.c        <a href="tel:2011-07-29" value="+35820110729">2011-07-29</a><br>
18:33:03.000000000 +0300<br>
+++ nginx-1.1.0-uwsgi_buffering/src/http/modules/ngx_http_uwsgi_module.c        <a href="tel:2011-08-04" value="+35820110804">2011-08-04</a><br>
13:16:<a href="tel:54.381528459" value="+35854381528459">54.381528459</a> +0300<br>
@@ -123,6 +123,13 @@<br>
       offsetof(ngx_http_uwsgi_loc_conf_t, upstream.store_access),<br>
       NULL },<br>
<br>
+    { ngx_string("uwsgi_buffering"),<br>
+      NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE123,<br>
+      ngx_conf_set_flag_slot,<br>
+      NGX_HTTP_LOC_CONF_OFFSET,<br>
+      offsetof(ngx_http_uwsgi_loc_conf_t, upstream.buffering),<br>
+      NULL },<br>
+<br>
     { ngx_string("uwsgi_ignore_client_abort"),<br>
       NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,<br>
       ngx_conf_set_flag_slot,<br>
@@ -445,7 +452,7 @@<br>
     u->abort_request = ngx_http_uwsgi_abort_request;<br>
     u->finalize_request = ngx_http_uwsgi_finalize_request;<br>
<br>
-    u->buffering = 1;<br>
+    u->buffering = uwcf->upstream.buffering;<br>
<br>
     u->pipe = ngx_pcalloc(r->pool, sizeof(ngx_event_pipe_t));<br>
     if (u->pipe == NULL) {<br>
@@ -1083,6 +1090,8 @@<br>
     /* "uwsgi_cyclic_temp_file" is disabled */<br>
     conf->upstream.cyclic_temp_file = 0;<br>
<br>
+    conf->upstream.change_buffering = 1;<br>
+<br>
     ngx_str_set(&conf->upstream.module, "uwsgi");<br>
<br>
     return conf;<br>
</div></div><br>