# HG changeset patch # User alanb # Date 1584758487 25200 # Fri Mar 20 19:41:27 2020 -0700 # Node ID 8c8d2ff4f2281582d1c456f72e342805a805ee4b # Parent b66b0a5c973b20080b6281767549c6a260c1dd77 8044365: (dc) MulticastSendReceiveTests.java failing with ENOMEM when joining group (OS X 10.9) Reviewed-by: alanb, vtewari, dfuchs diff --git a/src/solaris/native/sun/nio/ch/Net.c b/src/solaris/native/sun/nio/ch/Net.c --- a/src/solaris/native/sun/nio/ch/Net.c +++ b/src/solaris/native/sun/nio/ch/Net.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -568,6 +568,13 @@ } n = setsockopt(fdval(env,fdo), IPPROTO_IP, opt, optval, optlen); +#ifdef __APPLE__ + // workaround macOS bug where IP_ADD_MEMBERSHIP fails intermittently + if (n < 0 && errno == ENOMEM) { + n = setsockopt(fdval(env,fdo), IPPROTO_IP, opt, optval, optlen); + } +#endif + if (n < 0) { if (join && (errno == ENOPROTOOPT || errno == EOPNOTSUPP)) return IOS_UNAVAILABLE; @@ -639,6 +646,13 @@ } n = setsockopt(fdval(env,fdo), IPPROTO_IPV6, opt, optval, optlen); +#ifdef __APPLE__ + // workaround macOS bug where IPV6_ADD_MEMBERSHIP fails intermittently + if (n < 0 && errno == ENOMEM) { + n = setsockopt(fdval(env,fdo), IPPROTO_IPV6, opt, optval, optlen); + } +#endif + if (n < 0) { if (join && (errno == ENOPROTOOPT || errno == EOPNOTSUPP)) return IOS_UNAVAILABLE;