mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8194298: Add support for per Socket configuration of TCP keepalive
Reviewed-by: chegar, clanger, igerasim, alanb
This commit is contained in:
parent
611c72e5bc
commit
6a48db9cf6
20 changed files with 815 additions and 48 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2007, 2018, Oracle and/or its affiliates. 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
|
||||
|
@ -28,6 +28,7 @@ import java.io.IOException;
|
|||
import java.util.Set;
|
||||
import java.util.HashSet;
|
||||
import sun.net.ext.ExtendedSocketOptions;
|
||||
import static sun.net.ext.ExtendedSocketOptions.SOCK_DGRAM;
|
||||
|
||||
/*
|
||||
* On Unix systems we simply delegate to native methods.
|
||||
|
@ -77,18 +78,10 @@ class PlainDatagramSocketImpl extends AbstractPlainDatagramSocketImpl
|
|||
|
||||
protected Set<SocketOption<?>> supportedOptions() {
|
||||
HashSet<SocketOption<?>> options = new HashSet<>(super.supportedOptions());
|
||||
addExtSocketOptions(extendedOptions.options(), options);
|
||||
options.addAll(ExtendedSocketOptions.options(SOCK_DGRAM));
|
||||
return options;
|
||||
}
|
||||
|
||||
private void addExtSocketOptions(Set<SocketOption<?>> extOptions,
|
||||
Set<SocketOption<?>> options) {
|
||||
// TCP_QUICKACK is applicable for TCP Sockets only.
|
||||
extOptions.stream()
|
||||
.filter((option) -> !option.name().equals("TCP_QUICKACK"))
|
||||
.forEach((option) -> options.add(option));
|
||||
}
|
||||
|
||||
protected void socketSetOption(int opt, Object val) throws SocketException {
|
||||
if (opt == SocketOptions.SO_REUSEPORT &&
|
||||
!supportedOptions().contains(StandardSocketOptions.SO_REUSEPORT)) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2007, 2018, Oracle and/or its affiliates. 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
|
||||
|
@ -29,6 +29,7 @@ import java.io.FileDescriptor;
|
|||
import java.util.Set;
|
||||
import java.util.HashSet;
|
||||
import sun.net.ext.ExtendedSocketOptions;
|
||||
import static sun.net.ext.ExtendedSocketOptions.SOCK_STREAM;
|
||||
|
||||
/*
|
||||
* On Unix systems we simply delegate to native methods.
|
||||
|
@ -90,7 +91,7 @@ class PlainSocketImpl extends AbstractPlainSocketImpl
|
|||
|
||||
protected Set<SocketOption<?>> supportedOptions() {
|
||||
HashSet<SocketOption<?>> options = new HashSet<>(super.supportedOptions());
|
||||
addExtSocketOptions(extendedOptions.options(), options);
|
||||
addExtSocketOptions(ExtendedSocketOptions.options(SOCK_STREAM), options);
|
||||
return options;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue