-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Add TLS/SSL channel close timeouts #37246
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Pinging @elastic/es-security |
|
run gradle build tests 2 |
s1monw
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left some comments. looks good though. I was pretty confused about the use of ThreadLocal in your description. Maybe you can change that?
| } | ||
| } | ||
|
|
||
| public interface Cancellable { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we just use Runnable instead?
|
|
||
| private final PriorityQueue<DelayedTask> tasks = new PriorityQueue<>(Comparator.comparingLong(DelayedTask::getDeadline)); | ||
|
|
||
| public Cancellable schedule(Runnable task, TimeValue timeValue) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is trappy, can we only have the scheduleAtRelativeTime method instead?
| return scheduleAtRelativeTime(task, System.nanoTime() + timeValue.nanos()); | ||
| } | ||
|
|
||
| public Cancellable scheduleAtRelativeTime(Runnable task, long relativeNanos) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
javadocs please
| * A basic priority queue backed timer service. The service is thread local and should only be used by a | ||
| * single nio selector event loop thread. | ||
| */ | ||
| public class NioTimer { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the Nio in the name is obsolete?
|
run gradle build tests 1 |
Closing a channel using TLS/SSL requires reading and writing a
CLOSE_NOTIFY message (for pre-1.3 TLS versions). Many implementations do
not actually send the CLOSE_NOTIFY message, which means we are depending
on the TCP close from the other side to ensure channels are closed. In
case there is an issue with this, we need a timeout. This commit adds a
timeout to the channel close process for TLS secured channels.
As part of this change, we need a timer service. We could use the
generic Elasticsearch timeout threadpool. However, it would be nice to
have a local to the nio event loop timer service dedicated to network needs. In
the future this service could support read timeouts, connect timeouts,
request timeouts, etc. This commit adds a basic priority queue backed
service. Since our timeout volume (channel closes) is very low, this
should be fine. However, this can be updated to something more efficient
in the future if needed (timer wheel). Everything being local to the event loop
thread makes the logic simple as no locking or synchronization is necessary.