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
e3dd33ff
Commit
e3dd33ff
authored
10 years ago
by
Abhishek Kumar
Browse files
Options
Downloads
Patches
Plain Diff
clang formatting
parent
445612ec
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
test/core/fling/client.c
+8
-8
8 additions, 8 deletions
test/core/fling/client.c
test/core/fling/server.c
+60
-68
60 additions, 68 deletions
test/core/fling/server.c
with
68 additions
and
76 deletions
test/core/fling/client.c
+
8
−
8
View file @
e3dd33ff
...
@@ -83,7 +83,7 @@ static void init_ping_pong_request(void) {
...
@@ -83,7 +83,7 @@ static void init_ping_pong_request(void) {
static
void
step_ping_pong_request
(
void
)
{
static
void
step_ping_pong_request
(
void
)
{
call
=
grpc_channel_create_call
(
channel
,
cq
,
"/Reflector/reflectUnary"
,
call
=
grpc_channel_create_call
(
channel
,
cq
,
"/Reflector/reflectUnary"
,
"localhost"
,
gpr_inf_future
);
"localhost"
,
gpr_inf_future
);
GPR_ASSERT
(
GRPC_CALL_OK
==
grpc_call_start_batch
(
call
,
ops
,
6
,
(
void
*
)
1
));
GPR_ASSERT
(
GRPC_CALL_OK
==
grpc_call_start_batch
(
call
,
ops
,
6
,
(
void
*
)
1
));
grpc_event_finish
(
grpc_completion_queue_next
(
cq
,
gpr_inf_future
));
grpc_event_finish
(
grpc_completion_queue_next
(
cq
,
gpr_inf_future
));
grpc_call_destroy
(
call
);
grpc_call_destroy
(
call
);
...
@@ -92,11 +92,11 @@ static void step_ping_pong_request(void) {
...
@@ -92,11 +92,11 @@ static void step_ping_pong_request(void) {
static
void
init_ping_pong_stream
(
void
)
{
static
void
init_ping_pong_stream
(
void
)
{
call
=
grpc_channel_create_call
(
channel
,
cq
,
"/Reflector/reflectStream"
,
call
=
grpc_channel_create_call
(
channel
,
cq
,
"/Reflector/reflectStream"
,
"localhost"
,
gpr_inf_future
);
"localhost"
,
gpr_inf_future
);
stream_init_op
.
op
=
GRPC_OP_SEND_INITIAL_METADATA
;
stream_init_op
.
op
=
GRPC_OP_SEND_INITIAL_METADATA
;
stream_init_op
.
data
.
send_initial_metadata
.
count
=
0
;
stream_init_op
.
data
.
send_initial_metadata
.
count
=
0
;
GPR_ASSERT
(
GRPC_CALL_OK
==
grpc_call_start_batch
(
call
,
&
stream_init_op
,
1
,
GPR_ASSERT
(
GRPC_CALL_OK
==
(
void
*
)
1
));
grpc_call_start_batch
(
call
,
&
stream_init_op
,
1
,
(
void
*
)
1
));
grpc_event_finish
(
grpc_completion_queue_next
(
cq
,
gpr_inf_future
));
grpc_event_finish
(
grpc_completion_queue_next
(
cq
,
gpr_inf_future
));
grpc_metadata_array_init
(
&
initial_metadata_recv
);
grpc_metadata_array_init
(
&
initial_metadata_recv
);
...
@@ -108,8 +108,8 @@ static void init_ping_pong_stream(void) {
...
@@ -108,8 +108,8 @@ static void init_ping_pong_stream(void) {
}
}
static
void
step_ping_pong_stream
(
void
)
{
static
void
step_ping_pong_stream
(
void
)
{
GPR_ASSERT
(
GRPC_CALL_OK
==
grpc_call_start_batch
(
call
,
stream_step_ops
,
2
,
GPR_ASSERT
(
GRPC_CALL_OK
==
(
void
*
)
1
));
grpc_call_start_batch
(
call
,
stream_step_ops
,
2
,
(
void
*
)
1
));
grpc_event_finish
(
grpc_completion_queue_next
(
cq
,
gpr_inf_future
));
grpc_event_finish
(
grpc_completion_queue_next
(
cq
,
gpr_inf_future
));
}
}
...
@@ -126,7 +126,8 @@ typedef struct {
...
@@ -126,7 +126,8 @@ typedef struct {
static
const
scenario
scenarios
[]
=
{
static
const
scenario
scenarios
[]
=
{
{
"ping-pong-request"
,
init_ping_pong_request
,
step_ping_pong_request
},
{
"ping-pong-request"
,
init_ping_pong_request
,
step_ping_pong_request
},
{
"ping-pong-stream"
,
init_ping_pong_stream
,
step_ping_pong_stream
},
};
{
"ping-pong-stream"
,
init_ping_pong_stream
,
step_ping_pong_stream
},
};
int
main
(
int
argc
,
char
**
argv
)
{
int
main
(
int
argc
,
char
**
argv
)
{
gpr_slice
slice
=
gpr_slice_from_copied_string
(
"x"
);
gpr_slice
slice
=
gpr_slice_from_copied_string
(
"x"
);
...
@@ -176,7 +177,6 @@ int main(int argc, char **argv) {
...
@@ -176,7 +177,6 @@ int main(int argc, char **argv) {
the_buffer
=
grpc_byte_buffer_create
(
&
slice
,
payload_size
);
the_buffer
=
grpc_byte_buffer_create
(
&
slice
,
payload_size
);
histogram
=
gpr_histogram_create
(
0
.
01
,
60e9
);
histogram
=
gpr_histogram_create
(
0
.
01
,
60e9
);
sc
.
init
();
sc
.
init
();
for
(
i
=
0
;
i
<
1000
;
i
++
)
{
for
(
i
=
0
;
i
<
1000
;
i
++
)
{
...
...
This diff is collapsed.
Click to expand it.
test/core/fling/server.c
+
60
−
68
View file @
e3dd33ff
...
@@ -60,7 +60,6 @@ static grpc_byte_buffer *payload_buffer = NULL;
...
@@ -60,7 +60,6 @@ static grpc_byte_buffer *payload_buffer = NULL;
/* Used to drain the terminal read in unary calls. */
/* Used to drain the terminal read in unary calls. */
static
grpc_byte_buffer
*
terminal_buffer
=
NULL
;
static
grpc_byte_buffer
*
terminal_buffer
=
NULL
;
static
grpc_op
read_op
;
static
grpc_op
read_op
;
static
grpc_op
metadata_send_op
;
static
grpc_op
metadata_send_op
;
static
grpc_op
write_op
;
static
grpc_op
write_op
;
...
@@ -80,7 +79,7 @@ static void request_call(void) {
...
@@ -80,7 +79,7 @@ static void request_call(void) {
grpc_metadata_array_init
(
&
request_metadata_recv
);
grpc_metadata_array_init
(
&
request_metadata_recv
);
grpc_call_details_init
(
&
call_details
);
grpc_call_details_init
(
&
call_details
);
grpc_server_request_call
(
server
,
&
call
,
&
call_details
,
&
request_metadata_recv
,
grpc_server_request_call
(
server
,
&
call
,
&
call_details
,
&
request_metadata_recv
,
cq
,
tag
(
101
));
cq
,
tag
(
101
));
}
}
static
void
handle_unary_method
(
void
)
{
static
void
handle_unary_method
(
void
)
{
...
@@ -101,24 +100,22 @@ static void handle_unary_method(void) {
...
@@ -101,24 +100,22 @@ static void handle_unary_method(void) {
unary_ops
[
4
].
op
=
GRPC_OP_RECV_CLOSE_ON_SERVER
;
unary_ops
[
4
].
op
=
GRPC_OP_RECV_CLOSE_ON_SERVER
;
unary_ops
[
4
].
data
.
recv_close_on_server
.
cancelled
=
&
was_cancelled
;
unary_ops
[
4
].
data
.
recv_close_on_server
.
cancelled
=
&
was_cancelled
;
GPR_ASSERT
(
GRPC_CALL_OK
==
grpc_call_start_batch
(
call
,
unary_ops
,
5
,
GPR_ASSERT
(
GRPC_CALL_OK
==
grpc_call_start_batch
(
call
,
unary_ops
,
5
,
tag
(
6
)));
tag
(
6
)));
}
}
static
void
send_initial_metadata
(
void
)
{
static
void
send_initial_metadata
(
void
)
{
grpc_metadata_array_init
(
&
initial_metadata_send
);
grpc_metadata_array_init
(
&
initial_metadata_send
);
metadata_send_op
.
op
=
GRPC_OP_SEND_INITIAL_METADATA
;
metadata_send_op
.
op
=
GRPC_OP_SEND_INITIAL_METADATA
;
metadata_send_op
.
data
.
send_initial_metadata
.
count
=
0
;
metadata_send_op
.
data
.
send_initial_metadata
.
count
=
0
;
GPR_ASSERT
(
GRPC_CALL_OK
==
grpc_call_start_batch
(
call
,
&
metadata_send_op
,
1
,
GPR_ASSERT
(
GRPC_CALL_OK
==
tag
(
3
)));
grpc_call_start_batch
(
call
,
&
metadata_send_op
,
1
,
tag
(
3
)));
}
}
static
void
start_read_op
(
int
t
)
{
static
void
start_read_op
(
int
t
)
{
/* Starting read at server */
/* Starting read at server */
read_op
.
op
=
GRPC_OP_RECV_MESSAGE
;
read_op
.
op
=
GRPC_OP_RECV_MESSAGE
;
read_op
.
data
.
recv_message
=
&
payload_buffer
;
read_op
.
data
.
recv_message
=
&
payload_buffer
;
GPR_ASSERT
(
GRPC_CALL_OK
==
grpc_call_start_batch
(
call
,
&
read_op
,
1
,
GPR_ASSERT
(
GRPC_CALL_OK
==
grpc_call_start_batch
(
call
,
&
read_op
,
1
,
tag
(
t
)));
tag
(
t
)));
}
}
static
void
start_write_op
(
void
)
{
static
void
start_write_op
(
void
)
{
...
@@ -128,11 +125,9 @@ static void start_write_op(void) {
...
@@ -128,11 +125,9 @@ static void start_write_op(void) {
gpr_log
(
GPR_INFO
,
"NULL payload buffer !!!"
);
gpr_log
(
GPR_INFO
,
"NULL payload buffer !!!"
);
}
}
write_op
.
data
.
send_message
=
payload_buffer
;
write_op
.
data
.
send_message
=
payload_buffer
;
GPR_ASSERT
(
GRPC_CALL_OK
==
grpc_call_start_batch
(
call
,
&
write_op
,
1
,
GPR_ASSERT
(
GRPC_CALL_OK
==
grpc_call_start_batch
(
call
,
&
write_op
,
1
,
tag
(
2
)));
tag
(
2
)));
}
}
static
void
start_send_status
(
void
)
{
static
void
start_send_status
(
void
)
{
status_op
[
0
].
op
=
GRPC_OP_SEND_STATUS_FROM_SERVER
;
status_op
[
0
].
op
=
GRPC_OP_SEND_STATUS_FROM_SERVER
;
status_op
[
0
].
data
.
send_status_from_server
.
status
=
GRPC_STATUS_OK
;
status_op
[
0
].
data
.
send_status_from_server
.
status
=
GRPC_STATUS_OK
;
...
@@ -141,8 +136,7 @@ static void start_send_status(void) {
...
@@ -141,8 +136,7 @@ static void start_send_status(void) {
status_op
[
1
].
op
=
GRPC_OP_RECV_CLOSE_ON_SERVER
;
status_op
[
1
].
op
=
GRPC_OP_RECV_CLOSE_ON_SERVER
;
status_op
[
1
].
data
.
recv_close_on_server
.
cancelled
=
&
was_cancelled
;
status_op
[
1
].
data
.
recv_close_on_server
.
cancelled
=
&
was_cancelled
;
GPR_ASSERT
(
GRPC_CALL_OK
==
grpc_call_start_batch
(
call
,
status_op
,
2
,
GPR_ASSERT
(
GRPC_CALL_OK
==
grpc_call_start_batch
(
call
,
status_op
,
2
,
tag
(
4
)));
tag
(
4
)));
}
}
static
void
sigint_handler
(
int
x
)
{
got_sigint
=
1
;
}
static
void
sigint_handler
(
int
x
)
{
got_sigint
=
1
;
}
...
@@ -214,66 +208,64 @@ int main(int argc, char **argv) {
...
@@ -214,66 +208,64 @@ int main(int argc, char **argv) {
s
=
ev
->
tag
;
s
=
ev
->
tag
;
switch
(
ev
->
type
)
{
switch
(
ev
->
type
)
{
case
GRPC_OP_COMPLETE
:
case
GRPC_OP_COMPLETE
:
switch
((
gpr_intptr
)
s
)
{
switch
((
gpr_intptr
)
s
)
{
case
101
:
case
101
:
if
(
call
!=
NULL
)
{
if
(
call
!=
NULL
)
{
if
(
0
==
strcmp
(
call_details
.
method
,
if
(
0
==
"/Reflector/reflectStream"
))
{
strcmp
(
call_details
.
method
,
"/Reflector/reflectStream"
))
{
/* Received streaming call. Send metadata here. */
/* Received streaming call. Send metadata here. */
start_read_op
(
1
);
start_read_op
(
1
);
send_initial_metadata
();
send_initial_metadata
();
}
else
{
}
else
{
/* Received unary call. Can do all ops in one batch. */
/* Received unary call. Can do all ops in one batch. */
start_read_op
(
5
);
start_read_op
(
5
);
}
}
}
}
else
{
else
{
GPR_ASSERT
(
shutdown_started
);
GPR_ASSERT
(
shutdown_started
);
}
}
/* request_call();
/* request_call();
*/
*/
break
;
break
;
case
1
:
case
1
:
if
(
payload_buffer
!=
NULL
)
{
if
(
payload_buffer
!=
NULL
)
{
/* Received payload from client. */
/* Received payload from client. */
start_write_op
();
start_write_op
();
}
else
{
}
/* Received end of stream from client. */
else
{
start_send_status
();
/* Received end of stream from client. */
}
start_send_status
();
break
;
}
case
2
:
break
;
/* Write completed at server */
case
2
:
start_read_op
(
1
);
/* Write completed at server */
break
;
start_read_op
(
1
);
case
3
:
break
;
/* Metadata send completed at server */
case
3
:
break
;
/* Metadata send completed at server */
case
4
:
break
;
/* Send status and close completed at server */
case
4
:
grpc_call_destroy
(
call
);
/* Send status and close completed at server */
request_call
();
grpc_call_destroy
(
call
);
break
;
request_call
();
case
5
:
break
;
/* Finished payload read for unary. Start all reamaining
case
5
:
* unary ops in a batch.
/* Finished payload read for unary. Start all reamaining
*/
* unary ops in a batch.
handle_unary_method
();
*/
break
;
handle_unary_method
();
case
6
:
break
;
/* Finished unary call. */
case
6
:
grpc_call_destroy
(
call
);
/* Finished unary call. */
request_call
();
grpc_call_destroy
(
call
);
break
;
request_call
();
}
break
;
break
;
}
break
;
case
GRPC_SERVER_RPC_NEW
:
case
GRPC_SERVER_RPC_NEW
:
case
GRPC_WRITE_ACCEPTED
:
case
GRPC_WRITE_ACCEPTED
:
case
GRPC_READ
:
case
GRPC_READ
:
case
GRPC_FINISH_ACCEPTED
:
case
GRPC_FINISH_ACCEPTED
:
case
GRPC_FINISHED
:
case
GRPC_FINISHED
:
gpr_log
(
GPR_ERROR
,
"Unexpected event type."
);
gpr_log
(
GPR_ERROR
,
"Unexpected event type."
);
GPR_ASSERT
(
0
);
GPR_ASSERT
(
0
);
break
;
break
;
case
GRPC_QUEUE_SHUTDOWN
:
case
GRPC_QUEUE_SHUTDOWN
:
...
...
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