- Make checkpoint tracing a compile time option (off by default)
This commit is contained in:
parent
55d7b5a2bb
commit
16847ea255
5 changed files with 27 additions and 7 deletions
|
@ -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
|
||||
|
|
|
@ -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])
|
||||
|
|
|
@ -29,9 +29,11 @@
|
|||
#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;
|
||||
#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, ...)
|
||||
|
|
12
lib/utils.h
12
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__ */
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue