yaoweibin / nginx_upstream_check_module

Health checks upstreams for nginx
http://github.com/yaoweibin/nginx_upstream_check_module
2.04k stars 483 forks source link

check_keepalive_requests #90

Open gfrankliu opened 8 years ago

gfrankliu commented 8 years ago

If check_keepalive_requests is set to greater than 1, the checker module will only send first check request to upstream, it never sends any more after that, until the upstream server times out the keepalive link. Checker module will then create a new link, and on and on.

You can create a dummy upstream pool with check_keepalive_requests 100; use tcpdump to watch the checker behavior.

I compared the tengine source code and the only main difference I see is one line. After I made this one line change, the "check_keepalive_requests" > 1 seems to be working. Can you please check if this change has any bad effect?

diff --git a/ngx_http_upstream_check_module.c b/ngx_http_upstream_check_module.c
index b628436..6cc1074 100644
--- a/ngx_http_upstream_check_module.c
+++ b/ngx_http_upstream_check_module.c
@@ -1043,7 +1043,6 @@ ngx_http_upstream_check_begin_handler(ngx_event_t *event)

     /* This process is processing this peer now. */
     if ((peer->shm->owner == ngx_pid  ||
-        (peer->pc.connection != NULL) ||
         peer->check_timeout_ev.timer_set)) {
         return;
     }
gfrankliu commented 7 years ago

I sent PR 91 for this. https://github.com/yaoweibin/nginx_upstream_check_module/pulls