@ -49,6 +49,7 @@
# include "src/core/lib/channel/channel_args.h"
# include "src/core/lib/config/core_configuration.h"
# include "src/core/lib/debug/trace.h"
# include "src/core/lib/experiments/experiments.h"
# include "src/core/lib/gprpp/debug_location.h"
# include "src/core/lib/gprpp/orphanable.h"
# include "src/core/lib/gprpp/ref_counted.h"
@ -123,9 +124,11 @@ class OutlierDetectionLb : public LoadBalancingPolicy {
class SubchannelState ;
class SubchannelWrapper : public DelegatingSubchannel {
public :
SubchannelWrapper ( RefCountedPtr < SubchannelState > subchannel_state ,
SubchannelWrapper ( std : : shared_ptr < WorkSerializer > work_serializer ,
RefCountedPtr < SubchannelState > subchannel_state ,
RefCountedPtr < SubchannelInterface > subchannel )
: DelegatingSubchannel ( std : : move ( subchannel ) ) ,
work_serializer_ ( std : : move ( work_serializer ) ) ,
subchannel_state_ ( std : : move ( subchannel_state ) ) {
if ( subchannel_state_ ! = nullptr ) {
subchannel_state_ - > AddSubchannel ( this ) ;
@ -135,10 +138,21 @@ class OutlierDetectionLb : public LoadBalancingPolicy {
}
}
~ SubchannelWrapper ( ) override {
if ( subchannel_state_ ! = nullptr ) {
subchannel_state_ - > RemoveSubchannel ( this ) ;
void Orphan ( ) override {
if ( ! IsClientChannelSubchannelWrapperWorkSerializerOrphanEnabled ( ) ) {
if ( subchannel_state_ ! = nullptr ) {
subchannel_state_ - > RemoveSubchannel ( this ) ;
}
return ;
}
WeakRefCountedPtr < SubchannelWrapper > self = WeakRef ( ) ;
work_serializer_ - > Run (
[ self = std : : move ( self ) ] ( ) {
if ( self - > subchannel_state_ ! = nullptr ) {
self - > subchannel_state_ - > RemoveSubchannel ( self . get ( ) ) ;
}
} ,
DEBUG_LOCATION ) ;
}
void Eject ( ) ;
@ -206,6 +220,7 @@ class OutlierDetectionLb : public LoadBalancingPolicy {
bool ejected_ ;
} ;
std : : shared_ptr < WorkSerializer > work_serializer_ ;
RefCountedPtr < SubchannelState > subchannel_state_ ;
bool ejected_ = false ;
WatcherWrapper * watcher_wrapper_ = nullptr ;
@ -716,8 +731,9 @@ RefCountedPtr<SubchannelInterface> OutlierDetectionLb::Helper::CreateSubchannel(
}
}
auto subchannel = MakeRefCounted < SubchannelWrapper > (
subchannel_state , parent ( ) - > channel_control_helper ( ) - > CreateSubchannel (
std : : move ( address ) , args ) ) ;
parent ( ) - > work_serializer ( ) , subchannel_state ,
parent ( ) - > channel_control_helper ( ) - > CreateSubchannel ( std : : move ( address ) ,
args ) ) ;
if ( subchannel_state ! = nullptr ) {
subchannel_state - > AddSubchannel ( subchannel . get ( ) ) ;
}