From b486ba6b0d488b0331cd56d1fac6fd28935c7c46 Mon Sep 17 00:00:00 2001 From: Ruyi Wang Date: Sat, 14 Mar 2015 22:19:44 +0800 Subject: [PATCH] remove 'else' code, release lock by destructor --- src/cpp/server/server.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/cpp/server/server.cc b/src/cpp/server/server.cc index e69032a657d..87296805652 100644 --- a/src/cpp/server/server.cc +++ b/src/cpp/server/server.cc @@ -179,12 +179,12 @@ Server::Server(ThreadPoolInterface* thread_pool, bool thread_pool_owned) thread_pool_owned_(thread_pool_owned) {} Server::~Server() { - std::unique_lock lock(mu_); - if (started_ && !shutdown_) { - lock.unlock(); - Shutdown(); - } else { - lock.unlock(); + { + std::unique_lock lock(mu_); + if (started_ && !shutdown_) { + lock.unlock(); + Shutdown(); + } } grpc_server_destroy(server_); if (thread_pool_owned_) {