# HG changeset patch # User maxime <mu...@live.be> # Date 1715588655 -7200 # Mon May 13 10:24:15 2024 +0200 # Node ID dcadf0a3d97ff4d677440060290e9cda84c69ac7 # Parent 3d455e37abf870f79be26c36d6b1d9cad2c4dd16 Core: added socket protocol.
This patch updates the creation of listening sockets to use a new field of the `ngx_listening_s` structure. The `protocol` field can be used in conjunction with the `type` to specify the protocol to be used. Modules will then be able to specify a different protocol, e.g. IPPROTO_MPTCP. diff --git a/src/core/ngx_connection.c b/src/core/ngx_connection.c --- a/src/core/ngx_connection.c +++ b/src/core/ngx_connection.c @@ -487,7 +487,18 @@ ngx_open_listening_sockets(ngx_cycle_t * continue; } - s = ngx_socket(ls[i].sockaddr->sa_family, ls[i].type, 0); + s = (ngx_socket_t) -1; + if (ls[i].protocol > 0) { + s = ngx_socket(ls[i].sockaddr->sa_family, ls[i].type, + ls[i].protocol); + /* In case of error, retry with the default protocol */ + ngx_log_error(NGX_LOG_NOTICE, log, 0, + "socket(%d) failed, trying with 0", ls[i].protocol); + } + + if (s == (ngx_socket_t) -1) { + s = ngx_socket(ls[i].sockaddr->sa_family, ls[i].type, 0); + } if (s == (ngx_socket_t) -1) { ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno, diff --git a/src/core/ngx_connection.h b/src/core/ngx_connection.h --- a/src/core/ngx_connection.h +++ b/src/core/ngx_connection.h @@ -24,6 +24,7 @@ struct ngx_listening_s { ngx_str_t addr_text; int type; + int protocol; int backlog; int rcvbuf; -- nginx-devel mailing list nginx-devel@freenginx.org https://freenginx.org/mailman/listinfo/nginx-devel