On Thu, 8 Oct 2026 13:57:32 GMT, Harald Eilertsen <[email protected]> wrote:
>> The BSD's, like macOS store the SO_LINGER value in a signed short >> internally, so we need to clamp the value to 32767 for all the BSD's, not >> only macOS. >> >> This work is sponsored by The FreeBSD Foundation >> >> --------- >> - [x] I confirm that I make this contribution in accordance with the >> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai). > > Harald Eilertsen has updated the pull request incrementally with one > additional commit since the last revision: > > Remove unnecessary ignore Changes LGTM. 1. I've downloaded a [FreeBSD 15.1 VM image], and started a VM with that. 2. Created the following simple reproducer, `LingerRepro.java`: ``` import java.net.InetAddress; import java.net.ServerSocket; import java.net.Socket; import static java.net.StandardSocketOptions.SO_LINGER; public final class LingerRepro { public static void main(String[] args) throws Exception { try (var server = new ServerSocket(0, 1, InetAddress.getLoopbackAddress()); var client = new Socket(server.getInetAddress(), server.getLocalPort()); var accepted = server.accept()) { try { var expected = 32809; accepted.setSoLinger(true, expected); var actual = accepted.getSoLinger(); System.out.printf( "setSoLinger(%s); getSoLinger(): %s (%s)%n", expected, actual, actual == 32767 ? "OK" : "BAD"); accepted.setOption(SO_LINGER, expected); actual = accepted.getOption(SO_LINGER); System.out.printf( "setOption(SO_LINGER, %s); getOption(SO_LINGER): %s (%s)%n", expected, actual, actual == 32767 ? "OK" : "BAD"); } finally { accepted.setSoLinger(false, 0); } } } } ``` 3. Did `pkg install openjdk27` and run `LingerRepro`: ``` setSoLinger(32809); getSoLinger(): 32767 (OK) setOption(SO_LINGER, 32809); getOption(SO_LINGER): -32727 (BAD) ``` 4. Downloaded `/usr/ports`, manually patched `/usr/ports/java/openjdk27` with the `net_util_md.c` fix, build the JDK image, and re-run `LingerRepro`: ``` setSoLinger(32809); getSoLinger(): 32767 (OK) setOption(SO_LINGER, 32809); getOption(SO_LINGER): 32767 (OK) ``` [FreeBSD 15.1 VM image]: https://download.freebsd.org/releases/VM-IMAGES/15.1-RELEASE/ ------------- Marked as reviewed by vyazici (Reviewer). PR Review: https://git.openjdk.org/jdk/pull/33248#pullrequestreview-5469641271
