Don't write log messages to the umbilical pipe if we don't detach.
authorGuus Sliepen <guus@tinc-vpn.org>
Wed, 20 May 2015 19:25:06 +0000 (21:25 +0200)
committerGuus Sliepen <guus@tinc-vpn.org>
Wed, 20 May 2015 19:25:06 +0000 (21:25 +0200)
If we run in the foreground and are started by the CLI, this would
otherwise cause the first few log messages to appear twice.

src/logger.c
src/sptps_speed.c
src/sptps_test.c

index 8fbd344..ad7cef2 100644 (file)
@@ -26,6 +26,7 @@
 #include "logger.h"
 #include "connection.h"
 #include "control_common.h"
+#include "process.h"
 #include "sptps.h"
 
 debug_t debug_level = DEBUG_NOTHING;
@@ -80,7 +81,7 @@ static void real_logger(int level, int priority, const char *message) {
                                break;
                }
 
-               if(umbilical) {
+               if(umbilical && do_detach) {
                        write(umbilical, message, strlen(message));
                        write(umbilical, "\n", 1);
                }
index ab41e8d..d03246c 100644 (file)
@@ -33,6 +33,7 @@ bool send_request(void *c, const char *msg, ...) { return false; }
 struct list_t *connection_list = NULL;
 bool send_meta(void *c, const char *msg , int len) { return false; }
 char *logfilename = NULL;
+bool do_detach = false;
 struct timeval now;
 
 static bool send_data(void *handle, uint8_t type, const void *data, size_t len) {
index 38c2c08..f83307f 100644 (file)
@@ -35,6 +35,7 @@ bool send_request(void *c, const char *msg, ...) { return false; }
 struct list_t *connection_list = NULL;
 bool send_meta(void *c, const char *msg , int len) { return false; }
 char *logfilename = NULL;
+bool do_detach = false;
 struct timeval now;
 
 static bool verbose;