Example #1
0
File: aof.c Project: Akuan1994/Mira
void stopAppendOnly(void){
    /*Called when the user switches from "appendonly yes" to "appendonly no"at runtime using the CONFIG command.*/
    assert(server.aof_state == XREDIS_AOF_OFF);
    /*force buffer contents to AOF file*/
    flushAppendOnlyFile(1);
    /*wait until disk writting is finished*/
    aof_fsync(server.aof_fd);
    /*set aof state*/
    server.aof_fd = -1;
    server.aof_selected_db = -1;
    server.aof_state = XREDIS_AOF_OFF;
    /*rewrite operation in progress? kill it, wait child exit*/
    if(server.aof_child_pid != -1){
        int statloc;

        xredisLog(XREDIS_NOTICE, "killing running AOF rewrite child: %ld", (long)server.aof_child_pid);
        if(kill(server.aof_child_pid, SIGKILL) != -1){
            wait3(&statloc, 0, NULL);
        }
        /* reset the buffer accumulating changes while the child saves */
        aofRewriteBufferReset();        //release rewrite buffer;
        aofRemoveTempFile(server.aof_child_pid);   //remove temp file;
        /*change server state*/
        server.aof_child_pid = -1;
        server.aof_rewrite_time_start = -1;
    }
}
Example #2
0
/* Called when the user switches from "appendonly yes" to "appendonly no"
 * at runtime using the CONFIG command. */
void stopAppendOnly(void) {
    flushAppendOnlyFile(1);
    aof_fsync(server.appendfd);
    close(server.appendfd);

    server.appendfd = -1;
    server.appendseldb = -1;
    server.appendonly = 0;
    /* rewrite operation in progress? kill it, wait child exit */
    if (server.bgrewritechildpid != -1) {
        int statloc;

        if (kill(server.bgrewritechildpid,SIGKILL) != -1)
            wait3(&statloc,0,NULL);
        /* reset the buffer accumulating changes while the child saves */
        sdsfree(server.bgrewritebuf);
        server.bgrewritebuf = sdsempty();
        server.bgrewritechildpid = -1;
    }
}
Example #3
0
/* Called when the user switches from "appendonly yes" to "appendonly no"
 * at runtime using the CONFIG command. */
void stopAppendOnly(void) {
    redisAssert(server.aof_state != REDIS_AOF_OFF);
    flushAppendOnlyFile(1);
    aof_fsync(server.aof_fd);
    close(server.aof_fd);

    server.aof_fd = -1;
    server.aof_selected_db = -1;
    server.aof_state = REDIS_AOF_OFF;
    /* rewrite operation in progress? kill it, wait child exit */
    if (server.aof_child_pid != -1) {
        int statloc;

        redisLog(REDIS_NOTICE,"Killing running AOF rewrite child: %ld",
            (long) server.aof_child_pid);
        if (kill(server.aof_child_pid,SIGUSR1) != -1)
            wait3(&statloc,0,NULL);
        /* reset the buffer accumulating changes while the child saves */
        aofRewriteBufferReset();
        aofRemoveTempFile(server.aof_child_pid);
        server.aof_child_pid = -1;
        server.aof_rewrite_time_start = -1;
    }
}