return NULL;
}
-int dsRdbSave(char *filename) {
+int dsRdbSaveBackground(char *filename) {
pthread_t thread;
if (pthread_create(&thread,NULL,dsRdbSave_thread,zstrdup(filename)) != 0) {
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;
+}
if (server.ds_enabled) {
cacheForcePointInTime();
- return dsRdbSave(filename);
+ return dsRdbSaveBackground(filename);
}
if ((childpid = fork()) == 0) {
int dsDel(redisDb *db, robj *key);
int dsExists(redisDb *db, robj *key);
void dsFlushDb(int dbid);
+int dsRdbSaveBackground(char *filename);
int dsRdbSave(char *filename);
/* Disk Store Cache */