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
redis
Commits
13e4c2a9
Commit
13e4c2a9
authored
Mar 26, 2020
by
antirez
Browse files
Precise timeouts: fix comments after functional change.
parent
aa9d92d9
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/server.c
View file @
13e4c2a9
...
@@ -1530,7 +1530,7 @@ int clientsCronHandleTimeout(client *c, mstime_t now_ms) {
...
@@ -1530,7 +1530,7 @@ int clientsCronHandleTimeout(client *c, mstime_t now_ms) {
* reached the timeout already, if they are no longer existing or no longer
* reached the timeout already, if they are no longer existing or no longer
* blocked with such timeout, we just go forward.
* blocked with such timeout, we just go forward.
*
*
* Every time a client blocks with a
short
timeout, we add the client in
* Every time a client blocks with a timeout, we add the client in
* the tree. In beforeSleep() we call clientsHandleTimeout() to run
* the tree. In beforeSleep() we call clientsHandleTimeout() to run
* the tree and unblock the clients. */
* the tree and unblock the clients. */
...
@@ -1552,8 +1552,8 @@ void decodeTimeoutKey(unsigned char *buf, uint64_t *toptr, uint64_t *idptr) {
...
@@ -1552,8 +1552,8 @@ void decodeTimeoutKey(unsigned char *buf, uint64_t *toptr, uint64_t *idptr) {
}
}
/* Add the specified client id / timeout as a key in the radix tree we use
/* Add the specified client id / timeout as a key in the radix tree we use
* to handle
short
timeouts. The client is not added to the list
if its
* to handle
blocked clients
timeouts. The client is not added to the list
* timeout is zero (block forever). */
*
if its
timeout is zero (block forever). */
void
addClientToTimeoutTable
(
client
*
c
)
{
void
addClientToTimeoutTable
(
client
*
c
)
{
if
(
c
->
bpop
.
timeout
==
0
)
return
;
if
(
c
->
bpop
.
timeout
==
0
)
return
;
uint64_t
timeout
=
c
->
bpop
.
timeout
;
uint64_t
timeout
=
c
->
bpop
.
timeout
;
...
@@ -1563,8 +1563,8 @@ void addClientToTimeoutTable(client *c) {
...
@@ -1563,8 +1563,8 @@ void addClientToTimeoutTable(client *c) {
raxTryInsert
(
server
.
clients_timeout_table
,
buf
,
sizeof
(
buf
),
NULL
,
NULL
);
raxTryInsert
(
server
.
clients_timeout_table
,
buf
,
sizeof
(
buf
),
NULL
,
NULL
);
}
}
/* This function is called in beforeSleep() in order to unblock
ASAP
clients
/* This function is called in beforeSleep() in order to unblock clients
* that are waiting in blocking operations with a
short
timeout set. */
* that are waiting in blocking operations with a timeout set. */
void
clientsHandleTimeout
(
void
)
{
void
clientsHandleTimeout
(
void
)
{
if
(
raxSize
(
server
.
clients_timeout_table
)
==
0
)
return
;
if
(
raxSize
(
server
.
clients_timeout_table
)
==
0
)
return
;
uint64_t
now
=
mstime
();
uint64_t
now
=
mstime
();
...
...
src/server.h
View file @
13e4c2a9
...
@@ -1067,7 +1067,7 @@ struct redisServer {
...
@@ -1067,7 +1067,7 @@ struct redisServer {
list
*
clients_pending_read
;
/* Client has pending read socket buffers. */
list
*
clients_pending_read
;
/* Client has pending read socket buffers. */
list
*
slaves
,
*
monitors
;
/* List of slaves and MONITORs */
list
*
slaves
,
*
monitors
;
/* List of slaves and MONITORs */
client
*
current_client
;
/* Current client executing the command. */
client
*
current_client
;
/* Current client executing the command. */
rax
*
clients_timeout_table
;
/* Radix tree for
clients with short
timeout. */
rax
*
clients_timeout_table
;
/* Radix tree for
blocked clients
timeout
s
. */
long
fixed_time_expire
;
/* If > 0, expire keys against server.mstime. */
long
fixed_time_expire
;
/* If > 0, expire keys against server.mstime. */
rax
*
clients_index
;
/* Active clients dictionary by client ID. */
rax
*
clients_index
;
/* Active clients dictionary by client ID. */
int
clients_paused
;
/* True if clients are currently paused */
int
clients_paused
;
/* True if clients are currently paused */
...
...
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