# HG changeset patch # User maxime <mu...@live.be> # Date 1713355365 -7200 # Wed Apr 17 14:02:45 2024 +0200 # Node ID b7cbe9281f9d6911fd40a894ebc4ac2d701d8fa4 # Parent 49dce50fad40bf09db81ca2a35983ecd7b740e43 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,9 +487,20 @@ 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, ngx_socket_n " %V failed", &ls[i].addr_text); return NGX_ERROR; 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@nginx.org https://mailman.nginx.org/mailman/listinfo/nginx-devel