diff options
author | Dana Robinson <derobins@hdfgroup.org> | 2012-02-10 21:42:37 (GMT) |
---|---|---|
committer | Dana Robinson <derobins@hdfgroup.org> | 2012-02-10 21:42:37 (GMT) |
commit | 944da8a83b54eeaf228d64def88337418fa50311 (patch) | |
tree | 581df2226e59be9f707a629547808fff72c1a8f0 /src | |
parent | 5f94d17285913b2497d169cadfb639f300773407 (diff) | |
download | hdf5-944da8a83b54eeaf228d64def88337418fa50311.zip hdf5-944da8a83b54eeaf228d64def88337418fa50311.tar.gz hdf5-944da8a83b54eeaf228d64def88337418fa50311.tar.bz2 |
[svn-r21926] Merged fix for HDFFV-7780 (incorrect Windows thread creation function) from trunk (changeset 21816).
Tested on 64-bit Windows 7. This has baked in the trunk since Dec 5 with no issues.
Diffstat (limited to 'src')
-rw-r--r-- | src/H5TS.c | 13 | ||||
-rw-r--r-- | src/H5private.h | 6 |
2 files changed, 16 insertions, 3 deletions
@@ -393,13 +393,22 @@ H5TS_cancel_count_dec(void) *-------------------------------------------------------------------------- */ H5TS_thread_t -H5TS_create_thread(void * func, H5TS_attr_t * attr, void*udata) +H5TS_create_thread(void *func, H5TS_attr_t *attr, void *udata) { H5TS_thread_t ret_value; #ifdef H5_HAVE_WIN_THREADS - ret_value = CreateThread(NULL, 0, func, udata, 0, NULL); + /* When calling C runtime functions, you have to use _beginthread or + * _beginthreadex instead of CreateThread. Threads created with + * CreateThread risk being killed in low-memory situations. + * We use _beginthread instead of _begintheadex because the latter + * requires a stdcall function (and we don't need the more advanced + * features it exposes). + * + * NOTE: No error checks here! ret_value will be -1L on errors. + */ + ret_value = _beginthread(func, 0 /* stack size */, udata); #else /* H5_HAVE_WIN_THREADS */ diff --git a/src/H5private.h b/src/H5private.h index 24a8394..5bdd8ed 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -151,12 +151,16 @@ #ifdef H5_HAVE_WIN32_API -#define WIN32_LEAN_AND_MEAN /*Exclude rarely-used stuff from Windows headers */ +#define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */ #ifdef H5_HAVE_WINSOCK_H #include <winsock2.h> #endif +#ifdef H5_HAVE_THREADSAFE +#include <process.h> /* For _beginthread() */ +#endif + #include <windows.h> #include <direct.h> /* For _getcwd() */ |