aboutsummaryrefslogtreecommitdiff
path: root/src/stream/ngx_stream_core_module.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/stream/ngx_stream_core_module.c')
-rw-r--r--src/stream/ngx_stream_core_module.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/src/stream/ngx_stream_core_module.c b/src/stream/ngx_stream_core_module.c
index 0ecc448a4..ebc2b1c07 100644
--- a/src/stream/ngx_stream_core_module.c
+++ b/src/stream/ngx_stream_core_module.c
@@ -252,7 +252,7 @@ ngx_stream_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
in_port_t port;
ngx_str_t *value;
ngx_url_t u;
- ngx_uint_t i;
+ ngx_uint_t i, backlog;
struct sockaddr *sa;
struct sockaddr_in *sin;
ngx_stream_listen_t *ls;
@@ -343,6 +343,7 @@ ngx_stream_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
ls->socklen = u.socklen;
ls->backlog = NGX_LISTEN_BACKLOG;
+ ls->type = SOCK_STREAM;
ls->wildcard = u.wildcard;
ls->ctx = cf->ctx;
@@ -350,8 +351,17 @@ ngx_stream_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
ls->ipv6only = 1;
#endif
+ backlog = 0;
+
for (i = 2; i < cf->args->nelts; i++) {
+#if !(NGX_WIN32)
+ if (ngx_strcmp(value[i].data, "udp") == 0) {
+ ls->type = SOCK_DGRAM;
+ continue;
+ }
+#endif
+
if (ngx_strcmp(value[i].data, "bind") == 0) {
ls->bind = 1;
continue;
@@ -367,6 +377,8 @@ ngx_stream_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
return NGX_CONF_ERROR;
}
+ backlog = 1;
+
continue;
}
@@ -530,5 +542,21 @@ ngx_stream_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
return NGX_CONF_ERROR;
}
+ if (ls->type == SOCK_DGRAM) {
+ if (backlog) {
+ return "\"backlog\" parameter is incompatible with \"udp\"";
+ }
+
+#if (NGX_STREAM_SSL)
+ if (ls->ssl) {
+ return "\"ssl\" parameter is incompatible with \"udp\"";
+ }
+#endif
+
+ if (ls->so_keepalive) {
+ return "\"so_keepalive\" parameter is incompatible with \"udp\"";
+ }
+ }
+
return NGX_CONF_OK;
}