RFR: 8312166: (dc) DatagramChannel's socket adaptor does not release carrier thread when blocking in receive [v3]

Alan Bateman alanb at openjdk.org
Wed Jul 19 12:38:31 UTC 2023


> DatagramChannel is "virtual thread friendly"; when configured blocking, the receive/read methods release the carrier when there is no datagram to receive.
> 
> DatagramChannel's socket adaptor (used by DatagramSocket) is not currently virtual thread friendly. The original changes proposed to address this in JDK 19 interacted with the carrier thread's buffer cache so we decided to not include them at the time. The change proposed here are to address this issue, mostly by moving the implementation of the socket adaptor's send/receive methods into the DatagramChannel implementation so that a temporary direct buffer is not held when parked.
> 
> The only observable change should be to silly/broken code that changes a DatagramPacket's buffer (with setData or setLength) while a receive is in progress. Long standing, and undocumented, behavior would for setXXX to block while a receive is in progress, new behavior will be only access the DatagramPacket's buffer when a datagram is received. I can't think of anything that could rely on behavior like this.

Alan Bateman has updated the pull request incrementally with one additional commit since the last revision:

  Make test more robust in the face of other tests sending to random ports

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/14901/files
  - new: https://git.openjdk.org/jdk/pull/14901/files/29337d6d..ced9cf3f

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=14901&range=02
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=14901&range=01-02

  Stats: 7 lines in 1 file changed: 0 ins; 4 del; 3 mod
  Patch: https://git.openjdk.org/jdk/pull/14901.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/14901/head:pull/14901

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


More information about the nio-dev mailing list