[PATCH] ngx_event_pipe: remove unnecessary timer
quink
wantlamy at gmail.com
Sat Oct 17 15:43:29 UTC 2015
A timer of 1 msec is not necessary take into account the resolutions of
ngx_time() and p->start.
If we don't consider the truncation error of ngx_time() and p->start, '1'
should be '1000'. If we
consider the truncation error, don't add timer if limit == 0 and discard '+
1'.
---
src/event/ngx_event_pipe.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/event/ngx_event_pipe.c b/src/event/ngx_event_pipe.c
index 2d0e7d3..580a947 100644
--- a/src/event/ngx_event_pipe.c
+++ b/src/event/ngx_event_pipe.c
@@ -181,9 +181,9 @@ ngx_event_pipe_read_upstream(ngx_event_pipe_t *p)
limit = (off_t) p->limit_rate * (ngx_time() - p->start_sec
+ 1)
- p->read_length;
- if (limit <= 0) {
+ if (limit < 0) {
p->upstream->read->delayed = 1;
- delay = (ngx_msec_t) (- limit * 1000 / p->limit_rate +
1);
+ delay = (ngx_msec_t) (- limit * 1000 / p->limit_rate);
ngx_add_timer(p->upstream->read, delay);
break;
}
--
1.9.1
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20151017/7e82da87/attachment.html>
More information about the nginx-devel
mailing list