RFR: 8354024: [JMH] Create ephemeral UnixDomainSocketAddress provider with thread-safe close semantics [v6]

Volkan Yazici vyazici at openjdk.org
Mon May 12 19:53:35 UTC 2025


> `ServerUdsChannelHolder` is introduced to manage the life cycle of a `ServerSocketChannel` created using Unix domain sockets (UDS) in a thread-safe manner.
> 
> ### Testing
> 
> Changes can be tested as follows:
> 
> 
> make build-microbenchmark
> build/linux-x64/jdk/bin/java \
>   -jar build/linux-x64/images/test/micro/benchmarks.jar \
>   -f 1 -wi 1 -i 1 -t 2 \
>   "(SocketChannelConnectionSetup|UnixSocketChannelReadWrite)"
> 
> 
> ### Background
> 
> A UDS need to be pointed to a _non-existent_ file, which is to be created by `bind()`. The created file needs to be deleted as a part of the clean-up at exit. When tests employing UDS run in parallel, failures can happen at multiple places:
> 
> - `bind()` can fail, if the file is already created by another thread
> - the clean-up of the socket file can fail, if the file is already deleted
>   - reported for `SocketChannelConnectionSetup` in [8350915](https://bugs.openjdk.org/browse/JDK-8350915)
>   - reported for `UnixSocketChannelReadWrite` in [8351601](https://bugs.openjdk.org/browse/JDK-8351601)
> - the clean-up of the socket file parent directory can fail, if not all threads deleted their socket files, and hence, the folder is not empty
>   - reported for in `SocketChannelConnectionSetup` in [8354024](https://bugs.openjdk.org/browse/JDK-8354024)
> 
> This PR introduces `ServerUdsChannelHolder` utility to manage the life cycle of a UDS and avoids above shared issues by:
> - using a dedicated (temporary and unique) parent folder for the socket
> - encapsulating the termination logic (i.e., closing the socket, deleting the socket file and its (dedicated) parent folder) in `AutoCloseable::close`

Volkan Yazici has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains six additional commits since the last revision:

 - Merge remote-tracking branch 'upstream/master' into jmh-unix-sock
 - Remove redundant `volatile` modifier
 - Improve UDS file path obtain
 - Simplify UDS clean-up logic
 - Fix copyright year
 - 8354024: [JMH] Create ephemeral UnixDomainSocketAddress provider with thread-safe close semantics

-------------

Changes:
  - all: https://git.openjdk.org/jdk/pull/24568/files
  - new: https://git.openjdk.org/jdk/pull/24568/files/d830ec8b..07675a43

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=24568&range=05
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=24568&range=04-05

  Stats: 311949 lines in 3253 files changed: 98200 ins; 200412 del; 13337 mod
  Patch: https://git.openjdk.org/jdk/pull/24568.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/24568/head:pull/24568

PR: https://git.openjdk.org/jdk/pull/24568


More information about the net-dev mailing list