Welcome! Log In Create A New Profile

Advanced

[nginx] Stream: prevent repeated event notifications after eof.

Roman Arutyunyan
April 22, 2015 12:58PM
details: http://hg.nginx.org/nginx/rev/f1f222db290b
branches:
changeset: 6124:f1f222db290b
user: Roman Arutyunyan <arut@nginx.com>
date: Wed Apr 22 19:55:04 2015 +0300
description:
Stream: prevent repeated event notifications after eof.

When client or upstream connection is closed, level-triggered read event
remained active until the end of the session leading to cpu hog. Now the flag
NGX_CLOSE_EVENT is used to unschedule the event.

diffstat:

src/stream/ngx_stream_proxy_module.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)

diffs (22 lines):

diff -r caa103acf180 -r f1f222db290b src/stream/ngx_stream_proxy_module.c
--- a/src/stream/ngx_stream_proxy_module.c Wed Apr 22 18:37:34 2015 +0300
+++ b/src/stream/ngx_stream_proxy_module.c Wed Apr 22 19:55:04 2015 +0300
@@ -814,6 +814,7 @@ ngx_stream_proxy_process(ngx_stream_sess
size_t size;
ssize_t n;
ngx_buf_t *b;
+ ngx_uint_t flags;
ngx_connection_t *c, *pc, *src, *dst;
ngx_log_handler_pt handler;
ngx_stream_upstream_t *u;
@@ -911,7 +912,9 @@ ngx_stream_proxy_process(ngx_stream_sess
return NGX_DONE;
}

- if (ngx_handle_read_event(src->read, 0) != NGX_OK) {
+ flags = src->read->eof ? NGX_CLOSE_EVENT : 0;
+
+ if (ngx_handle_read_event(src->read, flags) != NGX_OK) {
ngx_stream_proxy_finalize(s, NGX_ERROR);
return NGX_ERROR;
}

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

[nginx] Stream: prevent repeated event notifications after eof.

Roman Arutyunyan 562 April 22, 2015 12:58PM



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

Online Users

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