From 334fa41ec092be984b011e88283c6af07d42eab9 Mon Sep 17 00:00:00 2001 From: Esun Kim <veblush@google.com> Date: Thu, 3 Oct 2019 12:14:10 -0700 Subject: [PATCH] Update by review --- src/core/lib/iomgr/buffer_list.h | 7 ++++--- src/core/lib/iomgr/cfstream_handle.h | 5 +++-- src/core/lib/slice/slice.cc | 1 - src/core/lib/slice/slice_hash_table.h | 7 ++++--- src/core/lib/slice/slice_weak_hash_table.h | 7 ++++--- src/core/tsi/ssl/session_cache/ssl_session_cache.h | 1 + 6 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/core/lib/iomgr/buffer_list.h b/src/core/lib/iomgr/buffer_list.h index 1e851dc4c9..8818f3c3b6 100644 --- a/src/core/lib/iomgr/buffer_list.h +++ b/src/core/lib/iomgr/buffer_list.h @@ -114,6 +114,10 @@ struct Timestamps { #ifdef GRPC_LINUX_ERRQUEUE class TracedBuffer { public: + /** Use AddNewEntry function instead of using this directly. */ + TracedBuffer(uint32_t seq_no, void* arg) + : seq_no_(seq_no), arg_(arg), next_(nullptr) {} + /** Add a new entry in the TracedBuffer list pointed to by head. Also saves * sendmsg_time with the current timestamp. */ static void AddNewEntry(grpc_core::TracedBuffer** head, uint32_t seq_no, @@ -132,9 +136,6 @@ class TracedBuffer { static void Shutdown(grpc_core::TracedBuffer** head, void* remaining, grpc_error* shutdown_err); - TracedBuffer(uint32_t seq_no, void* arg) - : seq_no_(seq_no), arg_(arg), next_(nullptr) {} - private: uint32_t seq_no_; /* The sequence number for the last byte in the buffer */ void* arg_; /* The arg to pass to timestamps_callback */ diff --git a/src/core/lib/iomgr/cfstream_handle.h b/src/core/lib/iomgr/cfstream_handle.h index 96765b8903..b0f0664a04 100644 --- a/src/core/lib/iomgr/cfstream_handle.h +++ b/src/core/lib/iomgr/cfstream_handle.h @@ -43,10 +43,12 @@ class CFStreamHandle : public GrpcLibraryInitHolder { public: static CFStreamHandle* CreateStreamHandle(CFReadStreamRef read_stream, CFWriteStreamRef write_stream); - ~CFStreamHandle() override; + /** Use CreateStreamHandle function instead of using this directly. */ + CFStreamHandle(CFReadStreamRef read_stream, CFWriteStreamRef write_stream); CFStreamHandle(const CFStreamHandle& ref) = delete; CFStreamHandle(CFStreamHandle&& ref) = delete; CFStreamHandle& operator=(const CFStreamHandle& rhs) = delete; + ~CFStreamHandle() override; void NotifyOnOpen(grpc_closure* closure); void NotifyOnRead(grpc_closure* closure); @@ -57,7 +59,6 @@ class CFStreamHandle : public GrpcLibraryInitHolder { void Unref(const char* file = "", int line = 0, const char* reason = nullptr); private: - CFStreamHandle(CFReadStreamRef read_stream, CFWriteStreamRef write_stream); static void ReadCallback(CFReadStreamRef stream, CFStreamEventType type, void* client_callback_info); static void WriteCallback(CFWriteStreamRef stream, CFStreamEventType type, diff --git a/src/core/lib/slice/slice.cc b/src/core/lib/slice/slice.cc index 5cafb4a6f3..a3936a8d2e 100644 --- a/src/core/lib/slice/slice.cc +++ b/src/core/lib/slice/slice.cc @@ -87,7 +87,6 @@ class NewSliceRefcount { grpc_slice_refcount* base_refcount() { return &base_; } private: - grpc_slice_refcount base_; RefCount refs_; void (*user_destroy_)(void*); diff --git a/src/core/lib/slice/slice_hash_table.h b/src/core/lib/slice/slice_hash_table.h index f94fd08cad..29a5fc6dd2 100644 --- a/src/core/lib/slice/slice_hash_table.h +++ b/src/core/lib/slice/slice_hash_table.h @@ -65,6 +65,10 @@ class SliceHashTable : public RefCounted<SliceHashTable<T>> { Entry* entries, ValueCmp value_cmp); + // Use Create function instead of using this directly. + SliceHashTable(size_t num_entries, Entry* entries, ValueCmp value_cmp); + virtual ~SliceHashTable(); + /// Returns the value from the table associated with \a key. /// Returns null if \a key is not found. const T* Get(const grpc_slice& key) const; @@ -77,9 +81,6 @@ class SliceHashTable : public RefCounted<SliceHashTable<T>> { /// - else, if value_cmp(a_value, b_value) < 1 (resp. > 1). static int Cmp(const SliceHashTable& a, const SliceHashTable& b); - SliceHashTable(size_t num_entries, Entry* entries, ValueCmp value_cmp); - virtual ~SliceHashTable(); - private: void Add(const grpc_slice& key, T& value); diff --git a/src/core/lib/slice/slice_weak_hash_table.h b/src/core/lib/slice/slice_weak_hash_table.h index 0d69156603..931e405c1e 100644 --- a/src/core/lib/slice/slice_weak_hash_table.h +++ b/src/core/lib/slice/slice_weak_hash_table.h @@ -39,14 +39,15 @@ namespace grpc_core { template <typename T, size_t Size> class SliceWeakHashTable : public RefCounted<SliceWeakHashTable<T, Size>> { public: - SliceWeakHashTable() = default; - ~SliceWeakHashTable() = default; - /// Creates a new table of at most \a size entries. static RefCountedPtr<SliceWeakHashTable> Create() { return MakeRefCounted<SliceWeakHashTable<T, Size>>(); } + /// Use Create function instead of using this directly. + SliceWeakHashTable() = default; + ~SliceWeakHashTable() = default; + /// Add a mapping from \a key to \a value, taking ownership of \a key. This /// operation will always succeed. It may discard older entries. void Add(const grpc_slice& key, T value) { 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 0808539a07..2eadab25ed 100644 --- a/src/core/tsi/ssl/session_cache/ssl_session_cache.h +++ b/src/core/tsi/ssl/session_cache/ssl_session_cache.h @@ -53,6 +53,7 @@ class SslSessionLRUCache : public grpc_core::RefCounted<SslSessionLRUCache> { return grpc_core::MakeRefCounted<SslSessionLRUCache>(capacity); } + // Use Create function instead of using this directly. explicit SslSessionLRUCache(size_t capacity); ~SslSessionLRUCache(); -- GitLab