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
c82c36b4
Commit
c82c36b4
authored
10 years ago
by
Craig Tiller
Browse files
Options
Downloads
Plain Diff
Merge pull request #920 from vjpai/async-probs
Solving crashes in async tests
parents
95fb8b12
dbb79631
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
src/cpp/server/server.cc
+4
-1
4 additions, 1 deletion
src/cpp/server/server.cc
test/cpp/qps/server_async.cc
+12
-8
12 additions, 8 deletions
test/cpp/qps/server_async.cc
with
16 additions
and
9 deletions
src/cpp/server/server.cc
+
4
−
1
View file @
c82c36b4
...
@@ -324,6 +324,7 @@ class Server::AsyncRequest GRPC_FINAL : public CompletionQueueTag {
...
@@ -324,6 +324,7 @@ class Server::AsyncRequest GRPC_FINAL : public CompletionQueueTag {
bool
FinalizeResult
(
void
**
tag
,
bool
*
status
)
GRPC_OVERRIDE
{
bool
FinalizeResult
(
void
**
tag
,
bool
*
status
)
GRPC_OVERRIDE
{
*
tag
=
tag_
;
*
tag
=
tag_
;
bool
orig_status
=
*
status
;
if
(
*
status
&&
request_
)
{
if
(
*
status
&&
request_
)
{
if
(
payload_
)
{
if
(
payload_
)
{
*
status
=
DeserializeProto
(
payload_
,
request_
);
*
status
=
DeserializeProto
(
payload_
,
request_
);
...
@@ -343,7 +344,9 @@ class Server::AsyncRequest GRPC_FINAL : public CompletionQueueTag {
...
@@ -343,7 +344,9 @@ class Server::AsyncRequest GRPC_FINAL : public CompletionQueueTag {
}
}
ctx_
->
call_
=
call_
;
ctx_
->
call_
=
call_
;
Call
call
(
call_
,
server_
,
cq_
);
Call
call
(
call_
,
server_
,
cq_
);
ctx_
->
BeginCompletionOp
(
&
call
);
if
(
orig_status
&&
call_
)
{
ctx_
->
BeginCompletionOp
(
&
call
);
}
// just the pointers inside call are copied here
// just the pointers inside call are copied here
stream_
->
BindCall
(
&
call
);
stream_
->
BindCall
(
&
call
);
delete
this
;
delete
this
;
...
...
This diff is collapsed.
Click to expand it.
test/cpp/qps/server_async.cc
+
12
−
8
View file @
c82c36b4
...
@@ -143,21 +143,24 @@ class AsyncQpsServerTest {
...
@@ -143,21 +143,24 @@ class AsyncQpsServerTest {
delete
contexts_
.
front
();
delete
contexts_
.
front
();
contexts_
.
pop_front
();
contexts_
.
pop_front
();
}
}
for
(
auto
&
thr
:
threads_
)
{
thr
.
join
();
}
}
}
void
ServeRpcs
(
int
num_threads
)
{
void
ServeRpcs
(
int
num_threads
)
{
std
::
vector
<
std
::
thread
>
threads
;
for
(
int
i
=
0
;
i
<
num_threads
;
i
++
)
{
for
(
int
i
=
0
;
i
<
num_threads
;
i
++
)
{
threads
.
push_back
(
std
::
thread
([
=
]()
{
threads
_
.
push_back
(
std
::
thread
([
=
]()
{
// Wait until work is available or we are shutting down
// Wait until work is available or we are shutting down
bool
ok
;
bool
ok
;
void
*
got_tag
;
void
*
got_tag
;
while
(
srv_cq_
.
Next
(
&
got_tag
,
&
ok
))
{
while
(
srv_cq_
.
Next
(
&
got_tag
,
&
ok
))
{
EXPECT_EQ
(
ok
,
true
);
if
(
ok
)
{
ServerRpcContext
*
ctx
=
detag
(
got_tag
);
ServerRpcContext
*
ctx
=
detag
(
got_tag
);
// The tag is a pointer to an RPC context to invoke
// The tag is a pointer to an RPC context to invoke
if
(
ctx
->
RunNextState
()
==
false
)
{
if
(
ctx
->
RunNextState
()
==
false
)
{
// this RPC context is done, so refresh it
// this RPC context is done, so refresh it
ctx
->
Reset
();
ctx
->
Reset
();
}
}
}
}
}
return
;
return
;
...
@@ -260,6 +263,7 @@ class AsyncQpsServerTest {
...
@@ -260,6 +263,7 @@ class AsyncQpsServerTest {
}
}
CompletionQueue
srv_cq_
;
CompletionQueue
srv_cq_
;
TestService
::
AsyncService
async_service_
;
TestService
::
AsyncService
async_service_
;
std
::
vector
<
std
::
thread
>
threads_
;
std
::
unique_ptr
<
Server
>
server_
;
std
::
unique_ptr
<
Server
>
server_
;
std
::
function
<
void
(
ServerContext
*
,
SimpleRequest
*
,
std
::
function
<
void
(
ServerContext
*
,
SimpleRequest
*
,
grpc
::
ServerAsyncResponseWriter
<
SimpleResponse
>
*
,
void
*
)
>
grpc
::
ServerAsyncResponseWriter
<
SimpleResponse
>
*
,
void
*
)
>
...
...
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