Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
B
brpc
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
brpc
Commits
6881c5bf
Commit
6881c5bf
authored
Oct 30, 2018
by
zhujiashun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refine comment
parent
d35d8210
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
7 deletions
+20
-7
controller_private_accessor.h
src/brpc/details/controller_private_accessor.h
+2
-0
http_rpc_protocol.cpp
src/brpc/policy/http_rpc_protocol.cpp
+18
-7
No files found.
src/brpc/details/controller_private_accessor.h
View file @
6881c5bf
...
...
@@ -128,6 +128,8 @@ public:
std
::
string
&
protocol_param
()
{
return
_cntl
->
protocol_param
();
}
const
std
::
string
&
protocol_param
()
const
{
return
_cntl
->
protocol_param
();
}
// Note: This function can only be called in server side. The deadline of client
// side is properly set in the RPC sending path.
void
set_deadline_us
(
int64_t
deadline_us
)
{
_cntl
->
_deadline_us
=
deadline_us
;
}
private
:
...
...
src/brpc/policy/http_rpc_protocol.cpp
View file @
6881c5bf
...
...
@@ -1191,7 +1191,7 @@ void EndRunningCallMethodInPool(
::
google
::
protobuf
::
Message
*
response
,
::
google
::
protobuf
::
Closure
*
done
);
static
int64_t
ConvertGrpcTimeoutTo
M
S
(
int64_t
timeout_value
,
const
char
timeout_unit
)
{
static
int64_t
ConvertGrpcTimeoutTo
U
S
(
int64_t
timeout_value
,
const
char
timeout_unit
)
{
switch
(
timeout_unit
)
{
case
'H'
:
timeout_value
*=
(
3600
*
1000000L
);
...
...
@@ -1451,12 +1451,23 @@ void ProcessHttpRequest(InputMessageBase *msg) {
const
std
::
string
*
grpc_timeout
=
req_header
.
GetHeader
(
common
->
GRPC_TIMEOUT
);
if
(
grpc_timeout
&&
!
grpc_timeout
->
empty
())
{
const
char
timeout_unit
=
grpc_timeout
->
back
();
// If no digits were found, strtol returns zero as timeout value
int64_t
timeout_value_ms
=
ConvertGrpcTimeoutToMS
((
int64_t
)
strtol
(
grpc_timeout
->
data
(),
NULL
,
10
),
timeout_unit
);
if
(
timeout_value_ms
>=
0
)
{
accessor
.
set_deadline_us
(
butil
::
gettimeofday_us
()
+
timeout_value_ms
);
char
*
endptr
=
NULL
;
int64_t
timeout_value
=
(
int64_t
)
strtol
(
grpc_timeout
->
data
(),
&
endptr
,
10
);
// Only the format that the digit number is equal to (timeout header size - 1) is valid.
// Otherwise the format is not valid and the is treated as no deadline.
// For example:
// 1H, 2993S, 82m is valid.
// 30A is also valid, but the following ConvertGrpcTimeoutToUS would return -1 since 'A'
// is not a valid time unit.
// 123ASH is not vaid since the digit number is 3, while the size is 6.
// HHH is not valid since the dight number is 0, while the size is 3.
if
(
endptr
-
grpc_timeout
->
data
()
==
grpc_timeout
->
size
()
-
1
)
{
int64_t
timeout_value_us
=
ConvertGrpcTimeoutToUS
(
timeout_unit
);
if
(
timeout_value_us
>=
0
)
{
accessor
.
set_deadline_us
(
butil
::
gettimeofday_us
()
+
timeout_value_us
);
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment