BGSAVE [SCHEDULE] */
| 2986 | |
| 2987 | /* BGSAVE [SCHEDULE] */ |
| 2988 | void bgsaveCommand(client *c) { |
| 2989 | int schedule = 0; |
| 2990 | |
| 2991 | /* The SCHEDULE option changes the behavior of BGSAVE when an AOF rewrite |
| 2992 | * is in progress. Instead of returning an error a BGSAVE gets scheduled. */ |
| 2993 | if (c->argc > 1) { |
| 2994 | if (c->argc == 2 && !strcasecmp(c->argv[1]->ptr,"schedule")) { |
| 2995 | schedule = 1; |
| 2996 | } else { |
| 2997 | addReplyErrorObject(c,shared.syntaxerr); |
| 2998 | return; |
| 2999 | } |
| 3000 | } |
| 3001 | |
| 3002 | rdbSaveInfo rsi, *rsiptr; |
| 3003 | rsiptr = rdbPopulateSaveInfo(&rsi); |
| 3004 | |
| 3005 | if (server.child_type == CHILD_TYPE_RDB) { |
| 3006 | addReplyError(c,"Background save already in progress"); |
| 3007 | } else if (hasActiveChildProcess()) { |
| 3008 | if (schedule) { |
| 3009 | server.rdb_bgsave_scheduled = 1; |
| 3010 | addReplyStatus(c,"Background saving scheduled"); |
| 3011 | } else { |
| 3012 | addReplyError(c, |
| 3013 | "Another child process is active (AOF?): can't BGSAVE right now. " |
| 3014 | "Use BGSAVE SCHEDULE in order to schedule a BGSAVE whenever " |
| 3015 | "possible."); |
| 3016 | } |
| 3017 | } else if (rdbSaveBackground(server.rdb_filename,rsiptr) == C_OK) { |
| 3018 | addReplyStatus(c,"Background saving started"); |
| 3019 | } else { |
| 3020 | addReplyErrorObject(c,shared.err); |
| 3021 | } |
| 3022 | } |
| 3023 | |
| 3024 | /* Populate the rdbSaveInfo structure used to persist the replication |
| 3025 | * information inside the RDB file. Currently the structure explicitly |
nothing calls this directly
no test coverage detected