hi,
i understand that NGX_AGAIN is returned when a chain could not be send
because more data cannot be buffered on that socket.
I need to understand the following: in my case, when i receive a request, i
start a timer every 10ms and send out some data, then i create a new timer
every10ms until i decide to finish sending out data (video frames).
But if in some triggered callback by the timer the
ngx_http_output_filter(..) returns NGX_AGAIN *i assume* NginX will send
that chain as soon as the socket becomes available again. But after that
happens, how can i restore my timer cycle ?
thnks.
J.Z.
Hello!
Akos Gyimesi reported a request hang (downstream connections stuck in
the CLOSE_WAIT state forever) regarding use of proxy_cache_lock in
subrequests.
The issue is that when proxy_cache_lock_timeout is reached,
ngx_http_file_cache_lock_wait_handler calls
r->connection->write->handler() directly, but
r->connection->write->handler is (usually) just
ngx_http_request_handler, which simply picks up r->connection->data,
which is *not* necessarily the current (sub)request, so the current
subrequest may never be continued nor finalized, leading to an
infinite request hang.
The following patch fixes this issue for me. Comments welcome!
Thanks!
-agentzh
--- nginx-1.4.3/src/http/ngx_http_file_cache.c 2013-10-08
05:07:14.000000000 -0700
+++ nginx-1.4.3-patched/src/http/ngx_http_file_cache.c 2013-10-26
14:47:56.184041728 -0700
@@ -432,6 +432,7 @@ ngx_http_file_cache_lock_wait_handler(ng
ngx_uint_t wait;
ngx_msec_t timer;
ngx_http_cache_t *c;
+ ngx_connection_t *conn;
ngx_http_request_t *r;
ngx_http_file_cache_t *cache;
@@ -471,7 +472,10 @@ wakeup:
c->waiting = 0;
r->main->blocked--;
- r->connection->write->handler(r->connection->write);
+
+ conn = r->connection;
+ r->write_event_handler(r);
+ ngx_http_run_posted_requests(conn);
}
Sorry if this is not the place to ask this or if this has been asked before (google hasn't been helpful), but I'm unsure of how to proceed with this problem.
I am developing a body filter module that processes html and has to do a process in the middle of sending a response that can take upwards of a couple seconds. So for example, the first half of the HTML gets sent immediately, a process happens and eventually finishes, then second half gets sent (the contents of the second half being dependent on the results of the process). How to I get a body filter to "wait" for a bit and then continue sometime later? The signal/flag/whatever to continue could come from a timer event or elsewhere. I'm looking for a non-blocking solution obviously.
I'm using nginx as a proxy if that makes any difference so the HTML doesn't originate on this server. And yes, it's a bit of a weird use case.
Thanks,
Tod.
details: http://hg.nginx.org/nginx/rev/c76d851c5e7a
branches:
changeset: 5925:c76d851c5e7a
user: Maxim Dounin <mdounin(a)mdounin.ru>
date: Fri Nov 28 16:57:50 2014 +0300
description:
Fixed post_action to not trigger "header already sent" alert.
The alert was introduced in 03ff14058272 (1.5.4), and was triggered on each
post_action invocation.
There is no real need to call header filters in case of post_action,
so return NGX_OK from ngx_http_send_header() if r->post_action is set.
diffstat:
src/http/ngx_http_core_module.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diffs (14 lines):
diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c
--- a/src/http/ngx_http_core_module.c
+++ b/src/http/ngx_http_core_module.c
@@ -1973,6 +1973,10 @@ ngx_http_send_response(ngx_http_request_
ngx_int_t
ngx_http_send_header(ngx_http_request_t *r)
{
+ if (r->post_action) {
+ return NGX_OK;
+ }
+
if (r->header_sent) {
ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0,
"header already sent");