]> git.saurik.com Git - redis.git/blobdiff - src/aof.c
volatile-lru maxmemory policy segfault fixed, thanks to Anthony Lauzon for reporting...
[redis.git] / src / aof.c
index 2396ba2c553183f6baaf7837c60e9aac8d971459..959a5f52af6a6a4baa1f3def8165d08758b72c2c 100644 (file)
--- a/src/aof.c
+++ b/src/aof.c
@@ -218,6 +218,7 @@ int loadAppendOnlyFile(char *filename) {
     FILE *fp = fopen(filename,"r");
     struct redis_stat sb;
     int appendonly = server.appendonly;
+    long loops = 0;
 
     if (redis_fstat(fileno(fp),&sb) != -1 && sb.st_size == 0)
         return REDIS_ERR;
@@ -232,6 +233,8 @@ int loadAppendOnlyFile(char *filename) {
     server.appendonly = 0;
 
     fakeClient = createFakeClient();
+    startLoading(fp);
+
     while(1) {
         int argc, j;
         unsigned long len;
@@ -241,6 +244,12 @@ int loadAppendOnlyFile(char *filename) {
         struct redisCommand *cmd;
         int force_swapout;
 
+        /* Serve the clients from time to time */
+        if (!(loops++ % 1000)) {
+            loadingProgress(ftello(fp));
+            aeProcessEvents(server.el, AE_FILE_EVENTS|AE_DONT_WAIT);
+        }
+
         if (fgets(buf,sizeof(buf),fp) == NULL) {
             if (feof(fp))
                 break;
@@ -297,6 +306,7 @@ int loadAppendOnlyFile(char *filename) {
     fclose(fp);
     freeFakeClient(fakeClient);
     server.appendonly = appendonly;
+    stopLoading();
     return REDIS_OK;
 
 readerr: