Skip to content

Commit

Permalink
[Windows] rewrite of open_files() (#1660)
Browse files Browse the repository at this point in the history
  • Loading branch information
giampaolo authored Jan 10, 2020
1 parent 90b4cef commit 3880e3f
Show file tree
Hide file tree
Showing 5 changed files with 197 additions and 225 deletions.
1 change: 1 addition & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ XXXX-XX-XX
due to a backward incompatible change in a C type introduced in 12.0.
- 1656_: [Windows] Process.memory_full_info() raises AccessDenied even for the
current user and os.getpid().
- 1660_: [Windows] Process.open_files() complete rewrite + check of errors.

5.6.7
=====
Expand Down
15 changes: 4 additions & 11 deletions psutil/_psutil_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ psutil_setup(void) {

// Needed to make these globally visible.
int PSUTIL_WINVER;
SYSTEM_INFO PSUTIL_SYSTEM_INFO;
SYSTEM_INFO PSUTIL_SYSTEM_INFO;
CRITICAL_SECTION PSUTIL_CRITICAL_SECTION;

#define NT_FACILITY_MASK 0xfff
#define NT_FACILITY_SHIFT 16
Expand Down Expand Up @@ -326,22 +327,14 @@ psutil_set_winver() {
return 0;
}


static int
psutil_load_sysinfo() {
GetSystemInfo(&PSUTIL_SYSTEM_INFO);
return 0;
}


int
psutil_load_globals() {
if (psutil_loadlibs() != 0)
return 1;
if (psutil_set_winver() != 0)
return 1;
if (psutil_load_sysinfo() != 0)
return 1;
GetSystemInfo(&PSUTIL_SYSTEM_INFO);
InitializeCriticalSection(&PSUTIL_CRITICAL_SECTION);
return 0;
}
#endif // PSUTIL_WINDOWS
5 changes: 4 additions & 1 deletion psutil/_psutil_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ int psutil_setup(void);
#include "arch/windows/ntextapi.h"

extern int PSUTIL_WINVER;
extern SYSTEM_INFO PSUTIL_SYSTEM_INFO;
extern SYSTEM_INFO PSUTIL_SYSTEM_INFO;
extern CRITICAL_SECTION PSUTIL_CRITICAL_SECTION;

#define PSUTIL_WINDOWS_VISTA 60
#define PSUTIL_WINDOWS_7 61
Expand All @@ -60,7 +61,9 @@ int psutil_setup(void);
#define PSUTIL_WINDOWS_NEW MAXLONG

#define MALLOC(x) HeapAlloc(GetProcessHeap(), 0, (x))
#define MALLOC_ZERO(x) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (x))
#define FREE(x) HeapFree(GetProcessHeap(), 0, (x))

#define LO_T 1e-7
#define HI_T 429.4967296

Expand Down
Loading

0 comments on commit 3880e3f

Please sign in to comment.