Browse Source

health check: check return value @size of send() or recv()

* check active close from peer in ngx_http_upstream_check_recv_handler():

   If there is no data to receive, we finish the health check before timeout.
   Note that, without this patch, timeout handler will do it for us.

 * send data later when send() returns 0 in ngx_http_upstream_check_send_handler():

   When the remote tcp receive buffer has been filled up or the local send
   buffer is completely full, send() could easily returns 0.
   In this case, we should send data later just like we handle NGX_AGAIN.

   A good example from nginx is in ngx_mail_send(), which does the same thing
   for `n == 0` and `n == NGX_AGAIN`.
pull/226/head
Xiaochen Wang 12 years ago
parent
commit
652f68fdbb
  1. 12
      src/http/ngx_http_upstream_check_module.c

12
src/http/ngx_http_upstream_check_module.c

@ -1100,10 +1100,12 @@ ngx_http_upstream_check_send_handler(ngx_event_t *event)
}
#endif
if (size >= 0) {
if (size > 0) {
ctx->send.pos += size;
} else if (size == NGX_AGAIN) {
} else if (size == 0 || size == NGX_AGAIN) {
return;
} else {
c->error = 1;
goto check_send_fail;
@ -1216,6 +1218,12 @@ ngx_http_upstream_check_recv_handler(ngx_event_t *event)
switch (rc) {
case NGX_AGAIN:
/* The peer has closed its half side of the connection. */
if (size == 0) {
ngx_http_upstream_check_status_update(peer, 0);
break;
}
return;
case NGX_ERROR:

Loading…
Cancel
Save