Welcome! Log In Create A New Profile

Advanced

[nginx] Stream: port from NGINX+.

Ruslan Ermilov
April 20, 2015 08:18AM
details: http://hg.nginx.org/nginx/rev/61d7ae76647d
branches:
changeset: 6115:61d7ae76647d
user: Ruslan Ermilov <ru@nginx.com>
date: Mon Apr 20 13:05:11 2015 +0300
description:
Stream: port from NGINX+.

diffstat:

auto/make | 57 +
auto/modules | 36 +
auto/options | 24 +
auto/sources | 34 +
src/core/ngx_log.c | 2 +-
src/core/ngx_log.h | 3 +-
src/stream/ngx_stream.c | 557 ++++++++
src/stream/ngx_stream.h | 215 +++
src/stream/ngx_stream_core_module.c | 495 +++++++
src/stream/ngx_stream_handler.c | 296 ++++
src/stream/ngx_stream_proxy_module.c | 1288 ++++++++++++++++++++
src/stream/ngx_stream_ssl_module.c | 456 +++++++
src/stream/ngx_stream_ssl_module.h | 49 +
src/stream/ngx_stream_upstream.c | 462 +++++++
src/stream/ngx_stream_upstream.h | 103 +
src/stream/ngx_stream_upstream_hash_module.c | 657 ++++++++++
src/stream/ngx_stream_upstream_least_conn_module.c | 305 ++++
src/stream/ngx_stream_upstream_round_robin.c | 697 ++++++++++
src/stream/ngx_stream_upstream_round_robin.h | 138 ++
src/stream/ngx_stream_upstream_zone_module.c | 207 +++
20 files changed, 6079 insertions(+), 2 deletions(-)

diffs (truncated from 6239 to 300 lines):

diff -r 4a640716f4e2 -r 61d7ae76647d auto/make
--- a/auto/make Sun Apr 19 22:41:09 2015 +0300
+++ b/auto/make Mon Apr 20 13:05:11 2015 +0300
@@ -10,6 +10,7 @@ mkdir -p $NGX_OBJS/src/core $NGX_OBJS/sr
$NGX_OBJS/src/http $NGX_OBJS/src/http/modules \
$NGX_OBJS/src/http/modules/perl \
$NGX_OBJS/src/mail \
+ $NGX_OBJS/src/stream \
$NGX_OBJS/src/misc


@@ -121,6 +122,32 @@ END
fi


+# the stream dependences and include paths
+
+if [ $STREAM = YES ]; then
+
+ ngx_all_srcs="$ngx_all_srcs $STREAM_SRCS"
+
+ ngx_deps=`echo $STREAM_DEPS \
+ | sed -e "s/ *\([^ ][^ ]*\)/$ngx_regex_cont\1/g" \
+ -e "s/\//$ngx_regex_dirsep/g"`
+
+ ngx_incs=`echo $STREAM_INCS \
+ | sed -e "s/ *\([^ ][^ ]*\)/$ngx_regex_cont$ngx_include_opt\1/g" \
+ -e "s/\//$ngx_regex_dirsep/g"`
+
+ cat << END >> $NGX_MAKEFILE
+
+STREAM_DEPS = $ngx_deps
+
+
+STREAM_INCS = $ngx_include_opt$ngx_incs
+
+END
+
+fi
+
+
ngx_all_srcs="$ngx_all_srcs $NGX_MISC_SRCS"


@@ -306,6 +333,36 @@ END
fi


+# the stream sources
+
+if [ $STREAM = YES ]; then
+
+ if test -n "$NGX_PCH"; then
+ ngx_cc="\$(CC) $ngx_compile_opt \$(CFLAGS) $ngx_use_pch \$(ALL_INCS)"
+ else
+ ngx_cc="\$(CC) $ngx_compile_opt \$(CFLAGS) \$(CORE_INCS) \$(STREAM_INCS)"
+ fi
+
+ for ngx_src in $STREAM_SRCS
+ do
+ ngx_src=`echo $ngx_src | sed -e "s/\//$ngx_regex_dirsep/g"`
+ ngx_obj=`echo $ngx_src \
+ | sed -e "s#^\(.*\.\)cpp\\$#$ngx_objs_dir\1$ngx_objext#g" \
+ -e "s#^\(.*\.\)cc\\$#$ngx_objs_dir\1$ngx_objext#g" \
+ -e "s#^\(.*\.\)c\\$#$ngx_objs_dir\1$ngx_objext#g" \
+ -e "s#^\(.*\.\)S\\$#$ngx_objs_dir\1$ngx_objext#g"`
+
+ cat << END >> $NGX_MAKEFILE
+
+$ngx_obj: \$(CORE_DEPS) \$(STREAM_DEPS)$ngx_cont$ngx_src
+ $ngx_cc$ngx_tab$ngx_objout$ngx_obj$ngx_tab$ngx_src$NGX_AUX
+
+END
+ done
+
+fi
+
+
# the misc sources

if test -n "$NGX_MISC_SRCS"; then
diff -r 4a640716f4e2 -r 61d7ae76647d auto/modules
--- a/auto/modules Sun Apr 19 22:41:09 2015 +0300
+++ b/auto/modules Mon Apr 20 13:05:11 2015 +0300
@@ -435,6 +435,12 @@ if [ $MAIL_SSL = YES ]; then
fi


+if [ $STREAM_SSL = YES ]; then
+ have=NGX_STREAM_SSL . auto/have
+ USE_OPENSSL=YES
+fi
+
+
modules="$CORE_MODULES $EVENT_MODULES"


@@ -505,6 +511,36 @@ if [ $MAIL = YES ]; then
fi


+if [ $STREAM = YES ]; then
+ have=NGX_STREAM . auto/have
+ modules="$modules $STREAM_MODULES"
+
+ if [ $STREAM_SSL = YES ]; then
+ modules="$modules $STREAM_SSL_MODULE"
+ STREAM_DEPS="$STREAM_DEPS $STREAM_SSL_DEPS"
+ STREAM_SRCS="$STREAM_SRCS $STREAM_SSL_SRCS"
+ fi
+
+ if [ $STREAM_UPSTREAM_HASH = YES ]; then
+ modules="$modules $STREAM_UPSTREAM_HASH_MODULE"
+ STREAM_SRCS="$STREAM_SRCS $STREAM_UPSTREAM_HASH_SRCS"
+ fi
+
+ if [ $STREAM_UPSTREAM_LEAST_CONN = YES ]; then
+ modules="$modules $STREAM_UPSTREAM_LEAST_CONN_MODULE"
+ STREAM_SRCS="$STREAM_SRCS $STREAM_UPSTREAM_LEAST_CONN_SRCS"
+ fi
+
+ if [ $STREAM_UPSTREAM_ZONE = YES ]; then
+ have=NGX_STREAM_UPSTREAM_ZONE . auto/have
+ modules="$modules $STREAM_UPSTREAM_ZONE_MODULE"
+ STREAM_SRCS="$STREAM_SRCS $STREAM_UPSTREAM_ZONE_SRCS"
+ fi
+
+ NGX_ADDON_DEPS="$NGX_ADDON_DEPS \$(STREAM_DEPS)"
+fi
+
+
if [ $NGX_GOOGLE_PERFTOOLS = YES ]; then
modules="$modules $NGX_GOOGLE_PERFTOOLS_MODULE"
NGX_MISC_SRCS="$NGX_MISC_SRCS $NGX_GOOGLE_PERFTOOLS_SRCS"
diff -r 4a640716f4e2 -r 61d7ae76647d auto/options
--- a/auto/options Sun Apr 19 22:41:09 2015 +0300
+++ b/auto/options Mon Apr 20 13:05:11 2015 +0300
@@ -114,6 +114,12 @@ MAIL_POP3=YES
MAIL_IMAP=YES
MAIL_SMTP=YES

+STREAM=NO
+STREAM_SSL=NO
+STREAM_UPSTREAM_HASH=YES
+STREAM_UPSTREAM_LEAST_CONN=YES
+STREAM_UPSTREAM_ZONE=YES
+
NGX_ADDONS=

USE_PCRE=NO
@@ -275,6 +281,15 @@ use the \"--without-http_limit_conn_modu
--without-mail_imap_module) MAIL_IMAP=NO ;;
--without-mail_smtp_module) MAIL_SMTP=NO ;;

+ --with-stream) STREAM=YES ;;
+ --with-stream_ssl_module) STREAM_SSL=YES ;;
+ --without-stream_upstream_hash_module)
+ STREAM_UPSTREAM_HASH=NO ;;
+ --without-stream_upstream_least_conn_module)
+ STREAM_UPSTREAM_LEAST_CONN=NO ;;
+ --without-stream_upstream_zone_module)
+ STREAM_UPSTREAM_ZONE=NO ;;
+
--with-google_perftools_module) NGX_GOOGLE_PERFTOOLS=YES ;;
--with-cpp_test_module) NGX_CPP_TEST=YES ;;

@@ -436,6 +451,15 @@ cat << END
--without-mail_imap_module disable ngx_mail_imap_module
--without-mail_smtp_module disable ngx_mail_smtp_module

+ --with-stream enable TCP proxy module
+ --with-stream_ssl_module enable ngx_stream_ssl_module
+ --without-stream_upstream_hash_module
+ disable ngx_stream_upstream_hash_module
+ --without-stream_upstream_least_conn_module
+ disable ngx_stream_upstream_least_conn_module
+ --without-stream_upstream_zone_module
+ disable ngx_stream_upstream_zone_module
+
--with-google_perftools_module enable ngx_google_perftools_module
--with-cpp_test_module enable ngx_cpp_test_module

diff -r 4a640716f4e2 -r 61d7ae76647d auto/sources
--- a/auto/sources Sun Apr 19 22:41:09 2015 +0300
+++ b/auto/sources Mon Apr 20 13:05:11 2015 +0300
@@ -554,6 +554,40 @@ MAIL_AUTH_HTTP_SRCS="src/mail/ngx_mail_a
MAIL_PROXY_MODULE="ngx_mail_proxy_module"
MAIL_PROXY_SRCS="src/mail/ngx_mail_proxy_module.c"

+
+STREAM_INCS="src/stream"
+
+STREAM_DEPS="src/stream/ngx_stream.h \
+ src/stream/ngx_stream_upstream.h \
+ src/stream/ngx_stream_upstream_round_robin.h"
+
+STREAM_MODULES="ngx_stream_module \
+ ngx_stream_core_module \
+ ngx_stream_proxy_module \
+ ngx_stream_upstream_module"
+
+STREAM_SRCS="src/stream/ngx_stream.c \
+ src/stream/ngx_stream_handler.c \
+ src/stream/ngx_stream_core_module.c \
+ src/stream/ngx_stream_proxy_module.c \
+ src/stream/ngx_stream_upstream.c \
+ src/stream/ngx_stream_upstream_round_robin.c"
+
+STREAM_SSL_MODULE="ngx_stream_ssl_module"
+STREAM_SSL_DEPS="src/stream/ngx_stream_ssl_module.h"
+STREAM_SSL_SRCS="src/stream/ngx_stream_ssl_module.c"
+
+STREAM_UPSTREAM_HASH_MODULE=ngx_stream_upstream_hash_module
+STREAM_UPSTREAM_HASH_SRCS=src/stream/ngx_stream_upstream_hash_module.c
+
+STREAM_UPSTREAM_LEAST_CONN_MODULE=ngx_stream_upstream_least_conn_module
+STREAM_UPSTREAM_LEAST_CONN_SRCS=" \
+ src/stream/ngx_stream_upstream_least_conn_module.c"
+
+STREAM_UPSTREAM_ZONE_MODULE=ngx_stream_upstream_zone_module
+STREAM_UPSTREAM_ZONE_SRCS=src/stream/ngx_stream_upstream_zone_module.c
+
+
NGX_GOOGLE_PERFTOOLS_MODULE=ngx_google_perftools_module
NGX_GOOGLE_PERFTOOLS_SRCS=src/misc/ngx_google_perftools_module.c

diff -r 4a640716f4e2 -r 61d7ae76647d src/core/ngx_log.c
--- a/src/core/ngx_log.c Sun Apr 19 22:41:09 2015 +0300
+++ b/src/core/ngx_log.c Mon Apr 20 13:05:11 2015 +0300
@@ -86,7 +86,7 @@ static ngx_str_t err_levels[] = {

static const char *debug_levels[] = {
"debug_core", "debug_alloc", "debug_mutex", "debug_event",
- "debug_http", "debug_mail", "debug_mysql"
+ "debug_http", "debug_mail", "debug_mysql", "debug_stream"
};


diff -r 4a640716f4e2 -r 61d7ae76647d src/core/ngx_log.h
--- a/src/core/ngx_log.h Sun Apr 19 22:41:09 2015 +0300
+++ b/src/core/ngx_log.h Mon Apr 20 13:05:11 2015 +0300
@@ -30,6 +30,7 @@
#define NGX_LOG_DEBUG_HTTP 0x100
#define NGX_LOG_DEBUG_MAIL 0x200
#define NGX_LOG_DEBUG_MYSQL 0x400
+#define NGX_LOG_DEBUG_STREAM 0x800

/*
* do not forget to update debug_levels[] in src/core/ngx_log.c
@@ -37,7 +38,7 @@
*/

#define NGX_LOG_DEBUG_FIRST NGX_LOG_DEBUG_CORE
-#define NGX_LOG_DEBUG_LAST NGX_LOG_DEBUG_MYSQL
+#define NGX_LOG_DEBUG_LAST NGX_LOG_DEBUG_STREAM
#define NGX_LOG_DEBUG_CONNECTION 0x80000000
#define NGX_LOG_DEBUG_ALL 0x7ffffff0

diff -r 4a640716f4e2 -r 61d7ae76647d src/stream/ngx_stream.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/stream/ngx_stream.c Mon Apr 20 13:05:11 2015 +0300
@@ -0,0 +1,557 @@
+
+/*
+ * Copyright (C) Roman Arutyunyan
+ * Copyright (C) Nginx, Inc.
+ */
+
+
+#include <ngx_config.h>
+#include <ngx_core.h>
+#include <ngx_event.h>
+#include <ngx_stream.h>
+
+
+static char *ngx_stream_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
+static ngx_int_t ngx_stream_add_ports(ngx_conf_t *cf, ngx_array_t *ports,
+ ngx_stream_listen_t *listen);
+static char *ngx_stream_optimize_servers(ngx_conf_t *cf, ngx_array_t *ports);
+static ngx_int_t ngx_stream_add_addrs(ngx_conf_t *cf, ngx_stream_port_t *stport,
+ ngx_stream_conf_addr_t *addr);
+#if (NGX_HAVE_INET6)
+static ngx_int_t ngx_stream_add_addrs6(ngx_conf_t *cf,
+ ngx_stream_port_t *stport, ngx_stream_conf_addr_t *addr);
+#endif
+static ngx_int_t ngx_stream_cmp_conf_addrs(const void *one, const void *two);
+
+
+ngx_uint_t ngx_stream_max_module;
+
+
+static ngx_command_t ngx_stream_commands[] = {
+
+ { ngx_string("stream"),
+ NGX_MAIN_CONF|NGX_CONF_BLOCK|NGX_CONF_NOARGS,
+ ngx_stream_block,
+ 0,
+ 0,
+ NULL },
+

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[nginx] Stream: port from NGINX+.

Ruslan Ermilov 624 April 20, 2015 08:18AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 169
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready