|  | @@ -121,6 +121,9 @@ grpc_error *grpc_tcp_server_create(grpc_closure *shutdown_complete,
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  static void finish_shutdown(grpc_exec_ctx *exec_ctx, grpc_tcp_server *s) {
 | 
	
		
			
				|  |  | +  gpr_mu_lock(&s->mu);
 | 
	
		
			
				|  |  | +  GPR_ASSERT(s->shutdown);
 | 
	
		
			
				|  |  | +  gpr_mu_unlock(&s->mu);
 | 
	
		
			
				|  |  |    if (s->shutdown_complete != NULL) {
 | 
	
		
			
				|  |  |      grpc_exec_ctx_sched(exec_ctx, s->shutdown_complete, GRPC_ERROR_NONE, NULL);
 | 
	
		
			
				|  |  |    }
 | 
	
	
		
			
				|  | @@ -139,7 +142,7 @@ static void finish_shutdown(grpc_exec_ctx *exec_ctx, grpc_tcp_server *s) {
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  grpc_tcp_server *grpc_tcp_server_ref(grpc_tcp_server *s) {
 | 
	
		
			
				|  |  | -  gpr_ref(&s->refs);
 | 
	
		
			
				|  |  | +  gpr_ref_non_zero(&s->refs);
 | 
	
		
			
				|  |  |    return s;
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -174,19 +177,11 @@ static void tcp_server_destroy(grpc_exec_ctx *exec_ctx, grpc_tcp_server *s) {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  void grpc_tcp_server_unref(grpc_exec_ctx *exec_ctx, grpc_tcp_server *s) {
 | 
	
		
			
				|  |  |    if (gpr_unref(&s->refs)) {
 | 
	
		
			
				|  |  | -    /* Complete shutdown_starting work before destroying. */
 | 
	
		
			
				|  |  | -    grpc_exec_ctx local_exec_ctx = GRPC_EXEC_CTX_INIT;
 | 
	
		
			
				|  |  | +    grpc_tcp_server_shutdown_listeners(exec_ctx, s);
 | 
	
		
			
				|  |  |      gpr_mu_lock(&s->mu);
 | 
	
		
			
				|  |  | -    grpc_exec_ctx_enqueue_list(&local_exec_ctx, &s->shutdown_starting, NULL);
 | 
	
		
			
				|  |  | +    grpc_exec_ctx_enqueue_list(exec_ctx, &s->shutdown_starting, NULL);
 | 
	
		
			
				|  |  |      gpr_mu_unlock(&s->mu);
 | 
	
		
			
				|  |  | -    if (exec_ctx == NULL) {
 | 
	
		
			
				|  |  | -      grpc_exec_ctx_flush(&local_exec_ctx);
 | 
	
		
			
				|  |  | -      tcp_server_destroy(&local_exec_ctx, s);
 | 
	
		
			
				|  |  | -      grpc_exec_ctx_finish(&local_exec_ctx);
 | 
	
		
			
				|  |  | -    } else {
 | 
	
		
			
				|  |  | -      grpc_exec_ctx_finish(&local_exec_ctx);
 | 
	
		
			
				|  |  | -      tcp_server_destroy(exec_ctx, s);
 | 
	
		
			
				|  |  | -    }
 | 
	
		
			
				|  |  | +    tcp_server_destroy(exec_ctx, s);
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 |