Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Grpc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tci-gateway-module
Grpc
Commits
3bf289d0
Commit
3bf289d0
authored
8 years ago
by
Craig Tiller
Browse files
Options
Downloads
Patches
Plain Diff
Begin converting lame_client.c to C++
parent
b3d70102
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/core/lib/surface/lame_client.cc
+36
-26
36 additions, 26 deletions
src/core/lib/surface/lame_client.cc
with
36 additions
and
26 deletions
src/core/lib/surface/lame_client.c
→
src/core/lib/surface/lame_client.c
c
+
36
−
26
View file @
3bf289d0
...
...
@@ -31,39 +31,49 @@
*
*/
#include
"src/core/lib/surface/lame_client.h"
#include
<grpc/grpc.h>
#include
<string.h>
#include
<atomic>
#include
<grpc/support/alloc.h>
#include
<grpc/support/log.h>
extern
"C"
{
#include
"src/core/lib/channel/channel_stack.h"
#include
"src/core/lib/support/string.h"
#include
"src/core/lib/surface/api_trace.h"
#include
"src/core/lib/surface/call.h"
#include
"src/core/lib/surface/channel.h"
#include
"src/core/lib/surface/lame_client.h"
#include
"src/core/lib/transport/static_metadata.h"
}
namespace
grpc_core
{
typedef
struct
{
namespace
{
struct
CallData
{
grpc_linked_mdelem
status
;
grpc_linked_mdelem
details
;
gpr_atm
filled_metadata
;
}
call_data
;
std
::
atomic
<
bool
>
filled_metadata
;
};
typedef
struct
{
struct
ChannelData
{
grpc_status_code
error_code
;
const
char
*
error_message
;
}
channel_data
;
};
static
void
fill_metadata
(
grpc_exec_ctx
*
exec_ctx
,
grpc_call_element
*
elem
,
grpc_metadata_batch
*
mdb
)
{
call_data
*
calld
=
elem
->
call_data
;
if
(
!
gpr_atm_no_barrier_cas
(
&
calld
->
filled_metadata
,
0
,
1
))
{
CallData
*
calld
=
static_cast
<
CallData
*>
(
elem
->
call_data
);
bool
expected
=
false
;
if
(
!
calld
->
filled_metadata
.
compare_exchange_strong
(
expected
,
true
,
std
::
memory_order_relaxed
,
std
::
memory_order_relaxed
))
{
return
;
}
c
hannel
_d
ata
*
chand
=
elem
->
channel_data
;
C
hannel
D
ata
*
chand
=
static_cast
<
ChannelData
*>
(
elem
->
channel_data
)
;
char
tmp
[
GPR_LTOA_MIN_BUFSIZE
];
gpr_ltoa
(
chand
->
error_code
,
tmp
);
calld
->
status
.
md
=
grpc_mdelem_from_slices
(
...
...
@@ -83,7 +93,6 @@ static void fill_metadata(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
static
void
lame_start_transport_stream_op
(
grpc_exec_ctx
*
exec_ctx
,
grpc_call_element
*
elem
,
grpc_transport_stream_op
*
op
)
{
GRPC_CALL_LOG_OP
(
GPR_INFO
,
elem
,
op
);
if
(
op
->
recv_initial_metadata
!=
NULL
)
{
fill_metadata
(
exec_ctx
,
elem
,
op
->
recv_initial_metadata
);
}
else
if
(
op
->
recv_trailing_metadata
!=
NULL
)
{
...
...
@@ -125,8 +134,6 @@ static void lame_start_transport_op(grpc_exec_ctx *exec_ctx,
static
grpc_error
*
init_call_elem
(
grpc_exec_ctx
*
exec_ctx
,
grpc_call_element
*
elem
,
const
grpc_call_element_args
*
args
)
{
call_data
*
calld
=
elem
->
call_data
;
gpr_atm_no_barrier_store
(
&
calld
->
filled_metadata
,
0
);
return
GRPC_ERROR_NONE
;
}
...
...
@@ -147,18 +154,22 @@ static grpc_error *init_channel_elem(grpc_exec_ctx *exec_ctx,
static
void
destroy_channel_elem
(
grpc_exec_ctx
*
exec_ctx
,
grpc_channel_element
*
elem
)
{}
const
grpc_channel_filter
grpc_lame_filter
=
{
lame_start_transport_stream_op
,
lame_start_transport_op
,
sizeof
(
call_data
),
init_call_elem
,
}
// namespace
}
// namespace grpc_core
extern
"C"
const
grpc_channel_filter
grpc_lame_filter
=
{
grpc_core
::
lame_start_transport_stream_op
,
grpc_core
::
lame_start_transport_op
,
sizeof
(
grpc_core
::
CallData
),
grpc_core
::
init_call_elem
,
grpc_call_stack_ignore_set_pollset_or_pollset_set
,
destroy_call_elem
,
sizeof
(
c
hannel
_d
ata
),
init_channel_elem
,
destroy_channel_elem
,
lame_get_peer
,
lame_get_channel_info
,
grpc_core
::
destroy_call_elem
,
sizeof
(
grpc_core
::
C
hannel
D
ata
),
grpc_core
::
init_channel_elem
,
grpc_core
::
destroy_channel_elem
,
grpc_core
::
lame_get_peer
,
grpc_core
::
lame_get_channel_info
,
"lame-client"
,
};
...
...
@@ -169,7 +180,6 @@ grpc_channel *grpc_lame_client_channel_create(const char *target,
const
char
*
error_message
)
{
grpc_exec_ctx
exec_ctx
=
GRPC_EXEC_CTX_INIT
;
grpc_channel_element
*
elem
;
channel_data
*
chand
;
grpc_channel
*
channel
=
grpc_channel_create
(
&
exec_ctx
,
target
,
NULL
,
GRPC_CLIENT_LAME_CHANNEL
,
NULL
);
elem
=
grpc_channel_stack_element
(
grpc_channel_get_channel_stack
(
channel
),
0
);
...
...
@@ -178,7 +188,7 @@ grpc_channel *grpc_lame_client_channel_create(const char *target,
"error_message=%s)"
,
3
,
(
target
,
(
int
)
error_code
,
error_message
));
GPR_ASSERT
(
elem
->
filter
==
&
grpc_lame_filter
);
chand
=
(
c
hannel
_d
ata
*
)
elem
->
channel_data
;
auto
chand
=
static_cast
<
grpc_core
::
C
hannel
D
ata
*
>
(
elem
->
channel_data
)
;
chand
->
error_code
=
error_code
;
chand
->
error_message
=
error_message
;
grpc_exec_ctx_finish
(
&
exec_ctx
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment