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;
server.appendonly = 0;
fakeClient = createFakeClient();
+ startLoading(fp);
+
while(1) {
int argc, j;
unsigned long len;
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;
fclose(fp);
freeFakeClient(fakeClient);
server.appendonly = appendonly;
+ stopLoading();
return REDIS_OK;
readerr:
char tmpfile[256];
if (server.vm_enabled) vmReopenSwapFile();
- close(server.fd);
+ if (server.ipfd > 0) close(server.ipfd);
+ if (server.sofd > 0) close(server.sofd);
snprintf(tmpfile,256,"temp-rewriteaof-bg-%d.aof", (int) getpid());
if (rewriteAppendOnlyFile(tmpfile) == REDIS_OK) {
_exit(0);