Attached a patch for the rrd-tool LIBDBI integration with the following improvements:
[rrdtool.git] / src / rrd_thread_safe_nt.c
index 899fe93..e0dad45 100644 (file)
@@ -1,5 +1,5 @@
 /*****************************************************************************
- * RRDtool 1.3rc7  Copyright by Tobi Oetiker, 1997-2008
+ * RRDtool 1.3.2  Copyright by Tobi Oetiker, 1997-2008
  * This file:     Copyright 2003 Peter Stamfest <peter@stamfest.at> 
  *                             & Tobias Oetiker
  * Distributed under the GPL
@@ -38,20 +38,20 @@ static void context_destroy_context(
 static void context_init_context(
     void)
 {
-    if (!InterlockedExchange(&context_key_once, 1)) {
+    if (!InterlockedExchange((LONG*)(&context_key_once), 1)) {
         context_key = TlsAlloc();
         InitializeCriticalSection(&CriticalSection);
         atexit(context_destroy_context);
     }
 }
-struct rrd_context *rrd_get_context(
+rrd_context_t *rrd_get_context(
     void)
 {
-    struct rrd_context *ctx;
+    rrd_context_t *ctx;
 
     context_init_context();
 
-    ctx = TlsGetValue(context_key);
+    ctx = (rrd_context_t*)TlsGetValue(context_key);
     if (!ctx) {
         ctx = rrd_new_context();
         TlsSetValue(context_key, ctx);
@@ -59,11 +59,28 @@ struct rrd_context *rrd_get_context(
     return ctx;
 }
 
+
+/* this was added by the win32 porters Christof.Wegmann@exitgames.com */
+
+rrd_context_t *rrd_force_new_context(
+    void)
+{
+    rrd_context_t *ctx;
+
+    context_init_context();
+
+    ctx = rrd_new_context();
+    TlsSetValue(context_key, ctx);
+
+    return ctx;
+}
+
+
 #undef strerror
 const char *rrd_strerror(
     int err)
 {
-    struct rrd_context *ctx;
+    rrd_context_t *ctx;
 
     context_init_context();