Opened 11 years ago

Closed 11 years ago

#5830 closed Support Requests (invalid)

mutex.inl: extraneous use of GetVersionEx

Reported by: anonymous Owned by: Anthony Williams
Milestone: To Be Determined Component: thread
Version: Boost 1.47.0 Severity: Problem
Keywords: Cc: noloader@…

Description

Index: mutex.inl =================================================================== RCS file: /cvsroot/boost/boost/libs/thread/src/mutex.inl,v retrieving revision 1.9 diff -r1.9 mutex.inl 21,28c21,34 < OSVERSIONINFO version_info = {sizeof(OSVERSIONINFO)}; < ::GetVersionEx(&version_info); < if (version_info.dwPlatformId == VER_PLATFORM_WIN32_NT && < version_info.dwMajorVersion >= 4) < { < if (HMODULE kernel_module = GetModuleHandle(TEXT("KERNEL32.DLL"))) < g_TryEnterCriticalSection = reinterpret_cast<TryEnterCriticalSection_type>(GetProcAddress(kernel_module, TEXT("TryEnterCriticalSection"))); < } ---

No need for this test since Boost is using GetModuleHandle/GetProcAddress.

OSVERSIONINFO version_info = {sizeof(OSVERSIONINFO)}; ::GetVersionEx(&version_info); if (version_info.dwPlatformId == VER_PLATFORM_WIN32_NT && version_info.dwMajorVersion >= 4) { if (HMODULE kernel_module = GetModuleHandle(TEXT("KERNEL32.DLL"))) g_TryEnterCriticalSection = reinterpret_cast<TryEnterCriticalSection_type>(GetProcAddress(kernel_module, TEXT("TryEnterCriticalSection"))); }

The GetModuleHandle function returns a handle to KERNEL32.DLL without incrementing its reference count

if (HMODULE kernel_module = GetModuleHandle(TEXT("KERNEL32.DLL"))) {

g_TryEnterCriticalSection = reinterpret_cast<TryEnterCriticalSection_type>(GetProcAddress(kernel_module, TEXT("TryEnterCriticalSection")));

}

Change History (6)

comment:1 by noloader@…, 11 years ago

Sorry about the poor formatting. It looks like the web submission system is cooking the copy/paste from the diff command.

comment:2 by Jeffrey Walton <noloader@…>, 11 years ago

Cc: noloader@… added
Component: Nonethread
Owner: set to Anthony Williams

in reply to:  1 comment:3 by viboes, 11 years ago

Replying to noloader@…:

Sorry about the poor formatting. It looks like the web submission system is cooking the copy/paste from the diff command.

Please use the code block. 5th widget from the left. E.g.

{
  code block
}

comment:4 by viboes, 11 years ago

Type: BugsSupport Requests

Moved to support request until the format is clear.

comment:5 by viboes, 11 years ago

Sorry, I don't see any file libs/thread/src/mutex.inl. Moved to support request until concerned file clarified.

comment:6 by viboes, 11 years ago

Resolution: invalid
Status: newclosed

Closed as it seems these doesn't corresponds to the current Boost.Thread implementation.

Note: See TracTickets for help on using tickets.