Skip to content

Commit

Permalink
8211851: (ch) java/nio/channels/AsynchronousSocketChannel/StressLoopb…
Browse files Browse the repository at this point in the history
…ack.java times out (aix)

Reviewed-by: mdoerr, varadam
  • Loading branch information
Joachim Kern committed Jan 7, 2025
1 parent 5e6cda4 commit 8b22517
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 34 deletions.
71 changes: 39 additions & 32 deletions src/java.base/aix/classes/sun/nio/ch/AixPollPort.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2008, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012 SAP SE. All rights reserved.
* Copyright (c) 2008, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2024 SAP SE. 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
Expand All @@ -26,15 +26,17 @@

package sun.nio.ch;

import java.nio.channels.spi.AsynchronousChannelProvider;
import sun.nio.ch.Pollset;
import java.io.FileDescriptor;
import java.io.IOException;
import java.util.HashSet;
import java.util.Iterator;
import java.nio.channels.spi.AsynchronousChannelProvider;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.ReentrantLock;
import java.util.concurrent.RejectedExecutionException;
import java.util.HashSet;
import java.util.Iterator;
import sun.nio.ch.IOUtil;
import sun.nio.ch.Pollset;

/**
* AsynchronousChannelGroup implementation based on the AIX pollset framework.
Expand Down Expand Up @@ -141,6 +143,8 @@ static class ControlEvent {
sv = new int[2];
try {
Pollset.socketpair(sv);
// make the reading part of the socket nonblocking, so the drain (drain_all) method works
IOUtil.configureBlocking(IOUtil.newFD(sv[0]), false);
// register one end with pollset
Pollset.pollsetCtl(pollset, Pollset.PS_ADD, sv[0], Net.POLLIN);
} catch (IOException x) {
Expand Down Expand Up @@ -271,23 +275,21 @@ private void queueControlEvent(ControlEvent ev) {

// Process all events currently stored in the control queue.
private void processControlQueue() {
synchronized (controlQueue) {
// On Aix it is only possible to set the event
// bits on the first call of pollsetCtl. Later
// calls only add bits, but cannot remove them.
// Therefore, we always remove the file
// descriptor ignoring the error and then add it.
Iterator<ControlEvent> iter = controlQueue.iterator();
while (iter.hasNext()) {
ControlEvent ev = iter.next();
Pollset.pollsetCtl(pollset, Pollset.PS_DELETE, ev.fd(), 0);
if (!ev.removeOnly()) {
ev.setError(Pollset.pollsetCtl(pollset, Pollset.PS_MOD, ev.fd(), ev.events()));
}
iter.remove();
// On Aix it is only possible to set the event
// bits on the first call of pollsetCtl. Later
// calls only add bits, but cannot remove them.
// Therefore, we always remove the file
// descriptor ignoring the error and then add it.
Iterator<ControlEvent> iter = controlQueue.iterator();
while (iter.hasNext()) {
ControlEvent ev = iter.next();
Pollset.pollsetCtl(pollset, Pollset.PS_DELETE, ev.fd(), 0);
if (!ev.removeOnly()) {
ev.setError(Pollset.pollsetCtl(pollset, Pollset.PS_MOD, ev.fd(), ev.events()));
}
controlQueue.notifyAll();
iter.remove();
}
controlQueue.notifyAll();
}

/*
Expand All @@ -306,8 +308,21 @@ private Event poll() throws IOException {
int n;
controlLock.lock();
try {
n = Pollset.pollsetPoll(pollset, address,
int m;
m = n = Pollset.pollsetPoll(pollset, address,
MAX_EVENTS_TO_POLL, Pollset.PS_NO_TIMEOUT);
while (m-- > 0) {
long eventAddress = Pollset.getEvent(address, m);
int fd = Pollset.getDescriptor(eventAddress);

// To emulate one shot semantic we need to remove
// the file descriptor here.
if (fd != sp[0] && fd != ctlSp[0]) {
synchronized (controlQueue) {
Pollset.pollsetCtl(pollset, Pollset.PS_DELETE, fd, 0);
}
}
}
} finally {
controlLock.unlock();
}
Expand All @@ -323,14 +338,6 @@ private Event poll() throws IOException {
long eventAddress = Pollset.getEvent(address, n);
int fd = Pollset.getDescriptor(eventAddress);

// To emulate one shot semantic we need to remove
// the file descriptor here.
if (fd != sp[0] && fd != ctlSp[0]) {
synchronized (controlQueue) {
Pollset.pollsetCtl(pollset, Pollset.PS_DELETE, fd, 0);
}
}

// wakeup
if (fd == sp[0]) {
if (wakeupCount.decrementAndGet() == 0) {
Expand All @@ -350,7 +357,7 @@ private Event poll() throws IOException {
// wakeup to process control event
if (fd == ctlSp[0]) {
synchronized (controlQueue) {
Pollset.drain1(ctlSp[0]);
IOUtil.drain(ctlSp[0]);
processControlQueue();
}
if (n > 0) {
Expand Down
2 changes: 0 additions & 2 deletions test/jdk/ProblemList.txt
Original file line number Diff line number Diff line change
Expand Up @@ -583,8 +583,6 @@ java/net/Socket/asyncClose/Race.java 8317801 aix-ppc6

# jdk_nio

java/nio/channels/AsynchronousSocketChannel/StressLoopback.java 8211851 aix-ppc64

java/nio/channels/Channels/SocketChannelStreams.java 8317838 aix-ppc64

java/nio/channels/DatagramChannel/AdaptorMulticasting.java 8308807,8144003 aix-ppc64,macosx-all
Expand Down

9 comments on commit 8b22517

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@varada1110
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport jdk24

@openjdk
Copy link

@openjdk openjdk bot commented on 8b22517 Jan 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@varada1110 The target repository jdk24 is not a valid target for backports.
List of valid target repositories: openjdk/jdk, openjdk/jdk11u, openjdk/jdk11u-dev, openjdk/jdk17u, openjdk/jdk17u-dev, openjdk/jdk21u, openjdk/jdk21u-dev, openjdk/jdk23u, openjdk/jdk24u, openjdk/jdk7u, openjdk/jdk8u, openjdk/jdk8u-dev, openjdk/jfx, openjdk/jfx17u, openjdk/jfx21u, openjdk/jfx23u, openjdk/lilliput-jdk17u, openjdk/lilliput-jdk21u, openjdk/shenandoah-jdk21u, openjdk/shenandoah-jdk8u.
Supplying the organization/group prefix is optional.

There is a branch jdk24 in the current repository openjdk/jdk.
To target a backport to this branch in the current repository use:
/backport :jdk24

@varada1110
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport jdk24u

@openjdk
Copy link

@openjdk openjdk bot commented on 8b22517 Jan 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@varada1110 the backport was successfully created on the branch backport-varada1110-8b22517c-master in my personal fork of openjdk/jdk24u. To create a pull request with this backport targeting openjdk/jdk24u:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 8b22517c from the openjdk/jdk repository.

The commit being backported was authored by Joachim Kern on 7 Jan 2025 and was reviewed by Martin Doerr and Varada M.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk24u:

$ git fetch https://github.com/openjdk-bots/jdk24u.git backport-varada1110-8b22517c-master:backport-varada1110-8b22517c-master
$ git checkout backport-varada1110-8b22517c-master
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk24u.git backport-varada1110-8b22517c-master

⚠️ @varada1110 You are not yet a collaborator in my fork openjdk-bots/jdk24u. An invite will be sent out and you need to accept it before you can proceed.

@varada1110
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport jdk23u

@openjdk
Copy link

@openjdk openjdk bot commented on 8b22517 Jan 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@varada1110 the backport was successfully created on the branch backport-varada1110-8b22517c-master in my personal fork of openjdk/jdk23u. To create a pull request with this backport targeting openjdk/jdk23u:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 8b22517c from the openjdk/jdk repository.

The commit being backported was authored by Joachim Kern on 7 Jan 2025 and was reviewed by Martin Doerr and Varada M.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk23u:

$ git fetch https://github.com/openjdk-bots/jdk23u.git backport-varada1110-8b22517c-master:backport-varada1110-8b22517c-master
$ git checkout backport-varada1110-8b22517c-master
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk23u.git backport-varada1110-8b22517c-master

⚠️ @varada1110 You are not yet a collaborator in my fork openjdk-bots/jdk23u. An invite will be sent out and you need to accept it before you can proceed.

@varada1110
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport jdk21u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on 8b22517 Jan 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@varada1110 the backport was successfully created on the branch backport-varada1110-8b22517c-master in my personal fork of openjdk/jdk21u-dev. To create a pull request with this backport targeting openjdk/jdk21u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 8b22517c from the openjdk/jdk repository.

The commit being backported was authored by Joachim Kern on 7 Jan 2025 and was reviewed by Martin Doerr and Varada M.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk21u-dev:

$ git fetch https://github.com/openjdk-bots/jdk21u-dev.git backport-varada1110-8b22517c-master:backport-varada1110-8b22517c-master
$ git checkout backport-varada1110-8b22517c-master
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk21u-dev.git backport-varada1110-8b22517c-master

⚠️ @varada1110 You are not yet a collaborator in my fork openjdk-bots/jdk21u-dev. An invite will be sent out and you need to accept it before you can proceed.

Please sign in to comment.