Skip to content

Commit

Permalink
#1448: fix Wine support due to missing rtlIpv6AddressToStringA
Browse files Browse the repository at this point in the history
  • Loading branch information
giampaolo committed Mar 5, 2019
1 parent 3621689 commit f832aa7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
2 changes: 2 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
**Bug fixes**

- 1329_: [AIX] psutil doesn't compile on AIX 6.1. (patch by Arnon Yaari)
- 1448_: [Windows] crash on import due to rtlIpv6AddressToStringA not available
on Wine.

5.6.0
=====
Expand Down
6 changes: 4 additions & 2 deletions psutil/_psutil_windows.c
Original file line number Diff line number Diff line change
Expand Up @@ -1565,7 +1565,8 @@ psutil_net_connections(PyObject *self, PyObject *args) {

// TCP IPv6
if ((PySequence_Contains(py_af_filter, _AF_INET6) == 1) &&
(PySequence_Contains(py_type_filter, _SOCK_STREAM) == 1))
(PySequence_Contains(py_type_filter, _SOCK_STREAM) == 1) &&
(psutil_rtlIpv6AddressToStringA != NULL))
{
table = NULL;
py_conn_tuple = NULL;
Expand Down Expand Up @@ -1715,7 +1716,8 @@ psutil_net_connections(PyObject *self, PyObject *args) {
// UDP IPv6

if ((PySequence_Contains(py_af_filter, _AF_INET6) == 1) &&
(PySequence_Contains(py_type_filter, _SOCK_DGRAM) == 1))
(PySequence_Contains(py_type_filter, _SOCK_DGRAM) == 1) &&
(psutil_rtlIpv6AddressToStringA != NULL))
{
table = NULL;
py_conn_tuple = NULL;
Expand Down
9 changes: 4 additions & 5 deletions psutil/arch/windows/global.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,6 @@ psutil_loadlibs() {
if (! psutil_rtlIpv4AddressToStringA)
return 1;

psutil_rtlIpv6AddressToStringA = psutil_GetProcAddressFromLib(
"ntdll.dll", "RtlIpv6AddressToStringA");
if (! psutil_rtlIpv6AddressToStringA)
return 1;

// minimum requirement: Win XP SP3
psutil_GetExtendedTcpTable = psutil_GetProcAddressFromLib(
"iphlpapi.dll", "GetExtendedTcpTable");
Expand Down Expand Up @@ -130,6 +125,10 @@ psutil_loadlibs() {
/*
* Optional.
*/
// not available on Wine
psutil_rtlIpv6AddressToStringA = psutil_GetProcAddressFromLib(
"ntdll.dll", "RtlIpv6AddressToStringA");

// minimum requirement: Win Vista
psutil_GetTickCount64 = psutil_GetProcAddress(
"kernel32", "GetTickCount64");
Expand Down

0 comments on commit f832aa7

Please sign in to comment.