* buffer and write it on disk using this function just before entering
* the event loop again. */
void flushAppendOnlyFile(void) {
- time_t now;
ssize_t nwritten;
if (sdslen(server.aofbuf) == 0) return;
server.aofbuf = sdsempty();
server.appendonly_current_size += nwritten;
- /* Don't Fsync if no-appendfsync-on-rewrite is set to yes and we have
- * childs performing heavy I/O on disk. */
+ /* Don't fsync if no-appendfsync-on-rewrite is set to yes and there are
+ * children doing I/O in the background. */
if (server.no_appendfsync_on_rewrite &&
(server.bgrewritechildpid != -1 || server.bgsavechildpid != -1))
return;
- /* Fsync if needed */
- now = time(NULL);
+
+ /* Perform the fsync if needed. */
if (server.appendfsync == APPENDFSYNC_ALWAYS ||
(server.appendfsync == APPENDFSYNC_EVERYSEC &&
- now-server.lastfsync > 1))
+ server.unixtime > server.lastfsync))
{
/* aof_fsync is defined as fdatasync() for Linux in order to avoid
* flushing metadata. */
aof_fsync(server.appendfd); /* Let's try to get this data on the disk */
- server.lastfsync = now;
+ server.lastfsync = server.unixtime;
}
}
/* The fake client should not have a reply */
redisAssert(fakeClient->bufpos == 0 && listLength(fakeClient->reply) == 0);
+ /* The fake client should never get blocked */
+ redisAssert((fakeClient->flags & REDIS_BLOCKED) == 0);
/* Clean up. Command code may have changed argv/argc so we use the
* argv/argc of the client instead of the local variables. */
long long start;
if (server.bgrewritechildpid != -1) return REDIS_ERR;
- if (server.ds_enabled != 0) {
- redisLog(REDIS_WARNING,"BGREWRITEAOF called with diskstore enabled: AOF is not supported when diskstore is enabled. Operation not performed.");
- return REDIS_ERR;
- }
start = ustime();
if ((childpid = fork()) == 0) {
char tmpfile[256];