blob: d5948c9516e7c1e0c57815c561881b838226edb9 [file] [log] [blame]
Yihua Zhang1435bfc2017-07-17 11:20:51 -07001/*
2 *
3 * Copyright 2017 gRPC authors.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 */
18
19#include "src/core/tsi/gts_transport_security.h"
20
21#include <string.h>
22
23static gts_shared_resource g_gts_resource;
24
Craig Tillerbaa14a92017-11-03 09:09:36 -070025gts_shared_resource* gts_get_shared_resource(void) { return &g_gts_resource; }
Yihua Zhang1435bfc2017-07-17 11:20:51 -070026
Yash Tibrewal83062842017-09-21 18:56:08 -070027extern "C" void grpc_tsi_gts_init() {
Yihua Zhang1435bfc2017-07-17 11:20:51 -070028 memset(&g_gts_resource, 0, sizeof(gts_shared_resource));
29 gpr_mu_init(&g_gts_resource.mu);
30}
31
Yash Tibrewal83062842017-09-21 18:56:08 -070032extern "C" void grpc_tsi_gts_shutdown() {
Yihua Zhang1435bfc2017-07-17 11:20:51 -070033 gpr_mu_destroy(&g_gts_resource.mu);
Craig Tiller4782d922017-11-10 09:53:21 -080034 if (g_gts_resource.cq == nullptr) {
Yihua Zhang1435bfc2017-07-17 11:20:51 -070035 return;
36 }
37 grpc_completion_queue_destroy(g_gts_resource.cq);
38 grpc_channel_destroy(g_gts_resource.channel);
39 gpr_thd_join(g_gts_resource.thread_id);
40}