]> git.saurik.com Git - redis.git/blobdiff - src/redis.c
Avoid division by zero issues in the automatically triggered AOF rewrite feature.
[redis.git] / src / redis.c
index 9243d55418dc52b263ab476addfee6557fab0c64..263172259f5e9befb61acfaf4ec33fa0ba1338bd 100644 (file)
@@ -695,8 +695,9 @@ int serverCron(struct aeEventLoop *eventLoop, long long id, void *clientData) {
          if (server.auto_aofrewrite_perc &&
              server.appendonly_current_size > server.auto_aofrewrite_min_size)
          {
-            int growth = (server.appendonly_current_size*100/
-                          server.auto_aofrewrite_base_size);
+            int base = server.auto_aofrewrite_base_size ?
+                            server.auto_aofrewrite_base_size : 1;
+            int growth = (server.appendonly_current_size*100/base);
             if (growth >= server.auto_aofrewrite_perc) {
                 redisLog(REDIS_NOTICE,"Starting automatic rewriting of AOF on %d growth",growth);
                 rewriteAppendOnlyFileBackground();