From: VMware, Inc <> Date: Mon, 26 Sep 2011 18:36:32 +0000 (-0700) Subject: lib/lock: bound thread ID creation on Windows X-Git-Tag: 2011.09.23-491607~49 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b27b971dfec9449df8015bd800942f66e73e4aeb;p=thirdparty%2Fopen-vm-tools.git lib/lock: bound thread ID creation on Windows Apparently thread IDs are reclaimed immediately on POSIXen. On Windows thread IDs are essentially unique leading to huge amounts of MXUser (lock) tracking memory being wasted. The fix is simple - use VThread_CurID. This is our bounded, quickly recycled thread ID service. Signed-off-by: Marcelo Vanzin --- diff --git a/open-vm-tools/lib/lock/ulInt.h b/open-vm-tools/lib/lock/ulInt.h index d5b793e2b..d6a52b6bf 100644 --- a/open-vm-tools/lib/lock/ulInt.h +++ b/open-vm-tools/lib/lock/ulInt.h @@ -380,13 +380,18 @@ MXUserGetThreadID(void) { /* All thread types must fit into a uintptr_t */ + ASSERT_ON_COMPILE(sizeof(VThreadID) <= sizeof (void *)); + return (void *) (uintptr_t) VThread_CurID(); + +/* #if defined(_WIN32) - ASSERT_ON_COMPILE(sizeof(DWORD) <= sizeof (void *)); - return (void *) (uintptr_t) GetCurrentThreadId(); + ASSERT_ON_COMPILE(sizeof(VThreadID) <= sizeof (void *)); + return (void *) (uintptr_t) VThread_CurID(); #else ASSERT_ON_COMPILE(sizeof(pthread_t) <= sizeof (void *)); return (void *) (uintptr_t) pthread_self(); #endif +*/ }