You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by rh...@apache.org on 2013/10/21 13:30:06 UTC
svn commit: r1534102 - in /subversion/trunk: build.conf
subversion/libsvn_subr/sysinfo.c
Author: rhuijben
Date: Mon Oct 21 11:30:06 2013
New Revision: 1534102
URL: http://svn.apache.org/r1534102
Log:
On Windows: stop linking against a system DLL that is not used by most
processes, to avoid a slight performance penalty on loading libsvn_subr
that is only needed for 'svn --version --verbose'.
As this dll is usually not loaded and not needed except for debugging,
we don't want to pay the system (and especially virusscanner) overhead
of always loading this dll.
* build.conf
(libsvn_subr): Remove psapi.lib.
* subversion/libsvn_subr/sysinfo.c
(FNENUMPROCESSMODULES): Fix definition to match system header.
(enum_loaded_modules): Obtain EnumProcessModules dynamically.
Modified:
subversion/trunk/build.conf
subversion/trunk/subversion/libsvn_subr/sysinfo.c
Modified: subversion/trunk/build.conf
URL: http://svn.apache.org/viewvc/subversion/trunk/build.conf?rev=1534102&r1=1534101&r2=1534102&view=diff
==============================================================================
--- subversion/trunk/build.conf (original)
+++ subversion/trunk/build.conf Mon Oct 21 11:30:06 2013
@@ -357,7 +357,7 @@ install = fsmod-lib
path = subversion/libsvn_subr
libs = aprutil apriconv apr xml zlib apr_memcache sqlite magic intl
msvc-libs = kernel32.lib advapi32.lib shfolder.lib ole32.lib
- crypt32.lib version.lib psapi.lib
+ crypt32.lib version.lib
msvc-export =
svn_auth.h svn_base64.h svn_cache_config.h svn_checksum.h svn_cmdline.h
svn_compat.h svn_config.h svn_ctype.h svn_dirent_uri.h svn_dso.h
Modified: subversion/trunk/subversion/libsvn_subr/sysinfo.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/sysinfo.c?rev=1534102&r1=1534101&r2=1534102&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/sysinfo.c (original)
+++ subversion/trunk/subversion/libsvn_subr/sysinfo.c Mon Oct 21 11:30:06 2013
@@ -546,7 +546,7 @@ linux_release_name(apr_pool_t *pool)
#ifdef WIN32
typedef DWORD (WINAPI *FNGETNATIVESYSTEMINFO)(LPSYSTEM_INFO);
-typedef BOOL (WINAPI *FNENUMPROCESSMODULES) (HANDLE, HMODULE, DWORD, LPDWORD);
+typedef BOOL (WINAPI *FNENUMPROCESSMODULES) (HANDLE, HMODULE*, DWORD, LPDWORD);
/* Get system and version info, and try to tell the difference
between the native system type and the runtime environment of the
@@ -763,16 +763,36 @@ win32_release_name(apr_pool_t *pool)
static HMODULE *
enum_loaded_modules(apr_pool_t *pool)
{
+ HMODULE psapi_dll = 0;
HANDLE current = GetCurrentProcess();
HMODULE dummy[1];
HMODULE *handles;
DWORD size;
+ FNENUMPROCESSMODULES EnumProcessModules_;
- if (!EnumProcessModules(current, dummy, sizeof(dummy), &size))
+ psapi_dll = GetModuleHandleA("psapi.dll");
+
+ if (!psapi_dll)
+ {
+ /* Load and never unload, just like static linking */
+ psapi_dll = LoadLibraryA("psapi.dll");
+ }
+
+ if (!psapi_dll)
+ return NULL;
+
+ EnumProcessModules_ = (FNENUMPROCESSMODULES)
+ GetProcAddress(psapi_dll, "EnumProcessModules");
+
+ /* Before Windows XP psapi was an optional module */
+ if (! EnumProcessModules_)
+ return NULL;
+
+ if (!EnumProcessModules_(current, dummy, sizeof(dummy), &size))
return NULL;
handles = apr_palloc(pool, size + sizeof *handles);
- if (!EnumProcessModules(current, handles, size, &size))
+ if (! EnumProcessModules_(current, handles, size, &size))
return NULL;
handles[size / sizeof *handles] = NULL;
return handles;
Re: svn commit: r1534102 - in /subversion/trunk: build.conf subversion/libsvn_subr/sysinfo.c
Posted by Ivan Zhakov <iv...@visualsvn.com>.
On 21 October 2013 15:30, <rh...@apache.org> wrote:
> Author: rhuijben
> Date: Mon Oct 21 11:30:06 2013
> New Revision: 1534102
>
> URL: http://svn.apache.org/r1534102
> Log:
> On Windows: stop linking against a system DLL that is not used by most
> processes, to avoid a slight performance penalty on loading libsvn_subr
> that is only needed for 'svn --version --verbose'.
>
> As this dll is usually not loaded and not needed except for debugging,
> we don't want to pay the system (and especially virusscanner) overhead
> of always loading this dll.
>
May be it's worth to remove #include <psapi.h> to prevent accidental
usage of psapi functions directly?
--
Ivan Zhakov
CTO | VisualSVN | http://www.visualsvn.com