X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Frrd_not_thread_safe.c;h=c68a161f280ad7082b721a472924a45a7ae5f56d;hb=daf8e7ff715a59e1f9827080d1b785ffb3c5a4b1;hp=cc1693b4a83e9c6274e15c7fc94a50d424326fe9;hpb=31f6e9071af7d014dac71d42d61594016832868c;p=rrdtool.git diff --git a/src/rrd_not_thread_safe.c b/src/rrd_not_thread_safe.c index cc1693b..c68a161 100644 --- a/src/rrd_not_thread_safe.c +++ b/src/rrd_not_thread_safe.c @@ -1,5 +1,5 @@ /***************************************************************************** - * RRDtool 1.2.2 Copyright by Tobi Oetiker, 1997-2005 + * RRDtool 1.3rc7 Copyright by Tobi Oetiker, 1997-2008 * This file: Copyright 2003 Peter Stamfest * & Tobias Oetiker * Distributed under the GPL @@ -14,20 +14,30 @@ #define MAXLEN 4096 #define ERRBUFLEN 256 -static char rrd_error[MAXLEN] = "\0"; -static char rrd_liberror[ERRBUFLEN] = "\0"; +static char rrd_error[MAXLEN + 10]; +static char rrd_liberror[ERRBUFLEN + 10]; +static int rrd_context_init = 0; + /* The global context is very useful in the transition period to even more thread-safe stuff, it can be used whereever we need a context and do not need to worry about concurrency. */ static struct rrd_context global_ctx = { - sizeof(rrd_error), - sizeof(rrd_liberror), - rrd_error, + MAXLEN, + ERRBUFLEN, + rrd_error, rrd_liberror }; -#include -struct rrd_context *rrd_get_context() { +/* #include */ + +struct rrd_context *rrd_get_context( + void) +{ + if (!rrd_context_init) { + rrd_context_init = 1; + global_ctx.rrd_error[0] = '\0'; + global_ctx.lib_errstr[0] = '\0'; + } return &global_ctx; } @@ -36,6 +46,8 @@ struct rrd_context *rrd_get_context() { silently turning misplaced strerror into rrd_strerror, but here this turns recursive! */ #undef strerror -const char *rrd_strerror(int err) { +const char *rrd_strerror( + int err) +{ return strerror(err); }