[PATCH] Fixed state protection when restarting during the websocket request process
乔志奇
qiaozhiqi2016 at gmail.com
Tue Dec 20 07:01:59 UTC 2022
# HG changeset patch
# User 乔志奇@Matebook-Qiao <qiaozhiqi2016 at 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);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20221220/ce83bc45/attachment.htm>
More information about the nginx-devel
mailing list