Skip to content

Commit

Permalink
native: Workaround for polling datagram sockets on z/OS
Browse files Browse the repository at this point in the history
Polling datagram sockets on z/OS with an infinite timeout fails.

Use a timeout of 1s.
  • Loading branch information
kohlschuetter committed Jul 28, 2023
1 parent 309c15f commit 013df5f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
*/
package org.newsclub.net.unix.domain;

import static org.junit.jupiter.api.Assumptions.assumeFalse;

import org.junit.jupiter.api.Test;
import org.newsclub.net.unix.AFSocketCapability;
import org.newsclub.net.unix.AFSocketCapabilityRequirement;

Expand All @@ -37,20 +34,4 @@ public ThroughputTest() {
protected String stbTestType() {
return "AF_UNIX";
}

@Override
@Test
public void testDatagramChannelNonBlocking() throws Exception {
assumeFalse("z/OS".equals(System.getProperty("os.name", "")),
"KNOWN ISSUE: Test may fail on z/OS");
super.testDatagramChannelNonBlocking();
}

@Override
@Test
public void testDatagramChannelNonBlockingDirect() throws Exception {
assumeFalse("z/OS".equals(System.getProperty("os.name", "")),
"KNOWN ISSUE: Test may fail on z/OS");
super.testDatagramChannelNonBlockingDirect();
}
}
7 changes: 7 additions & 0 deletions junixsocket-native/src/main/c/polling.c
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,13 @@ JNIEXPORT jint JNICALL Java_org_newsclub_net_unix_NativeUnixSocket_poll
}
}

#if __TOS_MVS__
if(timeout == -1) {
// polling on datagram sockets hangs if we don't set a short timeout on z/OS
timeout = 1000;
}
#endif

#if defined(_OS400)
if(timeout == -1) {
// unclear why, but a timeout of -1 returns EINVAL
Expand Down

0 comments on commit 013df5f

Please sign in to comment.