diff options
author | Mark D. Roth <roth@google.com> | 2018-04-20 10:44:17 -0700 |
---|---|---|
committer | Mark D. Roth <roth@google.com> | 2018-04-20 10:44:17 -0700 |
commit | 9635a04fed00cc1e9b72954cb3f72417b7f10e15 (patch) | |
tree | 0951982aa11a62c833384d36c15fe23dd346c879 /src | |
parent | a1459aa6ce2a11f8d11a067cb6c86e6af84ffd71 (diff) |
Work-around for ref-counted subclass deletion address problem.
Diffstat (limited to 'src')
-rw-r--r-- | src/core/ext/filters/client_channel/lb_policy.h | 4 | ||||
-rw-r--r-- | src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc | 4 | ||||
-rw-r--r-- | src/core/ext/filters/client_channel/method_params.h | 4 | ||||
-rw-r--r-- | src/core/ext/filters/client_channel/resolver.h | 4 | ||||
-rw-r--r-- | src/core/ext/filters/client_channel/retry_throttle.h | 4 | ||||
-rw-r--r-- | src/core/lib/gprpp/orphanable.h | 4 | ||||
-rw-r--r-- | src/core/lib/gprpp/ref_counted.h | 4 | ||||
-rw-r--r-- | src/core/lib/slice/slice_hash_table.h | 4 | ||||
-rw-r--r-- | src/core/lib/slice/slice_weak_hash_table.h | 4 | ||||
-rw-r--r-- | src/core/tsi/ssl/session_cache/ssl_session_cache.h | 4 |
10 files changed, 36 insertions, 4 deletions
diff --git a/src/core/ext/filters/client_channel/lb_policy.h b/src/core/ext/filters/client_channel/lb_policy.h index c3e43e5ef6..454e00a690 100644 --- a/src/core/ext/filters/client_channel/lb_policy.h +++ b/src/core/ext/filters/client_channel/lb_policy.h @@ -162,6 +162,10 @@ class LoadBalancingPolicy GRPC_ABSTRACT_BASE_CLASS protected: + // So Delete() can access our protected dtor. + template <typename T> + friend void Delete(T*); + explicit LoadBalancingPolicy(const Args& args); virtual ~LoadBalancingPolicy(); diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc index 0b2a30818e..097ff112f9 100644 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc @@ -189,6 +189,10 @@ class GrpcLb : public LoadBalancingPolicy { bool seen_initial_response() const { return seen_initial_response_; } private: + // So Delete() can access our private dtor. + template <typename T> + friend void grpc_core::Delete(T*); + ~BalancerCallState(); GrpcLb* grpclb_policy() const { diff --git a/src/core/ext/filters/client_channel/method_params.h b/src/core/ext/filters/client_channel/method_params.h index 099924edf3..a31d360f17 100644 --- a/src/core/ext/filters/client_channel/method_params.h +++ b/src/core/ext/filters/client_channel/method_params.h @@ -60,6 +60,10 @@ class ClientChannelMethodParams : public RefCounted<ClientChannelMethodParams> { template <typename T, typename... Args> friend T* grpc_core::New(Args&&... args); + // So Delete() can call our private dtor. + template <typename T> + friend void grpc_core::Delete(T*); + ClientChannelMethodParams() {} virtual ~ClientChannelMethodParams() {} diff --git a/src/core/ext/filters/client_channel/resolver.h b/src/core/ext/filters/client_channel/resolver.h index cdb5a20ea3..02380314dd 100644 --- a/src/core/ext/filters/client_channel/resolver.h +++ b/src/core/ext/filters/client_channel/resolver.h @@ -105,6 +105,10 @@ class Resolver : public InternallyRefCountedWithTracing<Resolver> { GRPC_ABSTRACT_BASE_CLASS protected: + // So Delete() can access our protected dtor. + template <typename T> + friend void Delete(T*); + /// Does NOT take ownership of the reference to \a combiner. // TODO(roth): Once we have a C++-like interface for combiners, this // API should change to take a RefCountedPtr<>, so that we always take diff --git a/src/core/ext/filters/client_channel/retry_throttle.h b/src/core/ext/filters/client_channel/retry_throttle.h index 2b6fa0a70b..fddafcd903 100644 --- a/src/core/ext/filters/client_channel/retry_throttle.h +++ b/src/core/ext/filters/client_channel/retry_throttle.h @@ -42,6 +42,10 @@ class ServerRetryThrottleData : public RefCounted<ServerRetryThrottleData> { intptr_t milli_token_ratio() const { return milli_token_ratio_; } private: + // So Delete() can call our private dtor. + template <typename T> + friend void grpc_core::Delete(T*); + ~ServerRetryThrottleData(); void GetReplacementThrottleDataIfNeeded( diff --git a/src/core/lib/gprpp/orphanable.h b/src/core/lib/gprpp/orphanable.h index a5bc8d8efc..b50f8c247c 100644 --- a/src/core/lib/gprpp/orphanable.h +++ b/src/core/lib/gprpp/orphanable.h @@ -100,7 +100,7 @@ class InternallyRefCounted : public Orphanable { void Unref() { if (gpr_unref(&refs_)) { - Delete(this); + Delete(static_cast<Child*>(this)); } } @@ -173,7 +173,7 @@ class InternallyRefCountedWithTracing : public Orphanable { void Unref() { if (gpr_unref(&refs_)) { - Delete(this); + Delete(static_cast<Child*>(this)); } } diff --git a/src/core/lib/gprpp/ref_counted.h b/src/core/lib/gprpp/ref_counted.h index 46bfaf7fb8..bd6874f3db 100644 --- a/src/core/lib/gprpp/ref_counted.h +++ b/src/core/lib/gprpp/ref_counted.h @@ -54,7 +54,7 @@ class RefCounted { // friend of this class. void Unref() { if (gpr_unref(&refs_)) { - Delete(this); + Delete(static_cast<Child*>(this)); } } @@ -114,7 +114,7 @@ class RefCountedWithTracing { void Unref() { if (gpr_unref(&refs_)) { - Delete(this); + Delete(static_cast<Child*>(this)); } } diff --git a/src/core/lib/slice/slice_hash_table.h b/src/core/lib/slice/slice_hash_table.h index fbe9cc58e8..4bbcf88e89 100644 --- a/src/core/lib/slice/slice_hash_table.h +++ b/src/core/lib/slice/slice_hash_table.h @@ -81,6 +81,10 @@ class SliceHashTable : public RefCounted<SliceHashTable<T>> { template <typename T2, typename... Args> friend T2* New(Args&&... args); + // So Delete() can call our private dtor. + template <typename T2> + friend void Delete(T2*); + SliceHashTable(size_t num_entries, Entry* entries, ValueCmp value_cmp); virtual ~SliceHashTable(); diff --git a/src/core/lib/slice/slice_weak_hash_table.h b/src/core/lib/slice/slice_weak_hash_table.h index 9d0ddfc2d2..dc3ccc5dad 100644 --- a/src/core/lib/slice/slice_weak_hash_table.h +++ b/src/core/lib/slice/slice_weak_hash_table.h @@ -65,6 +65,10 @@ class SliceWeakHashTable : public RefCounted<SliceWeakHashTable<T, Size>> { template <typename T2, typename... Args> friend T2* New(Args&&... args); + // So Delete() can call our private dtor. + template <typename T2> + friend void Delete(T2*); + SliceWeakHashTable() = default; ~SliceWeakHashTable() = default; diff --git a/src/core/tsi/ssl/session_cache/ssl_session_cache.h b/src/core/tsi/ssl/session_cache/ssl_session_cache.h index 488638c9bb..a90cca1a2e 100644 --- a/src/core/tsi/ssl/session_cache/ssl_session_cache.h +++ b/src/core/tsi/ssl/session_cache/ssl_session_cache.h @@ -69,6 +69,10 @@ class SslSessionLRUCache : public grpc_core::RefCounted<SslSessionLRUCache> { template <typename T, typename... Args> friend T* grpc_core::New(Args&&... args); + // So Delete() can call our private dtor. + template <typename T> + friend void grpc_core::Delete(T*); + class Node; explicit SslSessionLRUCache(size_t capacity); |