This function uses the config rewriting Redis engine in order to persist * the state of the Sentinel in the current configuration file. * * Before returning the function calls fsync() against the generated * configuration file to make sure changes are committed to disk. * * On failure the function logs a warning on the Redis log. */
| 2317 | * |
| 2318 | * On failure the function logs a warning on the Redis log. */ |
| 2319 | void sentinelFlushConfig(void) { |
| 2320 | int fd = -1; |
| 2321 | int saved_hz = g_pserver->hz; |
| 2322 | int rewrite_status; |
| 2323 | |
| 2324 | g_pserver->hz = CONFIG_DEFAULT_HZ; |
| 2325 | rewrite_status = rewriteConfig(cserver.configfile, 0); |
| 2326 | g_pserver->hz = saved_hz; |
| 2327 | |
| 2328 | if (rewrite_status == -1) goto werr; |
| 2329 | if ((fd = open(cserver.configfile,O_RDONLY)) == -1) goto werr; |
| 2330 | if (fsync(fd) == -1) goto werr; |
| 2331 | if (close(fd) == EOF) goto werr; |
| 2332 | return; |
| 2333 | |
| 2334 | werr: |
| 2335 | serverLog(LL_WARNING,"WARNING: Sentinel was not able to save the new configuration on disk!!!: %s", strerror(errno)); |
| 2336 | if (fd != -1) close(fd); |
| 2337 | } |
| 2338 | |
| 2339 | /* ====================== hiredis connection handling ======================= */ |
| 2340 |
no test coverage detected