From: Guus Sliepen Date: Wed, 8 Nov 2000 20:52:37 +0000 (+0000) Subject: - Make checkpoint tracing a compile time option (off by default) X-Git-Tag: release-1.0pre3~5 X-Git-Url: https://git.tinc-vpn.org/git/browse?a=commitdiff_plain;h=16847ea255fa8a7c0ed922af80a2f36b7bdf4b3b;p=tinc - Make checkpoint tracing a compile time option (off by default) --- diff --git a/acconfig.h b/acconfig.h index f1d9ee74..9861a745 100644 --- a/acconfig.h +++ b/acconfig.h @@ -53,3 +53,6 @@ /* Define to the location of if_tun.h */ #undef LINUX_IF_TUN_H + +/* Define to 1 if checkpoint tracing is enabled */ +#undef ENABLE_TRACING diff --git a/configure.in b/configure.in index 3514e0e2..4d5bf9dd 100644 --- a/configure.in +++ b/configure.in @@ -1,6 +1,6 @@ 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) @@ -84,6 +84,12 @@ AC_CHECK_FUNC(gethostbyname, [], [ 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]) diff --git a/lib/utils.c b/lib/utils.c index 7f588b47..8e460f4a 100644 --- a/lib/utils.c +++ b/lib/utils.c @@ -29,9 +29,11 @@ #include #include +#ifdef ENABLE_TRACING 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"; @@ -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 ...", @@ -74,6 +77,7 @@ void cp_trace() cp_file[cp_index], cp_line[cp_index] ); } +#endif #ifndef HAVE_ASPRINTF int asprintf(char **buf, const char *fmt, ...) diff --git a/lib/utils.h b/lib/utils.h index c172daa2..0fa5de3e 100644 --- a/lib/utils.h +++ b/lib/utils.h @@ -37,15 +37,21 @@ enum { #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 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 cp_trace(void); #endif /* __TINC_UTILS_H__ */ diff --git a/src/tincd.c b/src/tincd.c index eea15dbd..ea2d3a7a 100644 --- a/src/tincd.c +++ b/src/tincd.c @@ -17,7 +17,7 @@ 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" @@ -229,7 +229,8 @@ int keygen(int bits) 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); } @@ -371,7 +372,7 @@ void make_names(void) 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); }