Skip to content

Commit 7766912

Browse files
committed
fix more detected mu/cv leaks
1 parent 902820a commit 7766912

File tree

7 files changed

+14
-4
lines changed

7 files changed

+14
-4
lines changed

Diff for: src/core/ext/transport/inproc/inproc_transport.cc

+2-3
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,7 @@ struct shared_mu {
6464
gpr_ref_init(&refs, 2);
6565
}
6666

67-
~shared_mu() {
68-
gpr_mu_destroy(&mu);
69-
}
67+
~shared_mu() { gpr_mu_destroy(&mu); }
7068

7169
gpr_mu mu;
7270
gpr_refcount refs;
@@ -87,6 +85,7 @@ struct inproc_transport {
8785
~inproc_transport() {
8886
grpc_connectivity_state_destroy(&connectivity);
8987
if (gpr_unref(&mu->refs)) {
88+
mu->~shared_mu();
9089
gpr_free(mu);
9190
}
9291
}

Diff for: test/core/end2end/inproc_callback_test.cc

+4-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,10 @@ class ShutdownCallback : public grpc_experimental_completion_queue_functor {
6565
gpr_mu_init(&mu_);
6666
gpr_cv_init(&cv_);
6767
}
68-
~ShutdownCallback() {}
68+
~ShutdownCallback() {
69+
gpr_mu_destroy(&mu_);
70+
gpr_cv_destroy(&cv_);
71+
}
6972
static void StaticRun(grpc_experimental_completion_queue_functor* cb,
7073
int ok) {
7174
auto* callback = static_cast<ShutdownCallback*>(cb);

Diff for: test/core/gpr/cpu_test.cc

+2
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ static void cpu_test(void) {
140140
}
141141
fprintf(stderr, "] (%d/%d)\n", cores_seen, ct.ncores);
142142
fflush(stderr);
143+
gpr_mu_destroy(&ct.mu);
144+
gpr_cv_destroy(&ct.done_cv);
143145
gpr_free(ct.used);
144146
}
145147

Diff for: test/core/gpr/mpscq_test.cc

+1
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ static void test_mt_multipop(void) {
178178
for (auto& th : thds) {
179179
th.Join();
180180
}
181+
gpr_mu_destroy(&pa.mu);
181182
gpr_mpscq_destroy(&q);
182183
}
183184

Diff for: test/core/gprpp/thd_test.cc

+2
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ static void test1(void) {
7171
th.Join();
7272
}
7373
GPR_ASSERT(t.n == 0);
74+
gpr_mu_destroy(&t.mu);
75+
gpr_cv_destroy(&t.done_cv);
7476
}
7577

7678
static void thd_body2(void* v) {}

Diff for: test/cpp/microbenchmarks/bm_closure.cc

+2
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ static void BM_AcquireMutex(benchmark::State& state) {
183183
DoNothing(nullptr, GRPC_ERROR_NONE);
184184
gpr_mu_unlock(&mu);
185185
}
186+
gpr_mu_destroy(&mu);
186187

187188
track_counters.Finish(state);
188189
}
@@ -202,6 +203,7 @@ static void BM_TryAcquireMutex(benchmark::State& state) {
202203
abort();
203204
}
204205
}
206+
gpr_mu_destroy(&mu);
205207

206208
track_counters.Finish(state);
207209
}

Diff for: test/cpp/util/grpc_tool.cc

+1
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,7 @@ bool GrpcTool::CallMethod(int argc, const char** argv,
590590

591591
call.WritesDoneAndWait();
592592
read_thread.join();
593+
gpr_mu_destroy(&parser_mu);
593594

594595
std::multimap<grpc::string_ref, grpc::string_ref> server_trailing_metadata;
595596
Status status = call.Finish(&server_trailing_metadata);

0 commit comments

Comments
 (0)