- Make checkpoint tracing a compile time option (off by default)
authorGuus Sliepen <guus@tinc-vpn.org>
Wed, 8 Nov 2000 20:52:37 +0000 (20:52 +0000)
committerGuus Sliepen <guus@tinc-vpn.org>
Wed, 8 Nov 2000 20:52:37 +0000 (20:52 +0000)
acconfig.h
configure.in
lib/utils.c
lib/utils.h
src/tincd.c

index f1d9ee7..9861a74 100644 (file)
@@ -53,3 +53,6 @@
 
 /* Define to the location of if_tun.h */
 #undef LINUX_IF_TUN_H
 
 /* Define to the location of if_tun.h */
 #undef LINUX_IF_TUN_H
+
+/* Define to 1 if checkpoint tracing is enabled */
+#undef ENABLE_TRACING
index 3514e0e..4d5bf9d 100644 (file)
@@ -1,6 +1,6 @@
 dnl Process this file with autoconf to produce a configure script.
 
 dnl Process this file with autoconf to produce a configure script.
 
-dnl $Id: configure.in,v 1.13.2.15 2000/11/08 00:10:49 guus Exp $
+dnl $Id: configure.in,v 1.13.2.16 2000/11/08 20:52:36 guus Exp $
 
 AC_INIT(src/tincd.c)
 AM_INIT_AUTOMAKE(tinc, 1.0pre3)
 
 AC_INIT(src/tincd.c)
 AM_INIT_AUTOMAKE(tinc, 1.0pre3)
@@ -84,6 +84,12 @@ AC_CHECK_FUNC(gethostbyname, [], [
 dnl Check for TUN/TAP support in the kernel
 tinc_TUNTAP
 
 dnl Check for TUN/TAP support in the kernel
 tinc_TUNTAP
 
+dnl Check if checkpoint tracing has to be enabled
+AC_ARG_ENABLE(tracing,
+  --enable-tracing     enable checkpoint tracing (for debugging purposes only),
+  [ AC_DEFINE(ENABLE_TRACING) ]
+)
+
 AC_OUTPUT([Makefile src/Makefile
 doc/Makefile doc/es/Makefile intl/Makefile lib/Makefile
 m4/Makefile po/Makefile.in redhat/Makefile debian/Makefile])
 AC_OUTPUT([Makefile src/Makefile
 doc/Makefile doc/es/Makefile intl/Makefile lib/Makefile
 m4/Makefile po/Makefile.in redhat/Makefile debian/Makefile])
index 7f588b4..8e460f4 100644 (file)
 #include <syslog.h>
 #include <xalloc.h>
 
 #include <syslog.h>
 #include <xalloc.h>
 
+#ifdef ENABLE_TRACING
 volatile int (cp_line[]) = {0, 0, 0, 0, 0, 0, 0, 0};
 volatile char (*cp_file[]) = {"?", "?", "?", "?", "?", "?", "?", "?"};
 volatile int cp_index = 0;
 volatile int (cp_line[]) = {0, 0, 0, 0, 0, 0, 0, 0};
 volatile char (*cp_file[]) = {"?", "?", "?", "?", "?", "?", "?", "?"};
 volatile int cp_index = 0;
+#endif
 
 char *hexadecimals = "0123456789ABCDEF";
 
 
 char *hexadecimals = "0123456789ABCDEF";
 
@@ -61,6 +63,7 @@ void bin2hex(char *src, char *dst, int length)
     }
 }
 
     }
 }
 
+#ifdef ENABLE_TRACING
 void cp_trace()
 {
   syslog(LOG_DEBUG, "Checkpoint trace: %s:%d <- %s:%d <- %s:%d <- %s:%d <- %s:%d <- %s:%d <- %s:%d <- %s:%d ...",
 void cp_trace()
 {
   syslog(LOG_DEBUG, "Checkpoint trace: %s:%d <- %s:%d <- %s:%d <- %s:%d <- %s:%d <- %s:%d <- %s:%d <- %s:%d ...",
@@ -74,6 +77,7 @@ void cp_trace()
            cp_file[cp_index], cp_line[cp_index]
         );
 }
            cp_file[cp_index], cp_line[cp_index]
         );
 }
+#endif
 
 #ifndef HAVE_ASPRINTF
 int asprintf(char **buf, const char *fmt, ...)
 
 #ifndef HAVE_ASPRINTF
 int asprintf(char **buf, const char *fmt, ...)
index c172daa..0fa5de3 100644 (file)
@@ -37,15 +37,21 @@ enum {
 
 #define min(a,b) (((a)<(b))?(a):(b))
 
 
 #define min(a,b) (((a)<(b))?(a):(b))
 
+#ifdef ENABLE_TRACING
 extern volatile int cp_line[];
 extern volatile char *cp_file[];
 extern volatile int cp_index;
 extern volatile int cp_line[];
 extern volatile char *cp_file[];
 extern volatile int cp_index;
+extern void cp_trace(void);
 
 
-#define cp { cp_line[cp_index] = __LINE__; cp_file[cp_index] = __FILE__; cp_index++; cp_index %= 8; }
-#define ecp { fprintf(stderr, "Explicit checkpoint in %s line %d\n", __FILE__, __LINE__); }
+  #define cp { cp_line[cp_index] = __LINE__; cp_file[cp_index] = __FILE__; cp_index++; cp_index %= 8; }
+  #define ecp { fprintf(stderr, "Explicit checkpoint in %s line %d\n", __FILE__, __LINE__); }
+#else
+  #define cp
+  #define ecp
+  #define cp_trace()
+#endif
 
 extern void hex2bin(char *src, char *dst, int length);
 extern void bin2hex(char *src, char *dst, int length);
 
 extern void hex2bin(char *src, char *dst, int length);
 extern void bin2hex(char *src, char *dst, int length);
-extern void cp_trace(void);
 
 #endif /* __TINC_UTILS_H__ */
 
 #endif /* __TINC_UTILS_H__ */
index eea15db..ea2d3a7 100644 (file)
@@ -17,7 +17,7 @@
     along with this program; if not, write to the Free Software
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
     along with this program; if not, write to the Free Software
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
-    $Id: tincd.c,v 1.10.4.26 2000/11/08 00:20:06 guus Exp $
+    $Id: tincd.c,v 1.10.4.27 2000/11/08 20:52:37 guus Exp $
 */
 
 #include "config.h"
 */
 
 #include "config.h"
@@ -229,7 +229,8 @@ int keygen(int bits)
 
 void memory_full(int size)
 {
 
 void memory_full(int size)
 {
-  syslog(LOG_ERR, _("Memory exhausted (last is %s:%d) (couldn't allocate %d bytes), exiting."), cp_file, cp_line, size);
+  syslog(LOG_ERR, _("Memory exhausted (couldn't allocate %d bytes), exiting."), size);
+  cp_trace();
   exit(1);
 }
 
   exit(1);
 }
 
@@ -371,7 +372,7 @@ void make_names(void)
       if(!confbase)
         asprintf(&confbase, "%s/tinc/%s", CONFDIR, netname);
       else
       if(!confbase)
         asprintf(&confbase, "%s/tinc/%s", CONFDIR, netname);
       else
-        fprintf(stderr, "Both netname and configuration directory given, using the latter...\n");
+        fprintf(stderr, _("Both netname and configuration directory given, using the latter...\n"));
       if(!identname)
         asprintf(&identname, "tinc.%s", netname);
     }
       if(!identname)
         asprintf(&identname, "tinc.%s", netname);
     }