mirror of
https://github.com/redis/redis.git
synced 2026-05-28 04:02:46 -04:00
Merge c80f6f438e into 138263a1b4
This commit is contained in:
commit
29ec4dff49
1 changed files with 10 additions and 16 deletions
26
src/aof.c
26
src/aof.c
|
|
@ -1407,15 +1407,19 @@ sds genAofTimestampAnnotationIfNeeded(int force) {
|
|||
* argc - Number of values in argv
|
||||
*/
|
||||
void feedAppendOnlyFile(int dictid, robj **argv, int argc) {
|
||||
sds buf = sdsempty();
|
||||
|
||||
serverAssert(dictid == -1 || (dictid >= 0 && dictid < server.dbnum));
|
||||
|
||||
if (!(server.aof_state == AOF_ON ||
|
||||
(server.aof_state == AOF_WAIT_REWRITE && server.child_type == CHILD_TYPE_AOF)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/* Feed timestamp if needed */
|
||||
if (server.aof_timestamp_enabled) {
|
||||
sds ts = genAofTimestampAnnotationIfNeeded(0);
|
||||
if (ts != NULL) {
|
||||
buf = sdscatsds(buf, ts);
|
||||
server.aof_buf = sdscatsds(server.aof_buf, ts);
|
||||
sdsfree(ts);
|
||||
}
|
||||
}
|
||||
|
|
@ -1426,25 +1430,15 @@ void feedAppendOnlyFile(int dictid, robj **argv, int argc) {
|
|||
char seldb[64];
|
||||
|
||||
snprintf(seldb,sizeof(seldb),"%d",dictid);
|
||||
buf = sdscatprintf(buf,"*2\r\n$6\r\nSELECT\r\n$%lu\r\n%s\r\n",
|
||||
server.aof_buf = sdscatprintf(server.aof_buf,
|
||||
"*2\r\n$6\r\nSELECT\r\n$%lu\r\n%s\r\n",
|
||||
(unsigned long)strlen(seldb),seldb);
|
||||
server.aof_selected_db = dictid;
|
||||
}
|
||||
|
||||
/* All commands should be propagated the same way in AOF as in replication.
|
||||
* No need for AOF-specific translation. */
|
||||
buf = catAppendOnlyGenericCommand(buf,argc,argv);
|
||||
|
||||
/* Append to the AOF buffer. This will be flushed on disk just before
|
||||
* of re-entering the event loop, so before the client will get a
|
||||
* positive reply about the operation performed. */
|
||||
if (server.aof_state == AOF_ON ||
|
||||
(server.aof_state == AOF_WAIT_REWRITE && server.child_type == CHILD_TYPE_AOF))
|
||||
{
|
||||
server.aof_buf = sdscatlen(server.aof_buf, buf, sdslen(buf));
|
||||
}
|
||||
|
||||
sdsfree(buf);
|
||||
server.aof_buf = catAppendOnlyGenericCommand(server.aof_buf,argc,argv);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Reference in a new issue