projects
/
tinc
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Replace MinGW with Windows to avoid ambiguities
[tinc]
/
src
/
logger.c
diff --git
a/src/logger.c
b/src/logger.c
index
1a2e95f
..
390023b
100644
(file)
--- a/
src/logger.c
+++ b/
src/logger.c
@@
-1,6
+1,6
@@
/*
logger.c -- logging code
/*
logger.c -- logging code
- Copyright (C) 2004-20
17
Guus Sliepen <guus@tinc-vpn.org>
+ Copyright (C) 2004-20
22
Guus Sliepen <guus@tinc-vpn.org>
2004-2005 Ivo Timmermans
This program is free software; you can redistribute it and/or modify
2004-2005 Ivo Timmermans
This program is free software; you can redistribute it and/or modify
@@
-34,7
+34,7
@@
debug_t debug_level = DEBUG_NOTHING;
static logmode_t logmode = LOGMODE_STDERR;
static pid_t logpid;
static FILE *logfile = NULL;
static logmode_t logmode = LOGMODE_STDERR;
static pid_t logpid;
static FILE *logfile = NULL;
-#ifdef HAVE_
MINGW
+#ifdef HAVE_
WINDOWS
static HANDLE loghandle = NULL;
#endif
static const char *logident = NULL;
static HANDLE loghandle = NULL;
#endif
static const char *logident = NULL;
@@
-72,7
+72,7
@@
static void real_logger(debug_t level, int priority, const char *message) {
break;
case LOGMODE_SYSLOG:
break;
case LOGMODE_SYSLOG:
-#ifdef HAVE_
MINGW
+#ifdef HAVE_
WINDOWS
{
const char *messages[] = {message};
ReportEvent(loghandle, priority, 0, 0, NULL, 1, 0, messages, NULL);
{
const char *messages[] = {message};
ReportEvent(loghandle, priority, 0, 0, NULL, 1, 0, messages, NULL);
@@
-91,8
+91,11
@@
static void real_logger(debug_t level, int priority, const char *message) {
}
if(umbilical && do_detach) {
}
if(umbilical && do_detach) {
- write(umbilical, message, strlen(message));
- write(umbilical, "\n", 1);
+ size_t len = strlen(message);
+
+ if(write(umbilical, message, len) != (ssize_t)len || write(umbilical, "\n", 1) != 1) {
+ // Other end broken, nothing we can do about it.
+ }
}
}
}
}
@@
-113,7
+116,7
@@
static void real_logger(debug_t level, int priority, const char *message) {
size_t len = strlen(message);
size_t len = strlen(message);
- if(send_request(c, "%d %d %
zu", CONTROL, REQ_LOG,
len)) {
+ if(send_request(c, "%d %d %
lu", CONTROL, REQ_LOG, (unsigned long)
len)) {
send_meta(c, message, len);
}
}
send_meta(c, message, len);
}
}
@@
-192,7
+195,7
@@
void openlogger(const char *ident, logmode_t mode) {
break;
case LOGMODE_SYSLOG:
break;
case LOGMODE_SYSLOG:
-#ifdef HAVE_
MINGW
+#ifdef HAVE_
WINDOWS
loghandle = RegisterEventSource(NULL, logident);
if(!loghandle) {
loghandle = RegisterEventSource(NULL, logident);
if(!loghandle) {
@@
-220,7
+223,7
@@
void openlogger(const char *ident, logmode_t mode) {
}
}
}
}
-void reopenlogger() {
+void reopenlogger(
void
) {
if(logmode != LOGMODE_FILE) {
return;
}
if(logmode != LOGMODE_FILE) {
return;
}
@@
-245,7
+248,7
@@
void closelogger(void) {
break;
case LOGMODE_SYSLOG:
break;
case LOGMODE_SYSLOG:
-#ifdef HAVE_
MINGW
+#ifdef HAVE_
WINDOWS
DeregisterEventSource(loghandle);
break;
#else
DeregisterEventSource(loghandle);
break;
#else