$(MAKE) PROF="-pg"
gcov:
- $(MAKE) PROF="-fprofile-arcs -ftest-coverage"
+ $(MAKE) PROF="-fprofile-arcs -ftest-coverage -DCOVERAGE_TEST"
noopt:
$(MAKE) OPTIMIZATION=""
if (server.sofd > 0) close(server.sofd);
snprintf(tmpfile,256,"temp-rewriteaof-bg-%d.aof", (int) getpid());
if (rewriteAppendOnlyFile(tmpfile) == REDIS_OK) {
- _exit(0);
+ exitFromChild(0);
} else {
- _exit(1);
+ exitFromChild(1);
}
} else {
/* Parent */
if (server.ipfd > 0) close(server.ipfd);
if (server.sofd > 0) close(server.sofd);
retval = rdbSave(filename);
- _exit((retval == REDIS_OK) ? 0 : 1);
+ exitFromChild((retval == REDIS_OK) ? 0 : 1);
} else {
/* Parent */
server.stat_fork_time = ustime()-start;
return ustime()/1000;
}
+/* After an RDB dump or AOF rewrite we exit from children using _exit() instead of
+ * exit(), because the latter may interact with the same file objects used by
+ * the parent process. However if we are testing the coverage normal exit() is
+ * used in order to obtain the right coverage information. */
+void exitFromChild(int retcode) {
+#ifdef COVERAGE_TEST
+ exit(retcode);
+#else
+ _exit(retcode);
+#endif
+}
+
/*====================== Hash table type implementation ==================== */
/* This is an hash table type that uses the SDS dynamic strings libary as
long long mstime(void);
void getRandomHexChars(char *p, unsigned int len);
uint64_t crc64(const unsigned char *s, uint64_t l);
+void exitFromChild(int retcode);
/* networking.c -- Networking and Client related operations */
redisClient *createClient(int fd);