mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-29 21:08:24 +00:00
Setting off IPV6_V6ONLY for USE_IPV6 case
This commit is contained in:
1 parent
4505b00733
commit
fb5e2b8c2f
1 file changed
+7
@@ -4474,6 +4474,9 @@ static int parse_port_string(const struct vec *vec, struct socket *so) {
|
|||||||
static int set_ports_option(struct mg_context *ctx) {
|
static int set_ports_option(struct mg_context *ctx) {
|
||||||
const char *list = ctx->config[LISTENING_PORTS];
|
const char *list = ctx->config[LISTENING_PORTS];
|
||||||
int on = 1, success = 1;
|
int on = 1, success = 1;
|
||||||
|
#if defined(USE_IPV6)
|
||||||
|
int off = 0;
|
||||||
|
#endif
|
||||||
struct vec vec;
|
struct vec vec;
|
||||||
struct socket so;
|
struct socket so;
|
||||||
|
|
||||||
@@ -4491,6 +4494,10 @@ static int set_ports_option(struct mg_context *ctx) {
|
|||||||
// broadcast UDP sockets
|
// broadcast UDP sockets
|
||||||
setsockopt(so.sock, SOL_SOCKET, SO_REUSEADDR,
|
setsockopt(so.sock, SOL_SOCKET, SO_REUSEADDR,
|
||||||
(void *) &on, sizeof(on)) != 0 ||
|
(void *) &on, sizeof(on)) != 0 ||
|
||||||
|
#if defined(USE_IPV6)
|
||||||
|
setsockopt(so.sock, IPPROTO_IPV6, IPV6_V6ONLY, (void *) &off,
|
||||||
|
sizeof(off)) != 0 ||
|
||||||
|
#endif
|
||||||
bind(so.sock, &so.lsa.sa, sizeof(so.lsa)) != 0 ||
|
bind(so.sock, &so.lsa.sa, sizeof(so.lsa)) != 0 ||
|
||||||
listen(so.sock, SOMAXCONN) != 0) {
|
listen(so.sock, SOMAXCONN) != 0) {
|
||||||
cry(fc(ctx), "%s: cannot bind to %.*s: %s", __func__,
|
cry(fc(ctx), "%s: cannot bind to %.*s: %s", __func__,
|
||||||
|
|||||||
Reference in new issue
Block a user