Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
hiredis
Commits
be32bcdc
Unverified
Commit
be32bcdc
authored
Jul 26, 2020
by
Michael Grunder
Committed by
GitHub
Jul 26, 2020
Browse files
Minor refactor for scheduling an async timer. (#854)
Small change to the logic introduced in #839
parent
38b5ae54
Changes
2
Hide whitespace changes
Inline
Side-by-side
async_private.h
View file @
be32bcdc
...
...
@@ -54,14 +54,18 @@
} while(0);
static
inline
void
refreshTimeout
(
redisAsyncContext
*
ctx
)
{
if
(
!
(
ctx
->
c
.
flags
&
REDIS_CONNECTED
))
{
if
(
ctx
->
c
.
connect_timeout
&&
ctx
->
ev
.
scheduleTimer
&&
(
ctx
->
c
.
connect_timeout
->
tv_sec
||
ctx
->
c
.
connect_timeout
->
tv_usec
))
{
ctx
->
ev
.
scheduleTimer
(
ctx
->
ev
.
data
,
*
ctx
->
c
.
connect_timeout
);
#define REDIS_TIMER_ISSET(tvp) \
(tvp && ((tvp)->tv_sec || (tvp)->tv_usec))
#define REDIS_EL_TIMER(ac, tvp) \
if ((ac)->ev.scheduleTimer && REDIS_TIMER_ISSET(tvp)) { \
(ac)->ev.scheduleTimer((ac)->ev.data, *(tvp)); \
}
}
else
if
(
ctx
->
c
.
command_timeout
&&
ctx
->
ev
.
scheduleTimer
&&
(
ctx
->
c
.
command_timeout
->
tv_sec
||
ctx
->
c
.
command_timeout
->
tv_usec
))
{
ctx
->
ev
.
scheduleTimer
(
ctx
->
ev
.
data
,
*
ctx
->
c
.
command_timeout
);
if
(
ctx
->
c
.
flags
&
REDIS_CONNECTED
)
{
REDIS_EL_TIMER
(
ctx
,
ctx
->
c
.
command_timeout
);
}
else
{
REDIS_EL_TIMER
(
ctx
,
ctx
->
c
.
connect_timeout
);
}
}
...
...
hiredis.h
View file @
be32bcdc
...
...
@@ -176,9 +176,10 @@ typedef struct {
int
type
;
/* bit field of REDIS_OPT_xxx */
int
options
;
/* timeout value for connect operation.
i
f NULL, no timeout is used */
/* timeout value for connect operation.
I
f NULL, no timeout is used */
const
struct
timeval
*
connect_timeout
;
/* timeout value for commands. if NULL, no timeout is used. (can be set later on with redisSetTimeout/redisAsyncSetTimeout) */
/* timeout value for commands. If NULL, no timeout is used. This can be
* updated at runtime with redisSetTimeout/redisAsyncSetTimeout. */
const
struct
timeval
*
command_timeout
;
union
{
/** use this field for tcp/ip connections */
...
...
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