projects
/
umurmur.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix error message at client disconnect when using OpenSSL.
[umurmur.git]
/
src
/
log.c
diff --git
a/src/log.c
b/src/log.c
index 39b9cf9e48bc3f8fcc0bf943735d9ce2c798bcfd..0564dd3350859fb386420e6d3d2cd8238541667d 100644
(file)
--- a/
src/log.c
+++ b/
src/log.c
@@
-1,5
+1,5
@@
-/* Copyright (C) 2009-201
0
, Martin Johansson <martin@fatbob.nu>
- Copyright (C) 2005-201
0
, Thorvald Natvig <thorvald@natvig.com>
+/* Copyright (C) 2009-201
2
, Martin Johansson <martin@fatbob.nu>
+ Copyright (C) 2005-201
2
, Thorvald Natvig <thorvald@natvig.com>
All rights reserved.
All rights reserved.
@@
-53,10
+53,14
@@
static void openlogfile(const char *logfilename)
Log_fatal("Failed to open log file '%s' for writing: %s\n", logfilename, strerror(errno));
}
Log_fatal("Failed to open log file '%s' for writing: %s\n", logfilename, strerror(errno));
}
+ /* Set the stream as line buffered */
+ if (setvbuf(logfile, NULL, _IOLBF, 0) < 0)
+ Log_fatal("setvbuf() failed: %s\n", strerror(errno));
+
/* XXX - Is it neccessary/appropriate that logging to file is non-blocking?
* If not, there's a risk that execution blocks, meaning that voice blocks
* as well since uMurmur is single threaded by design. OTOH, what could
/* XXX - Is it neccessary/appropriate that logging to file is non-blocking?
* If not, there's a risk that execution blocks, meaning that voice blocks
* as well since uMurmur is single threaded by design. OTOH, what could
- * cause a block? If the disk causes blocking, it is probably br0ken
.
but
+ * cause a block? If the disk causes blocking, it is probably br0ken
,
but
* the log could be on a nfs or smb share, so let's set it up as
* non-blocking and we'll see what happens.
*/
* the log could be on a nfs or smb share, so let's set it up as
* non-blocking and we'll see what happens.
*/
@@
-148,10
+152,8
@@
void Log_info(const char *logstring, ...)
va_end(argp);
if (termprint)
fprintf(stderr, "%s\n", buf);
va_end(argp);
if (termprint)
fprintf(stderr, "%s\n", buf);
- else if (logfile)
{
+ else if (logfile)
fprintf(logfile, "%s\n", buf);
fprintf(logfile, "%s\n", buf);
- fflush(logfile);
- }
else
syslog(LOG_INFO, "%s", buf);
}
else
syslog(LOG_INFO, "%s", buf);
}
@@
-212,11
+214,13
@@
void Log_fatal(const char *logstring, ...)
fprintf(stderr, "%s\n", buf);
else if (logfile)
fprintf(logfile, "%s\n", buf);
fprintf(stderr, "%s\n", buf);
else if (logfile)
fprintf(logfile, "%s\n", buf);
- else { /* If logging subsystem is not initialized, fall back to s
yslog logging
- *
for fatal errors. Only config file reading that needs this currently.
+ else { /* If logging subsystem is not initialized, fall back to s
tderr +
+ *
syslog logging for fatal errors.
*/
*/
- if (!init)
+ if (!init)
{
openlog("uMurmurd", LOG_PID, LOG_DAEMON);
openlog("uMurmurd", LOG_PID, LOG_DAEMON);
+ fprintf(stderr, "%s\n", buf);
+ }
syslog(LOG_CRIT, "%s", buf);
}
syslog(LOG_CRIT, "%s", buf);
}