Do not set SO_LINGER to 0 when not shutting down (#26871)

This is a follow up to #26764. That commit set SO_LINGER to 0 in order
to fix a scenario where we were running out of resources during CI. We
are primarily interested in setting this to 0 when stopping the
tranport. Allowing TIMED_WAIT is standard for other failure scenarios
during normal operation.

Unfortunately this commit set SO_LINGER to 0 every time we close
NodeChannels. NodeChannels can be closed in case of an exception or
other failures (such as parsing a response). We want to only disable
linger when actually shutting down.
This commit is contained in:
Tim Brooks 2017-10-04 10:27:26 -06:00 committed by GitHub
parent 17b9baf5fd
commit ca35fcabd0

View File

@ -441,7 +441,8 @@ public abstract class TcpTransport<Channel> extends AbstractLifecycleComponent i
public void close() throws IOException {
if (closed.compareAndSet(false, true)) {
try {
closeChannels(Arrays.stream(channels).filter(Objects::nonNull).collect(Collectors.toList()), false, true);
closeChannels(Arrays.stream(channels).filter(Objects::nonNull).collect(Collectors.toList()), false,
lifecycle.stopped());
} finally {
transportService.onConnectionClosed(this);
}