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
e257ab2b
Commit
e257ab2b
authored
Nov 19, 2013
by
antirez
Browse files
Sentinel: sentinelFlushConfig() to CONFIG REWRITE + fsync.
parent
5998769c
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/redis.h
View file @
e257ab2b
...
@@ -1171,6 +1171,7 @@ void appendServerSaveParams(time_t seconds, int changes);
...
@@ -1171,6 +1171,7 @@ void appendServerSaveParams(time_t seconds, int changes);
void
resetServerSaveParams
();
void
resetServerSaveParams
();
struct
rewriteConfigState
;
/* Forward declaration to export API. */
struct
rewriteConfigState
;
/* Forward declaration to export API. */
void
rewriteConfigRewriteLine
(
struct
rewriteConfigState
*
state
,
char
*
option
,
sds
line
,
int
force
);
void
rewriteConfigRewriteLine
(
struct
rewriteConfigState
*
state
,
char
*
option
,
sds
line
,
int
force
);
int
rewriteConfig
(
char
*
path
);
/* db.c -- Keyspace access API */
/* db.c -- Keyspace access API */
int
removeExpire
(
redisDb
*
db
,
robj
*
key
);
int
removeExpire
(
redisDb
*
db
,
robj
*
key
);
...
...
src/sentinel.c
View file @
e257ab2b
...
@@ -36,6 +36,7 @@
...
@@ -36,6 +36,7 @@
#include <arpa/inet.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#include <sys/socket.h>
#include <sys/wait.h>
#include <sys/wait.h>
#include <fcntl.h>
extern
char
**
environ
;
extern
char
**
environ
;
...
@@ -1432,6 +1433,27 @@ void rewriteConfigSentinelOption(struct rewriteConfigState *state) {
...
@@ -1432,6 +1433,27 @@ void rewriteConfigSentinelOption(struct rewriteConfigState *state) {
dictReleaseIterator
(
di
);
dictReleaseIterator
(
di
);
}
}
/* This function uses the config rewriting Redis engine in order to persist
* the state of the Sentinel in the current configuration file.
*
* Before returning the function calls fsync() against the generated
* configuration file to make sure changes are committed to disk.
*
* On failure the function logs a warning on the Redis log. */
void
sentinelFlushConfig
(
void
)
{
int
fd
;
if
(
rewriteConfig
(
server
.
configfile
)
==
-
1
)
{
redisLog
(
REDIS_WARNING
,
"WARNING: Senitnel was not able to save the new configuration on disk!!!: %s"
,
strerror
(
errno
));
return
;
}
if
((
fd
=
open
(
server
.
configfile
,
O_RDONLY
))
!=
-
1
)
{
fsync
(
fd
);
close
(
fd
);
}
return
;
}
/* ====================== hiredis connection handling ======================= */
/* ====================== hiredis connection handling ======================= */
/* Completely disconnect an hiredis link from an instance. */
/* Completely disconnect an hiredis link from an instance. */
...
...
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