Commit 338cd483 authored by antirez's avatar antirez
Browse files

Fix logStackTrace() when logging to stdout.

When the semantics changed from logfile = NULL to logfile = "" to log
into standard output, no proper change was made to logStackTrace() to
make it able to work with the new setup.

This commit fixes the issue.
parent 9c2c878e
...@@ -619,11 +619,12 @@ void logRegisters(ucontext_t *uc) { ...@@ -619,11 +619,12 @@ void logRegisters(ucontext_t *uc) {
void logStackTrace(ucontext_t *uc) { void logStackTrace(ucontext_t *uc) {
void *trace[100]; void *trace[100];
int trace_size = 0, fd; int trace_size = 0, fd;
int log_to_stdout = server.logfile[0] == '\0';
/* Open the log file in append mode. */ /* Open the log file in append mode. */
fd = server.logfile ? fd = log_to_stdout ?
open(server.logfile, O_APPEND|O_CREAT|O_WRONLY, 0644) : STDOUT_FILENO :
STDOUT_FILENO; open(server.logfile, O_APPEND|O_CREAT|O_WRONLY, 0644);
if (fd == -1) return; if (fd == -1) return;
/* Generate the stack trace */ /* Generate the stack trace */
...@@ -637,7 +638,7 @@ void logStackTrace(ucontext_t *uc) { ...@@ -637,7 +638,7 @@ void logStackTrace(ucontext_t *uc) {
backtrace_symbols_fd(trace, trace_size, fd); backtrace_symbols_fd(trace, trace_size, fd);
/* Cleanup */ /* Cleanup */
if (server.logfile) close(fd); if (!log_to_stdout) close(fd);
} }
/* Log information about the "current" client, that is, the client that is /* Log information about the "current" client, that is, the client that is
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment