[nginx] Perl: pass additional linker options to perl module.

2016-09-22 Thread Konstantin Pavlov
details:   http://hg.nginx.org/nginx/rev/0d2956dfc4e6
branches:  
changeset: 6700:0d2956dfc4e6
user:  Konstantin Pavlov 
date:  Tue Sep 20 22:11:23 2016 +0300
description:
Perl: pass additional linker options to perl module.

Previously flags passed by --with-ld-opt were not used when building perl
module, which meant hardening flags provided by package build systems were not
applied.

diffstat:

 auto/lib/perl/conf|  4 +++-
 auto/lib/perl/make|  1 +
 auto/make |  1 +
 src/http/modules/perl/Makefile.PL |  2 ++
 4 files changed, 7 insertions(+), 1 deletions(-)

diffs (49 lines):

diff -r 9cf2dce316e5 -r 0d2956dfc4e6 auto/lib/perl/conf
--- a/auto/lib/perl/confTue Sep 20 15:07:16 2016 +0300
+++ b/auto/lib/perl/confTue Sep 20 22:11:23 2016 +0300
@@ -28,8 +28,10 @@ if test -n "$NGX_PERL_VER"; then
 exit 1;
 fi
 
+NGX_PM_CFLAGS=`$NGX_PERL -MExtUtils::Embed -e ccopts`
+NGX_PM_LDFLAGS=`$NGX_PERL -MConfig -e 'print $Config{lddlflags}'`
+
 NGX_PERL_CFLAGS="$CFLAGS `$NGX_PERL -MExtUtils::Embed -e ccopts`"
-NGX_PM_CFLAGS=`$NGX_PERL -MExtUtils::Embed -e ccopts`
 
 # gcc 4.1/4.2 warn about unused values in pTHX_
 NGX_PERL_CFLAGS=`echo $NGX_PERL_CFLAGS \
diff -r 9cf2dce316e5 -r 0d2956dfc4e6 auto/lib/perl/make
--- a/auto/lib/perl/makeTue Sep 20 15:07:16 2016 +0300
+++ b/auto/lib/perl/makeTue Sep 20 22:11:23 2016 +0300
@@ -35,6 +35,7 @@ cat << END  
 
cd $NGX_OBJS/src/http/modules/perl \\
&& NGX_PM_CFLAGS="\$(NGX_PM_CFLAGS) -g $NGX_CC_OPT" \\
+   NGX_PM_LDFLAGS="$NGX_LD_OPT \$(NGX_PM_LDFLAGS)" \\
NGX_INCS="$CORE_INCS $NGX_OBJS $HTTP_INCS" \\
NGX_DEPS="\$(CORE_DEPS) \$(HTTP_DEPS)" \\
$NGX_PERL Makefile.PL \\
diff -r 9cf2dce316e5 -r 0d2956dfc4e6 auto/make
--- a/auto/make Tue Sep 20 15:07:16 2016 +0300
+++ b/auto/make Tue Sep 20 22:11:23 2016 +0300
@@ -31,6 +31,7 @@ END
 if test -n "$NGX_PERL_CFLAGS"; then
 echo NGX_PERL_CFLAGS = $NGX_PERL_CFLAGS   >> $NGX_MAKEFILE
 echo NGX_PM_CFLAGS = $NGX_PM_CFLAGS   >> $NGX_MAKEFILE
+echo NGX_PM_LDFLAGS = $NGX_PM_LDFLAGS >> $NGX_MAKEFILE
 fi
 
 
diff -r 9cf2dce316e5 -r 0d2956dfc4e6 src/http/modules/perl/Makefile.PL
--- a/src/http/modules/perl/Makefile.PL Tue Sep 20 15:07:16 2016 +0300
+++ b/src/http/modules/perl/Makefile.PL Tue Sep 20 22:11:23 2016 +0300
@@ -16,6 +16,8 @@ WriteMakefile(
 CCFLAGS   => "$ENV{NGX_PM_CFLAGS}",
 OPTIMIZE  => '-O',
 
+LDDLFLAGS => "$ENV{NGX_PM_LDFLAGS}",
+
 INC   => join(" ", map {
  m#^/# ? "-I $_" : "-I ../../../../../$_"
  } (split /\s+/, $ENV{NGX_INCS})),

___
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel


[nginx] Upstream: style, ngx_http_upstream_rr_peer_t.next moved.

2016-09-22 Thread Maxim Dounin
details:   http://hg.nginx.org/nginx/rev/d69964eb8335
branches:  
changeset: 6701:d69964eb8335
user:  Maxim Dounin 
date:  Mon Jul 25 16:23:35 2016 +0300
description:
Upstream: style, ngx_http_upstream_rr_peer_t.next moved.

diffstat:

 src/http/ngx_http_upstream_round_robin.h |  4 ++--
 src/stream/ngx_stream_upstream_round_robin.h |  4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diffs (34 lines):

diff --git a/src/http/ngx_http_upstream_round_robin.h 
b/src/http/ngx_http_upstream_round_robin.h
--- a/src/http/ngx_http_upstream_round_robin.h
+++ b/src/http/ngx_http_upstream_round_robin.h
@@ -42,11 +42,11 @@ struct ngx_http_upstream_rr_peer_s {
 int ssl_session_len;
 #endif
 
-ngx_http_upstream_rr_peer_t*next;
-
 #if (NGX_HTTP_UPSTREAM_ZONE)
 ngx_atomic_tlock;
 #endif
+
+ngx_http_upstream_rr_peer_t*next;
 };
 
 
diff --git a/src/stream/ngx_stream_upstream_round_robin.h 
b/src/stream/ngx_stream_upstream_round_robin.h
--- a/src/stream/ngx_stream_upstream_round_robin.h
+++ b/src/stream/ngx_stream_upstream_round_robin.h
@@ -42,11 +42,11 @@ struct ngx_stream_upstream_rr_peer_s {
 int  ssl_session_len;
 #endif
 
-ngx_stream_upstream_rr_peer_t   *next;
-
 #if (NGX_STREAM_UPSTREAM_ZONE)
 ngx_atomic_t lock;
 #endif
+
+ngx_stream_upstream_rr_peer_t   *next;
 };
 
 

___
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel


[nginx] Upstream: introduced u->upstream.

2016-09-22 Thread Maxim Dounin
details:   http://hg.nginx.org/nginx/rev/edcd9303a4d3
branches:  
changeset: 6703:edcd9303a4d3
user:  Maxim Dounin 
date:  Thu Sep 22 19:32:26 2016 +0300
description:
Upstream: introduced u->upstream.

It holds upstream{} block configuration, including ones selected via
run-time lookup using variables.

diffstat:

 src/http/ngx_http_upstream.c |  2 ++
 src/http/ngx_http_upstream.h |  1 +
 src/stream/ngx_stream_proxy_module.c |  2 ++
 src/stream/ngx_stream_upstream.h |  1 +
 4 files changed, 6 insertions(+), 0 deletions(-)

diffs (46 lines):

diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c
--- a/src/http/ngx_http_upstream.c
+++ b/src/http/ngx_http_upstream.c
@@ -748,6 +748,8 @@ found:
 return;
 }
 
+u->upstream = uscf;
+
 #if (NGX_HTTP_SSL)
 u->ssl_name = uscf->host;
 #endif
diff --git a/src/http/ngx_http_upstream.h b/src/http/ngx_http_upstream.h
--- a/src/http/ngx_http_upstream.h
+++ b/src/http/ngx_http_upstream.h
@@ -313,6 +313,7 @@ struct ngx_http_upstream_s {
 ngx_chain_writer_ctx_t   writer;
 
 ngx_http_upstream_conf_t*conf;
+ngx_http_upstream_srv_conf_t*upstream;
 #if (NGX_HTTP_CACHE)
 ngx_array_t *caches;
 #endif
diff --git a/src/stream/ngx_stream_proxy_module.c 
b/src/stream/ngx_stream_proxy_module.c
--- a/src/stream/ngx_stream_proxy_module.c
+++ b/src/stream/ngx_stream_proxy_module.c
@@ -521,6 +521,8 @@ found:
 return;
 }
 
+u->upstream = uscf;
+
 #if (NGX_STREAM_SSL)
 u->ssl_name = uscf->host;
 #endif
diff --git a/src/stream/ngx_stream_upstream.h b/src/stream/ngx_stream_upstream.h
--- a/src/stream/ngx_stream_upstream.h
+++ b/src/stream/ngx_stream_upstream.h
@@ -124,6 +124,7 @@ typedef struct {
 ngx_str_t  ssl_name;
 #endif
 
+ngx_stream_upstream_srv_conf_t*upstream;
 ngx_stream_upstream_resolved_t*resolved;
 ngx_stream_upstream_state_t   *state;
 unsigned   connected:1;

___
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel


[nginx] Upstream: style.

2016-09-22 Thread Maxim Dounin
details:   http://hg.nginx.org/nginx/rev/914d8a63dbad
branches:  
changeset: 6702:914d8a63dbad
user:  Maxim Dounin 
date:  Thu Sep 22 19:31:08 2016 +0300
description:
Upstream: style.

diffstat:

 src/http/modules/ngx_http_upstream_hash_module.c   |  1 -
 src/http/modules/ngx_http_upstream_least_conn_module.c |  1 -
 src/http/ngx_http_upstream_round_robin.c   |  1 -
 src/stream/ngx_stream_upstream_hash_module.c   |  1 -
 src/stream/ngx_stream_upstream_least_conn_module.c |  1 -
 src/stream/ngx_stream_upstream_round_robin.c   |  1 -
 6 files changed, 0 insertions(+), 6 deletions(-)

diffs (66 lines):

diff --git a/src/http/modules/ngx_http_upstream_hash_module.c 
b/src/http/modules/ngx_http_upstream_hash_module.c
--- a/src/http/modules/ngx_http_upstream_hash_module.c
+++ b/src/http/modules/ngx_http_upstream_hash_module.c
@@ -523,7 +523,6 @@ ngx_http_upstream_get_chash_peer(ngx_pee
  peer;
  peer = peer->next, i++)
 {
-
 n = i / (8 * sizeof(uintptr_t));
 m = (uintptr_t) 1 << i % (8 * sizeof(uintptr_t));
 
diff --git a/src/http/modules/ngx_http_upstream_least_conn_module.c 
b/src/http/modules/ngx_http_upstream_least_conn_module.c
--- a/src/http/modules/ngx_http_upstream_least_conn_module.c
+++ b/src/http/modules/ngx_http_upstream_least_conn_module.c
@@ -136,7 +136,6 @@ ngx_http_upstream_get_least_conn_peer(ng
  peer;
  peer = peer->next, i++)
 {
-
 n = i / (8 * sizeof(uintptr_t));
 m = (uintptr_t) 1 << i % (8 * sizeof(uintptr_t));
 
diff --git a/src/http/ngx_http_upstream_round_robin.c 
b/src/http/ngx_http_upstream_round_robin.c
--- a/src/http/ngx_http_upstream_round_robin.c
+++ b/src/http/ngx_http_upstream_round_robin.c
@@ -521,7 +521,6 @@ ngx_http_upstream_get_peer(ngx_http_upst
  peer;
  peer = peer->next, i++)
 {
-
 n = i / (8 * sizeof(uintptr_t));
 m = (uintptr_t) 1 << i % (8 * sizeof(uintptr_t));
 
diff --git a/src/stream/ngx_stream_upstream_hash_module.c 
b/src/stream/ngx_stream_upstream_hash_module.c
--- a/src/stream/ngx_stream_upstream_hash_module.c
+++ b/src/stream/ngx_stream_upstream_hash_module.c
@@ -524,7 +524,6 @@ ngx_stream_upstream_get_chash_peer(ngx_p
  peer;
  peer = peer->next, i++)
 {
-
 n = i / (8 * sizeof(uintptr_t));
 m = (uintptr_t) 1 << i % (8 * sizeof(uintptr_t));
 
diff --git a/src/stream/ngx_stream_upstream_least_conn_module.c 
b/src/stream/ngx_stream_upstream_least_conn_module.c
--- a/src/stream/ngx_stream_upstream_least_conn_module.c
+++ b/src/stream/ngx_stream_upstream_least_conn_module.c
@@ -132,7 +132,6 @@ ngx_stream_upstream_get_least_conn_peer(
  peer;
  peer = peer->next, i++)
 {
-
 n = i / (8 * sizeof(uintptr_t));
 m = (uintptr_t) 1 << i % (8 * sizeof(uintptr_t));
 
diff --git a/src/stream/ngx_stream_upstream_round_robin.c 
b/src/stream/ngx_stream_upstream_round_robin.c
--- a/src/stream/ngx_stream_upstream_round_robin.c
+++ b/src/stream/ngx_stream_upstream_round_robin.c
@@ -527,7 +527,6 @@ ngx_stream_upstream_get_peer(ngx_stream_
  peer;
  peer = peer->next, i++)
 {
-
 n = i / (8 * sizeof(uintptr_t));
 m = (uintptr_t) 1 << i % (8 * sizeof(uintptr_t));
 

___
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel


[nginx] Upstream: removed the quick recovery mechanism.

2016-09-22 Thread Maxim Dounin
details:   http://hg.nginx.org/nginx/rev/a44ba757851d
branches:  
changeset: 6704:a44ba757851d
user:  Ruslan Ermilov 
date:  Thu Sep 22 19:32:45 2016 +0300
description:
Upstream: removed the quick recovery mechanism.

Its usefulness it questionable, and it interacts badly with max_conns.

diffstat:

 src/http/modules/ngx_http_upstream_least_conn_module.c |  6 --
 src/http/ngx_http_upstream_round_robin.c   |  6 --
 src/stream/ngx_stream_upstream_least_conn_module.c |  6 --
 src/stream/ngx_stream_upstream_round_robin.c   |  6 --
 4 files changed, 0 insertions(+), 24 deletions(-)

diffs (64 lines):

diff --git a/src/http/modules/ngx_http_upstream_least_conn_module.c 
b/src/http/modules/ngx_http_upstream_least_conn_module.c
--- a/src/http/modules/ngx_http_upstream_least_conn_module.c
+++ b/src/http/modules/ngx_http_upstream_least_conn_module.c
@@ -272,12 +272,6 @@ failed:
 ngx_http_upstream_rr_peers_wlock(peers);
 }
 
-/* all peers failed, mark them as live for quick recovery */
-
-for (peer = peers->peer; peer; peer = peer->next) {
-peer->fails = 0;
-}
-
 ngx_http_upstream_rr_peers_unlock(peers);
 
 pc->name = peers->name;
diff --git a/src/http/ngx_http_upstream_round_robin.c 
b/src/http/ngx_http_upstream_round_robin.c
--- a/src/http/ngx_http_upstream_round_robin.c
+++ b/src/http/ngx_http_upstream_round_robin.c
@@ -485,12 +485,6 @@ failed:
 ngx_http_upstream_rr_peers_wlock(peers);
 }
 
-/* all peers failed, mark them as live for quick recovery */
-
-for (peer = peers->peer; peer; peer = peer->next) {
-peer->fails = 0;
-}
-
 ngx_http_upstream_rr_peers_unlock(peers);
 
 pc->name = peers->name;
diff --git a/src/stream/ngx_stream_upstream_least_conn_module.c 
b/src/stream/ngx_stream_upstream_least_conn_module.c
--- a/src/stream/ngx_stream_upstream_least_conn_module.c
+++ b/src/stream/ngx_stream_upstream_least_conn_module.c
@@ -268,12 +268,6 @@ failed:
 ngx_stream_upstream_rr_peers_wlock(peers);
 }
 
-/* all peers failed, mark them as live for quick recovery */
-
-for (peer = peers->peer; peer; peer = peer->next) {
-peer->fails = 0;
-}
-
 ngx_stream_upstream_rr_peers_unlock(peers);
 
 pc->name = peers->name;
diff --git a/src/stream/ngx_stream_upstream_round_robin.c 
b/src/stream/ngx_stream_upstream_round_robin.c
--- a/src/stream/ngx_stream_upstream_round_robin.c
+++ b/src/stream/ngx_stream_upstream_round_robin.c
@@ -491,12 +491,6 @@ failed:
 ngx_stream_upstream_rr_peers_wlock(peers);
 }
 
-/* all peers failed, mark them as live for quick recovery */
-
-for (peer = peers->peer; peer; peer = peer->next) {
-peer->fails = 0;
-}
-
 ngx_stream_upstream_rr_peers_unlock(peers);
 
 pc->name = peers->name;

___
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel


[nginx] Upstream: max_conns.

2016-09-22 Thread Maxim Dounin
details:   http://hg.nginx.org/nginx/rev/29bf0dbc0a77
branches:  
changeset: 6705:29bf0dbc0a77
user:  Ruslan Ermilov 
date:  Thu Sep 22 19:32:47 2016 +0300
description:
Upstream: max_conns.

diffstat:

 src/http/modules/ngx_http_upstream_hash_module.c   |   9 
 src/http/modules/ngx_http_upstream_ip_hash_module.c|   5 
 src/http/modules/ngx_http_upstream_least_conn_module.c |   9 
 src/http/ngx_http_upstream.c   |  20 +-
 src/http/ngx_http_upstream.h   |   2 +
 src/http/ngx_http_upstream_round_robin.c   |  13 +++
 src/http/ngx_http_upstream_round_robin.h   |   1 +
 src/stream/ngx_stream_upstream.c   |  20 +-
 src/stream/ngx_stream_upstream.h   |   2 +
 src/stream/ngx_stream_upstream_hash_module.c   |   9 
 src/stream/ngx_stream_upstream_least_conn_module.c |   9 
 src/stream/ngx_stream_upstream_round_robin.c   |  11 +
 src/stream/ngx_stream_upstream_round_robin.h   |   1 +
 13 files changed, 109 insertions(+), 2 deletions(-)

diffs (444 lines):

diff --git a/src/http/modules/ngx_http_upstream_hash_module.c 
b/src/http/modules/ngx_http_upstream_hash_module.c
--- a/src/http/modules/ngx_http_upstream_hash_module.c
+++ b/src/http/modules/ngx_http_upstream_hash_module.c
@@ -242,6 +242,10 @@ ngx_http_upstream_get_hash_peer(ngx_peer
 goto next;
 }
 
+if (peer->max_conns && peer->conns >= peer->max_conns) {
+goto next;
+}
+
 break;
 
 next:
@@ -548,6 +552,10 @@ ngx_http_upstream_get_chash_peer(ngx_pee
 continue;
 }
 
+if (peer->max_conns && peer->conns >= peer->max_conns) {
+continue;
+}
+
 peer->current_weight += peer->effective_weight;
 total += peer->effective_weight;
 
@@ -647,6 +655,7 @@ ngx_http_upstream_hash(ngx_conf_t *cf, n
 
 uscf->flags = NGX_HTTP_UPSTREAM_CREATE
   |NGX_HTTP_UPSTREAM_WEIGHT
+  |NGX_HTTP_UPSTREAM_MAX_CONNS
   |NGX_HTTP_UPSTREAM_MAX_FAILS
   |NGX_HTTP_UPSTREAM_FAIL_TIMEOUT
   |NGX_HTTP_UPSTREAM_DOWN;
diff --git a/src/http/modules/ngx_http_upstream_ip_hash_module.c 
b/src/http/modules/ngx_http_upstream_ip_hash_module.c
--- a/src/http/modules/ngx_http_upstream_ip_hash_module.c
+++ b/src/http/modules/ngx_http_upstream_ip_hash_module.c
@@ -212,6 +212,10 @@ ngx_http_upstream_get_ip_hash_peer(ngx_p
 goto next;
 }
 
+if (peer->max_conns && peer->conns >= peer->max_conns) {
+goto next;
+}
+
 break;
 
 next:
@@ -259,6 +263,7 @@ ngx_http_upstream_ip_hash(ngx_conf_t *cf
 
 uscf->flags = NGX_HTTP_UPSTREAM_CREATE
   |NGX_HTTP_UPSTREAM_WEIGHT
+  |NGX_HTTP_UPSTREAM_MAX_CONNS
   |NGX_HTTP_UPSTREAM_MAX_FAILS
   |NGX_HTTP_UPSTREAM_FAIL_TIMEOUT
   |NGX_HTTP_UPSTREAM_DOWN;
diff --git a/src/http/modules/ngx_http_upstream_least_conn_module.c 
b/src/http/modules/ngx_http_upstream_least_conn_module.c
--- a/src/http/modules/ngx_http_upstream_least_conn_module.c
+++ b/src/http/modules/ngx_http_upstream_least_conn_module.c
@@ -154,6 +154,10 @@ ngx_http_upstream_get_least_conn_peer(ng
 continue;
 }
 
+if (peer->max_conns && peer->conns >= peer->max_conns) {
+continue;
+}
+
 /*
  * select peer with least number of connections; if there are
  * multiple peers with the same number of connections, select
@@ -209,6 +213,10 @@ ngx_http_upstream_get_least_conn_peer(ng
 continue;
 }
 
+if (peer->max_conns && peer->conns >= peer->max_conns) {
+continue;
+}
+
 peer->current_weight += peer->effective_weight;
 total += peer->effective_weight;
 
@@ -296,6 +304,7 @@ ngx_http_upstream_least_conn(ngx_conf_t 
 
 uscf->flags = NGX_HTTP_UPSTREAM_CREATE
   |NGX_HTTP_UPSTREAM_WEIGHT
+  |NGX_HTTP_UPSTREAM_MAX_CONNS
   |NGX_HTTP_UPSTREAM_MAX_FAILS
   |NGX_HTTP_UPSTREAM_FAIL_TIMEOUT
   |NGX_HTTP_UPSTREAM_DOWN
diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c
--- a/src/http/ngx_http_upstream.c
+++ b/src/http/ngx_http_upstream.c
@@ -5444,6 +5444,7 @@ ngx_http_upstream(ngx_conf_t *cf, ngx_co
 
 uscf = ngx_http_upstream_add(cf, &u, NGX_HTTP_UPSTREAM_CREATE
  |NGX_HTTP_UPSTREAM_WEIGHT
+ |NGX_HTTP_UPSTREAM_MAX_CONNS
  |NGX_HTTP_UPSTREAM_MAX_FAILS
  |NGX_HTTP_UPSTREAM_FAIL_TIMEOUT