netty: don't share transport tracers across transports

Found using TSAN, which shows the number of calls succeeded being incremented from multiple event loops
This commit is contained in:
Carl Mastrangelo 2019-07-15 11:18:35 -07:00 committed by GitHub
parent c3d7d74175
commit 25a72e1f6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 6 deletions

View File

@ -157,7 +157,7 @@ public final class TransportTracer {
} }
public static final class Factory { public static final class Factory {
private TimeProvider timeProvider; private final TimeProvider timeProvider;
@VisibleForTesting @VisibleForTesting
public Factory(TimeProvider timeProvider) { public Factory(TimeProvider timeProvider) {

View File

@ -441,7 +441,7 @@ public final class NettyChannelBuilder
negotiator, resolvedChannelFactory, channelOptions, negotiator, resolvedChannelFactory, channelOptions,
resolvedEventLoopGroupPool, flowControlWindow, maxInboundMessageSize(), resolvedEventLoopGroupPool, flowControlWindow, maxInboundMessageSize(),
maxHeaderListSize, keepAliveTimeNanos, keepAliveTimeoutNanos, keepAliveWithoutCalls, maxHeaderListSize, keepAliveTimeNanos, keepAliveTimeoutNanos, keepAliveWithoutCalls,
transportTracerFactory.create(), localSocketPicker); transportTracerFactory, localSocketPicker);
} }
@VisibleForTesting @VisibleForTesting
@ -557,7 +557,7 @@ public final class NettyChannelBuilder
private final AtomicBackoff keepAliveTimeNanos; private final AtomicBackoff keepAliveTimeNanos;
private final long keepAliveTimeoutNanos; private final long keepAliveTimeoutNanos;
private final boolean keepAliveWithoutCalls; private final boolean keepAliveWithoutCalls;
private final TransportTracer transportTracer; private final TransportTracer.Factory transportTracerFactory;
private final LocalSocketPicker localSocketPicker; private final LocalSocketPicker localSocketPicker;
private boolean closed; private boolean closed;
@ -567,7 +567,7 @@ public final class NettyChannelBuilder
Map<ChannelOption<?>, ?> channelOptions, ObjectPool<? extends EventLoopGroup> groupPool, Map<ChannelOption<?>, ?> channelOptions, ObjectPool<? extends EventLoopGroup> groupPool,
int flowControlWindow, int maxMessageSize, int maxHeaderListSize, int flowControlWindow, int maxMessageSize, int maxHeaderListSize,
long keepAliveTimeNanos, long keepAliveTimeoutNanos, boolean keepAliveWithoutCalls, long keepAliveTimeNanos, long keepAliveTimeoutNanos, boolean keepAliveWithoutCalls,
TransportTracer transportTracer, LocalSocketPicker localSocketPicker) { TransportTracer.Factory transportTracerFactory, LocalSocketPicker localSocketPicker) {
this.protocolNegotiator = protocolNegotiator; this.protocolNegotiator = protocolNegotiator;
this.channelFactory = channelFactory; this.channelFactory = channelFactory;
this.channelOptions = new HashMap<ChannelOption<?>, Object>(channelOptions); this.channelOptions = new HashMap<ChannelOption<?>, Object>(channelOptions);
@ -579,7 +579,7 @@ public final class NettyChannelBuilder
this.keepAliveTimeNanos = new AtomicBackoff("keepalive time nanos", keepAliveTimeNanos); this.keepAliveTimeNanos = new AtomicBackoff("keepalive time nanos", keepAliveTimeNanos);
this.keepAliveTimeoutNanos = keepAliveTimeoutNanos; this.keepAliveTimeoutNanos = keepAliveTimeoutNanos;
this.keepAliveWithoutCalls = keepAliveWithoutCalls; this.keepAliveWithoutCalls = keepAliveWithoutCalls;
this.transportTracer = transportTracer; this.transportTracerFactory = transportTracerFactory;
this.localSocketPicker = this.localSocketPicker =
localSocketPicker != null ? localSocketPicker : new LocalSocketPicker(); localSocketPicker != null ? localSocketPicker : new LocalSocketPicker();
} }
@ -614,7 +614,7 @@ public final class NettyChannelBuilder
localNegotiator, flowControlWindow, localNegotiator, flowControlWindow,
maxMessageSize, maxHeaderListSize, keepAliveTimeNanosState.get(), keepAliveTimeoutNanos, maxMessageSize, maxHeaderListSize, keepAliveTimeNanosState.get(), keepAliveTimeoutNanos,
keepAliveWithoutCalls, options.getAuthority(), options.getUserAgent(), keepAliveWithoutCalls, options.getAuthority(), options.getUserAgent(),
tooManyPingsRunnable, transportTracer, options.getEagAttributes(), tooManyPingsRunnable, transportTracerFactory.create(), options.getEagAttributes(),
localSocketPicker, channelLogger); localSocketPicker, channelLogger);
return transport; return transport;
} }