Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
cc275067
Commit
cc275067
authored
Jan 08, 2011
by
antirez
Browse files
blocking SAVE implemented
parent
43574a72
Changes
3
Show whitespace changes
Inline
Side-by-side
src/diskstore.c
View file @
cc275067
...
@@ -474,7 +474,7 @@ werr:
...
@@ -474,7 +474,7 @@ werr:
return
NULL
;
return
NULL
;
}
}
int
dsRdbSave
(
char
*
filename
)
{
int
dsRdbSave
Background
(
char
*
filename
)
{
pthread_t
thread
;
pthread_t
thread
;
if
(
pthread_create
(
&
thread
,
NULL
,
dsRdbSave_thread
,
zstrdup
(
filename
))
!=
0
)
{
if
(
pthread_create
(
&
thread
,
NULL
,
dsRdbSave_thread
,
zstrdup
(
filename
))
!=
0
)
{
...
@@ -486,3 +486,24 @@ int dsRdbSave(char *filename) {
...
@@ -486,3 +486,24 @@ int dsRdbSave(char *filename) {
return
REDIS_OK
;
return
REDIS_OK
;
}
}
}
}
int
dsRdbSave
(
char
*
filename
)
{
/* A blocking save is actually a non blocking save... just we wait
* for it to terminate in a non-busy loop. */
redisLog
(
REDIS_NOTICE
,
"Starting a blocking SAVE (BGSAVE + blocking wait)"
);
server
.
dirty_before_bgsave
=
server
.
dirty
;
if
(
dsRdbSaveBackground
(
filename
)
==
REDIS_ERR
)
return
REDIS_ERR
;
while
(
1
)
{
usleep
(
1000
);
int
state
;
pthread_mutex_lock
(
&
server
.
bgsavethread_mutex
);
state
=
server
.
bgsavethread_state
;
pthread_mutex_unlock
(
&
server
.
bgsavethread_mutex
);
if
(
state
==
REDIS_BGSAVE_THREAD_DONE_OK
||
state
==
REDIS_BGSAVE_THREAD_DONE_ERR
)
break
;
}
return
REDIS_OK
;
}
src/rdb.c
View file @
cc275067
...
@@ -504,7 +504,7 @@ int rdbSaveBackground(char *filename) {
...
@@ -504,7 +504,7 @@ int rdbSaveBackground(char *filename) {
if
(
server
.
ds_enabled
)
{
if
(
server
.
ds_enabled
)
{
cacheForcePointInTime
();
cacheForcePointInTime
();
return
dsRdbSave
(
filename
);
return
dsRdbSave
Background
(
filename
);
}
}
if
((
childpid
=
fork
())
==
0
)
{
if
((
childpid
=
fork
())
==
0
)
{
...
...
src/redis.h
View file @
cc275067
...
@@ -802,6 +802,7 @@ robj *dsGet(redisDb *db, robj *key, time_t *expire);
...
@@ -802,6 +802,7 @@ robj *dsGet(redisDb *db, robj *key, time_t *expire);
int
dsDel
(
redisDb
*
db
,
robj
*
key
);
int
dsDel
(
redisDb
*
db
,
robj
*
key
);
int
dsExists
(
redisDb
*
db
,
robj
*
key
);
int
dsExists
(
redisDb
*
db
,
robj
*
key
);
void
dsFlushDb
(
int
dbid
);
void
dsFlushDb
(
int
dbid
);
int
dsRdbSaveBackground
(
char
*
filename
);
int
dsRdbSave
(
char
*
filename
);
int
dsRdbSave
(
char
*
filename
);
/* Disk Store Cache */
/* Disk Store Cache */
...
...
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