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
124a635b
Commit
124a635b
authored
Feb 08, 2013
by
antirez
Browse files
Set SO_KEEPALIVE on client sockets if configured to do so.
parent
ee21c18e
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/config.c
View file @
124a635b
...
...
@@ -81,6 +81,11 @@ void loadServerConfigFromString(char *config) {
if
(
server
.
maxidletime
<
0
)
{
err
=
"Invalid timeout value"
;
goto
loaderr
;
}
}
else
if
(
!
strcasecmp
(
argv
[
0
],
"tcp-keepalive"
)
&&
argc
==
2
)
{
server
.
tcpkeepalive
=
atoi
(
argv
[
1
]);
if
(
server
.
tcpkeepalive
<
0
)
{
err
=
"Invalid tcp-keepalive value"
;
goto
loaderr
;
}
}
else
if
(
!
strcasecmp
(
argv
[
0
],
"port"
)
&&
argc
==
2
)
{
server
.
port
=
atoi
(
argv
[
1
]);
if
(
server
.
port
<
0
||
server
.
port
>
65535
)
{
...
...
@@ -528,6 +533,10 @@ void configSetCommand(redisClient *c) {
if
(
getLongLongFromObject
(
o
,
&
ll
)
==
REDIS_ERR
||
ll
<
0
||
ll
>
LONG_MAX
)
goto
badfmt
;
server
.
maxidletime
=
ll
;
}
else
if
(
!
strcasecmp
(
c
->
argv
[
2
]
->
ptr
,
"tcp-keepalive"
))
{
if
(
getLongLongFromObject
(
o
,
&
ll
)
==
REDIS_ERR
||
ll
<
0
||
ll
>
INT_MAX
)
goto
badfmt
;
server
.
tcpkeepalive
=
ll
;
}
else
if
(
!
strcasecmp
(
c
->
argv
[
2
]
->
ptr
,
"appendfsync"
))
{
if
(
!
strcasecmp
(
o
->
ptr
,
"no"
))
{
server
.
aof_fsync
=
AOF_FSYNC_NO
;
...
...
@@ -795,6 +804,7 @@ void configGetCommand(redisClient *c) {
config_get_numerical_field
(
"maxmemory"
,
server
.
maxmemory
);
config_get_numerical_field
(
"maxmemory-samples"
,
server
.
maxmemory_samples
);
config_get_numerical_field
(
"timeout"
,
server
.
maxidletime
);
config_get_numerical_field
(
"tcp-keepalive"
,
server
.
tcpkeepalive
);
config_get_numerical_field
(
"auto-aof-rewrite-percentage"
,
server
.
aof_rewrite_perc
);
config_get_numerical_field
(
"auto-aof-rewrite-min-size"
,
...
...
src/networking.c
View file @
124a635b
...
...
@@ -59,6 +59,8 @@ redisClient *createClient(int fd) {
if
(
fd
!=
-
1
)
{
anetNonBlock
(
NULL
,
fd
);
anetEnableTcpNoDelay
(
NULL
,
fd
);
if
(
server
.
tcpkeepalive
)
anetKeepAlive
(
NULL
,
fd
,
server
.
tcpkeepalive
);
if
(
aeCreateFileEvent
(
server
.
el
,
fd
,
AE_READABLE
,
readQueryFromClient
,
c
)
==
AE_ERR
)
{
...
...
src/redis.c
View file @
124a635b
...
...
@@ -1130,6 +1130,7 @@ void initServerConfig() {
server
.
dbnum
=
REDIS_DEFAULT_DBNUM
;
server
.
verbosity
=
REDIS_NOTICE
;
server
.
maxidletime
=
REDIS_MAXIDLETIME
;
server
.
tcpkeepalive
=
0
;
server
.
client_max_querybuf_len
=
REDIS_MAX_QUERYBUF_LEN
;
server
.
saveparams
=
NULL
;
server
.
loading
=
0
;
...
...
src/redis.h
View file @
124a635b
...
...
@@ -698,6 +698,7 @@ struct redisServer {
/* Configuration */
int
verbosity
;
/* Loglevel in redis.conf */
int
maxidletime
;
/* Client timeout in seconds */
int
tcpkeepalive
;
/* Set SO_KEEPALIVE if non-zero. */
size_t
client_max_querybuf_len
;
/* Limit for client query buffer length */
int
dbnum
;
/* Total number of configured DBs */
int
daemonize
;
/* True if running as a daemon */
...
...
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