Skip to content

8278339: ServerSocket::isClosed may return false after accept throws#6741

Closed
AlanBateman wants to merge 3 commits intoopenjdk:masterfrom
AlanBateman:JDK-8278339
Closed

8278339: ServerSocket::isClosed may return false after accept throws#6741
AlanBateman wants to merge 3 commits intoopenjdk:masterfrom
AlanBateman:JDK-8278339

Conversation

@AlanBateman
Copy link
Contributor

@AlanBateman AlanBateman commented Dec 7, 2021

JDK-8278270 introduces a small regression. If a ServerSocket is closed while another thread is blocked in the accept method then the other thread may observe isClosed returning false, i.e. code may catch IOException and check isClosed before the "closed" flag gets to true.

I've changed the close method to set the "closed" flag before closing the underlying impl. This is consistent with the network channels and also consistent with async close where the close completes on the thread that was blocked in accept. The change also prevents re-attempting the underlying impl in the unlikely event that it fails(an area that is completed unspecified). Overall I think this is preferable to have add synchronization to isClosed.


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8278339: ServerSocket::isClosed may return false after accept throws

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/6741/head:pull/6741
$ git checkout pull/6741

Update a local copy of the PR:
$ git checkout pull/6741
$ git pull https://git.openjdk.java.net/jdk pull/6741/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 6741

View PR using the GUI difftool:
$ git pr show -t 6741

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/6741.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Dec 7, 2021

👋 Welcome back alanb! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Dec 7, 2021

@AlanBateman The following label will be automatically applied to this pull request:

  • net

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the net net-dev@openjdk.org label Dec 7, 2021
@AlanBateman AlanBateman marked this pull request as ready for review December 7, 2021 13:57
@openjdk openjdk bot added the rfr Pull request is ready for review label Dec 7, 2021
@mlbridge
Copy link

mlbridge bot commented Dec 7, 2021

Webrevs

Copy link
Member

@dfuch dfuch left a comment

Choose a reason for hiding this comment

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

LGTM. I agree, setting the flag before attempting to close the impl is a better behavior.

@openjdk
Copy link

openjdk bot commented Dec 7, 2021

@AlanBateman This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8278339: ServerSocket::isClosed may return false after accept throws

Reviewed-by: dfuchs

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 4 new commits pushed to the master branch:

  • 3536127: 8277383: VM.metaspace optionally show chunk freelist details
  • 44fcee3: 8278289: Drop G1BlockOffsetTablePart::_object_can_span
  • b2638e5: 8244602: Add JTREG_REPEAT_COUNT to repeat execution of a test
  • 07669e3: 8275375: [REDO] JDK-8271949 dumppath in -XX:FlightRecorderOptions does not affect

Please see this link for an up-to-date comparison between the source branch of this pull request and the master branch.
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Dec 7, 2021
@AlanBateman
Copy link
Contributor Author

/integrate

@openjdk
Copy link

openjdk bot commented Dec 7, 2021

Going to push as commit 69d8669.
Since your change was applied there have been 5 commits pushed to the master branch:

  • 56ca66e: 8277863: Deprecate sun.misc.Unsafe methods that return offsets
  • 3536127: 8277383: VM.metaspace optionally show chunk freelist details
  • 44fcee3: 8278289: Drop G1BlockOffsetTablePart::_object_can_span
  • b2638e5: 8244602: Add JTREG_REPEAT_COUNT to repeat execution of a test
  • 07669e3: 8275375: [REDO] JDK-8271949 dumppath in -XX:FlightRecorderOptions does not affect

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot closed this Dec 7, 2021
@openjdk openjdk bot added integrated Pull request has been integrated and removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Dec 7, 2021
@openjdk
Copy link

openjdk bot commented Dec 7, 2021

@AlanBateman Pushed as commit 69d8669.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integrated Pull request has been integrated net net-dev@openjdk.org

Development

Successfully merging this pull request may close these issues.

2 participants