Skip to content

Commit 56972c6

Browse files
ArnoZellerPaul Hohensee
authored andcommitted
8354530: AIX: sporadic unexpected errno when calling setsockopt in Net.joinOrDrop
Backport-of: dc881ee36900bc12bea9616a6078a1f3266c183d
1 parent f5c4708 commit 56972c6

File tree

1 file changed

+11
-1
lines changed
  • src/java.base/unix/native/libnio/ch

1 file changed

+11
-1
lines changed

src/java.base/unix/native/libnio/ch/Net.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2001, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -655,6 +655,16 @@ Java_sun_nio_ch_Net_joinOrDrop4(JNIEnv *env, jobject this, jboolean join, jobjec
655655
n = setsockopt(fdval(env,fdo), IPPROTO_IP, opt, optval, optlen);
656656
}
657657
#endif
658+
#ifdef _AIX
659+
// workaround AIX bug where IP_ADD_MEMBERSHIP fails intermittently
660+
if (n < 0 && errno == EAGAIN) {
661+
int countdown = 3;
662+
while (n < 0 && errno == EAGAIN && countdown > 0) {
663+
n = setsockopt(fdval(env,fdo), IPPROTO_IP, opt, optval, optlen);
664+
countdown--;
665+
}
666+
}
667+
#endif
658668

659669
if (n < 0) {
660670
if (join && (errno == ENOPROTOOPT || errno == EOPNOTSUPP))

0 commit comments

Comments
 (0)