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
d35d8210
Commit
d35d8210
authored
Oct 29, 2018
by
zhujiashun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check emptiness of grpc_timeout && change the name of _abstime_us to _deadline_us
parent
6a75adeb
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
21 additions
and
21 deletions
+21
-21
channel.cpp
src/brpc/channel.cpp
+7
-7
controller.cpp
src/brpc/controller.cpp
+4
-4
controller.h
src/brpc/controller.h
+2
-2
controller_private_accessor.h
src/brpc/details/controller_private_accessor.h
+1
-3
parallel_channel.cpp
src/brpc/parallel_channel.cpp
+3
-3
http_rpc_protocol.cpp
src/brpc/policy/http_rpc_protocol.cpp
+4
-2
No files found.
src/brpc/channel.cpp
View file @
d35d8210
...
...
@@ -493,12 +493,12 @@ void Channel::CallMethod(const google::protobuf::MethodDescriptor* method,
// Setup timer for backup request. When it occurs, we'll setup a
// timer of timeout_ms before sending backup request.
// _
abstim
e_us is for truncating _connect_timeout_ms and resetting
// _
deadlin
e_us is for truncating _connect_timeout_ms and resetting
// timer when EBACKUPREQUEST occurs.
if
(
cntl
->
timeout_ms
()
<
0
)
{
cntl
->
_
abstim
e_us
=
-
1
;
cntl
->
_
deadlin
e_us
=
-
1
;
}
else
{
cntl
->
_
abstim
e_us
=
cntl
->
timeout_ms
()
*
1000L
+
start_send_real_us
;
cntl
->
_
deadlin
e_us
=
cntl
->
timeout_ms
()
*
1000L
+
start_send_real_us
;
}
const
int
rc
=
bthread_timer_add
(
&
cntl
->
_timeout_id
,
...
...
@@ -512,18 +512,18 @@ void Channel::CallMethod(const google::protobuf::MethodDescriptor* method,
}
else
if
(
cntl
->
timeout_ms
()
>=
0
)
{
// Setup timer for RPC timetout
// _
abstim
e_us is for truncating _connect_timeout_ms
cntl
->
_
abstim
e_us
=
cntl
->
timeout_ms
()
*
1000L
+
start_send_real_us
;
// _
deadlin
e_us is for truncating _connect_timeout_ms
cntl
->
_
deadlin
e_us
=
cntl
->
timeout_ms
()
*
1000L
+
start_send_real_us
;
const
int
rc
=
bthread_timer_add
(
&
cntl
->
_timeout_id
,
butil
::
microseconds_to_timespec
(
cntl
->
_
abstim
e_us
),
butil
::
microseconds_to_timespec
(
cntl
->
_
deadlin
e_us
),
HandleTimeout
,
(
void
*
)
correlation_id
.
value
);
if
(
BAIDU_UNLIKELY
(
rc
!=
0
))
{
cntl
->
SetFailed
(
rc
,
"Fail to add timer for timeout"
);
return
cntl
->
HandleSendFailed
();
}
}
else
{
cntl
->
_
abstim
e_us
=
-
1
;
cntl
->
_
deadlin
e_us
=
-
1
;
}
cntl
->
IssueRPC
(
start_send_real_us
);
...
...
src/brpc/controller.cpp
View file @
d35d8210
...
...
@@ -222,7 +222,7 @@ void Controller::ResetPods() {
_timeout_ms
=
UNSET_MAGIC_NUM
;
_backup_request_ms
=
UNSET_MAGIC_NUM
;
_connect_timeout_ms
=
UNSET_MAGIC_NUM
;
_
abstim
e_us
=
-
1
;
_
deadlin
e_us
=
-
1
;
_timeout_id
=
0
;
_begin_time_us
=
0
;
_end_time_us
=
0
;
...
...
@@ -568,7 +568,7 @@ void Controller::OnVersionedRPCReturned(const CompletionInfo& info,
if
(
timeout_ms
()
>=
0
)
{
rc
=
bthread_timer_add
(
&
_timeout_id
,
butil
::
microseconds_to_timespec
(
_
abstim
e_us
),
butil
::
microseconds_to_timespec
(
_
deadlin
e_us
),
HandleTimeout
,
(
void
*
)
_correlation_id
.
value
);
}
if
(
rc
!=
0
)
{
...
...
@@ -1111,10 +1111,10 @@ void Controller::IssueRPC(int64_t start_realtime_us) {
timespec
connect_abstime
;
timespec
*
pabstime
=
NULL
;
if
(
_connect_timeout_ms
>
0
)
{
if
(
_
abstim
e_us
>=
0
)
{
if
(
_
deadlin
e_us
>=
0
)
{
connect_abstime
=
butil
::
microseconds_to_timespec
(
std
::
min
(
_connect_timeout_ms
*
1000L
+
start_realtime_us
,
_
abstim
e_us
));
_
deadlin
e_us
));
}
else
{
connect_abstime
=
butil
::
microseconds_to_timespec
(
_connect_timeout_ms
*
1000L
+
start_realtime_us
);
...
...
src/brpc/controller.h
View file @
d35d8210
...
...
@@ -482,7 +482,7 @@ public:
// Get deadline of this RPC (since the Epoch in microseconds).
// -1 means no deadline.
int64_t
deadline_us
()
const
{
return
_
abstim
e_us
;
}
int64_t
deadline_us
()
const
{
return
_
deadlin
e_us
;
}
private
:
struct
CompletionInfo
{
...
...
@@ -667,7 +667,7 @@ private:
int32_t
_connect_timeout_ms
;
int32_t
_backup_request_ms
;
// Deadline of this RPC (since the Epoch in microseconds).
int64_t
_
abstim
e_us
;
int64_t
_
deadlin
e_us
;
// Timer registered to trigger RPC timeout event
bthread_timer_t
_timeout_id
;
...
...
src/brpc/details/controller_private_accessor.h
View file @
d35d8210
...
...
@@ -128,9 +128,7 @@ public:
std
::
string
&
protocol_param
()
{
return
_cntl
->
protocol_param
();
}
const
std
::
string
&
protocol_param
()
const
{
return
_cntl
->
protocol_param
();
}
void
set_deadline_us
(
int64_t
timeout_us
)
{
_cntl
->
_abstime_us
=
butil
::
gettimeofday_us
()
+
timeout_us
;
}
void
set_deadline_us
(
int64_t
deadline_us
)
{
_cntl
->
_deadline_us
=
deadline_us
;
}
private
:
Controller
*
_cntl
;
...
...
src/brpc/parallel_channel.cpp
View file @
d35d8210
...
...
@@ -658,18 +658,18 @@ void ParallelChannel::CallMethod(
cntl
->
set_timeout_ms
(
_options
.
timeout_ms
);
}
if
(
cntl
->
timeout_ms
()
>=
0
)
{
cntl
->
_
abstim
e_us
=
cntl
->
timeout_ms
()
*
1000L
+
cntl
->
_begin_time_us
;
cntl
->
_
deadlin
e_us
=
cntl
->
timeout_ms
()
*
1000L
+
cntl
->
_begin_time_us
;
// Setup timer for RPC timetout
const
int
rc
=
bthread_timer_add
(
&
cntl
->
_timeout_id
,
butil
::
microseconds_to_timespec
(
cntl
->
_
abstim
e_us
),
butil
::
microseconds_to_timespec
(
cntl
->
_
deadlin
e_us
),
HandleTimeout
,
(
void
*
)
cid
.
value
);
if
(
rc
!=
0
)
{
cntl
->
SetFailed
(
rc
,
"Fail to add timer"
);
goto
FAIL
;
}
}
else
{
cntl
->
_
abstim
e_us
=
-
1
;
cntl
->
_
deadlin
e_us
=
-
1
;
}
d
->
SaveThreadInfoOfCallsite
();
CHECK_EQ
(
0
,
bthread_id_unlock
(
cid
));
...
...
src/brpc/policy/http_rpc_protocol.cpp
View file @
d35d8210
...
...
@@ -1449,12 +1449,14 @@ void ProcessHttpRequest(InputMessageBase *msg) {
}
}
const
std
::
string
*
grpc_timeout
=
req_header
.
GetHeader
(
common
->
GRPC_TIMEOUT
);
if
(
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
(
timeout_value_ms
);
accessor
.
set_deadline_us
(
butil
::
gettimeofday_us
()
+
timeout_value_ms
);
}
}
}
...
...
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