Skip to content

Commit dc881ee

Browse files
ArnoZellerRealCLanger
authored andcommitted
8354530: AIX: sporadic unexpected errno when calling setsockopt in Net.joinOrDrop
Reviewed-by: alanb, clanger
1 parent 5e50a58 commit dc881ee

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
@@ -671,6 +671,16 @@ Java_sun_nio_ch_Net_joinOrDrop4(JNIEnv *env, jobject this, jboolean join, jobjec
671671
n = setsockopt(fdval(env,fdo), IPPROTO_IP, opt, optval, optlen);
672672
}
673673
#endif
674+
#ifdef _AIX
675+
// workaround AIX bug where IP_ADD_MEMBERSHIP fails intermittently
676+
if (n < 0 && errno == EAGAIN) {
677+
int countdown = 3;
678+
while (n < 0 && errno == EAGAIN && countdown > 0) {
679+
n = setsockopt(fdval(env,fdo), IPPROTO_IP, opt, optval, optlen);
680+
countdown--;
681+
}
682+
}
683+
#endif
674684

675685
if (n < 0) {
676686
if (join && (errno == ENOPROTOOPT || errno == EOPNOTSUPP))

0 commit comments

Comments
 (0)