Yihua Zhang | 1435bfc | 2017-07-17 11:20:51 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 23 | static gts_shared_resource g_gts_resource; |
| 24 | |
Craig Tiller | baa14a9 | 2017-11-03 09:09:36 -0700 | [diff] [blame] | 25 | gts_shared_resource* gts_get_shared_resource(void) { return &g_gts_resource; } |
Yihua Zhang | 1435bfc | 2017-07-17 11:20:51 -0700 | [diff] [blame] | 26 | |
Yash Tibrewal | 8306284 | 2017-09-21 18:56:08 -0700 | [diff] [blame] | 27 | extern "C" void grpc_tsi_gts_init() { |
Yihua Zhang | 1435bfc | 2017-07-17 11:20:51 -0700 | [diff] [blame] | 28 | memset(&g_gts_resource, 0, sizeof(gts_shared_resource)); |
| 29 | gpr_mu_init(&g_gts_resource.mu); |
| 30 | } |
| 31 | |
Yash Tibrewal | 8306284 | 2017-09-21 18:56:08 -0700 | [diff] [blame] | 32 | extern "C" void grpc_tsi_gts_shutdown() { |
Yihua Zhang | 1435bfc | 2017-07-17 11:20:51 -0700 | [diff] [blame] | 33 | gpr_mu_destroy(&g_gts_resource.mu); |
Craig Tiller | 4782d92 | 2017-11-10 09:53:21 -0800 | [diff] [blame] | 34 | if (g_gts_resource.cq == nullptr) { |
Yihua Zhang | 1435bfc | 2017-07-17 11:20:51 -0700 | [diff] [blame] | 35 | 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 | } |