Welcome! Log In Create A New Profile

Advanced

[PATCH] Fixed state protection when restarting during the websocket request process

乔志奇
December 20, 2022 02:04AM
# HG changeset patch
# User 乔志奇@Matebook-Qiao <qiaozhiqi2016@gmail.com>
# Date 1671515941 -28800
# Tue Dec 20 13:59:01 2022 +0800
# Branch nginx-bugfix-websocket
# Node ID 3e68435db4a9991921b5bf91d792787a1ad387fb
# Parent 3108d4d668e4b907868b815f0441d4c893bf4188
Fixed state protection when restarting during the websocket request process

During the websocket request process, it is necessary to add a timer
operation, but we need to do state protection for the timer addition
operation. When the nginx process is restarted or stopped, the timer should
be prohibited from being added, otherwise continuous websocket requests
will cause the old process to be unable to exit during the restart process
or unable to exit during the stop process.

diff -r 3108d4d668e4 -r 3e68435db4a9 src/http/ngx_http_upstream.c
--- a/src/http/ngx_http_upstream.c Fri Dec 16 01:15:15 2022 +0400
+++ b/src/http/ngx_http_upstream.c Tue Dec 20 13:59:01 2022 +0800
@@ -3559,7 +3559,9 @@
}

if (upstream->write->active && !upstream->write->ready) {
- ngx_add_timer(upstream->write, u->conf->send_timeout);
+ if (!ngx_exiting && !ngx_quit) {
+ ngx_add_timer(upstream->write, u->conf->send_timeout);
+ }

} else if (upstream->write->timer_set) {
ngx_del_timer(upstream->write);
@@ -3578,7 +3580,9 @@
}

if (upstream->read->active && !upstream->read->ready) {
- ngx_add_timer(upstream->read, u->conf->read_timeout);
+ if (!ngx_exiting && !ngx_quit) {
+ ngx_add_timer(upstream->read, u->conf->read_timeout);
+ }

} else if (upstream->read->timer_set) {
ngx_del_timer(upstream->read);
@@ -3604,7 +3608,9 @@
}

if (downstream->write->active && !downstream->write->ready) {
- ngx_add_timer(downstream->write, clcf->send_timeout);
+ if (!ngx_exiting && !ngx_quit) {
+ ngx_add_timer(downstream->write, clcf->send_timeout);
+ }

} else if (downstream->write->timer_set) {
ngx_del_timer(downstream->write);
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
https://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[PATCH] Fixed state protection when restarting during the websocket request process

乔志奇 417 December 20, 2022 02:04AM

Re: [PATCH] Fixed state protection when restarting during the websocket request process

Maxim Dounin 101 December 20, 2022 03:04AM

Re: [PATCH] Fixed state protection when restarting during the websocket request process

乔志奇 134 December 26, 2022 02:04AM



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

Online Users

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