alts_shared_resource.cc
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2018 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 
20 
22 
23 #include <grpc/support/log.h>
24 
27 
29 
32 }
33 
34 static void thread_worker(void* /*arg*/) {
35  while (true) {
36  grpc_event event =
39  GPR_ASSERT(event.type != GRPC_QUEUE_TIMEOUT);
40  if (event.type == GRPC_QUEUE_SHUTDOWN) {
41  break;
42  }
43  GPR_ASSERT(event.type == GRPC_OP_COMPLETE);
45  static_cast<alts_handshaker_client*>(event.tag);
47  }
48 }
49 
51  g_alts_resource_dedicated.cq = nullptr;
53 }
54 
56  const char* handshaker_service_url) {
58  if (g_alts_resource_dedicated.cq == nullptr) {
60  // Disable retries so that we quickly get a signal when the
61  // handshake server is not reachable.
62  grpc_arg disable_retries_arg = grpc_channel_arg_integer_create(
63  const_cast<char*>(GRPC_ARG_ENABLE_RETRIES), 0);
64  grpc_channel_args args = {1, &disable_retries_arg};
66  grpc_channel_create(handshaker_service_url, creds, &args);
71  grpc_core::Thread("alts_tsi_handshaker", &thread_worker, nullptr);
76  }
78 }
79 
81  if (g_alts_resource_dedicated.cq != nullptr) {
89  }
91 }
grpc_arg
Definition: grpc_types.h:103
grpc_alts_get_shared_resource_dedicated
alts_shared_resource_dedicated * grpc_alts_get_shared_resource_dedicated(void)
Definition: alts_shared_resource.cc:30
gpr_mu_unlock
GPRAPI void gpr_mu_unlock(gpr_mu *mu)
thread_worker
static void thread_worker(void *)
Definition: alts_shared_resource.cc:34
log.h
client
Definition: examples/python/async_streaming/client.py:1
alts_shared_resource_dedicated::thread
grpc_core::Thread thread
Definition: alts_shared_resource.h:36
alts_shared_resource_dedicated::channel
grpc_channel * channel
Definition: alts_shared_resource.h:41
grpc_alts_shared_resource_dedicated_init
void grpc_alts_shared_resource_dedicated_init()
Definition: alts_shared_resource.cc:50
grpc_pollset_set_create
grpc_pollset_set * grpc_pollset_set_create()
Definition: pollset_set.cc:29
GRPC_QUEUE_SHUTDOWN
@ GRPC_QUEUE_SHUTDOWN
Definition: grpc_types.h:554
GRPC_OP_COMPLETE
@ GRPC_OP_COMPLETE
Definition: grpc_types.h:558
gpr_inf_future
GPRAPI gpr_timespec gpr_inf_future(gpr_clock_type type)
Definition: src/core/lib/gpr/time.cc:55
grpc_alts_shared_resource_dedicated_shutdown
void grpc_alts_shared_resource_dedicated_shutdown()
Definition: alts_shared_resource.cc:80
alts_shared_resource_dedicated::mu
gpr_mu mu
Definition: alts_shared_resource.h:40
grpc_channel_args
Definition: grpc_types.h:132
alts_handshaker_client_handle_response
void alts_handshaker_client_handle_response(alts_handshaker_client *c, bool is_ok)
Definition: alts_handshaker_client.cc:190
gpr_mu_destroy
GPRAPI void gpr_mu_destroy(gpr_mu *mu)
GRPC_ARG_ENABLE_RETRIES
#define GRPC_ARG_ENABLE_RETRIES
Definition: grpc_types.h:396
alts_shared_resource_dedicated::interested_parties
grpc_pollset_set * interested_parties
Definition: alts_shared_resource.h:38
alts_handshaker_client.h
asyncio_get_stats.args
args
Definition: asyncio_get_stats.py:40
GPR_ASSERT
#define GPR_ASSERT(x)
Definition: include/grpc/impl/codegen/log.h:94
grpc_pollset_set_del_pollset
void grpc_pollset_set_del_pollset(grpc_pollset_set *pollset_set, grpc_pollset *pollset)
Definition: pollset_set.cc:42
g_alts_resource_dedicated
static alts_shared_resource_dedicated g_alts_resource_dedicated
Definition: alts_shared_resource.cc:28
grpc_alts_shared_resource_dedicated_start
void grpc_alts_shared_resource_dedicated_start(const char *handshaker_service_url)
Definition: alts_shared_resource.cc:55
gpr_mu_init
GPRAPI void gpr_mu_init(gpr_mu *mu)
grpc_event
Definition: grpc_types.h:564
grpc_pollset_set_destroy
void grpc_pollset_set_destroy(grpc_pollset_set *pollset_set)
Definition: pollset_set.cc:33
grpc_cq_pollset
grpc_pollset * grpc_cq_pollset(grpc_completion_queue *cq)
Definition: completion_queue.cc:1433
grpc_insecure_credentials_create
GRPCAPI grpc_channel_credentials * grpc_insecure_credentials_create()
Definition: core/lib/security/credentials/insecure/insecure_credentials.cc:64
grpc_core::Thread::Join
void Join()
Definition: thd.h:141
gpr_mu_lock
GPRAPI void gpr_mu_lock(gpr_mu *mu)
alts_handshaker_client
Definition: alts_handshaker_client.cc:43
alts_shared_resource.h
alts_shared_resource_dedicated
Definition: alts_shared_resource.h:35
grpc_core::Thread::Start
void Start()
Definition: thd.h:125
grpc_channel_credentials_release
GRPCAPI void grpc_channel_credentials_release(grpc_channel_credentials *creds)
Definition: credentials.cc:36
grpc_channel_create
GRPCAPI grpc_channel * grpc_channel_create(const char *target, grpc_channel_credentials *creds, const grpc_channel_args *args)
Definition: chttp2_connector.cc:366
grpc_channel_arg_integer_create
grpc_arg grpc_channel_arg_integer_create(char *name, int value)
Definition: channel_args.cc:484
grpc_completion_queue_destroy
GRPCAPI void grpc_completion_queue_destroy(grpc_completion_queue *cq)
Definition: completion_queue.cc:1424
grpc_completion_queue_next
GRPCAPI grpc_event grpc_completion_queue_next(grpc_completion_queue *cq, gpr_timespec deadline, void *reserved)
Definition: completion_queue.cc:1133
grpc_completion_queue_shutdown
GRPCAPI void grpc_completion_queue_shutdown(grpc_completion_queue *cq)
Definition: completion_queue.cc:1416
grpc_channel_destroy
GRPCAPI void grpc_channel_destroy(grpc_channel *channel)
Definition: channel.cc:437
grpc_core::Thread
Definition: thd.h:43
alts_shared_resource_dedicated::cq
grpc_completion_queue * cq
Definition: alts_shared_resource.h:37
channel_args.h
grpc_completion_queue_create_for_next
GRPCAPI grpc_completion_queue * grpc_completion_queue_create_for_next(void *reserved)
Definition: completion_queue_factory.cc:62
GPR_CLOCK_REALTIME
@ GPR_CLOCK_REALTIME
Definition: gpr_types.h:39
grpc_pollset_set_add_pollset
void grpc_pollset_set_add_pollset(grpc_pollset_set *pollset_set, grpc_pollset *pollset)
Definition: pollset_set.cc:37
GRPC_QUEUE_TIMEOUT
@ GRPC_QUEUE_TIMEOUT
Definition: grpc_types.h:556
grpc_channel_credentials
Definition: src/core/lib/security/credentials/credentials.h:96
port_platform.h


grpc
Author(s):
autogenerated on Fri May 16 2025 02:57:41