|  | @@ -281,6 +281,7 @@ Server::Server(ThreadPoolInterface* thread_pool, bool thread_pool_owned,
 | 
	
		
			
				|  |  |      : max_message_size_(max_message_size),
 | 
	
		
			
				|  |  |        started_(false),
 | 
	
		
			
				|  |  |        shutdown_(false),
 | 
	
		
			
				|  |  | +      shutdown_notified_(false),
 | 
	
		
			
				|  |  |        num_running_cb_(0),
 | 
	
		
			
				|  |  |        sync_methods_(new std::list<SyncRequest>),
 | 
	
		
			
				|  |  |        has_generic_service_(false),
 | 
	
	
		
			
				|  | @@ -462,13 +463,16 @@ void Server::ShutdownInternal(gpr_timespec deadline) {
 | 
	
		
			
				|  |  |      while (num_running_cb_ != 0) {
 | 
	
		
			
				|  |  |        callback_cv_.wait(lock);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    shutdown_notified_ = true;
 | 
	
		
			
				|  |  | +    shutdown_cv_.notify_all();
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  void Server::Wait() {
 | 
	
		
			
				|  |  |    grpc::unique_lock<grpc::mutex> lock(mu_);
 | 
	
		
			
				|  |  | -  while (num_running_cb_ != 0) {
 | 
	
		
			
				|  |  | -    callback_cv_.wait(lock);
 | 
	
		
			
				|  |  | +  while (started_ && !shutdown_notified_) {
 | 
	
		
			
				|  |  | +    shutdown_cv_.wait(lock);
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 |