~ubuntu-branches/ubuntu/saucy/rrdtool/saucy-proposed

« back to all changes in this revision

Viewing changes to src/rrd_thread_safe_nt.c

  • Committer: Bazaar Package Importer
  • Author(s): Clint Byrum
  • Date: 2010-07-22 08:07:01 UTC
  • mfrom: (1.2.8 upstream) (3.1.6 sid)
  • Revision ID: james.westby@ubuntu.com-20100722080701-k46mgdfz6euxwqsm
Tags: 1.4.3-1ubuntu1
* Merge from debian unstable, Remaining changes:
  - debian/control: Don't build against ruby1.9 as we don't want
    it in main.
* require libdbi >= 0.8.3 to prevent aborts when using dbi datasources

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*****************************************************************************
2
 
 * RRDtool 1.3.8  Copyright by Tobi Oetiker, 1997-2009
 
2
 * RRDtool 1.4.3  Copyright by Tobi Oetiker, 1997-2010
3
3
 * This file:     Copyright 2003 Peter Stamfest <peter@stamfest.at> 
4
4
 *                             & Tobias Oetiker
5
5
 * Distributed under the GPL
7
7
 * rrd_thread_safe.c   Contains routines used when thread safety is required
8
8
 *                     for win32
9
9
 *****************************************************************************
10
 
 * $Id: rrd_thread_safe_nt.c 1801 2009-05-19 13:45:05Z oetiker $
 
10
 * $Id: rrd_thread_safe_nt.c 2042 2010-03-22 16:05:55Z oetiker $
11
11
 *************************************************************************** */
12
12
 
13
13
#include <windows.h>
22
22
 
23
23
 
24
24
/* Once-only initialisation of the key */
25
 
static volatile LONG context_key_once = 0;
 
25
static DWORD context_key_once = 0;
26
26
 
27
27
 
28
28
/* Free the thread-specific rrd_context - we might actually use
38
38
static void context_init_context(
39
39
    void)
40
40
{
41
 
    if (!InterlockedExchange(&context_key_once, 1)) {
 
41
    if (!InterlockedExchange((LONG*)(&context_key_once), 1)) {
42
42
        context_key = TlsAlloc();
43
43
        InitializeCriticalSection(&CriticalSection);
44
44
        atexit(context_destroy_context);
51
51
 
52
52
    context_init_context();
53
53
 
54
 
    ctx = (rrd_context_t*)(TlsGetValue(context_key));
 
54
    ctx = (rrd_context_t*)TlsGetValue(context_key);
55
55
    if (!ctx) {
56
56
        ctx = rrd_new_context();
57
57
        TlsSetValue(context_key, ctx);
59
59
    return ctx;
60
60
}
61
61
 
62
 
#ifdef WIN32
63
 
        rrd_context_t *rrd_force_new_context(void)
64
 
        {
65
 
                rrd_context_t *ctx;
66
 
 
67
 
                context_init_context();
68
 
 
69
 
                ctx = rrd_new_context();
70
 
                TlsSetValue(context_key, ctx);
71
 
 
72
 
                return ctx;
73
 
        }
74
 
#endif
 
62
 
 
63
/* this was added by the win32 porters Christof.Wegmann@exitgames.com */
 
64
 
 
65
rrd_context_t *rrd_force_new_context(
 
66
    void)
 
67
{
 
68
    rrd_context_t *ctx;
 
69
 
 
70
    context_init_context();
 
71
 
 
72
    ctx = rrd_new_context();
 
73
    TlsSetValue(context_key, ctx);
 
74
 
 
75
    return ctx;
 
76
}
 
77
 
75
78
 
76
79
#undef strerror
77
80
const char *rrd_strerror(