]> git.saurik.com Git - redis.git/blobdiff - src/debug.c
Log from signal handlers is now safer.
[redis.git] / src / debug.c
index 49c76824d2223c66a6a7804006bf702d43a46ab8..e7b3ba407fd756adadba96b932caf56f2aad9853 100644 (file)
@@ -682,25 +682,16 @@ void watchdogSignalHandler(int sig, siginfo_t *info, void *secret) {
     REDIS_NOTUSED(info);
     REDIS_NOTUSED(sig);
     sds st, log;
-    time_t now = time(NULL);
-    char date[128];
-    FILE *fp;
 
-    fp = (server.logfile == NULL) ? stdout : fopen(server.logfile,"a");
-    if (fp == NULL) return;
-
-    strftime(date,sizeof(date),"%d %b %H:%M:%S",localtime(&now));
-    log = sdscatprintf(sdsempty(),
-        "\n--- WATCHDOG TIMER EXPIRED (%s) ---\n",date); 
+    log = sdsnew("\n--- WATCHDOG TIMER EXPIRED ---\n");
 #ifdef HAVE_BACKTRACE
     st = getStackTrace(uc);
 #else
     st = sdsnew("Sorry: no support for backtrace().\n");
 #endif
     log = sdscatsds(log,st);
-    log = sdscat(log,"------\n\n");
-    fprintf(fp,"%s",log);
-    if (server.logfile) fclose(fp);
+    log = sdscat(log,"------\n");
+    redisLogFromHandler(REDIS_WARNING,log);
     sdsfree(st);
     sdsfree(log);
 }