Welcome! Log In Create A New Profile

Advanced

[nginx] Fixed lingering_time check.

Maxim Dounin
May 13, 2013 10:26AM
details: http://hg.nginx.org/nginx/rev/ea2ba6dbe361
branches:
changeset: 5210:ea2ba6dbe361
user: Maxim Dounin <mdounin@mdounin.ru>
date: Mon May 13 17:39:45 2013 +0400
description:
Fixed lingering_time check.

There are two significant changes in this patch:

1) The <= 0 comparison is done with a signed type. This fixes the case
of ngx_time() being larger than r->lingering_time.

2) Calculation of r->lingering_time - ngx_time() is now always done
in the ngx_msec_t type. This ensures the calculation is correct
even if time_t is unsigned and differs in size from ngx_msec_t.

Thanks to Lanshun Zhou.

diffstat:

src/http/ngx_http_request.c | 4 ++--
src/http/ngx_http_request_body.c | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)

diffs (29 lines):

diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c
--- a/src/http/ngx_http_request.c
+++ b/src/http/ngx_http_request.c
@@ -3166,8 +3166,8 @@ ngx_http_lingering_close_handler(ngx_eve
return;
}

- timer = (ngx_msec_t) (r->lingering_time - ngx_time());
- if (timer <= 0) {
+ timer = (ngx_msec_t) r->lingering_time - (ngx_msec_t) ngx_time();
+ if ((ngx_msec_int_t) timer <= 0) {
ngx_http_close_request(r, 0);
return;
}
diff --git a/src/http/ngx_http_request_body.c b/src/http/ngx_http_request_body.c
--- a/src/http/ngx_http_request_body.c
+++ b/src/http/ngx_http_request_body.c
@@ -570,9 +570,9 @@ ngx_http_discarded_request_body_handler(
}

if (r->lingering_time) {
- timer = (ngx_msec_t) (r->lingering_time - ngx_time());
+ timer = (ngx_msec_t) r->lingering_time - (ngx_msec_t) ngx_time();

- if (timer <= 0) {
+ if ((ngx_msec_int_t) timer <= 0) {
r->discard_body = 0;
r->lingering_close = 0;
ngx_http_finalize_request(r, NGX_ERROR);

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

[nginx] Fixed lingering_time check.

Maxim Dounin 943 May 13, 2013 10:26AM



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

Online Users

Guests: 158
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready