Merge pull request #22085 from grpc/vjpai-patch-1

Don't depend on InlinedVector::clear to de-allocate
pull/22095/head
Vijay Pai 5 years ago committed by GitHub
commit 179506cb43
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      src/core/lib/iomgr/ev_epollex_linux.cc

@ -41,11 +41,11 @@
#include <grpc/support/alloc.h>
#include <grpc/support/string_util.h>
#include "absl/container/inlined_vector.h"
#include "src/core/lib/debug/stats.h"
#include "src/core/lib/gpr/spinlock.h"
#include "src/core/lib/gpr/tls.h"
#include "src/core/lib/gpr/useful.h"
#include "src/core/lib/gprpp/inlined_vector.h"
#include "src/core/lib/gprpp/manual_constructor.h"
#include "src/core/lib/gprpp/ref_counted.h"
#include "src/core/lib/gprpp/sync.h"
@ -190,7 +190,15 @@ struct grpc_fd {
grpc_iomgr_unregister_object(&iomgr_object);
POLLABLE_UNREF(pollable_obj, "fd_pollable");
pollset_fds.clear();
// To clear out the allocations of pollset_fds, we need to swap its
// contents with a newly-constructed (and soon to be destructed) local
// variable of its same type. This is because InlinedVector::clear is _not_
// guaranteed to actually free up allocations and this is important since
// this object doesn't have a conventional destructor.
absl::InlinedVector<int, 1> pollset_fds_tmp;
pollset_fds_tmp.swap(pollset_fds);
gpr_mu_destroy(&pollable_mu);
gpr_mu_destroy(&orphan_mu);
@ -232,8 +240,8 @@ struct grpc_fd {
// Protects pollable_obj and pollset_fds.
gpr_mu pollable_mu;
grpc_core::InlinedVector<int, 1> pollset_fds; // Used in PO_MULTI.
pollable* pollable_obj = nullptr; // Used in PO_FD.
absl::InlinedVector<int, 1> pollset_fds; // Used in PO_MULTI.
pollable* pollable_obj = nullptr; // Used in PO_FD.
grpc_core::LockfreeEvent read_closure;
grpc_core::LockfreeEvent write_closure;

Loading…
Cancel
Save