diff options
| author | Garrett D'Amore <garrett@damore.org> | 2017-01-16 16:27:22 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2017-01-16 16:27:22 -0800 |
| commit | ac8415c24ffea645105c3859e814843e81c97f8a (patch) | |
| tree | 7b64b4aab3de6ce5bdd69c3d5b7ead57f4a4b4e7 /src/platform/windows | |
| parent | b8f7236aa2928d70d9bff2e1071654982539eeda (diff) | |
| download | nng-ac8415c24ffea645105c3859e814843e81c97f8a.tar.gz nng-ac8415c24ffea645105c3859e814843e81c97f8a.tar.bz2 nng-ac8415c24ffea645105c3859e814843e81c97f8a.zip | |
Start of event framework.
This compiles correctly, but doesn't actually deliver events yet.
As part of this, I've made most of the initializables in nng
safe to tear-down if uninitialized (or set to zero e.g. via calloc).
This makes it loads easier to write the teardown on error code, since
I can deinit everything, without worrying about which things have been
initialized and which have not.
Diffstat (limited to 'src/platform/windows')
| -rw-r--r-- | src/platform/windows/win_impl.h | 1 | ||||
| -rw-r--r-- | src/platform/windows/win_thread.c | 6 |
2 files changed, 6 insertions, 1 deletions
diff --git a/src/platform/windows/win_impl.h b/src/platform/windows/win_impl.h index 9de47ce4..c6a68142 100644 --- a/src/platform/windows/win_impl.h +++ b/src/platform/windows/win_impl.h @@ -60,6 +60,7 @@ struct nni_plat_thr { struct nni_plat_mtx { CRITICAL_SECTION cs; DWORD owner; + int init; }; struct nni_plat_cv { diff --git a/src/platform/windows/win_thread.c b/src/platform/windows/win_thread.c index e2568626..1b903b26 100644 --- a/src/platform/windows/win_thread.c +++ b/src/platform/windows/win_thread.c @@ -35,6 +35,7 @@ int nni_plat_mtx_init(nni_plat_mtx *mtx) { InitializeCriticalSection(&mtx->cs); + mtx->init = 1; return (0); } @@ -42,7 +43,10 @@ nni_plat_mtx_init(nni_plat_mtx *mtx) void nni_plat_mtx_fini(nni_plat_mtx *mtx) { - DeleteCriticalSection(&mtx->cs); + if (mtx->init) { + DeleteCriticalSection(&mtx->cs); + mtx->init = 0; + } } |
