Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 13 Apr 2016 01:20:18 +0000 (UTC)
From:      "Sergey A. Osokin" <osa@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r413165 - in head/www: nginx nginx-devel nginx-devel/files nginx/files
Message-ID:  <201604130120.u3D1KITn023362@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: osa
Date: Wed Apr 13 01:20:18 2016
New Revision: 413165
URL: https://svnweb.freebsd.org/changeset/ports/413165

Log:
  Add third-party upstream check module.
  
  PR:	208380

Added:
  head/www/nginx-devel/files/extra-patch-ngx_http_upstream_fair_module.c   (contents, props changed)
  head/www/nginx-devel/files/extra-patch-src-http-modules-ngx_http_upstream_hash_module.c   (contents, props changed)
  head/www/nginx-devel/files/extra-patch-src-http-modules-ngx_http_upstream_ip_hash_module.c   (contents, props changed)
  head/www/nginx-devel/files/extra-patch-src-http-modules-ngx_http_upstream_least_conn_module.c   (contents, props changed)
  head/www/nginx-devel/files/extra-patch-src-http-ngx_http_upstream_round_robin.c   (contents, props changed)
  head/www/nginx-devel/files/extra-patch-src-http-ngx_http_upstream_round_robin.h   (contents, props changed)
  head/www/nginx/files/extra-patch-ngx_http_upstream_fair_module.c   (contents, props changed)
  head/www/nginx/files/extra-patch-src-http-modules-ngx_http_upstream_hash_module.c   (contents, props changed)
  head/www/nginx/files/extra-patch-src-http-modules-ngx_http_upstream_ip_hash_module.c   (contents, props changed)
  head/www/nginx/files/extra-patch-src-http-modules-ngx_http_upstream_least_conn_module.c   (contents, props changed)
  head/www/nginx/files/extra-patch-src-http-ngx_http_upstream_round_robin.c   (contents, props changed)
  head/www/nginx/files/extra-patch-src-http-ngx_http_upstream_round_robin.h   (contents, props changed)
Modified:
  head/www/nginx-devel/Makefile
  head/www/nginx-devel/distinfo
  head/www/nginx/Makefile
  head/www/nginx/distinfo

Modified: head/www/nginx-devel/Makefile
==============================================================================
--- head/www/nginx-devel/Makefile	Tue Apr 12 23:15:08 2016	(r413164)
+++ head/www/nginx-devel/Makefile	Wed Apr 13 01:20:18 2016	(r413165)
@@ -89,6 +89,7 @@ OPTIONS_DEFINE=	\
 	HTTP_TARANTOOL \
 	HTTP_UPLOAD \
 	HTTP_UPLOAD_PROGRESS \
+	HTTP_UPSTREAM_CHECK \
 	HTTP_UPSTREAM_FAIR \
 	HTTP_UPSTREAM_STICKY \
 	HTTP_VIDEO_THUMBEXTRACTOR \
@@ -193,6 +194,7 @@ HTTP_SUBS_FILTER_DESC=		3rd party subs f
 HTTP_TARANTOOL_DESC=		3rd party tarantool upstream module
 HTTP_UPLOAD_DESC=		3rd party upload module
 HTTP_UPLOAD_PROGRESS_DESC=	3rd party uploadprogress module
+HTTP_UPSTREAM_CHECK_DESC=	3rd party upstream check module
 HTTP_UPSTREAM_FAIR_DESC=	3rd party upstream fair module
 HTTP_UPSTREAM_STICKY_DESC=	3rd party upstream sticky module
 HTTP_VIDEO_THUMBEXTRACTOR_DESC=	3rd party video_thumbextractor module
@@ -622,11 +624,28 @@ GH_TAGNAME+=	v${NGINX_UPLOADPROGRESS_VER
 CONFIGURE_ARGS+=--add-module=${WRKSRC_uploadprogress}
 .endif
 
+.if !empty(PORT_OPTIONS:MHTTP_UPSTREAM_CHECK)
+# WWW: https://github.com/yaoweibin/nginx_upstream_check_module
+NGINX_UPSTREAM_CHECK_VERSION=	10782ea
+GH_ACCOUNT+=	yaoweibin:upstreamcheck
+GH_PROJECT+=	nginx_upstream_check_module:upstreamcheck
+GH_TAGNAME+=	${NGINX_UPSTREAM_CHECK_VERSION}:upstreamcheck
+CONFIGURE_ARGS+=--add-module=${WRKSRC_upstreamcheck}
+EXTRA_PATCHES+=	${PATCHDIR}/extra-patch-src-http-modules-ngx_http_upstream_hash_module.c \
+		${PATCHDIR}/extra-patch-src-http-modules-ngx_http_upstream_ip_hash_module.c \
+		${PATCHDIR}/extra-patch-src-http-modules-ngx_http_upstream_least_conn_module.c \
+		${PATCHDIR}/extra-patch-src-http-ngx_http_upstream_round_robin.c \
+		${PATCHDIR}/extra-patch-src-http-ngx_http_upstream_round_robin.h
+.endif
+
 .if !empty(PORT_OPTIONS:MHTTP_UPSTREAM_FAIR)
 NGINX_UPSTREAM_FAIR_VERSION=	20090923
 MASTER_SITES+=	LOCAL/osa:upstreamfair
 DISTFILES+=	nginx_upstream_fair-${NGINX_UPSTREAM_FAIR_VERSION}.tar.gz:upstreamfair
 CONFIGURE_ARGS+=--add-module=${WRKDIR}/nginx_upstream_fair-${NGINX_UPSTREAM_FAIR_VERSION}
+.if !empty(PORT_OPTIONS:MHTTP_UPSTREAM_CHECK)
+EXTRA_PATCHES+=	${PATCHDIR}/extra-patch-ngx_http_upstream_fair_module.c
+.endif
 .endif
 
 .if ${PORT_OPTIONS:MHTTP_UPSTREAM_STICKY}

Modified: head/www/nginx-devel/distinfo
==============================================================================
--- head/www/nginx-devel/distinfo	Tue Apr 12 23:15:08 2016	(r413164)
+++ head/www/nginx-devel/distinfo	Wed Apr 13 01:20:18 2016	(r413165)
@@ -74,6 +74,8 @@ SHA256 (vkholodkov-nginx-upload-module-a
 SIZE (vkholodkov-nginx-upload-module-aba1e3f34c_GH0.tar.gz) = 28296
 SHA256 (masterzen-nginx-upload-progress-module-v0.9.0_GH0.tar.gz) = 93e29b9b437a2e34713de54c2861ea51151624aca09f73f9f44d1caaff01a6b1
 SIZE (masterzen-nginx-upload-progress-module-v0.9.0_GH0.tar.gz) = 16990
+SHA256 (yaoweibin-nginx_upstream_check_module-10782ea_GH0.tar.gz) = 52e6acd8c0264a59c5c948271015a59acd3cbcf91377456b7c8dc6f9feecef4a
+SIZE (yaoweibin-nginx_upstream_check_module-10782ea_GH0.tar.gz) = 128281
 SHA256 (wandenberg-nginx-video-thumbextractor-module-0.7.0_GH0.tar.gz) = 382bb41fa739f471fdab9fbabc5384d8ec7f25b5bb0c45c153f5cc01d428abe2
 SIZE (wandenberg-nginx-video-thumbextractor-module-0.7.0_GH0.tar.gz) = 2709351
 SHA256 (openresty-drizzle-nginx-module-v0.1.9_GH0.tar.gz) = aafb79d87273eec023025333c34d6d0108026a1ce2e09b20a53e8e2d9bf65080

Added: head/www/nginx-devel/files/extra-patch-ngx_http_upstream_fair_module.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/www/nginx-devel/files/extra-patch-ngx_http_upstream_fair_module.c	Wed Apr 13 01:20:18 2016	(r413165)
@@ -0,0 +1,89 @@
+--- ../nginx_upstream_fair-20090923/ngx_http_upstream_fair_module.c.orig	2009-09-24 01:38:16.000000000 +0800
++++ ../nginx_upstream_fair-20090923/ngx_http_upstream_fair_module.c	2016-03-24 13:56:02.990728000 +0800
+@@ -9,6 +9,10 @@
+ #include <ngx_core.h>
+ #include <ngx_http.h>
+ 
++#if (NGX_HTTP_UPSTREAM_CHECK)
++#include "ngx_http_upstream_check_module.h"
++#endif
++
+ typedef struct {
+     ngx_uint_t                          nreq;
+     ngx_uint_t                          total_req;
+@@ -42,6 +46,10 @@
+     ngx_uint_t                          max_fails;
+     time_t                              fail_timeout;
+ 
++#if (NGX_HTTP_UPSTREAM_CHECK)
++    ngx_uint_t                          check_index;
++#endif
++
+     time_t                              accessed;
+     ngx_uint_t                          down:1;
+ 
+@@ -474,6 +482,15 @@
+                 peers->peer[n].fail_timeout = server[i].fail_timeout;
+                 peers->peer[n].down = server[i].down;
+                 peers->peer[n].weight = server[i].down ? 0 : server[i].weight;
++#if (NGX_HTTP_UPSTREAM_CHECK)
++                if (!server[i].down) {
++                    peers->peer[n].check_index =
++                        ngx_http_upstream_check_add_peer(cf, us, &server[i].addrs[j]);
++                }
++                else {
++                    peers->peer[n].check_index = (ngx_uint_t) NGX_ERROR;
++                }
++#endif
+                 n++;
+             }
+         }
+@@ -524,6 +541,15 @@
+                 backup->peer[n].max_fails = server[i].max_fails;
+                 backup->peer[n].fail_timeout = server[i].fail_timeout;
+                 backup->peer[n].down = server[i].down;
++#if (NGX_HTTP_UPSTREAM_CHECK)
++                if (!server[i].down) {
++                    backup->peer[n].check_index =
++                        ngx_http_upstream_check_add_peer(cf, us, &server[i].addrs[j]);
++                }
++                else {
++                    backup->peer[n].check_index = (ngx_uint_t) NGX_ERROR;
++                }
++#endif
+                 n++;
+             }
+         }
+@@ -580,6 +606,9 @@
+         peers->peer[i].weight = 1;
+         peers->peer[i].max_fails = 1;
+         peers->peer[i].fail_timeout = 10;
++#if (NGX_HTTP_UPSTREAM_CHECK)
++        peers->peer[i].check_index = (ngx_uint_t) NGX_ERROR;
++#endif
+     }
+ 
+     us->peer.data = peers;
+@@ -721,6 +750,12 @@
+     peer = &fp->peers->peer[peer_id];
+ 
+     if (!peer->down) {
++#if (NGX_HTTP_UPSTREAM_CHECK)
++        ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0,
++                       "[upstream_fair] get fair peer, check_index: %ui",
++                       peer->check_index);
++        if (!ngx_http_upstream_check_peer_down(peer->check_index)) {
++#endif
+         if (peer->max_fails == 0 || peer->shared->fails < peer->max_fails) {
+             return NGX_OK;
+         }
+@@ -731,6 +766,9 @@
+             peer->shared->fails = 0;
+             return NGX_OK;
+         }
++#if (NGX_HTTP_UPSTREAM_CHECK)
++        }
++#endif
+     }
+ 
+     return NGX_BUSY;

Added: head/www/nginx-devel/files/extra-patch-src-http-modules-ngx_http_upstream_hash_module.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/www/nginx-devel/files/extra-patch-src-http-modules-ngx_http_upstream_hash_module.c	Wed Apr 13 01:20:18 2016	(r413165)
@@ -0,0 +1,44 @@
+--- src/http/modules/ngx_http_upstream_hash_module.c.orig	2016-02-24 14:53:24 UTC
++++ src/http/modules/ngx_http_upstream_hash_module.c
+@@ -9,6 +9,9 @@
+ #include <ngx_core.h>
+ #include <ngx_http.h>
+ 
++#if (NGX_HTTP_UPSTREAM_CHECK)
++#include "ngx_http_upstream_check_module.h"
++#endif
+ 
+ typedef struct {
+     uint32_t                            hash;
+@@ -235,6 +238,15 @@ ngx_http_upstream_get_hash_peer(ngx_peer
+             goto next;
+         }
+ 
++#if (NGX_HTTP_UPSTREAM_CHECK)
++        ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0,
++            "get hash peer, check_index: %ui",
++             peer->check_index);
++        if (ngx_http_upstream_check_peer_down(peer->check_index)) {
++            goto next;
++        }
++#endif
++
+         if (peer->max_fails
+             && peer->fails >= peer->max_fails
+             && now - peer->checked <= peer->fail_timeout)
+@@ -535,6 +547,15 @@ ngx_http_upstream_get_chash_peer(ngx_pee
+                 continue;
+             }
+ 
++#if (NGX_HTTP_UPSTREAM_CHECK)
++            ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0,
++                "get consistent_hash peer, check_index: %ui",
++                 peer->check_index);
++            if (ngx_http_upstream_check_peer_down(peer->check_index)) {
++                continue;
++            }
++#endif
++
+             if (peer->server.len != server->len
+                 || ngx_strncmp(peer->server.data, server->data, server->len)
+                    != 0)

Added: head/www/nginx-devel/files/extra-patch-src-http-modules-ngx_http_upstream_ip_hash_module.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/www/nginx-devel/files/extra-patch-src-http-modules-ngx_http_upstream_ip_hash_module.c	Wed Apr 13 01:20:18 2016	(r413165)
@@ -0,0 +1,28 @@
+--- src/http/modules/ngx_http_upstream_ip_hash_module.c.orig	2016-02-24 14:53:24 UTC
++++ src/http/modules/ngx_http_upstream_ip_hash_module.c
+@@ -9,6 +9,9 @@
+ #include <ngx_core.h>
+ #include <ngx_http.h>
+ 
++#if (NGX_HTTP_UPSTREAM_CHECK)
++#include "ngx_http_upstream_check_module.h"
++#endif
+ 
+ typedef struct {
+     /* the round robin data must be first */
+@@ -205,6 +208,15 @@ ngx_http_upstream_get_ip_hash_peer(ngx_p
+             goto next;
+         }
+ 
++#if (NGX_HTTP_UPSTREAM_CHECK)
++        ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0,
++            "get ip_hash peer, check_index: %ui",
++             peer->check_index);
++        if (ngx_http_upstream_check_peer_down(peer->check_index)) {
++            goto next;
++        }
++#endif
++
+         if (peer->max_fails
+             && peer->fails >= peer->max_fails
+             && now - peer->checked <= peer->fail_timeout)

Added: head/www/nginx-devel/files/extra-patch-src-http-modules-ngx_http_upstream_least_conn_module.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/www/nginx-devel/files/extra-patch-src-http-modules-ngx_http_upstream_least_conn_module.c	Wed Apr 13 01:20:18 2016	(r413165)
@@ -0,0 +1,46 @@
+--- src/http/modules/ngx_http_upstream_least_conn_module.c.orig	2016-02-24 14:53:24 UTC
++++ src/http/modules/ngx_http_upstream_least_conn_module.c
+@@ -9,6 +9,9 @@
+ #include <ngx_core.h>
+ #include <ngx_http.h>
+ 
++#if (NGX_HTTP_UPSTREAM_CHECK)
++#include "ngx_http_upstream_check_module.h"
++#endif
+ 
+ static ngx_int_t ngx_http_upstream_init_least_conn_peer(ngx_http_request_t *r,
+     ngx_http_upstream_srv_conf_t *us);
+@@ -148,6 +151,16 @@ ngx_http_upstream_get_least_conn_peer(ng
+             continue;
+         }
+ 
++#if (NGX_HTTP_UPSTREAM_CHECK)
++        ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0,
++                "get least_conn peer, check_index: %ui",
++                peer->check_index);
++
++        if (ngx_http_upstream_check_peer_down(peer->check_index)) {
++            continue;
++        }
++#endif
++
+         if (peer->max_fails
+             && peer->fails >= peer->max_fails
+             && now - peer->checked <= peer->fail_timeout)
+@@ -199,6 +212,16 @@ ngx_http_upstream_get_least_conn_peer(ng
+                 continue;
+             }
+ 
++#if (NGX_HTTP_UPSTREAM_CHECK)
++            ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0,
++                    "get least_conn peer, check_index: %ui",
++                    peer->check_index);
++
++            if (ngx_http_upstream_check_peer_down(peer->check_index)) {
++                continue;
++            }
++#endif
++
+             if (peer->conns * best->weight != best->conns * peer->weight) {
+                 continue;
+             }

Added: head/www/nginx-devel/files/extra-patch-src-http-ngx_http_upstream_round_robin.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/www/nginx-devel/files/extra-patch-src-http-ngx_http_upstream_round_robin.c	Wed Apr 13 01:20:18 2016	(r413165)
@@ -0,0 +1,101 @@
+--- src/http/ngx_http_upstream_round_robin.c.orig	2016-02-24 14:53:24 UTC
++++ src/http/ngx_http_upstream_round_robin.c
+@@ -9,6 +9,9 @@
+ #include <ngx_core.h>
+ #include <ngx_http.h>
+ 
++#if (NGX_HTTP_UPSTREAM_CHECK)
++#include "ngx_http_upstream_check_module.h"
++#endif
+ 
+ #define ngx_http_upstream_tries(p) ((p)->number                               \
+                                     + ((p)->next ? (p)->next->number : 0))
+@@ -96,7 +99,14 @@ ngx_http_upstream_init_round_robin(ngx_c
+                 peer[n].fail_timeout = server[i].fail_timeout;
+                 peer[n].down = server[i].down;
+                 peer[n].server = server[i].name;
+-
++#if (NGX_HTTP_UPSTREAM_CHECK)
++                if (!server[i].down) {
++                    peer[n].check_index =
++                        ngx_http_upstream_check_add_peer(cf, us, &server[i].addrs[j]);
++                } else {
++                    peer[n].check_index = (ngx_uint_t) NGX_ERROR;
++                }
++#endif
+                 *peerp = &peer[n];
+                 peerp = &peer[n].next;
+                 n++;
+@@ -159,7 +169,15 @@ ngx_http_upstream_init_round_robin(ngx_c
+                 peer[n].fail_timeout = server[i].fail_timeout;
+                 peer[n].down = server[i].down;
+                 peer[n].server = server[i].name;
+-
++#if (NGX_HTTP_UPSTREAM_CHECK)
++                if (!server[i].down) {
++                    peer[n].check_index =
++                        ngx_http_upstream_check_add_peer(cf, us, &server[i].addrs[j]);
++                }
++                else {
++                    peer[n].check_index = (ngx_uint_t) NGX_ERROR;
++                }
++#endif
+                 *peerp = &peer[n];
+                 peerp = &peer[n].next;
+                 n++;
+@@ -225,6 +243,9 @@ ngx_http_upstream_init_round_robin(ngx_c
+         peer[i].current_weight = 0;
+         peer[i].max_fails = 1;
+         peer[i].fail_timeout = 10;
++#if (NGX_HTTP_UPSTREAM_CHECK)
++        peer[i].check_index = (ngx_uint_t) NGX_ERROR;
++#endif
+         *peerp = &peer[i];
+         peerp = &peer[i].next;
+     }
+@@ -339,6 +360,9 @@ ngx_http_upstream_create_round_robin_pee
+         peer[0].current_weight = 0;
+         peer[0].max_fails = 1;
+         peer[0].fail_timeout = 10;
++#if (NGX_HTTP_UPSTREAM_CHECK)
++        peer[0].check_index = (ngx_uint_t) NGX_ERROR;
++#endif
+         peers->peer = peer;
+ 
+     } else {
+@@ -381,6 +405,9 @@ ngx_http_upstream_create_round_robin_pee
+             peer[i].current_weight = 0;
+             peer[i].max_fails = 1;
+             peer[i].fail_timeout = 10;
++#if (NGX_HTTP_UPSTREAM_CHECK)
++            peer[i].check_index = (ngx_uint_t) NGX_ERROR;
++#endif
+             *peerp = &peer[i];
+             peerp = &peer[i].next;
+         }
+@@ -441,6 +468,12 @@ ngx_http_upstream_get_round_robin_peer(n
+             goto failed;
+         }
+ 
++#if (NGX_HTTP_UPSTREAM_CHECK)
++        if (ngx_http_upstream_check_peer_down(peer->check_index)) {
++            goto failed;
++        }
++#endif
++
+         rrp->current = peer;
+ 
+     } else {
+@@ -542,6 +575,12 @@ ngx_http_upstream_get_peer(ngx_http_upst
+             continue;
+         }
+ 
++#if (NGX_HTTP_UPSTREAM_CHECK)
++        if (ngx_http_upstream_check_peer_down(peer->check_index)) {
++            continue;
++        }
++#endif
++
+         if (peer->max_fails
+             && peer->fails >= peer->max_fails
+             && now - peer->checked <= peer->fail_timeout)

Added: head/www/nginx-devel/files/extra-patch-src-http-ngx_http_upstream_round_robin.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/www/nginx-devel/files/extra-patch-src-http-ngx_http_upstream_round_robin.h	Wed Apr 13 01:20:18 2016	(r413165)
@@ -0,0 +1,13 @@
+--- src/http/ngx_http_upstream_round_robin.h.orig	2016-02-24 14:53:24 UTC
++++ src/http/ngx_http_upstream_round_robin.h
+@@ -35,6 +35,10 @@ struct ngx_http_upstream_rr_peer_s {
+     ngx_uint_t                      max_fails;
+     time_t                          fail_timeout;
+ 
++#if (NGX_HTTP_UPSTREAM_CHECK)
++    ngx_uint_t                      check_index;
++#endif
++
+     ngx_uint_t                      down;          /* unsigned  down:1; */
+ 
+ #if (NGX_HTTP_SSL)

Modified: head/www/nginx/Makefile
==============================================================================
--- head/www/nginx/Makefile	Tue Apr 12 23:15:08 2016	(r413164)
+++ head/www/nginx/Makefile	Wed Apr 13 01:20:18 2016	(r413165)
@@ -85,6 +85,7 @@ OPTIONS_DEFINE=	\
 	HTTP_TARANTOOL \
 	HTTP_UPLOAD \
 	HTTP_UPLOAD_PROGRESS \
+	HTTP_UPSTREAM_CHECK \
 	HTTP_UPSTREAM_FAIR \
 	HTTP_UPSTREAM_STICKY \
 	HTTP_VIDEO_THUMBEXTRACTOR \
@@ -184,6 +185,7 @@ HTTP_SUBS_FILTER_DESC=		3rd party subs f
 HTTP_TARANTOOL_DESC=		3rd party tarantool upstream module
 HTTP_UPLOAD_DESC=		3rd party upload module
 HTTP_UPLOAD_PROGRESS_DESC=	3rd party uploadprogress module
+HTTP_UPSTREAM_CHECK_DESC=	3rd party upstream check module
 HTTP_UPSTREAM_FAIR_DESC=	3rd party upstream fair module
 HTTP_UPSTREAM_STICKY_DESC=	3rd party upstream sticky module
 HTTP_VIDEO_THUMBEXTRACTOR_DESC=	3rd party video_thumbextractor module
@@ -606,11 +608,28 @@ GH_TAGNAME+=	v${NGINX_UPLOADPROGRESS_VER
 CONFIGURE_ARGS+=--add-module=${WRKSRC_uploadprogress}
 .endif
 
+.if !empty(PORT_OPTIONS:MHTTP_UPSTREAM_CHECK)
+# WWW: https://github.com/yaoweibin/nginx_upstream_check_module
+NGINX_UPSTREAM_CHECK_VERSION=	10782ea
+GH_ACCOUNT+=	yaoweibin:upstreamcheck
+GH_PROJECT+=	nginx_upstream_check_module:upstreamcheck
+GH_TAGNAME+=	${NGINX_UPSTREAM_CHECK_VERSION}:upstreamcheck
+CONFIGURE_ARGS+=--add-module=${WRKSRC_upstreamcheck}
+EXTRA_PATCHES+=	${PATCHDIR}/extra-patch-src-http-modules-ngx_http_upstream_hash_module.c \
+		${PATCHDIR}/extra-patch-src-http-modules-ngx_http_upstream_ip_hash_module.c \
+		${PATCHDIR}/extra-patch-src-http-modules-ngx_http_upstream_least_conn_module.c \
+		${PATCHDIR}/extra-patch-src-http-ngx_http_upstream_round_robin.c \
+		${PATCHDIR}/extra-patch-src-http-ngx_http_upstream_round_robin.h
+.endif
+
 .if !empty(PORT_OPTIONS:MHTTP_UPSTREAM_FAIR)
 NGINX_UPSTREAM_FAIR_VERSION=	20090923
 MASTER_SITES+=	LOCAL/osa:upstreamfair
 DISTFILES+=	nginx_upstream_fair-${NGINX_UPSTREAM_FAIR_VERSION}.tar.gz:upstreamfair
 CONFIGURE_ARGS+=--add-module=${WRKDIR}/nginx_upstream_fair-${NGINX_UPSTREAM_FAIR_VERSION}
+.if !empty(PORT_OPTIONS:MHTTP_UPSTREAM_CHECK)
+EXTRA_PATCHES+=	${PATCHDIR}/extra-patch-ngx_http_upstream_fair_module.c
+.endif
 .endif
 
 .if ${PORT_OPTIONS:MHTTP_UPSTREAM_STICKY}

Modified: head/www/nginx/distinfo
==============================================================================
--- head/www/nginx/distinfo	Tue Apr 12 23:15:08 2016	(r413164)
+++ head/www/nginx/distinfo	Wed Apr 13 01:20:18 2016	(r413165)
@@ -74,6 +74,8 @@ SHA256 (vkholodkov-nginx-upload-module-a
 SIZE (vkholodkov-nginx-upload-module-aba1e3f34c_GH0.tar.gz) = 28296
 SHA256 (masterzen-nginx-upload-progress-module-v0.9.0_GH0.tar.gz) = 93e29b9b437a2e34713de54c2861ea51151624aca09f73f9f44d1caaff01a6b1
 SIZE (masterzen-nginx-upload-progress-module-v0.9.0_GH0.tar.gz) = 16990
+SHA256 (yaoweibin-nginx_upstream_check_module-10782ea_GH0.tar.gz) = 52e6acd8c0264a59c5c948271015a59acd3cbcf91377456b7c8dc6f9feecef4a
+SIZE (yaoweibin-nginx_upstream_check_module-10782ea_GH0.tar.gz) = 128281
 SHA256 (wandenberg-nginx-video-thumbextractor-module-0.7.0_GH0.tar.gz) = 382bb41fa739f471fdab9fbabc5384d8ec7f25b5bb0c45c153f5cc01d428abe2
 SIZE (wandenberg-nginx-video-thumbextractor-module-0.7.0_GH0.tar.gz) = 2709351
 SHA256 (openresty-drizzle-nginx-module-v0.1.9_GH0.tar.gz) = aafb79d87273eec023025333c34d6d0108026a1ce2e09b20a53e8e2d9bf65080

Added: head/www/nginx/files/extra-patch-ngx_http_upstream_fair_module.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/www/nginx/files/extra-patch-ngx_http_upstream_fair_module.c	Wed Apr 13 01:20:18 2016	(r413165)
@@ -0,0 +1,89 @@
+--- ../nginx_upstream_fair-20090923/ngx_http_upstream_fair_module.c.orig	2009-09-24 01:38:16.000000000 +0800
++++ ../nginx_upstream_fair-20090923/ngx_http_upstream_fair_module.c	2016-03-24 13:56:02.990728000 +0800
+@@ -9,6 +9,10 @@
+ #include <ngx_core.h>
+ #include <ngx_http.h>
+ 
++#if (NGX_HTTP_UPSTREAM_CHECK)
++#include "ngx_http_upstream_check_module.h"
++#endif
++
+ typedef struct {
+     ngx_uint_t                          nreq;
+     ngx_uint_t                          total_req;
+@@ -42,6 +46,10 @@
+     ngx_uint_t                          max_fails;
+     time_t                              fail_timeout;
+ 
++#if (NGX_HTTP_UPSTREAM_CHECK)
++    ngx_uint_t                          check_index;
++#endif
++
+     time_t                              accessed;
+     ngx_uint_t                          down:1;
+ 
+@@ -474,6 +482,15 @@
+                 peers->peer[n].fail_timeout = server[i].fail_timeout;
+                 peers->peer[n].down = server[i].down;
+                 peers->peer[n].weight = server[i].down ? 0 : server[i].weight;
++#if (NGX_HTTP_UPSTREAM_CHECK)
++                if (!server[i].down) {
++                    peers->peer[n].check_index =
++                        ngx_http_upstream_check_add_peer(cf, us, &server[i].addrs[j]);
++                }
++                else {
++                    peers->peer[n].check_index = (ngx_uint_t) NGX_ERROR;
++                }
++#endif
+                 n++;
+             }
+         }
+@@ -524,6 +541,15 @@
+                 backup->peer[n].max_fails = server[i].max_fails;
+                 backup->peer[n].fail_timeout = server[i].fail_timeout;
+                 backup->peer[n].down = server[i].down;
++#if (NGX_HTTP_UPSTREAM_CHECK)
++                if (!server[i].down) {
++                    backup->peer[n].check_index =
++                        ngx_http_upstream_check_add_peer(cf, us, &server[i].addrs[j]);
++                }
++                else {
++                    backup->peer[n].check_index = (ngx_uint_t) NGX_ERROR;
++                }
++#endif
+                 n++;
+             }
+         }
+@@ -580,6 +606,9 @@
+         peers->peer[i].weight = 1;
+         peers->peer[i].max_fails = 1;
+         peers->peer[i].fail_timeout = 10;
++#if (NGX_HTTP_UPSTREAM_CHECK)
++        peers->peer[i].check_index = (ngx_uint_t) NGX_ERROR;
++#endif
+     }
+ 
+     us->peer.data = peers;
+@@ -721,6 +750,12 @@
+     peer = &fp->peers->peer[peer_id];
+ 
+     if (!peer->down) {
++#if (NGX_HTTP_UPSTREAM_CHECK)
++        ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0,
++                       "[upstream_fair] get fair peer, check_index: %ui",
++                       peer->check_index);
++        if (!ngx_http_upstream_check_peer_down(peer->check_index)) {
++#endif
+         if (peer->max_fails == 0 || peer->shared->fails < peer->max_fails) {
+             return NGX_OK;
+         }
+@@ -731,6 +766,9 @@
+             peer->shared->fails = 0;
+             return NGX_OK;
+         }
++#if (NGX_HTTP_UPSTREAM_CHECK)
++        }
++#endif
+     }
+ 
+     return NGX_BUSY;

Added: head/www/nginx/files/extra-patch-src-http-modules-ngx_http_upstream_hash_module.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/www/nginx/files/extra-patch-src-http-modules-ngx_http_upstream_hash_module.c	Wed Apr 13 01:20:18 2016	(r413165)
@@ -0,0 +1,44 @@
+--- src/http/modules/ngx_http_upstream_hash_module.c.orig	2016-01-26 14:39:32 UTC
++++ src/http/modules/ngx_http_upstream_hash_module.c
+@@ -9,6 +9,9 @@
+ #include <ngx_core.h>
+ #include <ngx_http.h>
+ 
++#if (NGX_HTTP_UPSTREAM_CHECK)
++#include "ngx_http_upstream_check_module.h"
++#endif
+ 
+ typedef struct {
+     uint32_t                            hash;
+@@ -240,6 +243,15 @@ ngx_http_upstream_get_hash_peer(ngx_peer
+             goto next;
+         }
+ 
++#if (NGX_HTTP_UPSTREAM_CHECK)
++        ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0,
++            "get hash peer, check_index: %ui",
++             peer->check_index);
++        if (ngx_http_upstream_check_peer_down(peer->check_index)) {
++            goto next;
++        }
++#endif
++
+         if (peer->max_fails
+             && peer->fails >= peer->max_fails
+             && now - peer->checked <= peer->fail_timeout)
+@@ -516,6 +528,15 @@ ngx_http_upstream_get_chash_peer(ngx_pee
+                 continue;
+             }
+ 
++#if (NGX_HTTP_UPSTREAM_CHECK)
++        ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0,
++            "get consistent_hash peer, check_index: %ui",
++             peer->check_index);
++        if (ngx_http_upstream_check_peer_down(peer->check_index)) {
++            continue;
++        }
++#endif
++
+             if (peer->server.len != server->len
+                 || ngx_strncmp(peer->server.data, server->data, server->len)
+                    != 0)

Added: head/www/nginx/files/extra-patch-src-http-modules-ngx_http_upstream_ip_hash_module.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/www/nginx/files/extra-patch-src-http-modules-ngx_http_upstream_ip_hash_module.c	Wed Apr 13 01:20:18 2016	(r413165)
@@ -0,0 +1,28 @@
+--- src/http/modules/ngx_http_upstream_ip_hash_module.c.orig	2016-01-26 14:39:32 UTC
++++ src/http/modules/ngx_http_upstream_ip_hash_module.c
+@@ -9,6 +9,9 @@
+ #include <ngx_core.h>
+ #include <ngx_http.h>
+ 
++#if (NGX_HTTP_UPSTREAM_CHECK)
++#include "ngx_http_upstream_check_module.h"
++#endif
+ 
+ typedef struct {
+     /* the round robin data must be first */
+@@ -212,6 +215,15 @@ ngx_http_upstream_get_ip_hash_peer(ngx_p
+             goto next_try;
+         }
+ 
++#if (NGX_HTTP_UPSTREAM_CHECK)
++        ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0,
++            "get ip_hash peer, check_index: %ui",
++             peer->check_index);
++        if (ngx_http_upstream_check_peer_down(peer->check_index)) {
++            goto next_try;
++        }
++#endif
++
+         if (peer->max_fails
+             && peer->fails >= peer->max_fails
+             && now - peer->checked <= peer->fail_timeout)

Added: head/www/nginx/files/extra-patch-src-http-modules-ngx_http_upstream_least_conn_module.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/www/nginx/files/extra-patch-src-http-modules-ngx_http_upstream_least_conn_module.c	Wed Apr 13 01:20:18 2016	(r413165)
@@ -0,0 +1,46 @@
+--- src/http/modules/ngx_http_upstream_least_conn_module.c.orig	2016-01-26 14:39:32 UTC
++++ src/http/modules/ngx_http_upstream_least_conn_module.c
+@@ -9,6 +9,9 @@
+ #include <ngx_core.h>
+ #include <ngx_http.h>
+ 
++#if (NGX_HTTP_UPSTREAM_CHECK)
++#include "ngx_http_upstream_check_module.h"
++#endif
+ 
+ typedef struct {
+     ngx_uint_t                        *conns;
+@@ -203,6 +206,16 @@ ngx_http_upstream_get_least_conn_peer(ng
+             continue;
+         }
+ 
++#if (NGX_HTTP_UPSTREAM_CHECK)
++        ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0,
++                "get least_conn peer, check_index: %ui",
++                peer->check_index);
++
++        if (ngx_http_upstream_check_peer_down(peer->check_index)) {
++            continue;
++        }
++#endif
++
+         if (peer->max_fails
+             && peer->fails >= peer->max_fails
+             && now - peer->checked <= peer->fail_timeout)
+@@ -256,6 +269,16 @@ ngx_http_upstream_get_least_conn_peer(ng
+                 continue;
+             }
+ 
++#if (NGX_HTTP_UPSTREAM_CHECK)
++            ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0,
++                    "get least_conn peer, check_index: %ui",
++                    peer->check_index);
++
++            if (ngx_http_upstream_check_peer_down(peer->check_index)) {
++                continue;
++            }
++#endif
++
+             if (lcp->conns[i] * best->weight != lcp->conns[p] * peer->weight) {
+                 continue;
+             }

Added: head/www/nginx/files/extra-patch-src-http-ngx_http_upstream_round_robin.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/www/nginx/files/extra-patch-src-http-ngx_http_upstream_round_robin.c	Wed Apr 13 01:20:18 2016	(r413165)
@@ -0,0 +1,100 @@
+--- src/http/ngx_http_upstream_round_robin.c.orig	2016-01-26 14:39:33 UTC
++++ src/http/ngx_http_upstream_round_robin.c
+@@ -9,6 +9,9 @@
+ #include <ngx_core.h>
+ #include <ngx_http.h>
+ 
++#if (NGX_HTTP_UPSTREAM_CHECK)
++#include "ngx_http_upstream_check_module.h"
++#endif
+ 
+ #define ngx_http_upstream_tries(p) ((p)->number                               \
+                                     + ((p)->next ? (p)->next->number : 0))
+@@ -92,6 +95,14 @@ ngx_http_upstream_init_round_robin(ngx_c
+                 peer[n].fail_timeout = server[i].fail_timeout;
+                 peer[n].down = server[i].down;
+                 peer[n].server = server[i].name;
++#if (NGX_HTTP_UPSTREAM_CHECK)
++                if (!server[i].down) {
++                    peers->peer[n].check_index =
++                        ngx_http_upstream_check_add_peer(cf, us, &server[i].addrs[j]);
++                } else {
++                    peers->peer[n].check_index = (ngx_uint_t) NGX_ERROR;
++                }
++#endif
+                 n++;
+             }
+         }
+@@ -148,6 +159,15 @@ ngx_http_upstream_init_round_robin(ngx_c
+                 peer[n].fail_timeout = server[i].fail_timeout;
+                 peer[n].down = server[i].down;
+                 peer[n].server = server[i].name;
++#if (NGX_HTTP_UPSTREAM_CHECK)
++                if (!server[i].down) {
++                    backup->peer[n].check_index =
++                        ngx_http_upstream_check_add_peer(cf, us, &server[i].addrs[j]);
++                }
++                else {
++                    backup->peer[n].check_index = (ngx_uint_t) NGX_ERROR;
++                }
++#endif
+                 n++;
+             }
+         }
+@@ -207,6 +227,9 @@ ngx_http_upstream_init_round_robin(ngx_c
+         peer[i].current_weight = 0;
+         peer[i].max_fails = 1;
+         peer[i].fail_timeout = 10;
++#if (NGX_HTTP_UPSTREAM_CHECK)
++        peers->peer[i].check_index = (ngx_uint_t) NGX_ERROR;
++#endif
+     }
+ 
+     us->peer.data = peers;
+@@ -316,7 +339,9 @@ ngx_http_upstream_create_round_robin_pee
+         peer[0].current_weight = 0;
+         peer[0].max_fails = 1;
+         peer[0].fail_timeout = 10;
+-
++#if (NGX_HTTP_UPSTREAM_CHECK)
++        peers->peer[0].check_index = (ngx_uint_t) NGX_ERROR;
++#endif
+     } else {
+ 
+         for (i = 0; i < ur->naddrs; i++) {
+@@ -356,6 +381,9 @@ ngx_http_upstream_create_round_robin_pee
+             peer[i].current_weight = 0;
+             peer[i].max_fails = 1;
+             peer[i].fail_timeout = 10;
++#if (NGX_HTTP_UPSTREAM_CHECK)
++            peers->peer[i].check_index = (ngx_uint_t) NGX_ERROR;
++#endif
+         }
+     }
+ 
+@@ -415,6 +443,12 @@ ngx_http_upstream_get_round_robin_peer(n
+             goto failed;
+         }
+ 
++#if (NGX_HTTP_UPSTREAM_CHECK)
++        if (ngx_http_upstream_check_peer_down(peer->check_index)) {
++            goto failed;
++        }
++#endif
++
+     } else {
+ 
+         /* there are several peers */
+@@ -507,6 +541,12 @@ ngx_http_upstream_get_peer(ngx_http_upst
+             continue;
+         }
+ 
++#if (NGX_HTTP_UPSTREAM_CHECK)
++        if (ngx_http_upstream_check_peer_down(peer->check_index)) {
++            continue;
++        }
++#endif
++
+         if (peer->max_fails
+             && peer->fails >= peer->max_fails
+             && now - peer->checked <= peer->fail_timeout)

Added: head/www/nginx/files/extra-patch-src-http-ngx_http_upstream_round_robin.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/www/nginx/files/extra-patch-src-http-ngx_http_upstream_round_robin.h	Wed Apr 13 01:20:18 2016	(r413165)
@@ -0,0 +1,13 @@
+--- src/http/ngx_http_upstream_round_robin.h.orig	2016-01-26 14:39:33 UTC
++++ src/http/ngx_http_upstream_round_robin.h
+@@ -31,6 +31,10 @@ typedef struct {
+     ngx_uint_t                      max_fails;
+     time_t                          fail_timeout;
+ 
++#if (NGX_HTTP_UPSTREAM_CHECK)
++    ngx_uint_t                      check_index;
++#endif
++
+     ngx_uint_t                      down;          /* unsigned  down:1; */
+ 
+ #if (NGX_HTTP_SSL)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201604130120.u3D1KITn023362>